bug#16134: Bug#239816: [PATCH 2/2] libparted: Add support for atari partition tables

2016-12-09 Thread John Paul Adrian Glaubitz
Hi Colin!

On 12/09/2016 01:57 PM, Colin Watson wrote:
> Thanks for this.  I've satisfied myself that it shouldn't cause problems
> on other systems, so I've gone ahead and applied these patches to Debian
> unstable, though I expect I may need to refresh them at some point.

Thanks a lot, this is awesome :). Now I can build d-i images for m68k!

> A few minor comments, although I haven't reviewed the Atari-specific
> details:
> 
> On Sun, Dec 04, 2016 at 05:12:46PM +0100, John Paul Adrian Glaubitz wrote:
>> +static int
>> +atr_part_correct (AtariRawPartition* part, uint32_t hd_size)
>> +{
>> +uint32_t start, size;
>> +
>> +start = PED_BE32_TO_CPU (part->start);
>> +size = PED_BE32_TO_CPU (part->size);
>> +
>> +return isalnum_l(part->id[0], atr_c_locale)
>> +&& isalnum_l(part->id[1], atr_c_locale)
>> +&& isalnum_l(part->id[2], atr_c_locale)
>> +&& atr_start_size_correct (start, size, hd_size);
>> +}
> 
> I'd be inclined to just hand-roll a C-flavoured isalnum equivalent
> rather than bothering to instantiate a custom locale.

Makes sense. I can try looking into this.

>> @@ -96,6 +97,7 @@ init_disk_types ()
>>  ped_disk_bsd_init ();
>>  ped_disk_amiga_init ();
>>  ped_disk_aix_init ();
>> +ped_disk_atari_init ();
>>  }
> 
> Aside from dasd, these seem to be mostly reverse-alphabetical except
> that atari is now slightly out of sequence.  Any reason for that?
> (Ditto in done_disk_types.)

No, just an oversight :).

> Also, "git am" whinges about various minor whitespace things, which you
> should correct:
> 
> .git/rebase-apply/patch:710: space before tab in indent.
> disk,
> .git/rebase-apply/patch:711: space before tab in indent.
> PED_BE32_TO_CPU (table.part[i].start),
> .git/rebase-apply/patch:712: space before tab in indent.
>  ) )
> .git/rebase-apply/patch:1460: space before tab in indent.
>         < min_start ) ) {
> .git/rebase-apply/patch:1721: space before tab in indent.
>| PED_PARTITION_EXTENDED))

Thanks for spotting these. Will fix them!

Adrian

-- 
 .''`.  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





bug#16134: [parted-devel] [PATCH 2/2] libparted: Add support for atari partition tables

2016-12-05 Thread John Paul Adrian Glaubitz
On 12/05/2016 04:40 PM, Sebastian Parschauer wrote:
>> Are you one of the parted maintainers?
> 
> I'm maintaining SUSE parted since this year but don't have any upstream
> commit rights. I took that over from Petr Uzel.
> 
> I'm just wondering if this could be interesting for us as well and I try
> to help with review upstream.

Well, at first your comments sounded very dismissive, to be honest.

I know that m68k isn't mainstream these days anymore. But most packages
have well enough support for m68k that you can run current versions
of Linux on it. We just had a fresh commit to gcc earlier this
day [1].

And we're working on bringing full m68k support to qemu [2] as well with
work done by Laurent Vivier (RedHat), by me and Andreas Schwab
who has done a lot of m68k work and is still active in this field.

Thanks,
Adrian

> [1] https://gcc.gnu.org/viewcvs/gcc?view=revision=243247
> [2] https://github.com/vivier/qemu-m68k

-- 
 .''`.  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





bug#16134: [parted-devel] [PATCH 2/2] libparted: Add support for atari partition tables

2016-12-05 Thread John Paul Adrian Glaubitz
Btw, there is already lots of discussion regarding this in [1].

This change has already been planned to be merged two years ago. I just
didn't have the time to pick up the work again.

Thanks,
Adrian

> [1] http://bugs.debian.org/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





bug#16134: [parted-devel] [PATCH 2/2] libparted: Add support for atari partition tables

2016-12-05 Thread John Paul Adrian Glaubitz
On 12/05/2016 04:15 PM, Sebastian Parschauer wrote:
> On 04.12.2016 17:12, John Paul Adrian Glaubitz wrote:
>> Signed-off-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
> 
> Please write a long commit description for this one and link to specs.

