I started adding per-partition-table type with the "mac" table type.
That's the first patch. However, adding new interfaces to so many
tables and files is not at all maintainable, so the first step was
to factor out some of the duplication so I could add each new interface
in only one file, rather than in ten.
The 2nd patch makes parted use a gperf-generated lookup function
that maps from partition table type name to a structure defining
the limits for that type.
The third patch factors most of the members from the *_disk_ops tables
into the new pt-common.h header, as well as the *_partition_check functions.
[PATCH 4/5] does this, from its NEWS entry:
libparted: new functions to return per-partition-table-type limits:
- ped_disk_max_partition_start_sector: Return the largest representable
start sector number for a given "disk".
- ped_disk_max_partition_length: Return the maximum partition length
for a given "disk".
Subject: [PATCH 5/5] tests: exercise the new interfaces
I'll push these tomorrow.
>From db0d051a85f69f8033675eeedd546d6c24fdbff9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Thu, 3 Dec 2009 10:58:31 +0100
Subject: [PATCH 1/5] mac: hook up the partition_check function for this
partition table type
* libparted/labels/pt-tools.c (ptt_partition_max_start_len): Define
for MAC partition tables. They too have 32-bit-limited partition
starting sector number and partition length (in sectors).
* libparted/labels/mac.c (mac_partition_check): Use
ptt_partition_max_start_len.
---
libparted/labels/mac.c | 2 +-
libparted/labels/pt-tools.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index 561ca5f..319adcc 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -1628,7 +1628,7 @@ mac_get_max_supported_partition_count (const PedDisk*
disk, int *max_n)
static bool
mac_partition_check (const PedPartition* part)
{
- return true;
+ return ptt_partition_max_start_len ("mac", part);
}
static PedDiskOps mac_disk_ops = {
diff --git a/libparted/labels/pt-tools.c b/libparted/labels/pt-tools.c
index 7325f65..8b2ea4a 100644
--- a/libparted/labels/pt-tools.c
+++ b/libparted/labels/pt-tools.c
@@ -109,7 +109,7 @@ ptt_clear_sectors (PedDevice *dev, PedSector start,
PedSector n)
int
ptt_partition_max_start_len (char const *label_type, const PedPartition *part)
{
- static char const *const max_32[] = {"msdos", "dvh", "dasd"};
+ static char const *const max_32[] = {"msdos", "dvh", "dasd", "mac"};
unsigned int i;
for (i = 0; i < sizeof max_32 / sizeof *max_32; i++)
--
1.6.6.rc0.285.g73651
>From 347913c07fa6b0472a10e5b2cadd869d1ea5793f Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Thu, 3 Dec 2009 11:45:05 +0100
Subject: [PATCH 2/5] libparted: use gperf-generated lookup function
* libparted/labels/pt-tools.c (ptt_partition_max_start_len):
Rewrite to use the gperf-generated look-up function.
(ptt_partition_max_start_sector): New function.
(ptt_partition_max_length): New function.
* libparted/labels/pt-tools.h: Declare them.
* libparted/labels/Makefile.am (GPERF, GPERF_OPTIONS): Define.
(BUILT_SOURCES): Define.
(liblabels_la_SOURCES): Append pt-limit.gperf.
(pt-limit.c): New rule.
(MAINTAINERCLEANFILES): Remove useless definition.
(DISTCLEANFILES): Set to $(BUILT_SOURCES).
* libparted/labels/pt-limit.gperf: New file.
* cfg.mk (bootstrap-tools): Mention gperf.
* bootstrap.conf (buildreq): Require gperf-3.0.3.
---
.gitignore | 1 +
bootstrap.conf | 2 +-
cfg.mk | 3 +
libparted/.gitignore | 1 +
libparted/labels/Makefile.am | 16 ++++++-
libparted/labels/pt-limit.gperf | 12 +++++
libparted/labels/pt-tools.c | 93 +++++++++++++++++++++++++-------------
libparted/labels/pt-tools.h | 3 +
8 files changed, 97 insertions(+), 34 deletions(-)
create mode 100644 libparted/labels/pt-limit.gperf
diff --git a/.gitignore b/.gitignore
index 0394d17..6e4c561 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,5 +48,6 @@ partprobe/partprobe
po/.reference
stamp-h1
tests/init.sh
+tests/print-align
tests/t*.sh.log
tests/test-suite.log
diff --git a/bootstrap.conf b/bootstrap.conf
index 24f9aad..09870cd 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -123,7 +123,7 @@ automake 1.11
autopoint -
gettext -
git 1.4.4
-gperf -
+gperf 3.0.3
gzip -
makeinfo -
perl 5.5
diff --git a/cfg.mk b/cfg.mk
index ce0dfc1..afbdcc0 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -49,3 +49,6 @@ update-copyright-env = UPDATE_COPYRIGHT_USE_INTERVALS=1
useless_free_options = \
--name=pth_free
+
+# Tools used to bootstrap this package, used for "announcement".
+bootstrap-tools = autoconf,automake,gnulib,gperf
diff --git a/libparted/.gitignore b/libparted/.gitignore
index 66a3f3f..9f0df15 100644
--- a/libparted/.gitignore
+++ b/libparted/.gitignore
@@ -1,2 +1,3 @@
*.lo
*.la
+/labels/pt-limit.c
diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am
index 05810e5..9e8232c 100644
--- a/libparted/labels/Makefile.am
+++ b/libparted/labels/Makefile.am
@@ -37,4 +37,18 @@ liblabels_la_LIBADD = $(OS_LIBS) $(INTLLIBS)
INCLUDES = $(partedincludedir) $(INTLINCS)
-MAINTAINERCLEANFILES = Makefile.in
+BUILT_SOURCES = pt-limit.c
+DISTCLEANFILES = $(BUILT_SOURCES)
+liblabels_la_SOURCES += pt-limit.gperf
+
+GPERF = gperf
+GPERF_OPTIONS = \
+ -C -N pt_limit_lookup -n -t -s 6 -k '*' --language=ANSI-C
+
+pt-limit.c: pt-limit.gperf
+ rm -f $@ $...@-tmp
+ $(GPERF) $(GPERF_OPTIONS) $< \
+ | perl -ne '/__GNUC_STDC_INLINE__/ and print "static\n"; print' \
+ > $...@-tmp
+ chmod a-w $...@-tmp
+ mv $...@-tmp $@
diff --git a/libparted/labels/pt-limit.gperf b/libparted/labels/pt-limit.gperf
new file mode 100644
index 0000000..7e3f8ca
--- /dev/null
+++ b/libparted/labels/pt-limit.gperf
@@ -0,0 +1,12 @@
+struct partition_limit
+{
+ char const *name;
+ uint64_t max_start_sector;
+ uint64_t max_length;
+};
+%%
+dasd,UINT32_MAX,UINT32_MAX
+dvh,UINT32_MAX,UINT32_MAX
+gpt,UINT64_MAX,UINT64_MAX
+mac,UINT32_MAX,UINT32_MAX
+msdos,UINT32_MAX,UINT32_MAX
diff --git a/libparted/labels/pt-tools.c b/libparted/labels/pt-tools.c
index 8b2ea4a..e81bec5 100644
--- a/libparted/labels/pt-tools.c
+++ b/libparted/labels/pt-tools.c
@@ -103,46 +103,75 @@ ptt_clear_sectors (PedDevice *dev, PedSector start,
PedSector n)
? 1 : ped_device_write (dev, zero, start + n_z_sectors * i, rem));
}
+#include "pt-limit.c"
+
/* Throw an exception and return 0 if PART's starting sector number or
its length is greater than the maximum allowed value for LABEL_TYPE.
Otherwise, return 1. */
int
-ptt_partition_max_start_len (char const *label_type, const PedPartition *part)
+ptt_partition_max_start_len (char const *pt_type, const PedPartition *part)
{
- static char const *const max_32[] = {"msdos", "dvh", "dasd", "mac"};
- unsigned int i;
+ struct partition_limit const *pt_lim
+ = pt_limit_lookup (pt_type, strlen (pt_type));
+
+ /* If we don't have info on the type, return "true". */
+ if (pt_lim == NULL)
+ return 1;
- for (i = 0; i < sizeof max_32 / sizeof *max_32; i++)
+ /* If the length in sectors exceeds the limit, you lose. */
+ if (part->geom.length > pt_lim->max_length)
{
- if (strcmp (label_type, max_32[i]) == 0)
- {
- /* The length (in sectors) must fit in 32 bytes. */
- if (part->geom.length > UINT32_MAX)
- {
- ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
- _("partition length of %jd sectors exceeds"
- " the %s-partition-table-imposed maximum"
- " of %jd"),
- part->geom.length,
- label_type,
- UINT32_MAX);
- return 0;
- }
-
- /* The starting sector number must fit in 32 bytes. */
- if (part->geom.start > UINT32_MAX) {
- ped_exception_throw (
- PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
- _("starting sector number, %jd exceeds"
- " the %s-partition-table-imposed maximum"
- " of %jd"),
- part->geom.start,
- label_type,
- UINT32_MAX);
- return 0;
- }
- }
+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("partition length of %jd sectors exceeds"
+ " the %s-partition-table-imposed maximum"
+ " of %jd"),
+ part->geom.length,
+ pt_type,
+ UINT32_MAX);
+ return 0;
}
+ /* If the starting sector exceeds the limit, you lose. */
+ if (part->geom.start > pt_lim->max_start_sector) {
+ ped_exception_throw (
+ PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("starting sector number, %jd exceeds"
+ " the %s-partition-table-imposed maximum"
+ " of %jd"),
+ part->geom.start,
+ pt_type,
+ UINT32_MAX);
+ return 0;
+ }
+
return 1;
}
+
+/* Set *MAX to the largest representation-imposed starting sector number
+ of a partition of type PT_TYPE and return 0. If PT_TYPE is not
+ recognized, return -1. */
+int
+ptt_partition_max_start_sector (char const *pt_type, PedSector *max)
+{
+ struct partition_limit const *pt_lim
+ = pt_limit_lookup (pt_type, strlen (pt_type));
+ if (pt_lim == NULL)
+ return -1;
+
+ *max = pt_lim->max_start_sector;
+ return 0;
+}
+
+/* Set *MAX to the maximum representable length of a partition of type
+ PT_TYPE and return 0. If PT_TYPE is not recognized, return -1. */
+int
+ptt_partition_max_length (char const *pt_type, PedSector *max)
+{
+ struct partition_limit const *pt_lim
+ = pt_limit_lookup (pt_type, strlen (pt_type));
+ if (pt_lim == NULL)
+ return -1;
+
+ *max = pt_lim->max_length;
+ return 0;
+}
diff --git a/libparted/labels/pt-tools.h b/libparted/labels/pt-tools.h
index 3f275d0..8131501 100644
--- a/libparted/labels/pt-tools.h
+++ b/libparted/labels/pt-tools.h
@@ -24,3 +24,6 @@ int ptt_read_sectors (PedDevice const *dev, PedSector
start_sector,
int ptt_clear_sectors (PedDevice *dev, PedSector start, PedSector count);
int ptt_partition_max_start_len (char const *label_type,
const PedPartition *part);
+
+int ptt_partition_max_start_sector (char const *pt_type, PedSector *max);
+int ptt_partition_max_length (char const *pt_type, PedSector *max);
--
1.6.6.rc0.285.g73651
>From eb2f593a9487aa19027482041be128cdcac541ae Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Thu, 3 Dec 2009 18:52:25 +0100
Subject: [PATCH 3/5] libparted: factor out duplication, hook up new APIs
* include/parted/disk.h [struct _PedDiskOps]:
(max_length, max_start_sector): New members.
* libparted/labels/pt-common.h: New file.
* libparted/labels/Makefile.am (liblabels_la_SOURCES): Add it.
* libparted/labels/dos.c: Include "pt-common.h".
(msdos_partition_check): Remove function.
(msdos_disk_ops): Remove factored out initializers.
* libparted/labels/gpt.c: Likewise.
* libparted/labels/dvh.c: Likewise.
* libparted/labels/aix.c:
(aix_disk_ops, aix_partition_check): Likewise.
* libparted/labels/bsd.c:
(bsd_disk_ops, bsd_partition_check): Likewise.
* libparted/labels/dasd.c:
(dasd_disk_ops, dasd_partition_check): Likewise.
* libparted/labels/loop.c:
(loop_disk_ops, loop_partition_check): Likewise.
* libparted/labels/mac.c:
(mac_disk_ops, mac_partition_check): Likewise.
* libparted/labels/pc98.c:
(pc98_disk_ops, pc98_partition_check): Likewise.
* libparted/labels/rdb.c:
(amiga_disk_ops, amiga_partition_check): Likewise.
* libparted/labels/sun.c:
(sun_disk_ops, sun_partition_check): Likewise.
* libparted/labels/gpt.c (NULL_IF_DISCOVER_ONLY): Remove definition,
now that it's in pt-common.h.
---
include/parted/disk.h | 2 +
libparted/labels/Makefile.am | 1 +
libparted/labels/aix.c | 42 ++++-------------------------
libparted/labels/bsd.c | 42 ++++-------------------------
libparted/labels/dasd.c | 34 +++++-------------------
libparted/labels/dos.c | 51 ++++-------------------------------
libparted/labels/dvh.c | 48 +++------------------------------
libparted/labels/gpt.c | 34 +++--------------------
libparted/labels/loop.c | 44 +++++--------------------------
libparted/labels/mac.c | 43 +++++-------------------------
libparted/labels/pc98.c | 45 ++++++-------------------------
libparted/labels/pt-common.h | 55 +++++++++++++++++++++++++++++++++++++++
libparted/labels/pt-limit.gperf | 14 ++++++++++
libparted/labels/rdb.c | 46 ++++++--------------------------
libparted/labels/sun.c | 41 ++++------------------------
15 files changed, 145 insertions(+), 397 deletions(-)
create mode 100644 libparted/labels/pt-common.h
diff --git a/include/parted/disk.h b/include/parted/disk.h
index 3f383e2..3449df6 100644
--- a/include/parted/disk.h
+++ b/include/parted/disk.h
@@ -215,6 +215,8 @@ struct _PedDiskOps {
bool (*get_max_supported_partition_count) (const PedDisk* disk,
int* supported);
PedAlignment *(*get_partition_alignment)(const PedDisk *disk);
+ PedSector (*max_length) (void);
+ PedSector (*max_start_sector) (void);
};
struct _PedDiskType {
diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am
index 9e8232c..6621d73 100644
--- a/libparted/labels/Makefile.am
+++ b/libparted/labels/Makefile.am
@@ -28,6 +28,7 @@ liblabels_la_SOURCES = \
mac.c \
misc.h \
pc98.c \
+ pt-common.h \
pt-tools.c \
pt-tools.h \
rdb.c \
diff --git a/libparted/labels/aix.c b/libparted/labels/aix.c
index 1a0fcf9..73eb1b7 100644
--- a/libparted/labels/aix.c
+++ b/libparted/labels/aix.c
@@ -235,47 +235,17 @@ aix_alloc_metadata (PedDisk* disk)
return 1;
}
-static bool
-aix_partition_check (const PedPartition* part)
-{
- return true;
-}
+#include "pt-common.h"
+PT_define_limit_functions (aix)
static PedDiskOps aix_disk_ops = {
- probe: aix_probe,
-#ifndef DISCOVER_ONLY
- clobber: aix_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: aix_alloc,
- duplicate: aix_duplicate,
- free: aix_free,
- read: aix_read,
-#ifndef DISCOVER_ONLY
- write: aix_write,
-#else
- write: NULL,
-#endif
-
- partition_new: aix_partition_new,
- partition_duplicate: aix_partition_duplicate,
- partition_destroy: aix_partition_destroy,
- partition_set_system: aix_partition_set_system,
- partition_set_flag: aix_partition_set_flag,
- partition_get_flag: aix_partition_get_flag,
- partition_is_flag_available: aix_partition_is_flag_available,
- partition_align: aix_partition_align,
- partition_enumerate: aix_partition_enumerate,
- partition_check: aix_partition_check,
- alloc_metadata: aix_alloc_metadata,
- get_max_primary_partition_count:
- aix_get_max_primary_partition_count,
- get_max_supported_partition_count:
- aix_get_max_supported_partition_count,
+ clobber: NULL_IF_DISCOVER_ONLY (aix_clobber),
+ write: NULL_IF_DISCOVER_ONLY (aix_write),
partition_set_name: NULL,
partition_get_name: NULL,
+
+ PT_op_function_initializers (aix)
};
static PedDiskType aix_disk_type = {
diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c
index 54d13ee..11f2374 100644
--- a/libparted/labels/bsd.c
+++ b/libparted/labels/bsd.c
@@ -638,47 +638,17 @@ error:
return 0;
}
-static bool
-bsd_partition_check (const PedPartition* part)
-{
- return true;
-}
+#include "pt-common.h"
+PT_define_limit_functions (bsd)
static PedDiskOps bsd_disk_ops = {
- probe: bsd_probe,
-#ifndef DISCOVER_ONLY
- clobber: bsd_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: bsd_alloc,
- duplicate: bsd_duplicate,
- free: bsd_free,
- read: bsd_read,
-#ifndef DISCOVER_ONLY
- write: bsd_write,
-#else
- write: NULL,
-#endif
+ clobber: NULL_IF_DISCOVER_ONLY (bsd_clobber),
+ write: NULL_IF_DISCOVER_ONLY (bsd_write),
- partition_new: bsd_partition_new,
- partition_duplicate: bsd_partition_duplicate,
- partition_destroy: bsd_partition_destroy,
- partition_set_system: bsd_partition_set_system,
- partition_set_flag: bsd_partition_set_flag,
- partition_get_flag: bsd_partition_get_flag,
- partition_is_flag_available: bsd_partition_is_flag_available,
partition_set_name: NULL,
partition_get_name: NULL,
- partition_align: bsd_partition_align,
- partition_enumerate: bsd_partition_enumerate,
- partition_check: bsd_partition_check,
-
- alloc_metadata: bsd_alloc_metadata,
- get_max_primary_partition_count:
- bsd_get_max_primary_partition_count,
- get_max_supported_partition_count:
- bsd_get_max_supported_partition_count
+
+ PT_op_function_initializers (bsd)
};
static PedDiskType bsd_disk_type = {
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index dd492f2..59f1594 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -107,39 +107,19 @@ static int dasd_partition_set_system (PedPartition* part,
const
PedFileSystemType* fs_type);
static int dasd_alloc_metadata (PedDisk* disk);
-static bool
-dasd_partition_check (const PedPartition *part)
-{
- return ptt_partition_max_start_len ("dasd", part);
-}
+#include "pt-common.h"
+PT_define_limit_functions (dasd)
static PedDiskOps dasd_disk_ops = {
- probe: dasd_probe,
- clobber: dasd_clobber,
- read: dasd_read,
- write: dasd_write,
-
- alloc: dasd_alloc,
- duplicate: dasd_duplicate,
- free: dasd_free,
- partition_set_system: dasd_partition_set_system,
-
- partition_new: dasd_partition_new,
- partition_duplicate: dasd_partition_duplicate,
- partition_destroy: dasd_partition_destroy,
- partition_set_flag: dasd_partition_set_flag,
- partition_get_flag: dasd_partition_get_flag,
- partition_is_flag_available: dasd_partition_is_flag_available,
+ clobber: NULL_IF_DISCOVER_ONLY (dasd_clobber),
+ write: NULL_IF_DISCOVER_ONLY (dasd_write),
+
partition_set_name: NULL,
partition_get_name: NULL,
- partition_align: dasd_partition_align,
- partition_enumerate: dasd_partition_enumerate,
- alloc_metadata: dasd_alloc_metadata,
- get_max_primary_partition_count: dasd_get_max_primary_partition_count,
- get_max_supported_partition_count:
dasd_get_max_supported_partition_count,
get_partition_alignment: dasd_get_partition_alignment,
- partition_check: dasd_partition_check,
+
+ PT_op_function_initializers (dasd)
};
static PedDiskType dasd_disk_type = {
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index cc9e0e3..f1ccb0a 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -2274,56 +2274,17 @@ msdos_get_max_supported_partition_count(const PedDisk*
disk, int *max_n)
return true;
}
-/*
- * Enforce some restrictions inherent in the DOS partition table format.
- * 1. Partition size must be smaller than 2^32 (unsigned int) sectors.
- * If sector size is 512 bytes, this results in 2T aprox.
- * 2. Partition starting sector number must be smaller than 2^32.
- */
-static bool
-msdos_partition_check (const PedPartition* part)
-{
- if (!ptt_partition_max_start_len("msdos", part))
- return false;
-
- return true;
-}
+#include "pt-common.h"
+PT_define_limit_functions (msdos)
static PedDiskOps msdos_disk_ops = {
- probe: msdos_probe,
-#ifndef DISCOVER_ONLY
- clobber: msdos_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: msdos_alloc,
- duplicate: msdos_duplicate,
- free: msdos_free,
- read: msdos_read,
-#ifndef DISCOVER_ONLY
- write: msdos_write,
-#else
- write: NULL,
-#endif
+ clobber: NULL_IF_DISCOVER_ONLY (msdos_clobber),
+ write: NULL_IF_DISCOVER_ONLY (msdos_write),
- partition_new: msdos_partition_new,
- partition_duplicate: msdos_partition_duplicate,
- partition_destroy: msdos_partition_destroy,
- partition_set_system: msdos_partition_set_system,
- partition_set_flag: msdos_partition_set_flag,
- partition_get_flag: msdos_partition_get_flag,
- partition_is_flag_available: msdos_partition_is_flag_available,
partition_set_name: NULL,
partition_get_name: NULL,
- partition_align: msdos_partition_align,
- partition_enumerate: msdos_partition_enumerate,
- partition_check: msdos_partition_check,
-
- alloc_metadata: msdos_alloc_metadata,
- get_max_primary_partition_count:
- msdos_get_max_primary_partition_count,
- get_max_supported_partition_count:
- msdos_get_max_supported_partition_count
+
+ PT_op_function_initializers (msdos)
};
static PedDiskType msdos_disk_type = {
diff --git a/libparted/labels/dvh.c b/libparted/labels/dvh.c
index 9049b86..8cf16b1 100644
--- a/libparted/labels/dvh.c
+++ b/libparted/labels/dvh.c
@@ -887,54 +887,16 @@ error:
return 0;
}
-/*
- * Enforce some restrictions inherent in the dvh partition table format.
- * 1. Partition size must be smaller than 2^32 (unsigned int) sectors.
- * If sector size is 512 bytes, this results in 2T aprox.
- * 2. Partition starting sector number must be smaller than 2^32.
- */
-static bool
-dvh_partition_check (const PedPartition* part)
-{
- if (!ptt_partition_max_start_len("dvh", part))
- return false;
-
- return true;
-}
+#include "pt-common.h"
+PT_define_limit_functions (dvh)
static PedDiskOps dvh_disk_ops = {
- probe: dvh_probe,
-#ifndef DISCOVER_ONLY
- clobber: dvh_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: dvh_alloc,
- duplicate: dvh_duplicate,
- free: dvh_free,
- read: dvh_read,
-#ifndef DISCOVER_ONLY
- write: dvh_write,
-#else
- write: NULL,
-#endif
+ clobber: NULL_IF_DISCOVER_ONLY (dvh_clobber),
+ write: NULL_IF_DISCOVER_ONLY (dvh_write),
- partition_new: dvh_partition_new,
- partition_duplicate: dvh_partition_duplicate,
- partition_destroy: dvh_partition_destroy,
- partition_set_system: dvh_partition_set_system,
- partition_set_flag: dvh_partition_set_flag,
- partition_get_flag: dvh_partition_get_flag,
- partition_is_flag_available: dvh_partition_is_flag_available,
partition_set_name: dvh_partition_set_name,
partition_get_name: dvh_partition_get_name,
- partition_align: dvh_partition_align,
- partition_enumerate: dvh_partition_enumerate,
- partition_check: dvh_partition_check,
-
- alloc_metadata: dvh_alloc_metadata,
- get_max_primary_partition_count: dvh_get_max_primary_partition_count,
- get_max_supported_partition_count: dvh_get_max_supported_partition_count
+ PT_op_function_initializers (dvh)
};
static PedDiskType dvh_disk_type = {
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index e6347e3..ca842d3 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1690,42 +1690,18 @@ gpt_partition_align (PedPartition *part, const
PedConstraint *constraint)
return 0;
}
-static bool
-gpt_partition_check (const PedPartition *part)
-{
- return true;
-}
-
-#ifdef DISCOVER_ONLY
-# define NULL_IF_DISCOVER_ONLY(val) NULL
-#else
-# define NULL_IF_DISCOVER_ONLY(val) val
-#endif
+#include "pt-common.h"
+PT_define_limit_functions (gpt)
static PedDiskOps gpt_disk_ops =
{
- probe: gpt_probe,
clobber: NULL_IF_DISCOVER_ONLY (gpt_clobber),
- alloc: gpt_alloc,
- duplicate: gpt_duplicate,
- free: gpt_free,
- read: gpt_read,
write: NULL_IF_DISCOVER_ONLY (gpt_write),
- partition_new: gpt_partition_new,
- partition_duplicate: gpt_partition_duplicate,
- partition_destroy: gpt_partition_destroy,
- partition_set_system: gpt_partition_set_system,
- partition_set_flag: gpt_partition_set_flag,
- partition_get_flag: gpt_partition_get_flag,
- partition_is_flag_available: gpt_partition_is_flag_available,
+
partition_set_name: gpt_partition_set_name,
partition_get_name: gpt_partition_get_name,
- partition_align: gpt_partition_align,
- partition_enumerate: gpt_partition_enumerate,
- partition_check: gpt_partition_check,
- alloc_metadata: gpt_alloc_metadata,
- get_max_primary_partition_count: gpt_get_max_primary_partition_count,
- get_max_supported_partition_count: gpt_get_max_supported_partition_count
+
+ PT_op_function_initializers (gpt)
};
static PedDiskType gpt_disk_type =
diff --git a/libparted/labels/loop.c b/libparted/labels/loop.c
index 76a99af..8b8af0d 100644
--- a/libparted/labels/loop.c
+++ b/libparted/labels/loop.c
@@ -293,47 +293,17 @@ loop_get_max_supported_partition_count (const PedDisk*
disk, int *max_n)
return true;
}
-static bool
-loop_partition_check (const PedPartition* part)
-{
- return true;
-}
+#include "pt-common.h"
+PT_define_limit_functions (loop)
static PedDiskOps loop_disk_ops = {
- probe: loop_probe,
-#ifndef DISCOVER_ONLY
- clobber: loop_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: loop_alloc,
- duplicate: loop_duplicate,
- free: loop_free,
- read: loop_read,
-#ifndef DISCOVER_ONLY
- write: loop_write,
-#else
- write: NULL,
-#endif
-
- partition_new: loop_partition_new,
- partition_duplicate: loop_partition_duplicate,
- partition_destroy: loop_partition_destroy,
- partition_set_system: loop_partition_set_system,
- partition_set_flag: loop_partition_set_flag,
- partition_get_flag: loop_partition_get_flag,
- partition_is_flag_available: loop_partition_is_flag_available,
+ clobber: NULL_IF_DISCOVER_ONLY (loop_clobber),
+ write: NULL_IF_DISCOVER_ONLY (loop_write),
+
partition_set_name: NULL,
partition_get_name: NULL,
- partition_align: loop_partition_align,
- partition_enumerate: loop_partition_enumerate,
- partition_check: loop_partition_check,
-
- alloc_metadata: loop_alloc_metadata,
- get_max_primary_partition_count:
- loop_get_max_primary_partition_count,
- get_max_supported_partition_count:
- loop_get_max_supported_partition_count
+
+ PT_op_function_initializers (loop)
};
static PedDiskType loop_disk_type = {
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index 319adcc..d441140 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -1625,50 +1625,21 @@ mac_get_max_supported_partition_count (const PedDisk*
disk, int *max_n)
return true;
}
-static bool
-mac_partition_check (const PedPartition* part)
-{
- return ptt_partition_max_start_len ("mac", part);
-}
+#include "pt-common.h"
+PT_define_limit_functions (mac)
static PedDiskOps mac_disk_ops = {
- probe: mac_probe,
-#ifndef DISCOVER_ONLY
- clobber: mac_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: mac_alloc,
- duplicate: mac_duplicate,
- free: mac_free,
- read: mac_read,
-#ifndef DISCOVER_ONLY
+ clobber: NULL_IF_DISCOVER_ONLY (mac_clobber),
/* FIXME: remove this cast, once mac_write is fixed not to
modify its *DISK parameter. */
- write: (int (*) (const PedDisk*)) mac_write,
-#else
- write: NULL,
-#endif
+ write: NULL_IF_DISCOVER_ONLY ((int (*) (const PedDisk*)) mac_write),
- partition_new: mac_partition_new,
- partition_duplicate: mac_partition_duplicate,
- partition_destroy: mac_partition_destroy,
- partition_set_system: mac_partition_set_system,
- partition_set_flag: mac_partition_set_flag,
- partition_get_flag: mac_partition_get_flag,
- partition_is_flag_available: mac_partition_is_flag_available,
partition_set_name: mac_partition_set_name,
partition_get_name: mac_partition_get_name,
- partition_align: mac_partition_align,
- partition_enumerate: mac_partition_enumerate,
- partition_check: mac_partition_check,
-
- alloc_metadata: mac_alloc_metadata,
- get_max_primary_partition_count:
- mac_get_max_primary_partition_count,
- get_max_supported_partition_count:
- mac_get_max_supported_partition_count,
+
get_partition_alignment: mac_get_partition_alignment,
+
+ PT_op_function_initializers (mac)
};
static PedDiskType mac_disk_type = {
diff --git a/libparted/labels/pc98.c b/libparted/labels/pc98.c
index 51f1b11..506fb3b 100644
--- a/libparted/labels/pc98.c
+++ b/libparted/labels/pc98.c
@@ -22,6 +22,8 @@
#include <parted/debug.h>
#include <parted/endian.h>
+#include "pt-tools.h"
+
#if ENABLE_NLS
# include <libintl.h>
# define _(String) dgettext (PACKAGE, String)
@@ -851,48 +853,19 @@ pc98_get_max_supported_partition_count (const PedDisk*
disk, int *max_n)
return true;
}
-static bool
-pc98_partition_check (const PedPartition* part)
-{
- return true;
-}
+#include "pt-common.h"
+PT_define_limit_functions (pc98)
static PedDiskOps pc98_disk_ops = {
- probe: pc98_probe,
-#ifndef DISCOVER_ONLY
- clobber: pc98_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: pc98_alloc,
- duplicate: pc98_duplicate,
- free: pc98_free,
- read: pc98_read,
-#ifndef DISCOVER_ONLY
- write: pc98_write,
-#else
- write: NULL,
-#endif
+ clobber: NULL_IF_DISCOVER_ONLY (pc98_clobber),
+ write: NULL_IF_DISCOVER_ONLY (pc98_write),
- partition_new: pc98_partition_new,
- partition_duplicate: pc98_partition_duplicate,
- partition_destroy: pc98_partition_destroy,
- partition_set_system: pc98_partition_set_system,
- partition_set_flag: pc98_partition_set_flag,
- partition_get_flag: pc98_partition_get_flag,
- partition_is_flag_available: pc98_partition_is_flag_available,
partition_set_name: pc98_partition_set_name,
partition_get_name: pc98_partition_get_name,
- partition_align: pc98_partition_align,
- partition_enumerate: pc98_partition_enumerate,
- partition_check: pc98_partition_check,
-
- alloc_metadata: pc98_alloc_metadata,
- get_max_primary_partition_count:
- pc98_get_max_primary_partition_count,
- get_max_supported_partition_count:
- pc98_get_max_supported_partition_count,
+
get_partition_alignment: pc98_get_partition_alignment,
+
+ PT_op_function_initializers (pc98)
};
static PedDiskType pc98_disk_type = {
diff --git a/libparted/labels/pt-common.h b/libparted/labels/pt-common.h
new file mode 100644
index 0000000..97eee0a
--- /dev/null
+++ b/libparted/labels/pt-common.h
@@ -0,0 +1,55 @@
+/* Factor some of the duplication out of *.c. */
+
+#ifdef DISCOVER_ONLY
+# define NULL_IF_DISCOVER_ONLY(val) NULL
+#else
+# define NULL_IF_DISCOVER_ONLY(val) val
+#endif
+
+#define PT_define_limit_functions(PT_type) \
+ \
+static bool \
+PT_type##_partition_check (const PedPartition *part) \
+{ \
+ return ptt_partition_max_start_len (#PT_type, part); \
+} \
+ \
+static PedSector \
+PT_type##_partition_max_start_sector (void) \
+{ \
+ PedSector max; \
+ int err = ptt_partition_max_start_sector (#PT_type, &max); \
+ PED_ASSERT (err == 0, return 0); \
+ return max; \
+} \
+ \
+static PedSector \
+PT_type##_partition_max_length (void) \
+{ \
+ PedSector max; \
+ int err = ptt_partition_max_length (#PT_type, &max); \
+ PED_ASSERT (err == 0, return 0); \
+ return max; \
+}
+
+#define PT_op_function_initializers(PT_type) \
+probe: PT_type##_probe, \
+alloc: PT_type##_alloc, \
+duplicate: PT_type##_duplicate, \
+free: PT_type##_free, \
+read: PT_type##_read, \
+partition_new: PT_type##_partition_new, \
+partition_duplicate: PT_type##_partition_duplicate, \
+partition_set_flag: PT_type##_partition_set_flag, \
+partition_get_flag: PT_type##_partition_get_flag, \
+partition_set_system: PT_type##_partition_set_system, \
+partition_is_flag_available: PT_type##_partition_is_flag_available, \
+partition_align: PT_type##_partition_align, \
+partition_destroy: PT_type##_partition_destroy, \
+partition_enumerate: PT_type##_partition_enumerate, \
+alloc_metadata: PT_type##_alloc_metadata, \
+get_max_primary_partition_count: PT_type##_get_max_primary_partition_count, \
+get_max_supported_partition_count:PT_type##_get_max_supported_partition_count,\
+partition_check: PT_type##_partition_check, \
+max_length: PT_type##_partition_max_length, \
+max_start_sector: PT_type##_partition_max_start_sector
diff --git a/libparted/labels/pt-limit.gperf b/libparted/labels/pt-limit.gperf
index 7e3f8ca..f834647 100644
--- a/libparted/labels/pt-limit.gperf
+++ b/libparted/labels/pt-limit.gperf
@@ -10,3 +10,17 @@ dvh,UINT32_MAX,UINT32_MAX
gpt,UINT64_MAX,UINT64_MAX
mac,UINT32_MAX,UINT32_MAX
msdos,UINT32_MAX,UINT32_MAX
+#
+# Sun partitions are cylinder-aligned, and it looks like there are 128 sectors
+# in a cylinder. FIXME verify. Possibly compute sectors-per-cylinder, given
+# u_int16_t ntrks; /* Tracks per cylinder */
+# u_int16_t nsect; /* Sectors per track */
+sun,128ULL*UINT32_MAX,UINT32_MAX
+#
+bsd,UINT32_MAX,UINT32_MAX
+# aix,UINT32_MAX,UINT32_MAX
+loop,UINT32_MAX,UINT32_MAX
+pc98,UINT32_MAX,UINT32_MAX
+#
+# FIXME: not verified. looks like these are cylinder aligned, too
+amiga,UINT32_MAX,UINT32_MAX
diff --git a/libparted/labels/rdb.c b/libparted/labels/rdb.c
index 9460f0c..a206075 100644
--- a/libparted/labels/rdb.c
+++ b/libparted/labels/rdb.c
@@ -26,6 +26,8 @@
#include <parted/debug.h>
#include <parted/endian.h>
+#include "pt-tools.h"
+
#ifndef MAX
# define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif
@@ -1143,49 +1145,19 @@ amiga_get_max_supported_partition_count (const PedDisk*
disk, int *max_n)
return true;
}
-static bool
-amiga_partition_check (const PedPartition* part)
-{
- return true;
-}
+#include "pt-common.h"
+PT_define_limit_functions (amiga)
static PedDiskOps amiga_disk_ops = {
- probe: amiga_probe,
-#ifndef DISCOVER_ONLY
- clobber: amiga_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: amiga_alloc,
- duplicate: amiga_duplicate,
- free: amiga_free,
- read: amiga_read,
-#ifndef DISCOVER_ONLY
- write: amiga_write,
-#else
- write: NULL,
-#endif
+ clobber: NULL_IF_DISCOVER_ONLY (amiga_clobber),
+ write: NULL_IF_DISCOVER_ONLY (amiga_write),
- partition_new: amiga_partition_new,
- partition_duplicate: amiga_partition_duplicate,
- partition_destroy: amiga_partition_destroy,
- partition_set_system: amiga_partition_set_system,
- partition_set_flag: amiga_partition_set_flag,
- partition_get_flag: amiga_partition_get_flag,
- partition_is_flag_available:
- amiga_partition_is_flag_available,
partition_set_name: amiga_partition_set_name,
partition_get_name: amiga_partition_get_name,
- partition_align: amiga_partition_align,
- partition_enumerate: amiga_partition_enumerate,
- partition_check: amiga_partition_check,
-
- alloc_metadata: amiga_alloc_metadata,
- get_max_primary_partition_count:
- amiga_get_max_primary_partition_count,
- get_max_supported_partition_count:
- amiga_get_max_supported_partition_count,
+
get_partition_alignment: amiga_get_partition_alignment,
+
+ PT_op_function_initializers (amiga)
};
static PedDiskType amiga_disk_type = {
diff --git a/libparted/labels/sun.c b/libparted/labels/sun.c
index 86e4ef4..1909cc7 100644
--- a/libparted/labels/sun.c
+++ b/libparted/labels/sun.c
@@ -875,48 +875,19 @@ error:
return 0;
}
-static bool
-sun_partition_check (const PedPartition* part)
-{
- return true;
-}
+#include "pt-common.h"
+PT_define_limit_functions (sun)
static PedDiskOps sun_disk_ops = {
- probe: sun_probe,
-#ifndef DISCOVER_ONLY
- clobber: sun_clobber,
-#else
- clobber: NULL,
-#endif
- alloc: sun_alloc,
- duplicate: sun_duplicate,
- free: sun_free,
- read: sun_read,
-#ifndef DISCOVER_ONLY
- write: sun_write,
-#else
- write: NULL,
-#endif
+ clobber: NULL_IF_DISCOVER_ONLY (sun_clobber),
+ write: NULL_IF_DISCOVER_ONLY (sun_write),
- partition_new: sun_partition_new,
- partition_duplicate: sun_partition_duplicate,
- partition_destroy: sun_partition_destroy,
- partition_set_system: sun_partition_set_system,
- partition_set_flag: sun_partition_set_flag,
- partition_get_flag: sun_partition_get_flag,
- partition_is_flag_available: sun_partition_is_flag_available,
- partition_align: sun_partition_align,
- partition_enumerate: sun_partition_enumerate,
- partition_check: sun_partition_check,
- alloc_metadata: sun_alloc_metadata,
- get_max_primary_partition_count:
- sun_get_max_primary_partition_count,
- get_max_supported_partition_count:
- sun_get_max_supported_partition_count,
get_partition_alignment: sun_get_partition_alignment,
partition_set_name: NULL,
partition_get_name: NULL,
+
+ PT_op_function_initializers (sun)
};
static PedDiskType sun_disk_type = {
--
1.6.6.rc0.285.g73651
>From 5bf0ecbc32a64450d69d8e7db0b36bdc7f01e95d Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Fri, 4 Dec 2009 17:18:57 +0100
Subject: [PATCH 4/5] libparted: new interfaces: max start sector, max partition
length
* libparted/disk.c (ped_disk_max_partition_start_sector): New function.
(ped_disk_max_partition_length): New function.
* include/parted/disk.h: Declare them.
* NEWS (New features): Mention them.
---
NEWS | 6 ++++++
include/parted/disk.h | 3 +++
libparted/disk.c | 20 ++++++++++++++++++++
3 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
index 5241301..9a0ac2c 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,12 @@ GNU parted NEWS -*- outline
-*-
** New features
+ libparted: new functions to return per-partition-table-type limits:
+ - ped_disk_max_partition_start_sector: Return the largest representable
+ start sector number for a given "disk".
+ - ped_disk_max_partition_length: Return the maximum partition length
+ for a given "disk".
+
new command "align-check TYPE N" to determine whether the starting sector
of partition N is TYPE(minimal|optimal)-aligned for the disk. E.g.,
parted -s /dev/sda align-check min 1 && echo partition 1 is min-aligned
diff --git a/include/parted/disk.h b/include/parted/disk.h
index 3449df6..cb5d179 100644
--- a/include/parted/disk.h
+++ b/include/parted/disk.h
@@ -327,6 +327,9 @@ extern PedPartition* ped_disk_get_partition_by_sector
(const PedDisk* disk,
PedSector sect);
extern PedPartition* ped_disk_extended_partition (const PedDisk* disk);
+extern PedSector ped_disk_max_partition_length (const PedDisk *disk);
+extern PedSector ped_disk_max_partition_start_sector (const PedDisk *disk);
+
/* internal functions */
extern PedDisk* _ped_disk_alloc (const PedDevice* dev, const PedDiskType*
type);
extern void _ped_disk_free (PedDisk* disk);
diff --git a/libparted/disk.c b/libparted/disk.c
index 89476a7..a615d36 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -1479,6 +1479,26 @@ ped_disk_get_partition_by_sector (const PedDisk* disk,
PedSector sect)
return NULL;
}
+/**
+ * Return the maximum representable length (in sectors) of a
+ * partition on disk \disk.
+ */
+PedSector
+ped_disk_max_partition_length (const PedDisk* disk)
+{
+ return disk->type->ops->max_length ();
+}
+
+/**
+ * Return the maximum representable start sector of a
+ * partition on disk \disk.
+ */
+PedSector
+ped_disk_max_partition_start_sector (const PedDisk* disk)
+{
+ return disk->type->ops->max_start_sector ();
+}
+
/* I'm beginning to agree with Sedgewick :-/ */
static int
_disk_raw_insert_before (PedDisk* disk, PedPartition* loc, PedPartition* part)
--
1.6.6.rc0.285.g73651
>From 4840ea5979b34f5ab44b3adb6760d2231bfcd176 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Fri, 4 Dec 2009 19:36:58 +0100
Subject: [PATCH 5/5] tests: exercise the new interfaces
* tests/print-max.c: New file.
* tests/t9021-maxima.sh: New file.
* tests/Makefile.am (TESTS): Add t9021-maxima.sh.
(check_PROGRAMS): Add print-max.
---
tests/Makefile.am | 3 +-
tests/print-max.c | 35 +++++++++++++++++++++++++++++++
tests/t9021-maxima.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+), 1 deletions(-)
create mode 100644 tests/print-max.c
create mode 100755 tests/t9021-maxima.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b6d8ca2..7bfb22e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -31,12 +31,13 @@ TESTS = \
t8000-loop.sh \
t9010-big-sector.sh \
t9020-alignment.sh \
+ t9021-maxima.sh \
t9030-align-check.sh
EXTRA_DIST = \
$(TESTS) test-lib.sh t-lib.sh lvm-utils.sh t-local.sh t-lvm.sh
-check_PROGRAMS = print-align
+check_PROGRAMS = print-align print-max
LDADD = \
$(top_builddir)/libparted/libparted.la
AM_CPPFLAGS = \
diff --git a/tests/print-max.c b/tests/print-max.c
new file mode 100644
index 0000000..7560d49
--- /dev/null
+++ b/tests/print-max.c
@@ -0,0 +1,35 @@
+#include <config.h>
+#include <parted/parted.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "closeout.h"
+#include "progname.h"
+
+int
+main (int argc, char **argv)
+{
+ atexit (close_stdout);
+ set_program_name (argv[0]);
+
+ if (argc != 2)
+ return EXIT_FAILURE;
+
+ char const *dev_name = argv[1];
+ PedDevice *dev = ped_device_get (dev_name);
+ if (dev == NULL)
+ return EXIT_FAILURE;
+ PedDisk *disk = ped_disk_new (dev);
+ if (disk == NULL)
+ return EXIT_FAILURE;
+
+ PedSector max_length = ped_disk_max_partition_length (disk);
+ PedSector max_start_sector = ped_disk_max_partition_start_sector (disk);
+
+ printf ("max len: %llu\n", (unsigned long long) max_length);
+ printf ("max start sector: %llu\n", (unsigned long long) max_start_sector);
+
+ ped_disk_destroy (disk);
+ ped_device_destroy (dev);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/t9021-maxima.sh b/tests/t9021-maxima.sh
new file mode 100755
index 0000000..dbd4d3e
--- /dev/null
+++ b/tests/t9021-maxima.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+# verify that partition maxima-querying functions work
+
+# Copyright (C) 2009 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/>.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ parted --version
+fi
+
+: ${srcdir=.}
+. $srcdir/t-lib.sh
+
+fail=0
+dev=dev-file
+PATH="..:$PATH"
+export PATH
+
+# FIXME: add aix when/if it's supported again
+for t in msdos gpt dvh sun mac bsd amiga loop pc98; do
+ echo $t
+ rm -f $dev
+ dd if=/dev/zero of=$dev bs=512 count=1 seek=10000 || { fail=1; continue; }
+ parted -s $dev mklabel $t || { fail=1; continue; }
+
+ #case $t in pc98) sleep 999d;; esac
+
+ max_start=4294967295
+ max_len=4294967295
+ case $t in
+ gpt) max_start=18446744073709551615; max_len=$max_start;;
+ sun) max_start=549755813760;; # 128 * (2^32-1)
+ esac
+
+ print-max $dev > out 2>&1 || fail=1
+ printf '%s\n' "max len: $max_len" \
+ "max start sector: $max_start" > exp || fail=1
+ compare out exp || fail=1
+done
+
+Exit $fail
--
1.6.6.rc0.285.g73651
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel