diff options
author | Joel Granados Moreno <jgranado@redhat.com> | 2009-05-18 17:37:43 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-07-24 15:04:43 +0200 |
commit | f387fee8be8f6d5cba90555462e5ec0b88400c38 (patch) | |
tree | 4f45f8b4edb445a072dac4e84ccfafe963fb758c /libparted/disk.c | |
parent | a60bdc0795df2191106ac8078230428d234755c1 (diff) | |
download | parted-f387fee8be8f6d5cba90555462e5ec0b88400c38.tar.gz |
put partition-table-specific logic in the corresponding files
* include/parted/disk.h (struct _PedDiskOps) [partition_check]:
New member function.
* libparted/disk.c (_check_partition): Replace open-coded tests with
use of the new ->partition_check().
(_partition_max_start, _partition_max_len): Remove functions.
* libparted/labels/dvh.c (dvh_partition_check): New function.
* libparted/labels/dos.c (dos_partition_check): Likewise.
* libparted/labels/aix.c (aix_partition_check): New stub.
* libparted/labels/bsd.c (bsd_partition_check): Likewise.
* libparted/labels/gpt.c (gpt_partition_check): Likewise.
* libparted/labels/loop.c (loop_partition_check): Likewise.
* libparted/labels/mac.c (mac_partition_check): Likewise.
* libparted/labels/pc98.c (pc98_partition_check): Likewise.
* libparted/labels/rdb.c (rdb_partition_check): Likewise.
* libparted/labels/sun.c (sun_partition_check): Likewise.
Diffstat (limited to 'libparted/disk.c')
-rw-r--r-- | libparted/disk.c | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/libparted/disk.c b/libparted/disk.c index 4dae762..ab8514a 100644 --- a/libparted/disk.c +++ b/libparted/disk.c @@ -1700,31 +1700,6 @@ _check_extended_partition (PedDisk* disk, PedPartition* part) return 1; } -static PedSector -_partition_max_start (char const *label_type) -{ - /* List partition table names (a la disk->type->name) for which - the partition length, in sectors, must fit in 32 bytes. */ - static char const *const max_32[] = {"msdos", "dvh"}; - unsigned int i; - - for (i = 0; i < sizeof max_32 / sizeof *max_32; i++) - if (strcmp (label_type, max_32[i]) == 0) - return UINT32_MAX; - - return TYPE_MAXIMUM (PedSector); -} - -static PedSector -_partition_max_len (char const *label_type) -{ - /* NOTE: for now, they happen to be the same, so don't - duplicate needlessly. Of course, if there's some format - with different length and starting sector limits, then - these functions will diverge. */ - return _partition_max_start (label_type); -} - static int _check_partition (PedDisk* disk, PedPartition* part) { @@ -1765,44 +1740,9 @@ _check_partition (PedDisk* disk, PedPartition* part) return 0; } - if (!(part->type & PED_PARTITION_METADATA)) { - char const *label_type = disk->type->name; - /* Enforce some restrictions inherent in the DOS - partition table format. Without these, one would be able - to create a 2TB partition (or larger), and it would work, - but only until the next reboot. This was insidious: the - too-large partition would work initially, because with - Linux-2.4.x and newer we set the partition start sector - and length (in sectors) accurately and directly via the - BLKPG ioctl. However, only the last 32 bits of each - number would be written to the partition table, and the - next time the system would read/use those corrupted numbers - it would usually complain about an invalid partition. - The same applies to the starting sector number. */ - - if (part->geom.length > _partition_max_len (label_type)) { - 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, - _partition_max_len (label_type)); + if (!(part->type & PED_PARTITION_METADATA)) + if (!disk->type->ops->partition_check(part)) return 0; - } - - /* The starting sector number must fit in 32 bytes. */ - if (part->geom.start > _partition_max_start (label_type)) { - 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, - _partition_max_start (label_type)); - return 0; - } - } return 1; } |