summaryrefslogtreecommitdiff
path: root/util-linux/fdisk.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-19 14:43:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-19 14:43:38 +0000
commitbd852076b9f6600d039e75d646a6965b5b092606 (patch)
treeea133ee61be3857f3d7fa4c67302c52eb268391c /util-linux/fdisk.c
parentde8a6a01d84ebb09a333104bf0fd5f6e251d9eb7 (diff)
downloadbusybox-w32-bd852076b9f6600d039e75d646a6965b5b092606.tar.gz
busybox-w32-bd852076b9f6600d039e75d646a6965b5b092606.tar.bz2
busybox-w32-bd852076b9f6600d039e75d646a6965b5b092606.zip
fdisk: get rid of _() macro.
Shorten some messages. Stop using stderr - anyone who tries to use fdisk no-interactively is "strange" anyway. Improve storage handling in bsd module. text data bss dec hex filename 728112 1488 33788 763388 ba5fc busybox.t0/busybox 727248 1488 33372 762108 ba0fc busybox.t1/busybox
Diffstat (limited to 'util-linux/fdisk.c')
-rw-r--r--util-linux/fdisk.c908
1 files changed, 442 insertions, 466 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 6f1ba96de..493c6740b 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -9,7 +9,6 @@
9 9
10#include <assert.h> /* assert */ 10#include <assert.h> /* assert */
11#include "busybox.h" 11#include "busybox.h"
12#define _(x) x
13 12
14/* Looks like someone forgot to add this to config system */ 13/* Looks like someone forgot to add this to config system */
15#ifndef ENABLE_FEATURE_FDISK_BLKSIZE 14#ifndef ENABLE_FEATURE_FDISK_BLKSIZE
@@ -50,9 +49,14 @@ struct hd_geometry {
50 49
51#define HDIO_GETGEO 0x0301 /* get device geometry */ 50#define HDIO_GETGEO 0x0301 /* get device geometry */
52 51
53struct systypes { 52static const char msg_building_new_label[] =
54 const char *name; 53"Building a new %s. Changes will remain in memory only,\n"
55}; 54"until you decide to write them. After that the previous content\n"
55"won't be recoverable.\n\n";
56
57static const char msg_part_already_defined[] =
58"Partition %d is already defined, delete it before re-adding\n";
59
56 60
57static unsigned sector_size = DEFAULT_SECTOR_SIZE; 61static unsigned sector_size = DEFAULT_SECTOR_SIZE;
58static unsigned user_set_sector_size; 62static unsigned user_set_sector_size;
@@ -66,45 +70,6 @@ static unsigned heads, sectors, cylinders;
66static void update_units(void); 70static void update_units(void);
67 71
68 72
69/*
70 * return partition name - uses static storage unless buf is supplied
71 */
72static const char *
73partname(const char *dev, int pno, int lth)
74{
75 static char buffer[80];
76 const char *p;
77 int w, wp;
78 int bufsiz;
79 char *bufp;
80
81 bufp = buffer;
82 bufsiz = sizeof(buffer);
83
84 w = strlen(dev);
85 p = "";
86
87 if (isdigit(dev[w-1]))
88 p = "p";
89
90 /* devfs kludge - note: fdisk partition names are not supposed
91 to equal kernel names, so there is no reason to do this */
92 if (strcmp(dev + w - 4, "disc") == 0) {
93 w -= 4;
94 p = "part";
95 }
96
97 wp = strlen(p);
98
99 if (lth) {
100 snprintf(bufp, bufsiz, "%*.*s%s%-2u",
101 lth-wp-2, w, dev, p, pno);
102 } else {
103 snprintf(bufp, bufsiz, "%.*s%s%-2u", w, dev, p, pno);
104 }
105 return bufp;
106}
107
108struct partition { 73struct partition {
109 unsigned char boot_ind; /* 0x80 - active */ 74 unsigned char boot_ind; /* 0x80 - active */
110 unsigned char head; /* starting head */ 75 unsigned char head; /* starting head */
@@ -174,7 +139,7 @@ static void change_units(void);
174static void reread_partition_table(int leave); 139static void reread_partition_table(int leave);
175static void delete_partition(int i); 140static void delete_partition(int i);
176static int get_partition(int warn, int max); 141static int get_partition(int warn, int max);
177static void list_types(const struct systypes *sys); 142static void list_types(const char *const *sys);
178static unsigned read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg); 143static unsigned read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg);
179#endif 144#endif
180static const char *partition_type(unsigned char type); 145static const char *partition_type(unsigned char type);
@@ -242,6 +207,46 @@ struct globals {
242#define MBRbuffer (G.MBRbuffer) 207#define MBRbuffer (G.MBRbuffer)
243#define ptes (G.ptes) 208#define ptes (G.ptes)
244 209
210
211/*
212 * return partition name - uses static storage
213 */
214static const char *
215partname(const char *dev, int pno, int lth)
216{
217 static char buffer[80];
218 const char *p;
219 int w, wp;
220 int bufsiz;
221 char *bufp;
222
223 bufp = buffer;
224 bufsiz = sizeof(buffer);
225
226 w = strlen(dev);
227 p = "";
228
229 if (isdigit(dev[w-1]))
230 p = "p";
231
232 /* devfs kludge - note: fdisk partition names are not supposed
233 to equal kernel names, so there is no reason to do this */
234 if (strcmp(dev + w - 4, "disc") == 0) {
235 w -= 4;
236 p = "part";
237 }
238
239 wp = strlen(p);
240
241 if (lth) {
242 snprintf(bufp, bufsiz, "%*.*s%s%-2u",
243 lth-wp-2, w, dev, p, pno);
244 } else {
245 snprintf(bufp, bufsiz, "%.*s%s%-2u", w, dev, p, pno);
246 }
247 return bufp;
248}
249
245#if ENABLE_FEATURE_FDISK_WRITABLE 250#if ENABLE_FEATURE_FDISK_WRITABLE
246static void 251static void
247set_all_unchanged(void) 252set_all_unchanged(void)
@@ -269,9 +274,8 @@ static const char *
269str_units(int n) 274str_units(int n)
270{ /* n==1: use singular */ 275{ /* n==1: use singular */
271 if (n == 1) 276 if (n == 1)
272 return display_in_cyl_units ? _("cylinder") : _("sector"); 277 return display_in_cyl_units ? "cylinder" : "sector";
273 else 278 return display_in_cyl_units ? "cylinders" : "sectors";
274 return display_in_cyl_units ? _("cylinders") : _("sectors");
275} 279}
276 280
277static int 281static int
@@ -329,11 +333,11 @@ read_maybe_empty(const char *mesg)
329} 333}
330 334
331static int 335static int
332read_hex(const struct systypes *sys) 336read_hex(const char *const *sys)
333{ 337{
334 unsigned long v; 338 unsigned long v;
335 while (1) { 339 while (1) {
336 read_nonempty(_("Hex code (type L to list codes): ")); 340 read_nonempty("Hex code (type L to list codes): ");
337 if (*line_ptr == 'l' || *line_ptr == 'L') { 341 if (*line_ptr == 'l' || *line_ptr == 'L') {
338 list_types(sys); 342 list_types(sys);
339 continue; 343 continue;
@@ -377,25 +381,10 @@ typedef struct {
377 unsigned short csum; /* Label xor'd checksum */ 381 unsigned short csum; /* Label xor'd checksum */
378} sun_partition; 382} sun_partition;
379#define sunlabel ((sun_partition *)MBRbuffer) 383#define sunlabel ((sun_partition *)MBRbuffer)
380#define SUNOS_SWAP 3
381#define SUN_WHOLE_DISK 5
382STATIC_OSF void bsd_select(void); 384STATIC_OSF void bsd_select(void);
383STATIC_OSF void xbsd_print_disklabel(int); 385STATIC_OSF void xbsd_print_disklabel(int);
384#include "fdisk_osf.c" 386#include "fdisk_osf.c"
385 387
386#define SGI_VOLHDR 0x00
387/* 1 and 2 were used for drive types no longer supported by SGI */
388#define SGI_SWAP 0x03
389/* 4 and 5 were for filesystem types SGI haven't ever supported on MIPS CPUs */
390#define SGI_VOLUME 0x06
391#define SGI_EFS 0x07
392#define SGI_LVOL 0x08
393#define SGI_RLVOL 0x09
394#define SGI_XFS 0x0a
395#define SGI_XFSLOG 0x0b
396#define SGI_XLV 0x0c
397#define SGI_XVM 0x0d
398#define SGI_ENTIRE_DISK SGI_VOLUME
399#if ENABLE_FEATURE_SGI_LABEL || ENABLE_FEATURE_SUN_LABEL 388#if ENABLE_FEATURE_SGI_LABEL || ENABLE_FEATURE_SUN_LABEL
400static uint16_t 389static uint16_t
401fdisk_swap16(uint16_t x) 390fdisk_swap16(uint16_t x)
@@ -413,7 +402,7 @@ fdisk_swap32(uint32_t x)
413} 402}
414#endif 403#endif
415 404
416STATIC_SGI const struct systypes sgi_sys_types[]; 405STATIC_SGI const char *const sgi_sys_types[];
417STATIC_SGI unsigned sgi_get_num_sectors(int i); 406STATIC_SGI unsigned sgi_get_num_sectors(int i);
418STATIC_SGI int sgi_get_sysid(int i); 407STATIC_SGI int sgi_get_sysid(int i);
419STATIC_SGI void sgi_delete_partition(int i); 408STATIC_SGI void sgi_delete_partition(int i);
@@ -432,7 +421,7 @@ STATIC_SGI void sgi_write_table(void);
432STATIC_SGI void sgi_set_bootpartition(int i); 421STATIC_SGI void sgi_set_bootpartition(int i);
433#include "fdisk_sgi.c" 422#include "fdisk_sgi.c"
434 423
435STATIC_SUN const struct systypes sun_sys_types[]; 424STATIC_SUN const char *const sun_sys_types[];
436STATIC_SUN void sun_delete_partition(int i); 425STATIC_SUN void sun_delete_partition(int i);
437STATIC_SUN void sun_change_sysid(int i, int sys); 426STATIC_SUN void sun_change_sysid(int i, int sys);
438STATIC_SUN void sun_list_table(int xtra); 427STATIC_SUN void sun_list_table(int xtra);
@@ -452,107 +441,107 @@ STATIC_SUN void sun_write_table(void);
452 441
453/* DOS partition types */ 442/* DOS partition types */
454 443
455static const struct systypes i386_sys_types[] = { 444static const char *const i386_sys_types[] = {
456 { "\x00" "Empty" }, 445 "\x00" "Empty",
457 { "\x01" "FAT12" }, 446 "\x01" "FAT12",
458 { "\x04" "FAT16 <32M" }, 447 "\x04" "FAT16 <32M",
459 { "\x05" "Extended" }, /* DOS 3.3+ extended partition */ 448 "\x05" "Extended", /* DOS 3.3+ extended partition */
460 { "\x06" "FAT16" }, /* DOS 16-bit >=32M */ 449 "\x06" "FAT16", /* DOS 16-bit >=32M */
461 { "\x07" "HPFS/NTFS" }, /* OS/2 IFS, eg, HPFS or NTFS or QNX */ 450 "\x07" "HPFS/NTFS", /* OS/2 IFS, eg, HPFS or NTFS or QNX */
462 { "\x0a" "OS/2 Boot Manager" },/* OS/2 Boot Manager */ 451 "\x0a" "OS/2 Boot Manager",/* OS/2 Boot Manager */
463 { "\x0b" "Win95 FAT32" }, 452 "\x0b" "Win95 FAT32",
464 { "\x0c" "Win95 FAT32 (LBA)" },/* LBA really is 'Extended Int 13h' */ 453 "\x0c" "Win95 FAT32 (LBA)",/* LBA really is 'Extended Int 13h' */
465 { "\x0e" "Win95 FAT16 (LBA)" }, 454 "\x0e" "Win95 FAT16 (LBA)",
466 { "\x0f" "Win95 Ext'd (LBA)" }, 455 "\x0f" "Win95 Ext'd (LBA)",
467 { "\x11" "Hidden FAT12" }, 456 "\x11" "Hidden FAT12",
468 { "\x12" "Compaq diagnostics" }, 457 "\x12" "Compaq diagnostics",
469 { "\x14" "Hidden FAT16 <32M" }, 458 "\x14" "Hidden FAT16 <32M",
470 { "\x16" "Hidden FAT16" }, 459 "\x16" "Hidden FAT16",
471 { "\x17" "Hidden HPFS/NTFS" }, 460 "\x17" "Hidden HPFS/NTFS",
472 { "\x1b" "Hidden Win95 FAT32" }, 461 "\x1b" "Hidden Win95 FAT32",
473 { "\x1c" "Hidden W95 FAT32 (LBA)" }, 462 "\x1c" "Hidden W95 FAT32 (LBA)",
474 { "\x1e" "Hidden W95 FAT16 (LBA)" }, 463 "\x1e" "Hidden W95 FAT16 (LBA)",
475 { "\x3c" "Part.Magic recovery" }, 464 "\x3c" "Part.Magic recovery",
476 { "\x41" "PPC PReP Boot" }, 465 "\x41" "PPC PReP Boot",
477 { "\x42" "SFS" }, 466 "\x42" "SFS",
478 { "\x63" "GNU HURD or SysV" }, /* GNU HURD or Mach or Sys V/386 (such as ISC UNIX) */ 467 "\x63" "GNU HURD or SysV", /* GNU HURD or Mach or Sys V/386 (such as ISC UNIX) */
479 { "\x80" "Old Minix" }, /* Minix 1.4a and earlier */ 468 "\x80" "Old Minix", /* Minix 1.4a and earlier */
480 { "\x81" "Minix / old Linux" },/* Minix 1.4b and later */ 469 "\x81" "Minix / old Linux",/* Minix 1.4b and later */
481 { "\x82" "Linux swap" }, /* also Solaris */ 470 "\x82" "Linux swap", /* also Solaris */
482 { "\x83" "Linux" }, 471 "\x83" "Linux",
483 { "\x84" "OS/2 hidden C: drive" }, 472 "\x84" "OS/2 hidden C: drive",
484 { "\x85" "Linux extended" }, 473 "\x85" "Linux extended",
485 { "\x86" "NTFS volume set" }, 474 "\x86" "NTFS volume set",
486 { "\x87" "NTFS volume set" }, 475 "\x87" "NTFS volume set",
487 { "\x8e" "Linux LVM" }, 476 "\x8e" "Linux LVM",
488 { "\x9f" "BSD/OS" }, /* BSDI */ 477 "\x9f" "BSD/OS", /* BSDI */
489 { "\xa0" "Thinkpad hibernation" }, 478 "\xa0" "Thinkpad hibernation",
490 { "\xa5" "FreeBSD" }, /* various BSD flavours */ 479 "\xa5" "FreeBSD", /* various BSD flavours */
491 { "\xa6" "OpenBSD" }, 480 "\xa6" "OpenBSD",
492 { "\xa8" "Darwin UFS" }, 481 "\xa8" "Darwin UFS",
493 { "\xa9" "NetBSD" }, 482 "\xa9" "NetBSD",
494 { "\xab" "Darwin boot" }, 483 "\xab" "Darwin boot",
495 { "\xb7" "BSDI fs" }, 484 "\xb7" "BSDI fs",
496 { "\xb8" "BSDI swap" }, 485 "\xb8" "BSDI swap",
497 { "\xbe" "Solaris boot" }, 486 "\xbe" "Solaris boot",
498 { "\xeb" "BeOS fs" }, 487 "\xeb" "BeOS fs",
499 { "\xee" "EFI GPT" }, /* Intel EFI GUID Partition Table */ 488 "\xee" "EFI GPT", /* Intel EFI GUID Partition Table */
500 { "\xef" "EFI (FAT-12/16/32)" },/* Intel EFI System Partition */ 489 "\xef" "EFI (FAT-12/16/32)", /* Intel EFI System Partition */
501 { "\xf0" "Linux/PA-RISC boot" },/* Linux/PA-RISC boot loader */ 490 "\xf0" "Linux/PA-RISC boot", /* Linux/PA-RISC boot loader */
502 { "\xf2" "DOS secondary" }, /* DOS 3.3+ secondary */ 491 "\xf2" "DOS secondary", /* DOS 3.3+ secondary */
503 { "\xfd" "Linux raid autodetect" },/* New (2.2.x) raid partition with 492 "\xfd" "Linux raid autodetect", /* New (2.2.x) raid partition with
504 autodetect using persistent 493 autodetect using persistent
505 superblock */ 494 superblock */
506#if 0 /* ENABLE_WEIRD_PARTITION_TYPES */ 495#if 0 /* ENABLE_WEIRD_PARTITION_TYPES */
507 { "\x02" "XENIX root" }, 496 "\x02" "XENIX root",
508 { "\x03" "XENIX usr" }, 497 "\x03" "XENIX usr",
509 { "\x08" "AIX" }, /* AIX boot (AIX -- PS/2 port) or SplitDrive */ 498 "\x08" "AIX", /* AIX boot (AIX -- PS/2 port) or SplitDrive */
510 { "\x09" "AIX bootable" }, /* AIX data or Coherent */ 499 "\x09" "AIX bootable", /* AIX data or Coherent */
511 { "\x10" "OPUS" }, 500 "\x10" "OPUS",
512 { "\x18" "AST SmartSleep" }, 501 "\x18" "AST SmartSleep",
513 { "\x24" "NEC DOS" }, 502 "\x24" "NEC DOS",
514 { "\x39" "Plan 9" }, 503 "\x39" "Plan 9",
515 { "\x40" "Venix 80286" }, 504 "\x40" "Venix 80286",
516 { "\x4d" "QNX4.x" }, 505 "\x4d" "QNX4.x",
517 { "\x4e" "QNX4.x 2nd part" }, 506 "\x4e" "QNX4.x 2nd part",
518 { "\x4f" "QNX4.x 3rd part" }, 507 "\x4f" "QNX4.x 3rd part",
519 { "\x50" "OnTrack DM" }, 508 "\x50" "OnTrack DM",
520 { "\x51" "OnTrack DM6 Aux1" }, /* (or Novell) */ 509 "\x51" "OnTrack DM6 Aux1", /* (or Novell) */
521 { "\x52" "CP/M" }, /* CP/M or Microport SysV/AT */ 510 "\x52" "CP/M", /* CP/M or Microport SysV/AT */
522 { "\x53" "OnTrack DM6 Aux3" }, 511 "\x53" "OnTrack DM6 Aux3",
523 { "\x54" "OnTrackDM6" }, 512 "\x54" "OnTrackDM6",
524 { "\x55" "EZ-Drive" }, 513 "\x55" "EZ-Drive",
525 { "\x56" "Golden Bow" }, 514 "\x56" "Golden Bow",
526 { "\x5c" "Priam Edisk" }, 515 "\x5c" "Priam Edisk",
527 { "\x61" "SpeedStor" }, 516 "\x61" "SpeedStor",
528 { "\x64" "Novell Netware 286" }, 517 "\x64" "Novell Netware 286",
529 { "\x65" "Novell Netware 386" }, 518 "\x65" "Novell Netware 386",
530 { "\x70" "DiskSecure Multi-Boot" }, 519 "\x70" "DiskSecure Multi-Boot",
531 { "\x75" "PC/IX" }, 520 "\x75" "PC/IX",
532 { "\x93" "Amoeba" }, 521 "\x93" "Amoeba",
533 { "\x94" "Amoeba BBT" }, /* (bad block table) */ 522 "\x94" "Amoeba BBT", /* (bad block table) */
534 { "\xa7" "NeXTSTEP" }, 523 "\xa7" "NeXTSTEP",
535 { "\xbb" "Boot Wizard hidden" }, 524 "\xbb" "Boot Wizard hidden",
536 { "\xc1" "DRDOS/sec (FAT-12)" }, 525 "\xc1" "DRDOS/sec (FAT-12)",
537 { "\xc4" "DRDOS/sec (FAT-16 < 32M)" }, 526 "\xc4" "DRDOS/sec (FAT-16 < 32M)",
538 { "\xc6" "DRDOS/sec (FAT-16)" }, 527 "\xc6" "DRDOS/sec (FAT-16)",
539 { "\xc7" "Syrinx" }, 528 "\xc7" "Syrinx",
540 { "\xda" "Non-FS data" }, 529 "\xda" "Non-FS data",
541 { "\xdb" "CP/M / CTOS / ..." },/* CP/M or Concurrent CP/M or 530 "\xdb" "CP/M / CTOS / ...",/* CP/M or Concurrent CP/M or
542 Concurrent DOS or CTOS */ 531 Concurrent DOS or CTOS */
543 { "\xde" "Dell Utility" }, /* Dell PowerEdge Server utilities */ 532 "\xde" "Dell Utility", /* Dell PowerEdge Server utilities */
544 { "\xdf" "BootIt" }, /* BootIt EMBRM */ 533 "\xdf" "BootIt", /* BootIt EMBRM */
545 { "\xe1" "DOS access" }, /* DOS access or SpeedStor 12-bit FAT 534 "\xe1" "DOS access", /* DOS access or SpeedStor 12-bit FAT
546 extended partition */ 535 extended partition */
547 { "\xe3" "DOS R/O" }, /* DOS R/O or SpeedStor */ 536 "\xe3" "DOS R/O", /* DOS R/O or SpeedStor */
548 { "\xe4" "SpeedStor" }, /* SpeedStor 16-bit FAT extended 537 "\xe4" "SpeedStor", /* SpeedStor 16-bit FAT extended
549 partition < 1024 cyl. */ 538 partition < 1024 cyl. */
550 { "\xf1" "SpeedStor" }, 539 "\xf1" "SpeedStor",
551 { "\xf4" "SpeedStor" }, /* SpeedStor large partition */ 540 "\xf4" "SpeedStor", /* SpeedStor large partition */
552 { "\xfe" "LANstep" }, /* SpeedStor >1024 cyl. or LANstep */ 541 "\xfe" "LANstep", /* SpeedStor >1024 cyl. or LANstep */
553 { "\xff" "BBT" }, /* Xenix Bad Block Table */ 542 "\xff" "BBT", /* Xenix Bad Block Table */
554#endif 543#endif
555 { 0 } 544 NULL
556}; 545};
557 546
558 547
@@ -639,22 +628,22 @@ static void fdisk_fatal(enum failure why)
639 628
640 switch (why) { 629 switch (why) {
641 case unable_to_open: 630 case unable_to_open:
642 message = "\nUnable to open %s"; 631 message = "cannot open %s";
643 break; 632 break;
644 case unable_to_read: 633 case unable_to_read:
645 message = "\nUnable to read %s"; 634 message = "cannot read from %s";
646 break; 635 break;
647 case unable_to_seek: 636 case unable_to_seek:
648 message = "\nUnable to seek on %s"; 637 message = "cannot seek on %s";
649 break; 638 break;
650 case unable_to_write: 639 case unable_to_write:
651 message = "\nUnable to write %s"; 640 message = "cannot write to %s";
652 break; 641 break;
653 case ioctl_error: 642 case ioctl_error:
654 message = "\nBLKGETSIZE ioctl failed on %s"; 643 message = "BLKGETSIZE ioctl failed on %s";
655 break; 644 break;
656 default: 645 default:
657 message = "\nFatal error"; 646 message = "fatal error";
658 } 647 }
659 648
660 bb_error_msg_and_die(message, disk_device); 649 bb_error_msg_and_die(message, disk_device);
@@ -719,61 +708,61 @@ is_dos_partition(int t)
719static void 708static void
720menu(void) 709menu(void)
721{ 710{
722 puts(_("Command Action")); 711 puts("Command Action");
723 if (LABEL_IS_SUN) { 712 if (LABEL_IS_SUN) {
724 puts(_("a\ttoggle a read only flag")); /* sun */ 713 puts("a\ttoggle a read only flag"); /* sun */
725 puts(_("b\tedit bsd disklabel")); 714 puts("b\tedit bsd disklabel");
726 puts(_("c\ttoggle the mountable flag")); /* sun */ 715 puts("c\ttoggle the mountable flag"); /* sun */
727 puts(_("d\tdelete a partition")); 716 puts("d\tdelete a partition");
728 puts(_("l\tlist known partition types")); 717 puts("l\tlist known partition types");
729 puts(_("n\tadd a new partition")); 718 puts("n\tadd a new partition");
730 puts(_("o\tcreate a new empty DOS partition table")); 719 puts("o\tcreate a new empty DOS partition table");
731 puts(_("p\tprint the partition table")); 720 puts("p\tprint the partition table");
732 puts(_("q\tquit without saving changes")); 721 puts("q\tquit without saving changes");
733 puts(_("s\tcreate a new empty Sun disklabel")); /* sun */ 722 puts("s\tcreate a new empty Sun disklabel"); /* sun */
734 puts(_("t\tchange a partition's system id")); 723 puts("t\tchange a partition's system id");
735 puts(_("u\tchange display/entry units")); 724 puts("u\tchange display/entry units");
736 puts(_("v\tverify the partition table")); 725 puts("v\tverify the partition table");
737 puts(_("w\twrite table to disk and exit")); 726 puts("w\twrite table to disk and exit");
738#if ENABLE_FEATURE_FDISK_ADVANCED 727#if ENABLE_FEATURE_FDISK_ADVANCED
739 puts(_("x\textra functionality (experts only)")); 728 puts("x\textra functionality (experts only)");
740#endif 729#endif
741 } else if (LABEL_IS_SGI) { 730 } else if (LABEL_IS_SGI) {
742 puts(_("a\tselect bootable partition")); /* sgi flavour */ 731 puts("a\tselect bootable partition"); /* sgi flavour */
743 puts(_("b\tedit bootfile entry")); /* sgi */ 732 puts("b\tedit bootfile entry"); /* sgi */
744 puts(_("c\tselect sgi swap partition")); /* sgi flavour */ 733 puts("c\tselect sgi swap partition"); /* sgi flavour */
745 puts(_("d\tdelete a partition")); 734 puts("d\tdelete a partition");
746 puts(_("l\tlist known partition types")); 735 puts("l\tlist known partition types");
747 puts(_("n\tadd a new partition")); 736 puts("n\tadd a new partition");
748 puts(_("o\tcreate a new empty DOS partition table")); 737 puts("o\tcreate a new empty DOS partition table");
749 puts(_("p\tprint the partition table")); 738 puts("p\tprint the partition table");
750 puts(_("q\tquit without saving changes")); 739 puts("q\tquit without saving changes");
751 puts(_("s\tcreate a new empty Sun disklabel")); /* sun */ 740 puts("s\tcreate a new empty Sun disklabel"); /* sun */
752 puts(_("t\tchange a partition's system id")); 741 puts("t\tchange a partition's system id");
753 puts(_("u\tchange display/entry units")); 742 puts("u\tchange display/entry units");
754 puts(_("v\tverify the partition table")); 743 puts("v\tverify the partition table");
755 puts(_("w\twrite table to disk and exit")); 744 puts("w\twrite table to disk and exit");
756 } else if (LABEL_IS_AIX) { 745 } else if (LABEL_IS_AIX) {
757 puts(_("o\tcreate a new empty DOS partition table")); 746 puts("o\tcreate a new empty DOS partition table");
758 puts(_("q\tquit without saving changes")); 747 puts("q\tquit without saving changes");
759 puts(_("s\tcreate a new empty Sun disklabel")); /* sun */ 748 puts("s\tcreate a new empty Sun disklabel"); /* sun */
760 } else { 749 } else {
761 puts(_("a\ttoggle a bootable flag")); 750 puts("a\ttoggle a bootable flag");
762 puts(_("b\tedit bsd disklabel")); 751 puts("b\tedit bsd disklabel");
763 puts(_("c\ttoggle the dos compatibility flag")); 752 puts("c\ttoggle the dos compatibility flag");
764 puts(_("d\tdelete a partition")); 753 puts("d\tdelete a partition");
765 puts(_("l\tlist known partition types")); 754 puts("l\tlist known partition types");
766 puts(_("n\tadd a new partition")); 755 puts("n\tadd a new partition");
767 puts(_("o\tcreate a new empty DOS partition table")); 756 puts("o\tcreate a new empty DOS partition table");
768 puts(_("p\tprint the partition table")); 757 puts("p\tprint the partition table");
769 puts(_("q\tquit without saving changes")); 758 puts("q\tquit without saving changes");
770 puts(_("s\tcreate a new empty Sun disklabel")); /* sun */ 759 puts("s\tcreate a new empty Sun disklabel"); /* sun */
771 puts(_("t\tchange a partition's system id")); 760 puts("t\tchange a partition's system id");
772 puts(_("u\tchange display/entry units")); 761 puts("u\tchange display/entry units");
773 puts(_("v\tverify the partition table")); 762 puts("v\tverify the partition table");
774 puts(_("w\twrite table to disk and exit")); 763 puts("w\twrite table to disk and exit");
775#if ENABLE_FEATURE_FDISK_ADVANCED 764#if ENABLE_FEATURE_FDISK_ADVANCED
776 puts(_("x\textra functionality (experts only)")); 765 puts("x\textra functionality (experts only)");
777#endif 766#endif
778 } 767 }
779} 768}
@@ -784,70 +773,70 @@ menu(void)
784static void 773static void
785xmenu(void) 774xmenu(void)
786{ 775{
787 puts(_("Command Action")); 776 puts("Command Action");
788 if (LABEL_IS_SUN) { 777 if (LABEL_IS_SUN) {
789 puts(_("a\tchange number of alternate cylinders")); /*sun*/ 778 puts("a\tchange number of alternate cylinders"); /*sun*/
790 puts(_("c\tchange number of cylinders")); 779 puts("c\tchange number of cylinders");
791 puts(_("d\tprint the raw data in the partition table")); 780 puts("d\tprint the raw data in the partition table");
792 puts(_("e\tchange number of extra sectors per cylinder"));/*sun*/ 781 puts("e\tchange number of extra sectors per cylinder");/*sun*/
793 puts(_("h\tchange number of heads")); 782 puts("h\tchange number of heads");
794 puts(_("i\tchange interleave factor")); /*sun*/ 783 puts("i\tchange interleave factor"); /*sun*/
795 puts(_("o\tchange rotation speed (rpm)")); /*sun*/ 784 puts("o\tchange rotation speed (rpm)"); /*sun*/
796 puts(_("p\tprint the partition table")); 785 puts("p\tprint the partition table");
797 puts(_("q\tquit without saving changes")); 786 puts("q\tquit without saving changes");
798 puts(_("r\treturn to main menu")); 787 puts("r\treturn to main menu");
799 puts(_("s\tchange number of sectors/track")); 788 puts("s\tchange number of sectors/track");
800 puts(_("v\tverify the partition table")); 789 puts("v\tverify the partition table");
801 puts(_("w\twrite table to disk and exit")); 790 puts("w\twrite table to disk and exit");
802 puts(_("y\tchange number of physical cylinders")); /*sun*/ 791 puts("y\tchange number of physical cylinders"); /*sun*/
803 } else if (LABEL_IS_SGI) { 792 } else if (LABEL_IS_SGI) {
804 puts(_("b\tmove beginning of data in a partition")); /* !sun */ 793 puts("b\tmove beginning of data in a partition"); /* !sun */
805 puts(_("c\tchange number of cylinders")); 794 puts("c\tchange number of cylinders");
806 puts(_("d\tprint the raw data in the partition table")); 795 puts("d\tprint the raw data in the partition table");
807 puts(_("e\tlist extended partitions")); /* !sun */ 796 puts("e\tlist extended partitions"); /* !sun */
808 puts(_("g\tcreate an IRIX (SGI) partition table"));/* sgi */ 797 puts("g\tcreate an IRIX (SGI) partition table");/* sgi */
809 puts(_("h\tchange number of heads")); 798 puts("h\tchange number of heads");
810 puts(_("p\tprint the partition table")); 799 puts("p\tprint the partition table");
811 puts(_("q\tquit without saving changes")); 800 puts("q\tquit without saving changes");
812 puts(_("r\treturn to main menu")); 801 puts("r\treturn to main menu");
813 puts(_("s\tchange number of sectors/track")); 802 puts("s\tchange number of sectors/track");
814 puts(_("v\tverify the partition table")); 803 puts("v\tverify the partition table");
815 puts(_("w\twrite table to disk and exit")); 804 puts("w\twrite table to disk and exit");
816 } else if (LABEL_IS_AIX) { 805 } else if (LABEL_IS_AIX) {
817 puts(_("b\tmove beginning of data in a partition")); /* !sun */ 806 puts("b\tmove beginning of data in a partition"); /* !sun */
818 puts(_("c\tchange number of cylinders")); 807 puts("c\tchange number of cylinders");
819 puts(_("d\tprint the raw data in the partition table")); 808 puts("d\tprint the raw data in the partition table");
820 puts(_("e\tlist extended partitions")); /* !sun */ 809 puts("e\tlist extended partitions"); /* !sun */
821 puts(_("g\tcreate an IRIX (SGI) partition table"));/* sgi */ 810 puts("g\tcreate an IRIX (SGI) partition table");/* sgi */
822 puts(_("h\tchange number of heads")); 811 puts("h\tchange number of heads");
823 puts(_("p\tprint the partition table")); 812 puts("p\tprint the partition table");
824 puts(_("q\tquit without saving changes")); 813 puts("q\tquit without saving changes");
825 puts(_("r\treturn to main menu")); 814 puts("r\treturn to main menu");
826 puts(_("s\tchange number of sectors/track")); 815 puts("s\tchange number of sectors/track");
827 puts(_("v\tverify the partition table")); 816 puts("v\tverify the partition table");
828 puts(_("w\twrite table to disk and exit")); 817 puts("w\twrite table to disk and exit");
829 } else { 818 } else {
830 puts(_("b\tmove beginning of data in a partition")); /* !sun */ 819 puts("b\tmove beginning of data in a partition"); /* !sun */
831 puts(_("c\tchange number of cylinders")); 820 puts("c\tchange number of cylinders");
832 puts(_("d\tprint the raw data in the partition table")); 821 puts("d\tprint the raw data in the partition table");
833 puts(_("e\tlist extended partitions")); /* !sun */ 822 puts("e\tlist extended partitions"); /* !sun */
834 puts(_("f\tfix partition order")); /* !sun, !aix, !sgi */ 823 puts("f\tfix partition order"); /* !sun, !aix, !sgi */
835#if ENABLE_FEATURE_SGI_LABEL 824#if ENABLE_FEATURE_SGI_LABEL
836 puts(_("g\tcreate an IRIX (SGI) partition table"));/* sgi */ 825 puts("g\tcreate an IRIX (SGI) partition table");/* sgi */
837#endif 826#endif
838 puts(_("h\tchange number of heads")); 827 puts("h\tchange number of heads");
839 puts(_("p\tprint the partition table")); 828 puts("p\tprint the partition table");
840 puts(_("q\tquit without saving changes")); 829 puts("q\tquit without saving changes");
841 puts(_("r\treturn to main menu")); 830 puts("r\treturn to main menu");
842 puts(_("s\tchange number of sectors/track")); 831 puts("s\tchange number of sectors/track");
843 puts(_("v\tverify the partition table")); 832 puts("v\tverify the partition table");
844 puts(_("w\twrite table to disk and exit")); 833 puts("w\twrite table to disk and exit");
845 } 834 }
846} 835}
847#endif /* ADVANCED mode */ 836#endif /* ADVANCED mode */
848 837
849#if ENABLE_FEATURE_FDISK_WRITABLE 838#if ENABLE_FEATURE_FDISK_WRITABLE
850static const struct systypes * 839static const char *const *
851get_sys_types(void) 840get_sys_types(void)
852{ 841{
853 return ( 842 return (
@@ -859,16 +848,17 @@ get_sys_types(void)
859#define get_sys_types() i386_sys_types 848#define get_sys_types() i386_sys_types
860#endif /* FEATURE_FDISK_WRITABLE */ 849#endif /* FEATURE_FDISK_WRITABLE */
861 850
862static const char *partition_type(unsigned char type) 851static const char *
852partition_type(unsigned char type)
863{ 853{
864 int i; 854 int i;
865 const struct systypes *types = get_sys_types(); 855 const char *const *types = get_sys_types();
866 856
867 for (i = 0; types[i].name; i++) 857 for (i = 0; types[i]; i++)
868 if ((unsigned char)types[i].name[0] == type) 858 if ((unsigned char)types[i][0] == type)
869 return types[i].name + 1; 859 return types[i] + 1;
870 860
871 return _("Unknown"); 861 return "Unknown";
872} 862}
873 863
874 864
@@ -881,7 +871,8 @@ get_sysid(int i)
881 ptes[i].part_table->sys_ind); 871 ptes[i].part_table->sys_ind);
882} 872}
883 873
884static void list_types(const struct systypes *sys) 874static void
875list_types(const char *const *sys)
885{ 876{
886 enum { COLS = 3 }; 877 enum { COLS = 3 };
887 878
@@ -889,7 +880,7 @@ static void list_types(const struct systypes *sys)
889 unsigned done, next, size; 880 unsigned done, next, size;
890 int i; 881 int i;
891 882
892 for (size = 0; sys[size].name; size++) /* */; 883 for (size = 0; sys[size]; size++) /* */;
893 884
894 done = 0; 885 done = 0;
895 for (i = COLS-1; i >= 0; i--) { 886 for (i = COLS-1; i >= 0; i--) {
@@ -900,8 +891,8 @@ static void list_types(const struct systypes *sys)
900 i = done = next = 0; 891 i = done = next = 0;
901 do { 892 do {
902 printf("%c%2x %-22.22s", i ? ' ' : '\n', 893 printf("%c%2x %-22.22s", i ? ' ' : '\n',
903 (unsigned char)sys[next].name[0], 894 (unsigned char)sys[next][0],
904 sys[next].name + 1); 895 sys[next] + 1);
905 next = last[i++] + done; 896 next = last[i++] + done;
906 if (i >= COLS || next >= last[i]) { 897 if (i >= COLS || next >= last[i]) {
907 i = 0; 898 i = 0;
@@ -957,40 +948,23 @@ set_partition(int i, int doext, off_t start, off_t stop, int sysid)
957#endif 948#endif
958 949
959static int 950static int
960test_c(const char **m, const char *mesg)
961{
962 int val = 0;
963 if (!*m)
964 printf(_("You must set"));
965 else {
966 printf(" %s", *m);
967 val = 1;
968 }
969 *m = mesg;
970 return val;
971}
972
973static int
974warn_geometry(void) 951warn_geometry(void)
975{ 952{
976 const char *m = NULL; 953 if (heads && sectors && cylinders)
977 int prev = 0; 954 return 0;
978 955
956 printf("Unknown value(s) for:");
979 if (!heads) 957 if (!heads)
980 prev = test_c(&m, _("heads")); 958 printf(" heads");
981 if (!sectors) 959 if (!sectors)
982 prev = test_c(&m, _("sectors")); 960 printf(" sectors");
983 if (!cylinders) 961 if (!cylinders)
984 prev = test_c(&m, _("cylinders")); 962 printf(" cylinders");
985 if (!m) 963 printf(
986 return 0;
987
988 printf("%s%s.\n"
989#if ENABLE_FEATURE_FDISK_WRITABLE 964#if ENABLE_FEATURE_FDISK_WRITABLE
990 "You can do this from the extra functions menu.\n" 965 " (settable in the extra functions menu)"
991#endif 966#endif
992 , prev ? _(" and ") : " ", m); 967 "\n");
993
994 return 1; 968 return 1;
995} 969}
996 970
@@ -1010,13 +984,13 @@ static void
1010warn_cylinders(void) 984warn_cylinders(void)
1011{ 985{
1012 if (LABEL_IS_DOS && cylinders > 1024 && !nowarn) 986 if (LABEL_IS_DOS && cylinders > 1024 && !nowarn)
1013 printf(_("\n" 987 printf("\n"
1014"The number of cylinders for this disk is set to %d.\n" 988"The number of cylinders for this disk is set to %d.\n"
1015"There is nothing wrong with that, but this is larger than 1024,\n" 989"There is nothing wrong with that, but this is larger than 1024,\n"
1016"and could in certain setups cause problems with:\n" 990"and could in certain setups cause problems with:\n"
1017"1) software that runs at boot time (e.g., old versions of LILO)\n" 991"1) software that runs at boot time (e.g., old versions of LILO)\n"
1018"2) booting and partitioning software from other OSs\n" 992"2) booting and partitioning software from other OSs\n"
1019" (e.g., DOS FDISK, OS/2 FDISK)\n"), 993" (e.g., DOS FDISK, OS/2 FDISK)\n",
1020 cylinders); 994 cylinders);
1021} 995}
1022#endif 996#endif
@@ -1034,7 +1008,7 @@ read_extended(int ext)
1034 1008
1035 p = pex->part_table; 1009 p = pex->part_table;
1036 if (!get_start_sect(p)) { 1010 if (!get_start_sect(p)) {
1037 printf(_("Bad offset in primary extended partition\n")); 1011 printf("Bad offset in primary extended partition\n");
1038 return; 1012 return;
1039 } 1013 }
1040 1014
@@ -1047,7 +1021,7 @@ read_extended(int ext)
1047 Do not try to 'improve' this test. */ 1021 Do not try to 'improve' this test. */
1048 struct pte *pre = &ptes[partitions-1]; 1022 struct pte *pre = &ptes[partitions-1];
1049#if ENABLE_FEATURE_FDISK_WRITABLE 1023#if ENABLE_FEATURE_FDISK_WRITABLE
1050 printf(_("Warning: deleting partitions after %d\n"), 1024 printf("Warning: deleting partitions after %d\n",
1051 partitions); 1025 partitions);
1052 pre->changed = 1; 1026 pre->changed = 1;
1053#endif 1027#endif
@@ -1064,16 +1038,16 @@ read_extended(int ext)
1064 for (i = 0; i < 4; i++, p++) if (get_nr_sects(p)) { 1038 for (i = 0; i < 4; i++, p++) if (get_nr_sects(p)) {
1065 if (IS_EXTENDED(p->sys_ind)) { 1039 if (IS_EXTENDED(p->sys_ind)) {
1066 if (pe->ext_pointer) 1040 if (pe->ext_pointer)
1067 printf(_("Warning: extra link " 1041 printf("Warning: extra link "
1068 "pointer in partition table" 1042 "pointer in partition table"
1069 " %d\n"), partitions + 1); 1043 " %d\n", partitions + 1);
1070 else 1044 else
1071 pe->ext_pointer = p; 1045 pe->ext_pointer = p;
1072 } else if (p->sys_ind) { 1046 } else if (p->sys_ind) {
1073 if (pe->part_table) 1047 if (pe->part_table)
1074 printf(_("Warning: ignoring extra " 1048 printf("Warning: ignoring extra "
1075 "data in partition table" 1049 "data in partition table"
1076 " %d\n"), partitions + 1); 1050 " %d\n", partitions + 1);
1077 else 1051 else
1078 pe->part_table = p; 1052 pe->part_table = p;
1079 } 1053 }
@@ -1103,9 +1077,10 @@ read_extended(int ext)
1103 for (i = 4; i < partitions; i++) { 1077 for (i = 4; i < partitions; i++) {
1104 struct pte *pe = &ptes[i]; 1078 struct pte *pe = &ptes[i];
1105 1079
1106 if (!get_nr_sects(pe->part_table) && 1080 if (!get_nr_sects(pe->part_table)
1107 (partitions > 5 || ptes[4].part_table->sys_ind)) { 1081 && (partitions > 5 || ptes[4].part_table->sys_ind)
1108 printf("omitting empty partition (%d)\n", i+1); 1082 ) {
1083 printf("Omitting empty partition (%d)\n", i+1);
1109 delete_partition(i); 1084 delete_partition(i);
1110 goto remove; /* numbering changed */ 1085 goto remove; /* numbering changed */
1111 } 1086 }
@@ -1119,10 +1094,7 @@ create_doslabel(void)
1119{ 1094{
1120 int i; 1095 int i;
1121 1096
1122 printf( 1097 printf(msg_building_new_label, "DOS disklabel");
1123 _("Building a new DOS disklabel. Changes will remain in memory only,\n"
1124 "until you decide to write them. After that, of course, the previous\n"
1125 "content won't be recoverable.\n\n"));
1126 1098
1127 current_label_type = label_dos; 1099 current_label_type = label_dos;
1128 1100
@@ -1149,7 +1121,7 @@ get_sectorsize(void)
1149 if (ioctl(fd, BLKSSZGET, &arg) == 0) 1121 if (ioctl(fd, BLKSSZGET, &arg) == 0)
1150 sector_size = arg; 1122 sector_size = arg;
1151 if (sector_size != DEFAULT_SECTOR_SIZE) 1123 if (sector_size != DEFAULT_SECTOR_SIZE)
1152 printf(_("Note: sector size is %d (not %d)\n"), 1124 printf("Note: sector size is %d (not %d)\n",
1153 sector_size, DEFAULT_SECTOR_SIZE); 1125 sector_size, DEFAULT_SECTOR_SIZE);
1154 } 1126 }
1155} 1127}
@@ -1230,7 +1202,7 @@ get_geometry(void)
1230 1202
1231 if (ioctl(fd, BLKGETSIZE, &longsectors)) 1203 if (ioctl(fd, BLKGETSIZE, &longsectors))
1232 longsectors = 0; 1204 longsectors = 0;
1233 bytes = ((unsigned long long) longsectors) << 9; 1205 bytes = ((unsigned long long) longsectors) << 9;
1234 } 1206 }
1235 1207
1236 total_number_of_sectors = (bytes >> 9); 1208 total_number_of_sectors = (bytes >> 9);
@@ -1280,14 +1252,16 @@ get_boot(enum action what)
1280 if (what == create_empty_dos) 1252 if (what == create_empty_dos)
1281 goto got_dos_table; /* skip reading disk */ 1253 goto got_dos_table; /* skip reading disk */
1282 1254
1283 if ((fd = open(disk_device, type_open)) < 0) { 1255 fd = open(disk_device, type_open);
1284 if ((fd = open(disk_device, O_RDONLY)) < 0) { 1256 if (fd < 0) {
1257 fd = open(disk_device, O_RDONLY);
1258 if (fd < 0) {
1285 if (what == try_only) 1259 if (what == try_only)
1286 return 1; 1260 return 1;
1287 fdisk_fatal(unable_to_open); 1261 fdisk_fatal(unable_to_open);
1288 } else 1262 } else
1289 printf(_("You will not be able to write " 1263 printf("You will not be able to write "
1290 "the partition table.\n")); 1264 "the partition table\n");
1291 } 1265 }
1292 1266
1293 if (512 != read(fd, MBRbuffer, 512)) { 1267 if (512 != read(fd, MBRbuffer, 512)) {
@@ -1296,7 +1270,8 @@ get_boot(enum action what)
1296 fdisk_fatal(unable_to_read); 1270 fdisk_fatal(unable_to_read);
1297 } 1271 }
1298#else 1272#else
1299 if ((fd = open(disk_device, O_RDONLY)) < 0) 1273 fd = open(disk_device, O_RDONLY);
1274 if (fd < 0)
1300 return 1; 1275 return 1;
1301 if (512 != read(fd, MBRbuffer, 512)) 1276 if (512 != read(fd, MBRbuffer, 512))
1302 return 1; 1277 return 1;
@@ -1328,8 +1303,8 @@ get_boot(enum action what)
1328 current_label_type = label_osf; 1303 current_label_type = label_osf;
1329 return 0; 1304 return 0;
1330 } 1305 }
1331 printf(_("This disk has both DOS and BSD magic.\n" 1306 printf("This disk has both DOS and BSD magic.\n"
1332 "Give the 'b' command to go to BSD mode.\n")); 1307 "Give the 'b' command to go to BSD mode.\n");
1333 } 1308 }
1334#endif 1309#endif
1335 1310
@@ -1343,9 +1318,9 @@ get_boot(enum action what)
1343#else 1318#else
1344 switch (what) { 1319 switch (what) {
1345 case fdisk: 1320 case fdisk:
1346 printf(_("Device contains neither a valid DOS " 1321 printf("Device contains neither a valid DOS "
1347 "partition table, nor Sun, SGI or OSF " 1322 "partition table, nor Sun, SGI or OSF "
1348 "disklabel\n")); 1323 "disklabel\n");
1349#ifdef __sparc__ 1324#ifdef __sparc__
1350#if ENABLE_FEATURE_SUN_LABEL 1325#if ENABLE_FEATURE_SUN_LABEL
1351 create_sunlabel(); 1326 create_sunlabel();
@@ -1362,7 +1337,7 @@ get_boot(enum action what)
1362#endif 1337#endif
1363 break; 1338 break;
1364 default: 1339 default:
1365 bb_error_msg_and_die(_("internal error")); 1340 bb_error_msg_and_die("internal error");
1366 } 1341 }
1367#endif /* FEATURE_FDISK_WRITABLE */ 1342#endif /* FEATURE_FDISK_WRITABLE */
1368 } 1343 }
@@ -1377,8 +1352,8 @@ get_boot(enum action what)
1377 1352
1378 if (IS_EXTENDED(pe->part_table->sys_ind)) { 1353 if (IS_EXTENDED(pe->part_table->sys_ind)) {
1379 if (partitions != 4) 1354 if (partitions != 4)
1380 printf(_("Ignoring extra extended " 1355 printf("Ignoring extra extended "
1381 "partition %d\n"), i + 1); 1356 "partition %d\n", i + 1);
1382 else 1357 else
1383 read_extended(i); 1358 read_extended(i);
1384 } 1359 }
@@ -1388,8 +1363,8 @@ get_boot(enum action what)
1388 struct pte *pe = &ptes[i]; 1363 struct pte *pe = &ptes[i];
1389 1364
1390 if (!valid_part_table_flag(pe->sectorbuffer)) { 1365 if (!valid_part_table_flag(pe->sectorbuffer)) {
1391 printf(_("Warning: invalid flag 0x%02x,0x%02x of partition " 1366 printf("Warning: invalid flag 0x%02x,0x%02x of partition "
1392 "table %d will be corrected by w(rite)\n"), 1367 "table %d will be corrected by w(rite)\n",
1393 pe->sectorbuffer[510], 1368 pe->sectorbuffer[510],
1394 pe->sectorbuffer[511], 1369 pe->sectorbuffer[511],
1395 i + 1); 1370 i + 1);
@@ -1484,12 +1459,13 @@ read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *
1484 use_default = 0; 1459 use_default = 0;
1485 } 1460 }
1486 } 1461 }
1487 if (use_default) 1462 if (use_default) {
1488 printf(_("Using default value %u\n"), i = dflt); 1463 i = dflt;
1464 printf("Using default value %u\n", i);
1465 }
1489 if (i >= low && i <= high) 1466 if (i >= low && i <= high)
1490 break; 1467 break;
1491 else 1468 printf("Value is out of range\n");
1492 printf(_("Value is out of range\n"));
1493 } 1469 }
1494 return i; 1470 return i;
1495} 1471}
@@ -1500,7 +1476,7 @@ get_partition(int warn, int max)
1500 struct pte *pe; 1476 struct pte *pe;
1501 int i; 1477 int i;
1502 1478
1503 i = read_int(1, 0, max, 0, _("Partition number")) - 1; 1479 i = read_int(1, 0, max, 0, "Partition number") - 1;
1504 pe = &ptes[i]; 1480 pe = &ptes[i];
1505 1481
1506 if (warn) { 1482 if (warn) {
@@ -1508,7 +1484,7 @@ get_partition(int warn, int max)
1508 || (LABEL_IS_SUN && (!sunlabel->partitions[i].num_sectors || !sunlabel->infos[i].id)) 1484 || (LABEL_IS_SUN && (!sunlabel->partitions[i].num_sectors || !sunlabel->infos[i].id))
1509 || (LABEL_IS_SGI && !sgi_get_num_sectors(i)) 1485 || (LABEL_IS_SGI && !sgi_get_num_sectors(i))
1510 ) { 1486 ) {
1511 printf(_("Warning: partition %d has empty type\n"), i+1); 1487 printf("Warning: partition %d has empty type\n", i+1);
1512 } 1488 }
1513 } 1489 }
1514 return i; 1490 return i;
@@ -1531,10 +1507,10 @@ get_existing_partition(int warn, int max)
1531 } 1507 }
1532 } 1508 }
1533 if (pno >= 0) { 1509 if (pno >= 0) {
1534 printf(_("Selected partition %d\n"), pno+1); 1510 printf("Selected partition %d\n", pno+1);
1535 return pno; 1511 return pno;
1536 } 1512 }
1537 printf(_("No partition is defined yet!\n")); 1513 printf("No partition is defined yet!\n");
1538 return -1; 1514 return -1;
1539 1515
1540 not_unique: 1516 not_unique:
@@ -1558,10 +1534,10 @@ get_nonexisting_partition(int warn, int max)
1558 } 1534 }
1559 } 1535 }
1560 if (pno >= 0) { 1536 if (pno >= 0) {
1561 printf(_("Selected partition %d\n"), pno+1); 1537 printf("Selected partition %d\n", pno+1);
1562 return pno; 1538 return pno;
1563 } 1539 }
1564 printf(_("All primary partitions have been defined already!\n")); 1540 printf("All primary partitions have been defined already!\n");
1565 return -1; 1541 return -1;
1566 1542
1567 not_unique: 1543 not_unique:
@@ -1574,7 +1550,7 @@ change_units(void)
1574{ 1550{
1575 display_in_cyl_units = !display_in_cyl_units; 1551 display_in_cyl_units = !display_in_cyl_units;
1576 update_units(); 1552 update_units();
1577 printf(_("Changing display/entry units to %s\n"), 1553 printf("Changing display/entry units to %s\n",
1578 str_units(PLURAL)); 1554 str_units(PLURAL));
1579} 1555}
1580 1556
@@ -1585,7 +1561,7 @@ toggle_active(int i)
1585 struct partition *p = pe->part_table; 1561 struct partition *p = pe->part_table;
1586 1562
1587 if (IS_EXTENDED(p->sys_ind) && !p->boot_ind) 1563 if (IS_EXTENDED(p->sys_ind) && !p->boot_ind)
1588 printf(_("WARNING: Partition %d is an extended partition\n"), i + 1); 1564 printf("WARNING: Partition %d is an extended partition\n", i + 1);
1589 p->boot_ind = (p->boot_ind ? 0 : ACTIVE_FLAG); 1565 p->boot_ind = (p->boot_ind ? 0 : ACTIVE_FLAG);
1590 pe->changed = 1; 1566 pe->changed = 1;
1591} 1567}
@@ -1596,11 +1572,10 @@ toggle_dos_compatibility_flag(void)
1596 dos_compatible_flag = ~dos_compatible_flag; 1572 dos_compatible_flag = ~dos_compatible_flag;
1597 if (dos_compatible_flag) { 1573 if (dos_compatible_flag) {
1598 sector_offset = sectors; 1574 sector_offset = sectors;
1599 printf(_("DOS Compatibility flag is set\n")); 1575 printf("DOS Compatibility flag is set\n");
1600 } 1576 } else {
1601 else {
1602 sector_offset = 1; 1577 sector_offset = 1;
1603 printf(_("DOS Compatibility flag is not set\n")); 1578 printf("DOS Compatibility flag is not set\n");
1604 } 1579 }
1605} 1580}
1606 1581
@@ -1699,46 +1674,48 @@ change_sysid(void)
1699 /* if changing types T to 0 is allowed, then 1674 /* if changing types T to 0 is allowed, then
1700 the reverse change must be allowed, too */ 1675 the reverse change must be allowed, too */
1701 if (!sys && !LABEL_IS_SGI && !LABEL_IS_SUN && !get_nr_sects(p)) { 1676 if (!sys && !LABEL_IS_SGI && !LABEL_IS_SUN && !get_nr_sects(p)) {
1702 printf(_("Partition %d does not exist yet!\n"), i + 1); 1677 printf("Partition %d does not exist yet!\n", i + 1);
1703 return; 1678 return;
1704 } 1679 }
1705 while (1) { 1680 while (1) {
1706 sys = read_hex (get_sys_types()); 1681 sys = read_hex(get_sys_types());
1707 1682
1708 if (!sys && !LABEL_IS_SGI && !LABEL_IS_SUN) { 1683 if (!sys && !LABEL_IS_SGI && !LABEL_IS_SUN) {
1709 printf(_("Type 0 means free space to many systems\n" 1684 printf("Type 0 means free space to many systems\n"
1710 "(but not to Linux). Having partitions of\n" 1685 "(but not to Linux). Having partitions of\n"
1711 "type 0 is probably unwise. You can delete\n" 1686 "type 0 is probably unwise.\n");
1712 "a partition using the 'd' command.\n"));
1713 /* break; */ 1687 /* break; */
1714 } 1688 }
1715 1689
1716 if (!LABEL_IS_SUN && !LABEL_IS_SGI) { 1690 if (!LABEL_IS_SUN && !LABEL_IS_SGI) {
1717 if (IS_EXTENDED(sys) != IS_EXTENDED(p->sys_ind)) { 1691 if (IS_EXTENDED(sys) != IS_EXTENDED(p->sys_ind)) {
1718 printf(_("You cannot change a partition into" 1692 printf("You cannot change a partition into"
1719 " an extended one or vice versa\n" 1693 " an extended one or vice versa\n");
1720 "Delete it first.\n"));
1721 break; 1694 break;
1722 } 1695 }
1723 } 1696 }
1724 1697
1725 if (sys < 256) { 1698 if (sys < 256) {
1699#if ENABLE_FEATURE_SUN_LABEL
1726 if (LABEL_IS_SUN && i == 2 && sys != SUN_WHOLE_DISK) 1700 if (LABEL_IS_SUN && i == 2 && sys != SUN_WHOLE_DISK)
1727 printf(_("Consider leaving partition 3 " 1701 printf("Consider leaving partition 3 "
1728 "as Whole disk (5),\n" 1702 "as Whole disk (5),\n"
1729 "as SunOS/Solaris expects it and " 1703 "as SunOS/Solaris expects it and "
1730 "even Linux likes it.\n\n")); 1704 "even Linux likes it\n\n");
1705#endif
1706#if ENABLE_FEATURE_SGI_LABEL
1731 if (LABEL_IS_SGI && 1707 if (LABEL_IS_SGI &&
1732 ( 1708 (
1733 (i == 10 && sys != SGI_ENTIRE_DISK) || 1709 (i == 10 && sys != SGI_ENTIRE_DISK) ||
1734 (i == 8 && sys != 0) 1710 (i == 8 && sys != 0)
1735 ) 1711 )
1736 ){ 1712 ) {
1737 printf(_("Consider leaving partition 9 " 1713 printf("Consider leaving partition 9 "
1738 "as volume header (0),\nand " 1714 "as volume header (0),\nand "
1739 "partition 11 as entire volume (6)" 1715 "partition 11 as entire volume (6)"
1740 "as IRIX expects it.\n\n")); 1716 "as IRIX expects it\n\n");
1741 } 1717 }
1718#endif
1742 if (sys == origsys) 1719 if (sys == origsys)
1743 break; 1720 break;
1744 if (LABEL_IS_SUN) { 1721 if (LABEL_IS_SUN) {
@@ -1748,8 +1725,8 @@ change_sysid(void)
1748 } else 1725 } else
1749 p->sys_ind = sys; 1726 p->sys_ind = sys;
1750 1727
1751 printf(_("Changed system type of partition %d " 1728 printf("Changed system type of partition %d "
1752 "to %x (%s)\n"), i + 1, sys, 1729 "to %x (%s)\n", i + 1, sys,
1753 partition_type(sys)); 1730 partition_type(sys));
1754 ptes[i].changed = 1; 1731 ptes[i].changed = 1;
1755 if (is_dos_partition(origsys) || 1732 if (is_dos_partition(origsys) ||
@@ -1807,23 +1784,23 @@ check_consistency(const struct partition *p, int partition)
1807 1784
1808/* Same physical / logical beginning? */ 1785/* Same physical / logical beginning? */
1809 if (cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) { 1786 if (cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) {
1810 printf(_("Partition %d has different physical/logical " 1787 printf("Partition %d has different physical/logical "
1811 "beginnings (non-Linux?):\n"), partition + 1); 1788 "beginnings (non-Linux?):\n", partition + 1);
1812 printf(_(" phys=(%d, %d, %d) "), pbc, pbh, pbs); 1789 printf(" phys=(%d, %d, %d) ", pbc, pbh, pbs);
1813 printf(_("logical=(%d, %d, %d)\n"),lbc, lbh, lbs); 1790 printf("logical=(%d, %d, %d)\n",lbc, lbh, lbs);
1814 } 1791 }
1815 1792
1816/* Same physical / logical ending? */ 1793/* Same physical / logical ending? */
1817 if (cylinders <= 1024 && (pec != lec || peh != leh || pes != les)) { 1794 if (cylinders <= 1024 && (pec != lec || peh != leh || pes != les)) {
1818 printf(_("Partition %d has different physical/logical " 1795 printf("Partition %d has different physical/logical "
1819 "endings:\n"), partition + 1); 1796 "endings:\n", partition + 1);
1820 printf(_(" phys=(%d, %d, %d) "), pec, peh, pes); 1797 printf(" phys=(%d, %d, %d) ", pec, peh, pes);
1821 printf(_("logical=(%d, %d, %d)\n"),lec, leh, les); 1798 printf("logical=(%d, %d, %d)\n", lec, leh, les);
1822 } 1799 }
1823 1800
1824/* Ending on cylinder boundary? */ 1801/* Ending on cylinder boundary? */
1825 if (peh != (heads - 1) || pes != sectors) { 1802 if (peh != (heads - 1) || pes != sectors) {
1826 printf(_("Partition %i does not end on cylinder boundary.\n"), 1803 printf("Partition %i does not end on cylinder boundary\n",
1827 partition + 1); 1804 partition + 1);
1828 } 1805 }
1829} 1806}
@@ -1835,17 +1812,17 @@ list_disk_geometry(void)
1835 long megabytes = bytes/1000000; 1812 long megabytes = bytes/1000000;
1836 1813
1837 if (megabytes < 10000) 1814 if (megabytes < 10000)
1838 printf(_("\nDisk %s: %ld MB, %lld bytes\n"), 1815 printf("\nDisk %s: %ld MB, %lld bytes\n",
1839 disk_device, megabytes, bytes); 1816 disk_device, megabytes, bytes);
1840 else 1817 else
1841 printf(_("\nDisk %s: %ld.%ld GB, %lld bytes\n"), 1818 printf("\nDisk %s: %ld.%ld GB, %lld bytes\n",
1842 disk_device, megabytes/1000, (megabytes/100)%10, bytes); 1819 disk_device, megabytes/1000, (megabytes/100)%10, bytes);
1843 printf(_("%d heads, %d sectors/track, %d cylinders"), 1820 printf("%d heads, %d sectors/track, %d cylinders",
1844 heads, sectors, cylinders); 1821 heads, sectors, cylinders);
1845 if (units_per_sector == 1) 1822 if (units_per_sector == 1)
1846 printf(_(", total %llu sectors"), 1823 printf(", total %llu sectors",
1847 total_number_of_sectors / (sector_size/512)); 1824 total_number_of_sectors / (sector_size/512));
1848 printf(_("\nUnits = %s of %d * %d = %d bytes\n\n"), 1825 printf("\nUnits = %s of %d * %d = %d bytes\n\n",
1849 str_units(PLURAL), 1826 str_units(PLURAL),
1850 units_per_sector, sector_size, units_per_sector * sector_size); 1827 units_per_sector, sector_size, units_per_sector * sector_size);
1851} 1828}
@@ -1958,7 +1935,7 @@ fix_partition_table_order(void)
1958 int i,k; 1935 int i,k;
1959 1936
1960 if (!wrong_p_order(NULL)) { 1937 if (!wrong_p_order(NULL)) {
1961 printf(_("Nothing to do. Ordering is correct already.\n\n")); 1938 printf("Ordering is already correct\n\n");
1962 return; 1939 return;
1963 } 1940 }
1964 1941
@@ -2022,9 +1999,9 @@ list_table(int xtra)
2022 if (w < 5) 1999 if (w < 5)
2023 w = 5; 2000 w = 5;
2024 2001
2025 // 1 12345678901 12345678901 12345678901 12 2002 // 1 12345678901 12345678901 12345678901 12
2026 printf(_("%*s Boot Start End Blocks Id System\n"), 2003 printf("%*s Boot Start End Blocks Id System\n",
2027 w+1, _("Device")); 2004 w+1, "Device");
2028 2005
2029 for (i = 0; i < partitions; i++) { 2006 for (i = 0; i < partitions; i++) {
2030 const struct pte *pe = &ptes[i]; 2007 const struct pte *pe = &ptes[i];
@@ -2066,7 +2043,7 @@ list_table(int xtra)
2066 is a sgi, sun or aix labeled disk... */ 2043 is a sgi, sun or aix labeled disk... */
2067 if (LABEL_IS_DOS && wrong_p_order(NULL)) { 2044 if (LABEL_IS_DOS && wrong_p_order(NULL)) {
2068 /* FIXME */ 2045 /* FIXME */
2069 printf(_("\nPartition table entries are not in disk order\n")); 2046 printf("\nPartition table entries are not in disk order\n");
2070 } 2047 }
2071} 2048}
2072 2049
@@ -2078,9 +2055,9 @@ x_list_table(int extend)
2078 const struct partition *p; 2055 const struct partition *p;
2079 int i; 2056 int i;
2080 2057
2081 printf(_("\nDisk %s: %d heads, %d sectors, %d cylinders\n\n"), 2058 printf("\nDisk %s: %d heads, %d sectors, %d cylinders\n\n",
2082 disk_device, heads, sectors, cylinders); 2059 disk_device, heads, sectors, cylinders);
2083 printf(_("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n")); 2060 printf("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n");
2084 for (i = 0 ; i < partitions; i++) { 2061 for (i = 0 ; i < partitions; i++) {
2085 pe = &ptes[i]; 2062 pe = &ptes[i];
2086 p = (extend ? pe->ext_pointer : pe->part_table); 2063 p = (extend ? pe->ext_pointer : pe->part_table);
@@ -2128,19 +2105,19 @@ check(int n, unsigned h, unsigned s, unsigned c, off_t start)
2128 real_c = cylinder(s, c); 2105 real_c = cylinder(s, c);
2129 total = (real_c * sectors + real_s) * heads + h; 2106 total = (real_c * sectors + real_s) * heads + h;
2130 if (!total) 2107 if (!total)
2131 printf(_("Warning: partition %d contains sector 0\n"), n); 2108 printf("Partition %d contains sector 0\n", n);
2132 if (h >= heads) 2109 if (h >= heads)
2133 printf(_("Partition %d: head %d greater than maximum %d\n"), 2110 printf("Partition %d: head %d greater than maximum %d\n",
2134 n, h + 1, heads); 2111 n, h + 1, heads);
2135 if (real_s >= sectors) 2112 if (real_s >= sectors)
2136 printf(_("Partition %d: sector %d greater than " 2113 printf("Partition %d: sector %d greater than "
2137 "maximum %d\n"), n, s, sectors); 2114 "maximum %d\n", n, s, sectors);
2138 if (real_c >= cylinders) 2115 if (real_c >= cylinders)
2139 printf(_("Partitions %d: cylinder %llu greater than " 2116 printf("Partition %d: cylinder %"OFF_FMT"u greater than "
2140 "maximum %d\n"), n, (unsigned long long)real_c + 1, cylinders); 2117 "maximum %d\n", n, real_c + 1, cylinders);
2141 if (cylinders <= 1024 && start != total) 2118 if (cylinders <= 1024 && start != total)
2142 printf(_("Partition %d: previous sectors %llu disagrees with " 2119 printf("Partition %d: previous sectors %"OFF_FMT"u disagrees with "
2143 "total %llu\n"), n, (unsigned long long)start, (unsigned long long)total); 2120 "total %"OFF_FMT"u\n", n, start, total);
2144} 2121}
2145 2122
2146static void 2123static void
@@ -2171,20 +2148,21 @@ verify(void)
2171 if (p->sys_ind && !IS_EXTENDED(p->sys_ind)) { 2148 if (p->sys_ind && !IS_EXTENDED(p->sys_ind)) {
2172 check_consistency(p, i); 2149 check_consistency(p, i);
2173 if (get_partition_start(pe) < first[i]) 2150 if (get_partition_start(pe) < first[i])
2174 printf(_("Warning: bad start-of-data in " 2151 printf("Warning: bad start-of-data in "
2175 "partition %d\n"), i + 1); 2152 "partition %d\n", i + 1);
2176 check(i + 1, p->end_head, p->end_sector, p->end_cyl, 2153 check(i + 1, p->end_head, p->end_sector, p->end_cyl,
2177 last[i]); 2154 last[i]);
2178 total += last[i] + 1 - first[i]; 2155 total += last[i] + 1 - first[i];
2179 for (j = 0; j < i; j++) 2156 for (j = 0; j < i; j++) {
2180 if ((first[i] >= first[j] && first[i] <= last[j]) 2157 if ((first[i] >= first[j] && first[i] <= last[j])
2181 || ((last[i] <= last[j] && last[i] >= first[j]))) { 2158 || ((last[i] <= last[j] && last[i] >= first[j]))) {
2182 printf(_("Warning: partition %d overlaps " 2159 printf("Warning: partition %d overlaps "
2183 "partition %d.\n"), j + 1, i + 1); 2160 "partition %d\n", j + 1, i + 1);
2184 total += first[i] >= first[j] ? 2161 total += first[i] >= first[j] ?
2185 first[i] : first[j]; 2162 first[i] : first[j];
2186 total -= last[i] <= last[j] ? 2163 total -= last[i] <= last[j] ?
2187 last[i] : last[j]; 2164 last[i] : last[j];
2165 }
2188 } 2166 }
2189 } 2167 }
2190 } 2168 }
@@ -2199,21 +2177,23 @@ verify(void)
2199 p = ptes[i].part_table; 2177 p = ptes[i].part_table;
2200 if (!p->sys_ind) { 2178 if (!p->sys_ind) {
2201 if (i != 4 || i + 1 < partitions) 2179 if (i != 4 || i + 1 < partitions)
2202 printf(_("Warning: partition %d " 2180 printf("Warning: partition %d "
2203 "is empty\n"), i + 1); 2181 "is empty\n", i + 1);
2182 } else if (first[i] < extended_offset || last[i] > e_last) {
2183 printf("Logical partition %d not entirely in "
2184 "partition %d\n", i + 1, ext_index + 1);
2204 } 2185 }
2205 else if (first[i] < extended_offset ||
2206 last[i] > e_last)
2207 printf(_("Logical partition %d not entirely in "
2208 "partition %d\n"), i + 1, ext_index + 1);
2209 } 2186 }
2210 } 2187 }
2211 2188
2212 if (total > heads * sectors * cylinders) 2189 if (total > heads * sectors * cylinders)
2213 printf(_("Total allocated sectors %d greater than the maximum " 2190 printf("Total allocated sectors %d greater than the maximum "
2214 "%d\n"), total, heads * sectors * cylinders); 2191 "%d\n", total, heads * sectors * cylinders);
2215 else if ((total = heads * sectors * cylinders - total) != 0) 2192 else {
2216 printf(_("%d unallocated sectors\n"), total); 2193 total = heads * sectors * cylinders - total;
2194 if (total != 0)
2195 printf("%d unallocated sectors\n", total);
2196 }
2217} 2197}
2218 2198
2219static void 2199static void
@@ -2228,8 +2208,7 @@ add_partition(int n, int sys)
2228 first[partitions], last[partitions]; 2208 first[partitions], last[partitions];
2229 2209
2230 if (p && p->sys_ind) { 2210 if (p && p->sys_ind) {
2231 printf(_("Partition %d is already defined. Delete " 2211 printf(msg_part_already_defined, n + 1);
2232 "it before re-adding it.\n"), n + 1);
2233 return; 2212 return;
2234 } 2213 }
2235 fill_bounds(first, last); 2214 fill_bounds(first, last);
@@ -2255,7 +2234,7 @@ add_partition(int n, int sys)
2255 for (i = 0; i < partitions; i++) 2234 for (i = 0; i < partitions; i++)
2256 first[i] = (cround(first[i]) - 1) * units_per_sector; 2235 first[i] = (cround(first[i]) - 1) * units_per_sector;
2257 2236
2258 snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); 2237 snprintf(mesg, sizeof(mesg), "First %s", str_units(SINGULAR));
2259 do { 2238 do {
2260 temp = start; 2239 temp = start;
2261 for (i = 0; i < partitions; i++) { 2240 for (i = 0; i < partitions; i++) {
@@ -2270,7 +2249,7 @@ add_partition(int n, int sys)
2270 if (start > limit) 2249 if (start > limit)
2271 break; 2250 break;
2272 if (start >= temp+units_per_sector && num_read) { 2251 if (start >= temp+units_per_sector && num_read) {
2273 printf(_("Sector %"OFF_FMT"d is already allocated\n"), temp); 2252 printf("Sector %"OFF_FMT"d is already allocated\n", temp);
2274 temp = start; 2253 temp = start;
2275 num_read = 0; 2254 num_read = 0;
2276 } 2255 }
@@ -2307,7 +2286,7 @@ add_partition(int n, int sys)
2307 limit = first[i] - 1; 2286 limit = first[i] - 1;
2308 } 2287 }
2309 if (start > limit) { 2288 if (start > limit) {
2310 printf(_("No free sectors available\n")); 2289 printf("No free sectors available\n");
2311 if (n > 4) 2290 if (n > 4)
2312 partitions--; 2291 partitions--;
2313 return; 2292 return;
@@ -2316,7 +2295,7 @@ add_partition(int n, int sys)
2316 stop = limit; 2295 stop = limit;
2317 } else { 2296 } else {
2318 snprintf(mesg, sizeof(mesg), 2297 snprintf(mesg, sizeof(mesg),
2319 _("Last %s or +size or +sizeM or +sizeK"), 2298 "Last %s or +size or +sizeM or +sizeK",
2320 str_units(SINGULAR)); 2299 str_units(SINGULAR));
2321 stop = read_int(cround(start), cround(limit), cround(limit), 2300 stop = read_int(cround(start), cround(limit), cround(limit),
2322 cround(start), mesg); 2301 cround(start), mesg);
@@ -2379,11 +2358,9 @@ new_partition(void)
2379 return; 2358 return;
2380 } 2359 }
2381 if (LABEL_IS_AIX) { 2360 if (LABEL_IS_AIX) {
2382 printf(_("\tSorry - this fdisk cannot handle AIX disk labels." 2361 printf("Sorry - this fdisk cannot handle AIX disk labels.\n"
2383 "\n\tIf you want to add DOS-type partitions, create" 2362"If you want to add DOS-type partitions, create a new empty DOS partition\n"
2384 "\n\ta new empty DOS partition table first. (Use o.)" 2363"table first (use 'o'). This will destroy the present disk contents.\n");
2385 "\n\tWARNING: "
2386 "This will destroy the present disk contents.\n"));
2387 return; 2364 return;
2388 } 2365 }
2389 2366
@@ -2391,7 +2368,7 @@ new_partition(void)
2391 free_primary += !ptes[i].part_table->sys_ind; 2368 free_primary += !ptes[i].part_table->sys_ind;
2392 2369
2393 if (!free_primary && partitions >= MAXIMUM_PARTS) { 2370 if (!free_primary && partitions >= MAXIMUM_PARTS) {
2394 printf(_("The maximum number of partitions has been created\n")); 2371 printf("The maximum number of partitions has been created\n");
2395 return; 2372 return;
2396 } 2373 }
2397 2374
@@ -2399,8 +2376,8 @@ new_partition(void)
2399 if (extended_offset) 2376 if (extended_offset)
2400 add_logical(); 2377 add_logical();
2401 else 2378 else
2402 printf(_("You must delete some partition and add " 2379 printf("You must delete some partition and add "
2403 "an extended partition first\n")); 2380 "an extended partition first\n");
2404 } else { 2381 } else {
2405 char c, line[LINE_LENGTH]; 2382 char c, line[LINE_LENGTH];
2406 snprintf(line, sizeof(line), 2383 snprintf(line, sizeof(line),
@@ -2417,19 +2394,18 @@ new_partition(void)
2417 add_partition(i, LINUX_NATIVE); 2394 add_partition(i, LINUX_NATIVE);
2418 return; 2395 return;
2419 } 2396 }
2420 else if (c == 'l' && extended_offset) { 2397 if (c == 'l' && extended_offset) {
2421 add_logical(); 2398 add_logical();
2422 return; 2399 return;
2423 } 2400 }
2424 else if (c == 'e' && !extended_offset) { 2401 if (c == 'e' && !extended_offset) {
2425 i = get_nonexisting_partition(0, 4); 2402 i = get_nonexisting_partition(0, 4);
2426 if (i >= 0) 2403 if (i >= 0)
2427 add_partition(i, EXTENDED); 2404 add_partition(i, EXTENDED);
2428 return; 2405 return;
2429 } 2406 }
2430 else 2407 printf("Invalid partition number "
2431 printf(_("Invalid partition number " 2408 "for type '%c'\n", c);
2432 "for type '%c'\n"), c);
2433 } 2409 }
2434 } 2410 }
2435} 2411}
@@ -2466,7 +2442,7 @@ write_table(void)
2466 sun_write_table(); 2442 sun_write_table();
2467 } 2443 }
2468 2444
2469 printf(_("The partition table has been altered!\n\n")); 2445 printf("The partition table has been altered!\n\n");
2470 reread_partition_table(1); 2446 reread_partition_table(1);
2471} 2447}
2472 2448
@@ -2475,9 +2451,9 @@ reread_partition_table(int leave)
2475{ 2451{
2476 int i; 2452 int i;
2477 2453
2478 printf(_("Calling ioctl() to re-read partition table\n")); 2454 printf("Calling ioctl() to re-read partition table\n");
2479 sync(); 2455 sync();
2480 sleep(2); /* Huh? */ 2456 /* sleep(2); Huh? */
2481 i = ioctl(fd, BLKRRPART); 2457 i = ioctl(fd, BLKRRPART);
2482#if 0 2458#if 0
2483 else { 2459 else {
@@ -2498,9 +2474,9 @@ reread_partition_table(int leave)
2498#if 0 2474#if 0
2499 if (dos_changed) 2475 if (dos_changed)
2500 printf( 2476 printf(
2501 _("\nWARNING: If you have created or modified any DOS 6.x\n" 2477 "\nWARNING: If you have created or modified any DOS 6.x\n"
2502 "partitions, please see the fdisk manual page for additional\n" 2478 "partitions, please see the fdisk manual page for additional\n"
2503 "information.\n")); 2479 "information\n");
2504#endif 2480#endif
2505 2481
2506 if (leave) { 2482 if (leave) {
@@ -2537,7 +2513,7 @@ print_raw(void)
2537{ 2513{
2538 int i; 2514 int i;
2539 2515
2540 printf(_("Device: %s\n"), disk_device); 2516 printf("Device: %s\n", disk_device);
2541 if (LABEL_IS_SGI || LABEL_IS_SUN) 2517 if (LABEL_IS_SGI || LABEL_IS_SUN)
2542 print_buffer(MBRbuffer); 2518 print_buffer(MBRbuffer);
2543 else { 2519 else {
@@ -2556,12 +2532,12 @@ move_begin(int i)
2556 if (warn_geometry()) 2532 if (warn_geometry())
2557 return; 2533 return;
2558 if (!p->sys_ind || !get_nr_sects(p) || IS_EXTENDED(p->sys_ind)) { 2534 if (!p->sys_ind || !get_nr_sects(p) || IS_EXTENDED(p->sys_ind)) {
2559 printf(_("Partition %d has no data area\n"), i + 1); 2535 printf("Partition %d has no data area\n", i + 1);
2560 return; 2536 return;
2561 } 2537 }
2562 first = get_partition_start(pe); 2538 first = get_partition_start(pe);
2563 new = read_int(first, first, first + get_nr_sects(p) - 1, first, 2539 new = read_int(first, first, first + get_nr_sects(p) - 1, first,
2564 _("New beginning of data")) - pe->offset; 2540 "New beginning of data") - pe->offset;
2565 2541
2566 if (new != get_nr_sects(p)) { 2542 if (new != get_nr_sects(p)) {
2567 first = get_nr_sects(p) + get_start_sect(p) - new; 2543 first = get_nr_sects(p) + get_start_sect(p) - new;
@@ -2578,7 +2554,7 @@ xselect(void)
2578 2554
2579 while (1) { 2555 while (1) {
2580 putchar('\n'); 2556 putchar('\n');
2581 c = tolower(read_nonempty(_("Expert command (m for help): "))); 2557 c = tolower(read_nonempty("Expert command (m for help): "));
2582 switch (c) { 2558 switch (c) {
2583 case 'a': 2559 case 'a':
2584 if (LABEL_IS_SUN) 2560 if (LABEL_IS_SUN)
@@ -2591,7 +2567,7 @@ xselect(void)
2591 case 'c': 2567 case 'c':
2592 user_cylinders = cylinders = 2568 user_cylinders = cylinders =
2593 read_int(1, cylinders, 1048576, 0, 2569 read_int(1, cylinders, 1048576, 0,
2594 _("Number of cylinders")); 2570 "Number of cylinders");
2595 if (LABEL_IS_SUN) 2571 if (LABEL_IS_SUN)
2596 sun_set_ncyl(cylinders); 2572 sun_set_ncyl(cylinders);
2597 if (LABEL_IS_DOS) 2573 if (LABEL_IS_DOS)
@@ -2619,7 +2595,7 @@ xselect(void)
2619 break; 2595 break;
2620 case 'h': 2596 case 'h':
2621 user_heads = heads = read_int(1, heads, 256, 0, 2597 user_heads = heads = read_int(1, heads, 256, 0,
2622 _("Number of heads")); 2598 "Number of heads");
2623 update_units(); 2599 update_units();
2624 break; 2600 break;
2625 case 'i': 2601 case 'i':
@@ -2644,11 +2620,11 @@ xselect(void)
2644 return; 2620 return;
2645 case 's': 2621 case 's':
2646 user_sectors = sectors = read_int(1, sectors, 63, 0, 2622 user_sectors = sectors = read_int(1, sectors, 63, 0,
2647 _("Number of sectors")); 2623 "Number of sectors");
2648 if (dos_compatible_flag) { 2624 if (dos_compatible_flag) {
2649 sector_offset = sectors; 2625 sector_offset = sectors;
2650 printf(_("Warning: setting sector offset for DOS " 2626 printf("Warning: setting sector offset for DOS "
2651 "compatiblity\n")); 2627 "compatiblity\n");
2652 } 2628 }
2653 update_units(); 2629 update_units();
2654 break; 2630 break;
@@ -2728,8 +2704,8 @@ trydev(const char *device, int user_specified)
2728#if ENABLE_FEATURE_OSF_LABEL 2704#if ENABLE_FEATURE_OSF_LABEL
2729 if (bsd_trydev(device) < 0) 2705 if (bsd_trydev(device) < 0)
2730#endif 2706#endif
2731 printf(_("Disk %s doesn't contain a valid " 2707 printf("Disk %s doesn't contain a valid "
2732 "partition table\n"), device); 2708 "partition table\n", device);
2733 close(fd); 2709 close(fd);
2734 } else { 2710 } else {
2735 close(fd); 2711 close(fd);
@@ -2745,7 +2721,7 @@ trydev(const char *device, int user_specified)
2745 and SCSI hard disks which may not be 2721 and SCSI hard disks which may not be
2746 installed on the system. */ 2722 installed on the system. */
2747 if (errno == EACCES) { 2723 if (errno == EACCES) {
2748 printf(_("Cannot open %s\n"), device); 2724 printf("Cannot open %s\n", device);
2749 return; 2725 return;
2750 } 2726 }
2751 } 2727 }
@@ -2781,7 +2757,7 @@ tryprocpt(void)
2781static void 2757static void
2782unknown_command(int c) 2758unknown_command(int c)
2783{ 2759{
2784 printf(_("%c: unknown command\n"), c); 2760 printf("%c: unknown command\n", c);
2785} 2761}
2786#endif 2762#endif
2787 2763
@@ -2845,8 +2821,8 @@ int fdisk_main(int argc, char **argv)
2845 //if (opt & OPT_s) // -s 2821 //if (opt & OPT_s) // -s
2846 2822
2847 if (user_set_sector_size && argc != 1) 2823 if (user_set_sector_size && argc != 1)
2848 printf(_("Warning: the -b (set sector size) option should" 2824 printf("Warning: the -b (set sector size) option should"
2849 " be used with one specified device\n")); 2825 " be used with one specified device\n");
2850 2826
2851#if ENABLE_FEATURE_FDISK_WRITABLE 2827#if ENABLE_FEATURE_FDISK_WRITABLE
2852 if (opt & OPT_l) { 2828 if (opt & OPT_l) {
@@ -2910,8 +2886,8 @@ int fdisk_main(int argc, char **argv)
2910 2886
2911 if (LABEL_IS_OSF) { 2887 if (LABEL_IS_OSF) {
2912 /* OSF label, and no DOS label */ 2888 /* OSF label, and no DOS label */
2913 printf(_("Detected an OSF/1 disklabel on %s, entering " 2889 printf("Detected an OSF/1 disklabel on %s, entering "
2914 "disklabel mode.\n"), disk_device); 2890 "disklabel mode\n", disk_device);
2915 bsd_select(); 2891 bsd_select();
2916 /*Why do we do this? It seems to be counter-intuitive*/ 2892 /*Why do we do this? It seems to be counter-intuitive*/
2917 current_label_type = label_dos; 2893 current_label_type = label_dos;
@@ -2921,7 +2897,7 @@ int fdisk_main(int argc, char **argv)
2921 while (1) { 2897 while (1) {
2922 int c; 2898 int c;
2923 putchar('\n'); 2899 putchar('\n');
2924 c = tolower(read_nonempty(_("Command (m for help): "))); 2900 c = tolower(read_nonempty("Command (m for help): "));
2925 switch (c) { 2901 switch (c) {
2926 case 'a': 2902 case 'a':
2927 if (LABEL_IS_DOS) 2903 if (LABEL_IS_DOS)
@@ -2937,11 +2913,11 @@ int fdisk_main(int argc, char **argv)
2937 break; 2913 break;
2938 case 'b': 2914 case 'b':
2939 if (LABEL_IS_SGI) { 2915 if (LABEL_IS_SGI) {
2940 printf(_("\nThe current boot file is: %s\n"), 2916 printf("\nThe current boot file is: %s\n",
2941 sgi_get_bootfile()); 2917 sgi_get_bootfile());
2942 if (read_maybe_empty(_("Please enter the name of the " 2918 if (read_maybe_empty("Please enter the name of the "
2943 "new boot file: ")) == '\n') 2919 "new boot file: ") == '\n')
2944 printf(_("Boot file unchanged\n")); 2920 printf("Boot file unchanged\n");
2945 else 2921 else
2946 sgi_set_bootfile(line_ptr); 2922 sgi_set_bootfile(line_ptr);
2947 } 2923 }
@@ -3022,8 +2998,8 @@ int fdisk_main(int argc, char **argv)
3022#if ENABLE_FEATURE_FDISK_ADVANCED 2998#if ENABLE_FEATURE_FDISK_ADVANCED
3023 case 'x': 2999 case 'x':
3024 if (LABEL_IS_SGI) { 3000 if (LABEL_IS_SGI) {
3025 printf(_("\n\tSorry, no experts menu for SGI " 3001 printf("\n\tSorry, no experts menu for SGI "
3026 "partition tables available.\n\n")); 3002 "partition tables available\n\n");
3027 } else 3003 } else
3028 xselect(); 3004 xselect();
3029 break; 3005 break;