summaryrefslogtreecommitdiffstats
path: root/fdisk
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:26:02 +0100
committerKarel Zak2006-12-07 00:26:02 +0100
commit0e6f4a203d8715710ff09683390be2897cca3804 (patch)
tree982a4e50be23b6c30245c61bfed170c592b34e41 /fdisk
parentImported from util-linux-2.11u tarball. (diff)
downloadkernel-qcow2-util-linux-0e6f4a203d8715710ff09683390be2897cca3804.tar.gz
kernel-qcow2-util-linux-0e6f4a203d8715710ff09683390be2897cca3804.tar.xz
kernel-qcow2-util-linux-0e6f4a203d8715710ff09683390be2897cca3804.zip
Imported from util-linux-2.11v tarball.
Diffstat (limited to 'fdisk')
-rw-r--r--fdisk/fdisk.820
-rw-r--r--fdisk/fdisk.c30
2 files changed, 43 insertions, 7 deletions
diff --git a/fdisk/fdisk.8 b/fdisk/fdisk.8
index 3ee111b40..9f30c32b8 100644
--- a/fdisk/fdisk.8
+++ b/fdisk/fdisk.8
@@ -5,9 +5,10 @@
.SH NAME
fdisk \- Partition table manipulator for Linux
.SH SYNOPSIS
-.BI "fdisk [\-u] [\-b sectorsize]" device
+.BI "fdisk [\-u] [\-b " sectorsize ]
+.BI "[\-C " cyls "] [\-H " heads "] [\-S " sects "] " device
.sp
-.BI "fdisk \-l [\-u] [\-b sectorsize] [" "device ..." ]
+.BI "fdisk \-l [\-u] [" "device ..." ]
.sp
.BI "fdisk \-s " "partition ..."
.sp
@@ -174,6 +175,21 @@ Specify the sector size of the disk. Valid values are 512, 1024, or 2048.
(Recent kernels know the sector size. Use this only on old kernels or
to override the kernel's ideas.)
.TP
+.BI "\-C " cyls
+Specify the number of cylinders of the disk.
+I have no idea why anybody would want to do so.
+.TP
+.BI "\-H " heads
+Specify the number of heads of the disk. (Not the physical number,
+of course, but the number used for partition tables.)
+Reasonable values are 255 and 16.
+.TP
+.BI "\-S " sects
+Specify the number of sectors per track of the disk.
+(Not the physical number, of course, but the number used for
+partition tables.)
+A reasonable value is 63.
+.TP
.B \-l
List the partition tables for the specified devices and then exit.
If no devices are given, those mentioned in
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;