From 0e6f4a203d8715710ff09683390be2897cca3804 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 7 Dec 2006 00:26:02 +0100 Subject: Imported from util-linux-2.11v tarball. --- fdisk/fdisk.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'fdisk/fdisk.c') diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 1ff518411..a1d84e561 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -1269,7 +1269,9 @@ change_sysid(void) { origsys = sys = get_sysid(i); - if (!sys && !sgi_label && !sun_label) + /* if changing types T to 0 is allowed, then + the reverse change must be allowed, too */ + if (!sys && !sgi_label && !sun_label && !get_nr_sects(p)) printf(_("Partition %d does not exist yet!\n"), i + 1); else while (1) { sys = read_hex (get_sys_types()); @@ -1304,7 +1306,7 @@ change_sysid(void) { "partition 11 as entire volume (6)" "as IRIX expects it.\n\n")); if (sys == origsys) - break; + break; if (sun_label) { sun_change_sysid(i, sys); } else @@ -2316,12 +2318,17 @@ main(int argc, char **argv) { * fdisk -l [-b sectorsize] [-u] device ... * fdisk -s [partition] ... * fdisk [-b sectorsize] [-u] device + * + * Options -C, -H, -S set the geometry. + * */ - while ((c = getopt(argc, argv, "b:lsuvV")) != -1) { + while ((c = getopt(argc, argv, "b:C:H:lsS:uvV")) != -1) { switch (c) { case 'b': - /* ugly: this sector size is really per device, - so cannot be combined with multiple disks */ + /* Ugly: this sector size is really per device, + so cannot be combined with multiple disks, + and te same goes for the C/H/S options. + */ sector_size = atoi(optarg); if (sector_size != 512 && sector_size != 1024 && sector_size != 2048) @@ -2329,6 +2336,19 @@ main(int argc, char **argv) { sector_offset = 2; user_set_sector_size = 1; break; + case 'C': + user_cylinders = atoi(optarg); + break; + case 'H': + user_heads = atoi(optarg); + if (user_heads <= 0 || user_heads >= 256) + user_heads = 0; + break; + case 'S': + user_sectors = atoi(optarg); + if (user_sectors <= 0 || user_sectors >= 64) + user_sectors = 0; + break; case 'l': optl = 1; break; -- cgit v1.2.3-55-g7522