[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] (no subject)

2016-10-17 Thread John Paul Adrian Glaubitz
Hi!

The following patch adds support for Atari partition tables as used
on classic Atari computers like the Atari ST or Falcon as well
as the ARAnyM Atari emulator.

This patch was originally written by Guillaume Knispel in 2005 [1]
for parted 1.6.6. I have ported the patch to parted 3.2.x and cleaned
up the code.

With my changes to the patch, parted builds and runs fine and
I can create Atari partition tables and partitions in a disk
image file and use the disk image in ARAnyM running Linux/m68k
with byte-swapping enabled (as expected on Atari).

Running "make check" fails though as the testsuite tries to create
partition tables with sector sizes other than 512 bytes which is
not supported for these partition tables. Thus, it would be great
if someone could help me resolving this issue as well as otherwise
the code is working as expected.

Let me know what needs to be improved to get this merged!

Thanks,
Adrian

> [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=239816

--
 .''`.  John Paul Adrian Glaubitz
 : :' :  Debian Developer - glaub...@debian.org
 `. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
   `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913




[parted-devel] Add support for atari partition tables, v3

2016-10-17 Thread John Paul Adrian Glaubitz
Hi!

This is my third revision of this patch series which enables both the
tests for partition flags (tests/t3310-flags.sh) as well as the
test _implemented_disk_label from the libparted test suite.

For the latter to work, I needed to move get_sector_size() from disk.c
to common.c so it could be used to test the sector size and make sure
the tests are only performed with 512 byte sectors on atari partition
tables.

Adrian




[parted-devel] Atari partition table support, v2

2016-10-17 Thread John Paul Adrian Glaubitz
Fixed the description at the top of libparted/labels/atari.c.

Adrian




[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",