[parted-devel] [PATCH] libparted: Add support for Atari partition tables

2016-10-17 Thread John Paul Adrian Glaubitz
Signed-off-by: John Paul Adrian Glaubitz 
---
 libparted/labels/Makefile.am |1 +
 libparted/labels/atari.c | 1969 ++
 libparted/libparted.c|4 +
 po/POTFILES.in   |1 +
 4 files changed, 1975 insertions(+)
 create mode 100644 libparted/labels/atari.c

diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am
index c996f81..3327c8c 100644
--- a/libparted/labels/Makefile.am
+++ b/libparted/labels/Makefile.am
@@ -19,6 +19,7 @@ noinst_LTLIBRARIES=   liblabels.la
 liblabels_la_SOURCES = \
   $(S390_SRCS) \
   aix.c\
+  atari.c  \
   bsd.c\
   dos.c\
   dvh.c\
diff --git a/libparted/labels/atari.c b/libparted/labels/atari.c
new file mode 100644
index 000..8ed0dfb
--- /dev/null
+++ b/libparted/labels/atari.c
@@ -0,0 +1,1969 @@
+/* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+
+libparted - a library for manipulating disk partitions
+atari.c - libparted module to manipulate Atari partition tables.
+Copyright (C) 2000-2001, 2004, 2007-2014 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see .
+
+Contributor:  Guillaume Knispel 
+  John Paul Adrian Glaubitz 
+*/
+
+/*
+   Documentation :
+   README file of atari-fdisk
+   atari-fdisk source code
+   Linux atari partitions parser source code
+   ( fs/partitions/atari.[ch] )
+*/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pt-tools.h"
+
+#if ENABLE_NLS
+#  include 
+#  define _(String) dgettext (PACKAGE, String)
+#else
+#  define _(String) (String)
+#endif /* ENABLE_NLS */
+
+
+/** Atari data and structure stuff **/
+
+#define BOOTABLE_CKSUM 0x1234
+#define NONBOOT_CKSUM  0x4321
+
+#define GEM_MAX((32*1024*1024)/PED_SECTOR_SIZE_DEFAULT)
+
+#define PART_FLAG_USED 0x01
+#define PART_FLAG_BOOT_GEM 0x80/* GEMDOS  */
+#define PART_FLAG_BOOT_ASV 0x40/* Atari System V  */
+#define PART_FLAG_BOOT_BSD 0x20/* Net(?)BSD   */
+#define PART_FLAG_BOOT_LNX 0x10/* Linux   */
+#define PART_FLAG_BOOT_UNK 0x08/* unknown / other */
+
+#define N_AHDI 4
+#define N_ICD  8
+
+#define MAXIMUM_PARTS  64
+
+/* what we put instead of id, start and size in empty */
+/* partition tables, to be able to detect it */
+#define SIGNATURE_EMPTY_TABLE  "PARTEDATARI"
+#define SIGNATURE_EMPTY_SIZE   11
+
+/* to be compared to the last two bytes of 1st sector (Big Endian) */
+static const uint16_t atr_forbidden_sign[] = {
+   0x55AA,
+   0
+};
+
+static const char *atr_known_icd_pid[] = {
+   "BGM", "GEM", "LNX", "SWP", "RAW", NULL
+};
+
+/* static const char *atr_known_pid[] = { */
+/* "BGM", "GEM", "LNX", "MAC", "MIX", "MNX", "RAW", "SWP", "UNX", */
+/* "F32", "SV4", NULL */
+/* }; */
+
+struct _AtariPartID2BootFlag {
+   const char  pid[4];
+   uint8_t flag;
+};
+typedef struct _AtariPartID2BootFlag AtariPartID2BootFlag;
+
+static AtariPartID2BootFlag atr_pid2bf[] = {
+   { "GEM", PART_FLAG_BOOT_GEM },
+   { "BGM", PART_FLAG_BOOT_GEM },
+   { "UNX", PART_FLAG_BOOT_ASV },
+   { "LNX", PART_FLAG_BOOT_LNX },
+   { "",PART_FLAG_BOOT_UNK },
+};
+
+struct _AtariFS2PartId {
+   const char* fs;
+   const char  pid[4];
+   PedSector   max_sectors;
+};
+typedef struct _AtariFS2PartId AtariFS2PartId;
+
+static AtariFS2PartId atr_fs2pid[] = {
+/* Other ID are available : MIX MNX <= minix
+   UNX <= Atari SysV Unix
+   SV4 <= Univ System 4   */
+   { "ext2",   "LNX", INT32_MAX },
+   { "ext3",   "LNX", INT32_MAX },
+   { "fat16",  "GEM",   GEM_MAX }, /* small partitions */
+   { "fat16",  "BGM", INT32_MAX }, /* big partitions */
+   { "fat32",  "F32", INT32_MAX },
+   { "hfs","MAC", INT32_MAX },
+   { "hfs+",   "MAC", INT32_MAX },
+  

[parted-devel] [PATCH] libparted: Add support for Atari partition tables

2016-10-17 Thread John Paul Adrian Glaubitz
Signed-off-by: John Paul Adrian Glaubitz 
---
 libparted/labels/Makefile.am |1 +
 libparted/labels/atari.c | 1969 ++
 libparted/libparted.c|4 +
 po/POTFILES.in   |1 +
 4 files changed, 1975 insertions(+)
 create mode 100644 libparted/labels/atari.c

diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am
index c996f81..3327c8c 100644
--- a/libparted/labels/Makefile.am
+++ b/libparted/labels/Makefile.am
@@ -19,6 +19,7 @@ noinst_LTLIBRARIES=   liblabels.la
 liblabels_la_SOURCES = \
   $(S390_SRCS) \
   aix.c\
+  atari.c  \
   bsd.c\
   dos.c\
   dvh.c\
diff --git a/libparted/labels/atari.c b/libparted/labels/atari.c
new file mode 100644
index 000..8f85ccd
--- /dev/null
+++ b/libparted/labels/atari.c
@@ -0,0 +1,1969 @@
+/* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+
+libparted - a library for manipulating disk partitions
+disk_amiga.c - libparted module to manipulate amiga RDB partition tables.
+Copyright (C) 2000-2001, 2004, 2007-2014 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see .
+
+Contributor:  Guillaume Knispel 
+  John Paul Adrian Glaubitz 
+*/
+
+/*
+   Documentation :
+   README file of atari-fdisk
+   atari-fdisk source code
+   Linux atari partitions parser source code
+   ( fs/partitions/atari.[ch] )
+*/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pt-tools.h"
+
+#if ENABLE_NLS
+#  include 
+#  define _(String) dgettext (PACKAGE, String)
+#else
+#  define _(String) (String)
+#endif /* ENABLE_NLS */
+
+
+/** Atari data and structure stuff **/
+
+#define BOOTABLE_CKSUM 0x1234
+#define NONBOOT_CKSUM  0x4321
+
+#define GEM_MAX((32*1024*1024)/PED_SECTOR_SIZE_DEFAULT)
+
+#define PART_FLAG_USED 0x01
+#define PART_FLAG_BOOT_GEM 0x80/* GEMDOS  */
+#define PART_FLAG_BOOT_ASV 0x40/* Atari System V  */
+#define PART_FLAG_BOOT_BSD 0x20/* Net(?)BSD   */
+#define PART_FLAG_BOOT_LNX 0x10/* Linux   */
+#define PART_FLAG_BOOT_UNK 0x08/* unknown / other */
+
+#define N_AHDI 4
+#define N_ICD  8
+
+#define MAXIMUM_PARTS  64
+
+/* what we put instead of id, start and size in empty */
+/* partition tables, to be able to detect it */
+#define SIGNATURE_EMPTY_TABLE  "PARTEDATARI"
+#define SIGNATURE_EMPTY_SIZE   11
+
+/* to be compared to the last two bytes of 1st sector (Big Endian) */
+static const uint16_t atr_forbidden_sign[] = {
+   0x55AA,
+   0
+};
+
+static const char *atr_known_icd_pid[] = {
+   "BGM", "GEM", "LNX", "SWP", "RAW", NULL
+};
+
+/* static const char *atr_known_pid[] = { */
+/* "BGM", "GEM", "LNX", "MAC", "MIX", "MNX", "RAW", "SWP", "UNX", */
+/* "F32", "SV4", NULL */
+/* }; */
+
+struct _AtariPartID2BootFlag {
+   const char  pid[4];
+   uint8_t flag;
+};
+typedef struct _AtariPartID2BootFlag AtariPartID2BootFlag;
+
+static AtariPartID2BootFlag atr_pid2bf[] = {
+   { "GEM", PART_FLAG_BOOT_GEM },
+   { "BGM", PART_FLAG_BOOT_GEM },
+   { "UNX", PART_FLAG_BOOT_ASV },
+   { "LNX", PART_FLAG_BOOT_LNX },
+   { "",PART_FLAG_BOOT_UNK },
+};
+
+struct _AtariFS2PartId {
+   const char* fs;
+   const char  pid[4];
+   PedSector   max_sectors;
+};
+typedef struct _AtariFS2PartId AtariFS2PartId;
+
+static AtariFS2PartId atr_fs2pid[] = {
+/* Other ID are available : MIX MNX <= minix
+   UNX <= Atari SysV Unix
+   SV4 <= Univ System 4   */
+   { "ext2",   "LNX", INT32_MAX },
+   { "ext3",   "LNX", INT32_MAX },
+   { "fat16",  "GEM",   GEM_MAX }, /* small partitions */
+   { "fat16",  "BGM", INT32_MAX }, /* big partitions */
+   { "fat32",  "F32", INT32_MAX },
+   { "hfs","MAC", INT32_MAX },
+   { "hfs+",   "MAC",