Can do.

> Please make clear why this is needed.

Debian/m68k.

> Please show how many and which kind of users are waiting for this.

Users of Debian/m68k. There is also an openSuSE port for m68k by Andreas Schwab.

> Please show how many and what kind of systems would benefit from this.

All systems with m68k CPUs.

> What's your role for this? Will you help to maintain this the next years?
> 
> To be able to maintain this, it is important that there is an active
> community for this and it's not just a homebrew project which is
> discontinued soon again.

There is still very active support for m68k in the Linux kernel, the
toolchain and in Debian. The largest part of this change is adding atari.c
which is self-containing, so there isn't that much to be maintained about
this minus the few compile patches here and there. Note that we also
have support for amiga partition tables in parted.

Are you one of the parted maintainers?

Thanks,
Adrian

-- 
 .''`.  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





bug#16134: [PATCH 3/3] libparted:tests: Enable _implemented_disk_label for atari

2016-10-16 Thread John Paul Adrian Glaubitz
Use get_sector_size() to ensure we're testing on 512-byte
sectors only.

Signed-off-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
---
 libparted/tests/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libparted/tests/common.c b/libparted/tests/common.c
index 8ef3915..2be0e3a 100644
--- a/libparted/tests/common.c
+++ b/libparted/tests/common.c
@@ -82,7 +82,9 @@ _implemented_disk_label (const char *label)
 {
 /* FIXME: these have minor problems, so skip them, temporarily.  */
 if (STREQ (label, "amiga")) return 0;
-if (STREQ (label, "atari")) return 0;
+
+if (STREQ (label, "atari") && get_sector_size() != 512)
+return 0;
 
 /* Not implemented yet */
 if (STREQ (label, "aix")) return 0;
-- 
2.9.3






bug#16134: [PATCH 1/3] libparted: Add support for atari partition tables

2016-10-16 Thread John Paul Adrian Glaubitz
Signed-off-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
---
 libparted/labels/Makefile.am |1 +
 libparted/labels/atari.c | 1969 ++
 libparted/libparted.c|4 +
 libparted/tests/common.c |1 +
 po/POTFILES.in   |1 +
 tests/t3310-flags.sh |6 +-
 6 files changed, 1981 insertions(+), 1 deletion(-)
 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 <http://www.gnu.org/licenses/>.
+
+Contributor:  Guillaume Knispel <k_guilla...@libertysurf.fr>
+      John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
+*/
+
+/*
+   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   */
+

bug#16134: [PATCH 2/3] libparted:tests: Move get_sector_size() to common.c

2016-10-16 Thread John Paul Adrian Glaubitz
Moving get_sector_size() to common.c allows us to use it
in _implemented_disk_label to test for 512-byte sectors.

Signed-off-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
---
 libparted/tests/common.c | 14 ++
 libparted/tests/common.h |  5 +
 libparted/tests/disk.c   | 15 ---
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/libparted/tests/common.c b/libparted/tests/common.c
index 46e029f..8ef3915 100644
--- a/libparted/tests/common.c
+++ b/libparted/tests/common.c
@@ -7,9 +7,23 @@
 #include 
 
 #include "common.h"
+#include "xstrtol.h"
 
 #define STREQ(a, b) (strcmp (a, b) == 0)
 
+size_t get_sector_size (void)
+{
+  char *p = getenv ("PARTED_SECTOR_SIZE");
+  size_t ss = 512;
+  unsigned long val;
+  if (p
+  && xstrtoul (p, NULL, 10, , NULL) == LONGINT_OK
+  && val % 512 == 0)
+ss = val;
+
+  return ss;
+}
+
 PedExceptionOption
 _test_exception_handler (PedException* e)
 {
diff --git a/libparted/tests/common.h b/libparted/tests/common.h
index 1b1c801..5d7485e 100644
--- a/libparted/tests/common.h
+++ b/libparted/tests/common.h
@@ -1,5 +1,10 @@
 #include 
 
+/* Determine sector size from environment
+ *
+ */
+size_t get_sector_size (void);
+
 /* Create an empty disk image
  *
  * filename: file (with full path) where to write the disk image
diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
index 48561b9..62d20c1 100644
--- a/libparted/tests/disk.c
+++ b/libparted/tests/disk.c
@@ -7,24 +7,9 @@
 
 #include "common.h"
 #include "progname.h"
-#include "xstrtol.h"
 
 static char* temporary_disk;
 
-static
-size_t get_sector_size (void)
-{
-  char *p = getenv ("PARTED_SECTOR_SIZE");
-  size_t ss = 512;
-  unsigned long val;
-  if (p
-  && xstrtoul (p, NULL, 10, , NULL) == LONGINT_OK
-  && val % 512 == 0)
-ss = val;
-
-  return ss;
-}
-
 static void
 create_disk (void)
 {
-- 
2.9.3






bug#16134: Add support for atari partition tables, v3

2016-10-16 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






bug#16134: Bug#239816: bug#16134: libparted Atari partition table support

2016-10-15 Thread John Paul Adrian Glaubitz
On 10/15/2016 09:15 PM, Michael Schmitz wrote:
> good to see you managed to fix the libparted issues!

Thanks. I just happened to be in the situation that I'm writing a guide
how to set up a minimal Debian/m68k system on ARAnyM from scratch.

>> Ah, it works after enabling byte-swapping in ARAnyM :).
> 
> Did you write the table on the host and then had to byte swap to get it
> read in ARAnyM?

Correct. I created an empty image, mapped it to /dev/loop0 using losetup
and ran my patched version of parted to create an Atari partition table
plus two partitions for the system and swap.

In ARAnyM, I had to enable byte-swapping as otherwise the partitions
were not recognized.

> Just checked - Atari byte order disk image files of IDE disks don't need
> byte swapping. Host native byte order ones do, that suggests your
> partition table is in host native order. To get it to work in ARAnyM out
> of the box, and more importantly on real hardware the partition table
> would need to be written to the disk image with byte swapping.

Wouldn't ARAnyM or a real Atari write the data byte-swapped to the
disk anyway? I would expect that parted just uses the host order
which is why I had to byte-swap the disk image when using it in
ARAnyM. But I think we could add the byte-swapping later if
necessary.

> Note that SCSI disks don't need byte swapping so if you want to support
> both targets, libparted would need a byte swap option ...

Ok, good to know.

Adrian

-- 
 .''`.  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





