[PATCH 3/5] libparted: factor out duplication, hook up new APIs
Jim Meyering
meyering at redhat.com
Thu Dec 3 17:52:25 UTC 2009
* 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
More information about the parted-devel
mailing list