summaryrefslogtreecommitdiff
path: root/fdisk/fdisk.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-06-16 10:52:20 +0200
committerKarel Zak <kzak@redhat.com>2010-06-16 10:52:20 +0200
commit278f63c0e6266eb60535ad2e65db01c0e8b85d56 (patch)
tree1c8b73376af84a040037f722d928d44b5e9bdf83 /fdisk/fdisk.c
parentd1f5a55949a2c34656ae413b4afa21ebc96e32fa (diff)
downloadutil-linux-old-278f63c0e6266eb60535ad2e65db01c0e8b85d56.tar.gz
fdisk: extend -c and -u options to support old DOS stuff
The DOS mode and cylinders as display units are disabled by default now. For users who need old DOS behavior is it necessary to extend -c (compatibility) and -u (units) command line options. The change is backwardly compatible (so people who already uses -u and -c are not affected with this change). New form: -c[=<mode>] where <mode> is 'dos' or 'nondos' (default) -u[=<units>] where <units> is 'cylinders' or 'sectors' (default) For example old deprecated DOS behavior could be enabled by: fdisk -u=cylinders -c=dos /dev/sda Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisk/fdisk.c')
-rw-r--r--fdisk/fdisk.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index f1392e7b..99b50aac 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -260,9 +260,9 @@ void fatal(enum failure why) {
" fdisk -s <partition> give partition size(s) in blocks\n"
"\nOptions:\n"
" -b <size> sector size (512, 1024, 2048 or 4096)\n"
-" -c switch off DOS-compatible mode (default)\n"
+" -c[=<mode>] compatible mode: 'dos' or 'nondos' (default)\n"
" -h print this help text\n"
-" -u show sizes in sectors instead of cylinders (default)\n"
+" -u[=<unit>] dysplay units: 'cylinders' or 'sectors' (default)\n"
" -v print program version\n"
" -C <number> specify the number of cylinders\n"
" -H <number> specify the number of heads\n"
@@ -1609,8 +1609,11 @@ void change_units(void)
{
display_in_cyl_units = !display_in_cyl_units;
update_units();
- printf(_("Changing display/entry units to %s\n"),
- str_units(PLURAL));
+
+ if (display_in_cyl_units)
+ printf(_("Changing display/entry units to cylinders (DEPRECATED!)\n"));
+ else
+ printf(_("Changing display/entry units to sectors\n"));
}
static void
@@ -1630,7 +1633,7 @@ static void
toggle_dos_compatibility_flag(void) {
dos_compatible_flag = ~dos_compatible_flag;
if (dos_compatible_flag)
- printf(_("DOS Compatibility flag is set\n"));
+ printf(_("DOS Compatibility flag is set (DEPRECATED!)\n"));
else
printf(_("DOS Compatibility flag is not set\n"));
@@ -2919,7 +2922,7 @@ main(int argc, char **argv) {
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((c = getopt(argc, argv, "b:cC:hH:lsS:uvV")) != -1) {
+ while ((c = getopt(argc, argv, "b:c::C:hH:lsS:u::vV")) != -1) {
switch (c) {
case 'b':
/* Ugly: this sector size is really per device,
@@ -2937,7 +2940,12 @@ main(int argc, char **argv) {
user_cylinders = atoi(optarg);
break;
case 'c':
- dos_compatible_flag = 0;
+ dos_compatible_flag = 0; /* default */
+
+ if (optarg && !strcmp(optarg, "=dos"))
+ dos_compatible_flag = ~0;
+ else if (optarg && strcmp(optarg, "=nondos"))
+ fatal(usage);
break;
case 'h':
fatal(help);
@@ -2959,7 +2967,11 @@ main(int argc, char **argv) {
opts = 1;
break;
case 'u':
- display_in_cyl_units = 0;
+ display_in_cyl_units = 0; /* default */
+ if (optarg && strcmp(optarg, "=cylinders") == 0)
+ display_in_cyl_units = !display_in_cyl_units;
+ else if (optarg && strcmp(optarg, "=sectors"))
+ fatal(usage);
break;
case 'V':
case 'v':