bug#16134: Bug#239816: bug#16134: libparted Atari partition table support

2016-10-15 Thread John Paul Adrian Glaubitz
On 10/15/2016 03:11 PM, John Paul Adrian Glaubitz wrote:
> I then tried the image on Aranym but to my disappointment, the kernel did
> not recognize the partition table, so there is still something wrong with
> the patch as-is.

Ah, it works after enabling byte-swapping in ARAnyM :).

Alright, will clean this up, add tests and then get it merged!

Adrian

-- 
 .''`.  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





bug#16134: Atari partition table support, v2

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

Adrian






bug#16134: [PATCH] libparted: Add support for Atari partition tables

2016-10-15 Thread John Paul Adrian Glaubitz
Signed-off-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
---
 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 <http://www.gnu.org/licenses/>.
+
+Contributor:  Guillaume Knispel <k_guilla...@libertysurf.fr>
+      John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
+*/
+
+/*
+   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",  

bug#16134: [PATCH] libparted: Add support for Atari partition tables

2016-10-15 Thread John Paul Adrian Glaubitz
Signed-off-by: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
---
 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 <http://www.gnu.org/licenses/>.
+
+Contributor:  Guillaume Knispel <k_guilla...@libertysurf.fr>
+      John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
+*/
+
+/*
+   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 },
+   { "e

bug#16134:

2016-10-15 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






bug#16134: Bug#239816: bug#16134: libparted Atari partition table support

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

I just stumbled into this bug again since I wanted to use parted today to
create a disk image that would be recognized by ARAnyM with a kernel with
just Atari partition support.

I pulled the old patch from Stephen's git repository, applied it to the
current git version of parted which surprisingly still worked, albeit
the patches applied with some fuzz.

However, the code did not build anymore, so I fixed all compiler errors
and warnings and was now able to run parted with the patch merged.

Creating a partition table with "mklabel atari" worked, but now libparted
crashed when running "mkpart". After refactoring the Atari code to make
use of pt-common.h and pt-tools.h, this problem was fixed, too.

I then tried the image on Aranym but to my disappointment, the kernel did
not recognize the partition table, so there is still something wrong with
the patch as-is.

I'm attaching my current patch for parted. Maybe someone else has an idea
what I might be missing here to get the kernel recognize the partition
table created with the patched version of parted.

Once we have sorted the remaining issues out, I will take care of adding
the necessary tests and get the changes merged upstream.

Thanks,
Adrian

-- 
 .''`.  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
>From c965b4144784341003d9b1000df96da1a1ac1aff Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
Date: Sat, 15 Oct 2016 14:52:17 +0200
Subject: [PATCH] Add support for Atari partition labels

---
 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 <http://www.gnu.org/licenses/>.
+
+Contributor:  Guillaume Knispel <k_guilla...@libertysurf.fr>
+  John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
+*/
+
+/*
+	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 con

bug#16134: libparted Atari partition table support

2013-12-14 Thread John Paul Adrian Glaubitz
Hi!

While chatting with someone who was trying to install Linux onto his
ATARI Falcon 060, we stumbled into the task getting the hard disk
partitioned for the ATARI Falcon to be used.

Since I already successfully created an Amiga partition table with
the help of gparted and libparted, I thought it would be as easy as
that for ATARI partitions, too.

Unfortunately, libparted currently doesn't support ATARI partition
tables. However, there is a long-standing bug report open which
contains the necessary patches for libparted to support that [1].

Since we're in the process of reviving the m68k port of Debian,
I guess we should also put efforts into getting this patch finally
to upstream so people can prepare their ATARI hard disks on their
Linux PCs before using them in the ATARI or change partitions
once Linux is running on their ATARIs.

Adrian

 [1] http://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



signature.asc
Description: OpenPGP digital signature


bug#16147: Bug#239816: libparted Atari partition table support

2013-12-14 Thread John Paul Adrian Glaubitz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 12/14/2013 06:12 PM, Phillip Susi wrote:
 On 12/14/2013 02:26 AM, Thorsten Glaser wrote:
 The ST, maybe (except for the only-in-museums part), but the TT 
 and Falcon run Debian GNU/Linux just finely.
 
 Linux ara5.mirbsd.org 3.11-2-m68k #1 Debian 3.11.7-1
 (2013-11-09) m68k GNU/Linux
 
 (Hm, should dist-upgrade and reboot that box, too.)
 
 I'm still not following.  You are talking about a 30 year old
 computer running at like 16 MHz with maybe 512k of ram?

No, rather a Motorola 68060 running at 100 MHz with 512 MB of RAM [1].

Adrian

 [1] http://www.powerphenix.com/ct60/english/overview.htm

- -- 
 .''`.  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
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.15 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBCAAGBQJSrJSkAAoJEHQmOzf1tfkTwqMQAL66NzlsEWG3zmXA8C+1FpH4
OzgnyCT9hQzt+sx81a1dODJmJZRS+Rlwe5aG9gUSevuaCksitzzFM24JLOeB6fQg
iW6RAYlhlOgjWjj3TR96ADu6TGNAW0D0JMvDfy5PYiDQqTHMBCM9OUWHa/KiWaIM
yUTx0KoxyEPs3iK9q5O4qh1Q37LAgh8xYtpbRILil8ga3rOVg3Gucv6tZjNNFUls
WuvENs+65IqrIvkCLOKKJNyydRmAfBmRcJ8spBPRxl+B1ARdvQSAcOyAJOcwtnYD
FhvU9HCM/IwDgx538TiwAqhnpx/z5HGgUK7MyOlFJ00BL+62v61/joczkdzUl2sD
kqqTSZVP05jO/f8GZmH8eJ9zy5JwcM1fg1VT+VygLzrBLNk7+RsiB6GdN9lNemHd
3MrHZjjpcFweAvog5UFxgErhK3/FAVtv8O1eQ6Fz1bajWm0uMYFtbUo9GZsROi+p
B8uzoNwNSRnG2taBZfILtNuSQnkcLfrcJpT7DMpsCJrLYQmMJY+vixS725FevQ7s
1g+g7s0Jo4d91G2RzZujNXj5i+08XQpuoFajMZpsKUald1K0kzSXKNmdwov2YW05
yFLBFyBKEnrMT5VEP/+Ed+7pJgluGSMaX8odYJQWpSYxedeyJModgxWBLBNl21oN
65W87kyDGwqu8PUULBxS
=q8fX
-END PGP SIGNATURE-