aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--util-linux/fdisk.c908
-rw-r--r--util-linux/fdisk_aix.c21
-rw-r--r--util-linux/fdisk_osf.c245
-rw-r--r--util-linux/fdisk_sgi.c245
-rw-r--r--util-linux/fdisk_sun.c167
5 files changed, 791 insertions, 795 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;
diff --git a/util-linux/fdisk_aix.c b/util-linux/fdisk_aix.c
index 2402e294a..8095fc4ab 100644
--- a/util-linux/fdisk_aix.c
+++ b/util-linux/fdisk_aix.c
@@ -39,18 +39,15 @@ static short aix_volumes = 1;
39static void 39static void
40aix_info(void) 40aix_info(void)
41{ 41{
42 puts( 42 puts("\n"
43 _("\n\tThere is a valid AIX label on this disk.\n" 43"There is a valid AIX label on this disk.\n"
44 "\tUnfortunately Linux cannot handle these\n" 44"Unfortunately Linux cannot handle these disks at the moment.\n"
45 "\tdisks at the moment. Nevertheless some\n" 45"Nevertheless some advice:\n"
46 "\tadvice:\n" 46"1. fdisk will destroy its contents on write.\n"
47 "\t1. fdisk will destroy its contents on write.\n" 47"2. Be sure that this disk is NOT a still vital part of a volume group.\n"
48 "\t2. Be sure that this disk is NOT a still vital\n" 48" (Otherwise you may erase the other disks as well, if unmirrored.)\n"
49 "\t part of a volume group. (Otherwise you may\n" 49"3. Before deleting this physical volume be sure to remove the disk\n"
50 "\t erase the other disks as well, if unmirrored.)\n" 50" logically from your AIX machine. (Otherwise you become an AIXpert).\n"
51 "\t3. Before deleting this physical volume be sure\n"
52 "\t to remove the disk logically from your AIX\n"
53 "\t machine. (Otherwise you become an AIXpert).")
54 ); 51 );
55} 52}
56 53
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
index 2555c2e7b..dbb342886 100644
--- a/util-linux/fdisk_osf.c
+++ b/util-linux/fdisk_osf.c
@@ -195,29 +195,29 @@ static const char * const xbsd_dktypenames[] = {
195#define BSD_FS_MSDOS 8 /* MS-DOS file system */ 195#define BSD_FS_MSDOS 8 /* MS-DOS file system */
196#endif 196#endif
197 197
198static const struct systypes xbsd_fstypes[] = { 198static const char *const xbsd_fstypes[] = {
199 { "\x00" "unused" }, /* BSD_FS_UNUSED */ 199 "\x00" "unused", /* BSD_FS_UNUSED */
200 { "\x01" "swap" }, /* BSD_FS_SWAP */ 200 "\x01" "swap", /* BSD_FS_SWAP */
201 { "\x02" "Version 6" }, /* BSD_FS_V6 */ 201 "\x02" "Version 6", /* BSD_FS_V6 */
202 { "\x03" "Version 7" }, /* BSD_FS_V7 */ 202 "\x03" "Version 7", /* BSD_FS_V7 */
203 { "\x04" "System V" }, /* BSD_FS_SYSV */ 203 "\x04" "System V", /* BSD_FS_SYSV */
204 { "\x05" "4.1BSD" }, /* BSD_FS_V71K */ 204 "\x05" "4.1BSD", /* BSD_FS_V71K */
205 { "\x06" "Eighth Edition" }, /* BSD_FS_V8 */ 205 "\x06" "Eighth Edition", /* BSD_FS_V8 */
206 { "\x07" "4.2BSD" }, /* BSD_FS_BSDFFS */ 206 "\x07" "4.2BSD", /* BSD_FS_BSDFFS */
207#ifdef __alpha__ 207#ifdef __alpha__
208 { "\x08" "ext2" }, /* BSD_FS_EXT2 */ 208 "\x08" "ext2", /* BSD_FS_EXT2 */
209#else 209#else
210 { "\x08" "MS-DOS" }, /* BSD_FS_MSDOS */ 210 "\x08" "MS-DOS", /* BSD_FS_MSDOS */
211#endif 211#endif
212 { "\x09" "4.4LFS" }, /* BSD_FS_BSDLFS */ 212 "\x09" "4.4LFS", /* BSD_FS_BSDLFS */
213 { "\x0a" "unknown" }, /* BSD_FS_OTHER */ 213 "\x0a" "unknown", /* BSD_FS_OTHER */
214 { "\x0b" "HPFS" }, /* BSD_FS_HPFS */ 214 "\x0b" "HPFS", /* BSD_FS_HPFS */
215 { "\x0c" "ISO-9660" }, /* BSD_FS_ISO9660 */ 215 "\x0c" "ISO-9660", /* BSD_FS_ISO9660 */
216 { "\x0d" "boot" }, /* BSD_FS_BOOT */ 216 "\x0d" "boot", /* BSD_FS_BOOT */
217 { "\x0e" "ADOS" }, /* BSD_FS_ADOS */ 217 "\x0e" "ADOS", /* BSD_FS_ADOS */
218 { "\x0f" "HFS" }, /* BSD_FS_HFS */ 218 "\x0f" "HFS", /* BSD_FS_HFS */
219 { "\x10" "AdvFS" }, /* BSD_FS_ADVFS */ 219 "\x10" "AdvFS", /* BSD_FS_ADVFS */
220 { NULL } 220 NULL
221}; 221};
222#define BSD_FSMAXTYPES (SIZE(xbsd_fstypes)-1) 222#define BSD_FSMAXTYPES (SIZE(xbsd_fstypes)-1)
223 223
@@ -257,9 +257,9 @@ static int xbsd_get_part_index(int max);
257static int xbsd_check_new_partition(int *i); 257static int xbsd_check_new_partition(int *i);
258static void xbsd_list_types(void); 258static void xbsd_list_types(void);
259static uint16_t xbsd_dkcksum(struct xbsd_disklabel *lp); 259static uint16_t xbsd_dkcksum(struct xbsd_disklabel *lp);
260static int xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d); 260static int xbsd_initlabel(struct partition *p);
261static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d); 261static int xbsd_readlabel(struct partition *p);
262static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d); 262static int xbsd_writelabel(struct partition *p);
263 263
264#if defined(__alpha__) 264#if defined(__alpha__)
265static void alpha_bootblock_checksum(char *boot); 265static void alpha_bootblock_checksum(char *boot);
@@ -272,11 +272,22 @@ static struct partition *xbsd_part;
272static int xbsd_part_index; 272static int xbsd_part_index;
273#endif 273#endif
274 274
275
276/* Group big globals data and allocate it in one go */
277struct bsd_globals {
275/* We access this through a uint64_t * when checksumming */ 278/* We access this through a uint64_t * when checksumming */
276/* hopefully xmalloc gives us required alignment */ 279/* hopefully xmalloc gives us required alignment */
277static char *disklabelbuffer; /*[BSD_BBSIZE]*/ 280 char disklabelbuffer[BSD_BBSIZE];
281 struct xbsd_disklabel xbsd_dlabel;
282};
283
284static struct bsd_globals *bsd_globals_ptr;
285
286#define disklabelbuffer (bsd_globals_ptr->disklabelbuffer)
287#define xbsd_dlabel (bsd_globals_ptr->xbsd_dlabel)
278 288
279static struct xbsd_disklabel xbsd_dlabel; 289
290/* Code */
280 291
281#define bsd_cround(n) \ 292#define bsd_cround(n) \
282 (display_in_cyl_units ? ((n)/xbsd_dlabel.d_secpercyl) + 1 : (n)) 293 (display_in_cyl_units ? ((n)/xbsd_dlabel.d_secpercyl) + 1 : (n))
@@ -290,7 +301,7 @@ static struct xbsd_disklabel xbsd_dlabel;
290static int 301static int
291check_osf_label(void) 302check_osf_label(void)
292{ 303{
293 if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0) 304 if (xbsd_readlabel(NULL) == 0)
294 return 0; 305 return 0;
295 return 1; 306 return 1;
296} 307}
@@ -298,9 +309,9 @@ check_osf_label(void)
298static int 309static int
299bsd_trydev(const char * dev) 310bsd_trydev(const char * dev)
300{ 311{
301 if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0) 312 if (xbsd_readlabel(NULL) == 0)
302 return -1; 313 return -1;
303 printf(_("\nBSD label for device: %s\n"), dev); 314 printf("\nBSD label for device: %s\n", dev);
304 xbsd_print_disklabel(0); 315 xbsd_print_disklabel(0);
305 return 0; 316 return 0;
306} 317}
@@ -308,21 +319,21 @@ bsd_trydev(const char * dev)
308static void 319static void
309bsd_menu(void) 320bsd_menu(void)
310{ 321{
311 puts(_("Command Action")); 322 puts("Command Action");
312 puts(_("d\tdelete a BSD partition")); 323 puts("d\tdelete a BSD partition");
313 puts(_("e\tedit drive data")); 324 puts("e\tedit drive data");
314 puts(_("i\tinstall bootstrap")); 325 puts("i\tinstall bootstrap");
315 puts(_("l\tlist known filesystem types")); 326 puts("l\tlist known filesystem types");
316 puts(_("n\tadd a new BSD partition")); 327 puts("n\tadd a new BSD partition");
317 puts(_("p\tprint BSD partition table")); 328 puts("p\tprint BSD partition table");
318 puts(_("q\tquit without saving changes")); 329 puts("q\tquit without saving changes");
319 puts(_("r\treturn to main menu")); 330 puts("r\treturn to main menu");
320 puts(_("s\tshow complete disklabel")); 331 puts("s\tshow complete disklabel");
321 puts(_("t\tchange a partition's filesystem id")); 332 puts("t\tchange a partition's filesystem id");
322 puts(_("u\tchange units (cylinders/sectors)")); 333 puts("u\tchange units (cylinders/sectors)");
323 puts(_("w\twrite disklabel to disk")); 334 puts("w\twrite disklabel to disk");
324#if !defined(__alpha__) 335#if !defined(__alpha__)
325 puts(_("x\tlink BSD partition to non-BSD partition")); 336 puts("x\tlink BSD partition to non-BSD partition");
326#endif 337#endif
327} 338}
328 339
@@ -357,13 +368,13 @@ bsd_select(void)
357 xbsd_part_index = t; 368 xbsd_part_index = t;
358 ss = get_start_sect(xbsd_part); 369 ss = get_start_sect(xbsd_part);
359 if (ss == 0) { 370 if (ss == 0) {
360 fprintf(stderr, _("Partition %s has invalid starting sector 0.\n"), 371 printf("Partition %s has invalid starting sector 0\n",
361 partname(disk_device, t+1, 0)); 372 partname(disk_device, t+1, 0));
362 return; 373 return;
363 } 374 }
364 printf(_("Reading disklabel of %s at sector %d.\n"), 375 printf("Reading disklabel of %s at sector %d\n",
365 partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR); 376 partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR);
366 if (xbsd_readlabel(xbsd_part, &xbsd_dlabel) == 0) 377 if (xbsd_readlabel(xbsd_part) == 0)
367 if (xbsd_create_disklabel() == 0) 378 if (xbsd_create_disklabel() == 0)
368 return; 379 return;
369 break; 380 break;
@@ -371,13 +382,13 @@ bsd_select(void)
371 } 382 }
372 383
373 if (t == 4) { 384 if (t == 4) {
374 printf(_("There is no *BSD partition on %s.\n"), disk_device); 385 printf("There is no *BSD partition on %s\n", disk_device);
375 return; 386 return;
376 } 387 }
377 388
378#elif defined(__alpha__) 389#elif defined(__alpha__)
379 390
380 if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0) 391 if (xbsd_readlabel(NULL) == 0)
381 if (xbsd_create_disklabel() == 0) 392 if (xbsd_create_disklabel() == 0)
382 exit(EXIT_SUCCESS); 393 exit(EXIT_SUCCESS);
383 394
@@ -385,7 +396,7 @@ bsd_select(void)
385 396
386 while (1) { 397 while (1) {
387 putchar('\n'); 398 putchar('\n');
388 switch (tolower(read_nonempty(_("BSD disklabel command (m for help): ")))) { 399 switch (tolower(read_nonempty("BSD disklabel command (m for help): "))) {
389 case 'd': 400 case 'd':
390 xbsd_delete_part(); 401 xbsd_delete_part();
391 break; 402 break;
@@ -465,14 +476,14 @@ xbsd_new_part(void)
465 end = xbsd_dlabel.d_secperunit - 1; 476 end = xbsd_dlabel.d_secperunit - 1;
466#endif 477#endif
467 478
468 snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); 479 snprintf(mesg, sizeof(mesg), "First %s", str_units(SINGULAR));
469 begin = read_int(bsd_cround(begin), bsd_cround(begin), bsd_cround(end), 480 begin = read_int(bsd_cround(begin), bsd_cround(begin), bsd_cround(end),
470 0, mesg); 481 0, mesg);
471 482
472 if (display_in_cyl_units) 483 if (display_in_cyl_units)
473 begin = (begin - 1) * xbsd_dlabel.d_secpercyl; 484 begin = (begin - 1) * xbsd_dlabel.d_secpercyl;
474 485
475 snprintf(mesg, sizeof(mesg), _("Last %s or +size or +sizeM or +sizeK"), 486 snprintf(mesg, sizeof(mesg), "Last %s or +size or +sizeM or +sizeK",
476 str_units(SINGULAR)); 487 str_units(SINGULAR));
477 end = read_int(bsd_cround(begin), bsd_cround(end), bsd_cround(end), 488 end = read_int(bsd_cround(begin), bsd_cround(end), bsd_cround(end),
478 bsd_cround(begin), mesg); 489 bsd_cround(begin), mesg);
@@ -499,35 +510,35 @@ xbsd_print_disklabel(int show_all)
499 printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0)); 510 printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0));
500#endif 511#endif
501 if ((unsigned) lp->d_type < BSD_DKMAXTYPES) 512 if ((unsigned) lp->d_type < BSD_DKMAXTYPES)
502 printf(_("type: %s\n"), xbsd_dktypenames[lp->d_type]); 513 printf("type: %s\n", xbsd_dktypenames[lp->d_type]);
503 else 514 else
504 printf(_("type: %d\n"), lp->d_type); 515 printf("type: %d\n", lp->d_type);
505 printf(_("disk: %.*s\n"), (int) sizeof(lp->d_typename), lp->d_typename); 516 printf("disk: %.*s\n", (int) sizeof(lp->d_typename), lp->d_typename);
506 printf(_("label: %.*s\n"), (int) sizeof(lp->d_packname), lp->d_packname); 517 printf("label: %.*s\n", (int) sizeof(lp->d_packname), lp->d_packname);
507 printf(_("flags:")); 518 printf("flags:");
508 if (lp->d_flags & BSD_D_REMOVABLE) 519 if (lp->d_flags & BSD_D_REMOVABLE)
509 printf(_(" removable")); 520 printf(" removable");
510 if (lp->d_flags & BSD_D_ECC) 521 if (lp->d_flags & BSD_D_ECC)
511 printf(_(" ecc")); 522 printf(" ecc");
512 if (lp->d_flags & BSD_D_BADSECT) 523 if (lp->d_flags & BSD_D_BADSECT)
513 printf(_(" badsect")); 524 printf(" badsect");
514 puts(""); 525 puts("");
515 /* On various machines the fields of *lp are short/int/long */ 526 /* On various machines the fields of *lp are short/int/long */
516 /* In order to avoid problems, we cast them all to long. */ 527 /* In order to avoid problems, we cast them all to long. */
517 printf(_("bytes/sector: %ld\n"), (long) lp->d_secsize); 528 printf("bytes/sector: %ld\n", (long) lp->d_secsize);
518 printf(_("sectors/track: %ld\n"), (long) lp->d_nsectors); 529 printf("sectors/track: %ld\n", (long) lp->d_nsectors);
519 printf(_("tracks/cylinder: %ld\n"), (long) lp->d_ntracks); 530 printf("tracks/cylinder: %ld\n", (long) lp->d_ntracks);
520 printf(_("sectors/cylinder: %ld\n"), (long) lp->d_secpercyl); 531 printf("sectors/cylinder: %ld\n", (long) lp->d_secpercyl);
521 printf(_("cylinders: %ld\n"), (long) lp->d_ncylinders); 532 printf("cylinders: %ld\n", (long) lp->d_ncylinders);
522 printf(_("rpm: %d\n"), lp->d_rpm); 533 printf("rpm: %d\n", lp->d_rpm);
523 printf(_("interleave: %d\n"), lp->d_interleave); 534 printf("interleave: %d\n", lp->d_interleave);
524 printf(_("trackskew: %d\n"), lp->d_trackskew); 535 printf("trackskew: %d\n", lp->d_trackskew);
525 printf(_("cylinderskew: %d\n"), lp->d_cylskew); 536 printf("cylinderskew: %d\n", lp->d_cylskew);
526 printf(_("headswitch: %ld\t\t# milliseconds\n"), 537 printf("headswitch: %ld\t\t# milliseconds\n",
527 (long) lp->d_headswitch); 538 (long) lp->d_headswitch);
528 printf(_("track-to-track seek: %ld\t# milliseconds\n"), 539 printf("track-to-track seek: %ld\t# milliseconds\n",
529 (long) lp->d_trkseek); 540 (long) lp->d_trkseek);
530 printf(_("drivedata: ")); 541 printf("drivedata: ");
531 for (i = NDDATA - 1; i >= 0; i--) 542 for (i = NDDATA - 1; i >= 0; i--)
532 if (lp->d_drivedata[i]) 543 if (lp->d_drivedata[i])
533 break; 544 break;
@@ -536,8 +547,8 @@ xbsd_print_disklabel(int show_all)
536 for (j = 0; j <= i; j++) 547 for (j = 0; j <= i; j++)
537 printf("%ld ", (long) lp->d_drivedata[j]); 548 printf("%ld ", (long) lp->d_drivedata[j]);
538 } 549 }
539 printf(_("\n%d partitions:\n"), lp->d_npartitions); 550 printf("\n%d partitions:\n", lp->d_npartitions);
540 printf(_("# start end size fstype [fsize bsize cpg]\n")); 551 printf("# start end size fstype [fsize bsize cpg]\n");
541 pp = lp->d_partitions; 552 pp = lp->d_partitions;
542 for (i = 0; i < lp->d_npartitions; i++, pp++) { 553 for (i = 0; i < lp->d_npartitions; i++, pp++) {
543 if (pp->p_size) { 554 if (pp->p_size) {
@@ -561,7 +572,7 @@ xbsd_print_disklabel(int show_all)
561 } 572 }
562 573
563 if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES) 574 if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES)
564 printf("%8.8s", xbsd_fstypes[pp->p_fstype].name); 575 printf("%8.8s", xbsd_fstypes[pp->p_fstype]);
565 else 576 else
566 printf("%8x", pp->p_fstype); 577 printf("%8x", pp->p_fstype);
567 578
@@ -587,12 +598,12 @@ static void
587xbsd_write_disklabel(void) 598xbsd_write_disklabel(void)
588{ 599{
589#if defined(__alpha__) 600#if defined(__alpha__)
590 printf(_("Writing disklabel to %s.\n"), disk_device); 601 printf("Writing disklabel to %s\n", disk_device);
591 xbsd_writelabel(NULL, &xbsd_dlabel); 602 xbsd_writelabel(NULL);
592#else 603#else
593 printf(_("Writing disklabel to %s.\n"), 604 printf("Writing disklabel to %s\n",
594 partname(disk_device, xbsd_part_index + 1, 0)); 605 partname(disk_device, xbsd_part_index + 1, 0));
595 xbsd_writelabel(xbsd_part, &xbsd_dlabel); 606 xbsd_writelabel(xbsd_part);
596#endif 607#endif
597 reread_partition_table(0); /* no exit yet */ 608 reread_partition_table(0); /* no exit yet */
598} 609}
@@ -603,21 +614,21 @@ xbsd_create_disklabel(void)
603 char c; 614 char c;
604 615
605#if defined(__alpha__) 616#if defined(__alpha__)
606 fprintf(stderr, _("%s contains no disklabel.\n"), disk_device); 617 printf("%s contains no disklabel\n", disk_device);
607#else 618#else
608 fprintf(stderr, _("%s contains no disklabel.\n"), 619 printf("%s contains no disklabel\n",
609 partname(disk_device, xbsd_part_index + 1, 0)); 620 partname(disk_device, xbsd_part_index + 1, 0));
610#endif 621#endif
611 622
612 while (1) { 623 while (1) {
613 c = read_nonempty(_("Do you want to create a disklabel? (y/n) ")); 624 c = read_nonempty("Do you want to create a disklabel? (y/n) ");
614 if (c == 'y' || c == 'Y') { 625 if (c == 'y' || c == 'Y') {
615 if (xbsd_initlabel( 626 if (xbsd_initlabel(
616#if defined(__alpha__) || defined(__powerpc__) || defined(__hppa__) || \ 627#if defined(__alpha__) || defined(__powerpc__) || defined(__hppa__) || \
617 defined(__s390__) || defined(__s390x__) 628 defined(__s390__) || defined(__s390x__)
618 NULL, &xbsd_dlabel 629 NULL
619#else 630#else
620 xbsd_part, &xbsd_dlabel/* not used, xbsd_part_index*/ 631 xbsd_part
621#endif 632#endif
622 ) == 1) { 633 ) == 1) {
623 xbsd_print_disklabel(1); 634 xbsd_print_disklabel(1);
@@ -651,27 +662,27 @@ xbsd_edit_disklabel(void)
651 d = &xbsd_dlabel; 662 d = &xbsd_dlabel;
652 663
653#if defined(__alpha__) || defined(__ia64__) 664#if defined(__alpha__) || defined(__ia64__)
654 d->d_secsize = edit_int(d->d_secsize ,_("bytes/sector")); 665 d->d_secsize = edit_int(d->d_secsize , "bytes/sector");
655 d->d_nsectors = edit_int(d->d_nsectors ,_("sectors/track")); 666 d->d_nsectors = edit_int(d->d_nsectors , "sectors/track");
656 d->d_ntracks = edit_int(d->d_ntracks ,_("tracks/cylinder")); 667 d->d_ntracks = edit_int(d->d_ntracks , "tracks/cylinder");
657 d->d_ncylinders = edit_int(d->d_ncylinders ,_("cylinders")); 668 d->d_ncylinders = edit_int(d->d_ncylinders , "cylinders");
658#endif 669#endif
659 670
660 /* d->d_secpercyl can be != d->d_nsectors * d->d_ntracks */ 671 /* d->d_secpercyl can be != d->d_nsectors * d->d_ntracks */
661 while (1) { 672 while (1) {
662 d->d_secpercyl = edit_int(d->d_nsectors * d->d_ntracks, 673 d->d_secpercyl = edit_int(d->d_nsectors * d->d_ntracks,
663 _("sectors/cylinder")); 674 "sectors/cylinder");
664 if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks) 675 if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks)
665 break; 676 break;
666 677
667 printf(_("Must be <= sectors/track * tracks/cylinder (default).\n")); 678 printf("Must be <= sectors/track * tracks/cylinder (default)\n");
668 } 679 }
669 d->d_rpm = edit_int(d->d_rpm ,_("rpm")); 680 d->d_rpm = edit_int(d->d_rpm , "rpm");
670 d->d_interleave = edit_int(d->d_interleave,_("interleave")); 681 d->d_interleave = edit_int(d->d_interleave, "interleave");
671 d->d_trackskew = edit_int(d->d_trackskew ,_("trackskew")); 682 d->d_trackskew = edit_int(d->d_trackskew , "trackskew");
672 d->d_cylskew = edit_int(d->d_cylskew ,_("cylinderskew")); 683 d->d_cylskew = edit_int(d->d_cylskew , "cylinderskew");
673 d->d_headswitch = edit_int(d->d_headswitch,_("headswitch")); 684 d->d_headswitch = edit_int(d->d_headswitch, "headswitch");
674 d->d_trkseek = edit_int(d->d_trkseek ,_("track-to-track seek")); 685 d->d_trkseek = edit_int(d->d_trkseek , "track-to-track seek");
675 686
676 d->d_secperunit = d->d_secpercyl * d->d_ncylinders; 687 d->d_secperunit = d->d_secpercyl * d->d_ncylinders;
677} 688}
@@ -699,9 +710,9 @@ xbsd_get_bootstrap(char *path, void *ptr, int size)
699static void 710static void
700sync_disks(void) 711sync_disks(void)
701{ 712{
702 printf(_("\nSyncing disks.\n")); 713 printf("Syncing disks\n");
703 sync(); 714 sync();
704 sleep(4); /* What? */ 715 /* sleep(4); What? */
705} 716}
706 717
707static void 718static void
@@ -743,7 +754,7 @@ xbsd_write_bootstrap(void)
743 e = d + sizeof(struct xbsd_disklabel); 754 e = d + sizeof(struct xbsd_disklabel);
744 for (p = d; p < e; p++) 755 for (p = d; p < e; p++)
745 if (*p) { 756 if (*p) {
746 fprintf(stderr, _("Bootstrap overlaps with disk label!\n")); 757 printf("Bootstrap overlaps with disk label!\n");
747 exit(EXIT_FAILURE); 758 exit(EXIT_FAILURE);
748 } 759 }
749 760
@@ -764,9 +775,9 @@ xbsd_write_bootstrap(void)
764 fdisk_fatal(unable_to_write); 775 fdisk_fatal(unable_to_write);
765 776
766#if defined(__alpha__) 777#if defined(__alpha__)
767 printf(_("Bootstrap installed on %s.\n"), disk_device); 778 printf("Bootstrap installed on %s\n", disk_device);
768#else 779#else
769 printf(_("Bootstrap installed on %s.\n"), 780 printf("Bootstrap installed on %s\n",
770 partname(disk_device, xbsd_part_index+1, 0)); 781 partname(disk_device, xbsd_part_index+1, 0));
771#endif 782#endif
772 783
@@ -785,10 +796,10 @@ xbsd_change_fstype(void)
785static int 796static int
786xbsd_get_part_index(int max) 797xbsd_get_part_index(int max)
787{ 798{
788 char prompt[256]; 799 char prompt[sizeof("Partition (a-%c): ") + 16];
789 char l; 800 char l;
790 801
791 snprintf(prompt, sizeof(prompt), _("Partition (a-%c): "), 'a' + max - 1); 802 snprintf(prompt, sizeof(prompt), "Partition (a-%c): ", 'a' + max - 1);
792 do 803 do
793 l = tolower(read_nonempty(prompt)); 804 l = tolower(read_nonempty(prompt));
794 while (l < 'a' || l > 'a' + max - 1); 805 while (l < 'a' || l > 'a' + max - 1);
@@ -807,8 +818,7 @@ xbsd_check_new_partition(int *i)
807 break; 818 break;
808 819
809 if (t == BSD_MAXPARTITIONS) { 820 if (t == BSD_MAXPARTITIONS) {
810 fprintf(stderr, _("The maximum number of partitions " 821 printf("The maximum number of partitions has been created\n");
811 "has been created\n"));
812 return 0; 822 return 0;
813 } 823 }
814 } 824 }
@@ -819,7 +829,7 @@ xbsd_check_new_partition(int *i)
819 xbsd_dlabel.d_npartitions = (*i) + 1; 829 xbsd_dlabel.d_npartitions = (*i) + 1;
820 830
821 if (xbsd_dlabel.d_partitions[*i].p_size != 0) { 831 if (xbsd_dlabel.d_partitions[*i].p_size != 0) {
822 fprintf(stderr, _("This partition already exists.\n")); 832 printf("This partition already exists\n");
823 return 0; 833 return 0;
824 } 834 }
825 835
@@ -846,8 +856,9 @@ xbsd_dkcksum(struct xbsd_disklabel *lp)
846} 856}
847 857
848static int 858static int
849xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d) 859xbsd_initlabel(struct partition *p)
850{ 860{
861 struct xbsd_disklabel *d = &xbsd_dlabel;
851 struct xbsd_partition *pp; 862 struct xbsd_partition *pp;
852 863
853 get_geometry(); 864 get_geometry();
@@ -897,7 +908,7 @@ xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d)
897 pp->p_offset = 0; 908 pp->p_offset = 0;
898 pp->p_size = d->d_secperunit; 909 pp->p_size = d->d_secperunit;
899 pp->p_fstype = BSD_FS_UNUSED; 910 pp->p_fstype = BSD_FS_UNUSED;
900#elif defined(__alpha__) 911#else
901 d->d_npartitions = 3; 912 d->d_npartitions = 3;
902 pp = &d->d_partitions[2]; /* Partition C should be 913 pp = &d->d_partitions[2]; /* Partition C should be
903 the whole disk */ 914 the whole disk */
@@ -914,17 +925,20 @@ xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d)
914 * If it has the right magic, return 1. 925 * If it has the right magic, return 1.
915 */ 926 */
916static int 927static int
917xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d) 928xbsd_readlabel(struct partition *p)
918{ 929{
930 struct xbsd_disklabel *d;
919 int t, sector; 931 int t, sector;
920 932
921 if (!disklabelbuffer) 933 if (!bsd_globals_ptr)
922 disklabelbuffer = xmalloc(BSD_BBSIZE); 934 bsd_globals_ptr = xzalloc(sizeof(*bsd_globals_ptr));
935
936 d = &xbsd_dlabel;
923 937
924 /* p is used only to get the starting sector */ 938 /* p is used only to get the starting sector */
925#if !defined(__alpha__) 939#if !defined(__alpha__)
926 sector = (p ? get_start_sect(p) : 0); 940 sector = (p ? get_start_sect(p) : 0);
927#elif defined(__alpha__) 941#else
928 sector = 0; 942 sector = 0;
929#endif 943#endif
930 944
@@ -946,15 +960,15 @@ xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d)
946 } 960 }
947 961
948 if (d->d_npartitions > BSD_MAXPARTITIONS) 962 if (d->d_npartitions > BSD_MAXPARTITIONS)
949 fprintf(stderr, _("Warning: too many partitions " 963 printf("Warning: too many partitions (%d, maximum is %d)\n",
950 "(%d, maximum is %d).\n"),
951 d->d_npartitions, BSD_MAXPARTITIONS); 964 d->d_npartitions, BSD_MAXPARTITIONS);
952 return 1; 965 return 1;
953} 966}
954 967
955static int 968static int
956xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d) 969xbsd_writelabel(struct partition *p)
957{ 970{
971 struct xbsd_disklabel *d = &xbsd_dlabel;
958 unsigned int sector; 972 unsigned int sector;
959 973
960#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__hppa__) 974#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__hppa__)
@@ -1028,7 +1042,6 @@ xbsd_link_part(void)
1028#endif 1042#endif
1029 1043
1030#if defined(__alpha__) 1044#if defined(__alpha__)
1031
1032static void 1045static void
1033alpha_bootblock_checksum(char *boot) 1046alpha_bootblock_checksum(char *boot)
1034{ 1047{
@@ -1043,4 +1056,8 @@ alpha_bootblock_checksum(char *boot)
1043} 1056}
1044#endif /* __alpha__ */ 1057#endif /* __alpha__ */
1045 1058
1059/* Undefine 'global' tricks */
1060#undef disklabelbuffer
1061#undef xbsd_dlabel
1062
1046#endif /* OSF_LABEL */ 1063#endif /* OSF_LABEL */
diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c
index 937ac883b..b2e0d7a62 100644
--- a/util-linux/fdisk_sgi.c
+++ b/util-linux/fdisk_sgi.c
@@ -6,6 +6,20 @@
6 * the terms of the GNU Public License. 6 * the terms of the GNU Public License.
7 */ 7 */
8 8
9#define SGI_VOLHDR 0x00
10/* 1 and 2 were used for drive types no longer supported by SGI */
11#define SGI_SWAP 0x03
12/* 4 and 5 were for filesystem types SGI haven't ever supported on MIPS CPUs */
13#define SGI_VOLUME 0x06
14#define SGI_EFS 0x07
15#define SGI_LVOL 0x08
16#define SGI_RLVOL 0x09
17#define SGI_XFS 0x0a
18#define SGI_XFSLOG 0x0b
19#define SGI_XLV 0x0c
20#define SGI_XVM 0x0d
21#define SGI_ENTIRE_DISK SGI_VOLUME
22
9struct device_parameter { /* 48 bytes */ 23struct device_parameter { /* 48 bytes */
10 unsigned char skew; 24 unsigned char skew;
11 unsigned char gap1; 25 unsigned char gap1;
@@ -159,26 +173,26 @@ isinfreelist(unsigned int b)
159 * end of free blocks section 173 * end of free blocks section
160 */ 174 */
161 175
162static const struct systypes sgi_sys_types[] = { 176static const char *const sgi_sys_types[] = {
163/* SGI_VOLHDR */ { "\x00" "SGI volhdr" }, 177/* SGI_VOLHDR */ "\x00" "SGI volhdr" ,
164/* 0x01 */ { "\x01" "SGI trkrepl" }, 178/* 0x01 */ "\x01" "SGI trkrepl" ,
165/* 0x02 */ { "\x02" "SGI secrepl" }, 179/* 0x02 */ "\x02" "SGI secrepl" ,
166/* SGI_SWAP */ { "\x03" "SGI raw" }, 180/* SGI_SWAP */ "\x03" "SGI raw" ,
167/* 0x04 */ { "\x04" "SGI bsd" }, 181/* 0x04 */ "\x04" "SGI bsd" ,
168/* 0x05 */ { "\x05" "SGI sysv" }, 182/* 0x05 */ "\x05" "SGI sysv" ,
169/* SGI_ENTIRE_DISK */ { "\x06" "SGI volume" }, 183/* SGI_ENTIRE_DISK */ "\x06" "SGI volume" ,
170/* SGI_EFS */ { "\x07" "SGI efs" }, 184/* SGI_EFS */ "\x07" "SGI efs" ,
171/* 0x08 */ { "\x08" "SGI lvol" }, 185/* 0x08 */ "\x08" "SGI lvol" ,
172/* 0x09 */ { "\x09" "SGI rlvol" }, 186/* 0x09 */ "\x09" "SGI rlvol" ,
173/* SGI_XFS */ { "\x0a" "SGI xfs" }, 187/* SGI_XFS */ "\x0a" "SGI xfs" ,
174/* SGI_XFSLOG */ { "\x0b" "SGI xfslog" }, 188/* SGI_XFSLOG */ "\x0b" "SGI xfslog" ,
175/* SGI_XLV */ { "\x0c" "SGI xlv" }, 189/* SGI_XLV */ "\x0c" "SGI xlv" ,
176/* SGI_XVM */ { "\x0d" "SGI xvm" }, 190/* SGI_XVM */ "\x0d" "SGI xvm" ,
177/* LINUX_SWAP */ { "\x82" "Linux swap" }, 191/* LINUX_SWAP */ "\x82" "Linux swap" ,
178/* LINUX_NATIVE */ { "\x83" "Linux native" }, 192/* LINUX_NATIVE */ "\x83" "Linux native",
179/* LINUX_LVM */ { "\x8d" "Linux LVM" }, 193/* LINUX_LVM */ "\x8d" "Linux LVM" ,
180/* LINUX_RAID */ { "\xfd" "Linux RAID" }, 194/* LINUX_RAID */ "\xfd" "Linux RAID" ,
181 { NULL } 195 NULL
182}; 196};
183 197
184 198
@@ -206,18 +220,20 @@ two_s_complement_32bit_sum(unsigned int* base, int size /* in bytes */)
206 return sum; 220 return sum;
207} 221}
208 222
223void BUG_bad_sgi_partition_size(void);
224
209static int 225static int
210check_sgi_label(void) 226check_sgi_label(void)
211{ 227{
212 if (sizeof(sgilabel) > 512) { 228 if (sizeof(sgi_partition) > 512) {
213 fprintf(stderr, 229 /* According to MIPS Computer Systems, Inc the label
214 _("According to MIPS Computer Systems, Inc the " 230 * must not contain more than 512 bytes */
215 "Label must not contain more than 512 bytes\n")); 231 BUG_bad_sgi_partition_size();
216 exit(1);
217 } 232 }
218 233
219 if (sgilabel->magic != SGI_LABEL_MAGIC 234 if (sgilabel->magic != SGI_LABEL_MAGIC
220 && sgilabel->magic != SGI_LABEL_MAGIC_SWAPPED) { 235 && sgilabel->magic != SGI_LABEL_MAGIC_SWAPPED
236 ) {
221 current_label_type = label_dos; 237 current_label_type = label_dos;
222 return 0; 238 return 0;
223 } 239 }
@@ -228,8 +244,7 @@ check_sgi_label(void)
228 */ 244 */
229 if (two_s_complement_32bit_sum((unsigned int*)sgilabel, 245 if (two_s_complement_32bit_sum((unsigned int*)sgilabel,
230 sizeof(*sgilabel))) { 246 sizeof(*sgilabel))) {
231 fprintf(stderr, 247 printf("Detected sgi disklabel with wrong checksum\n");
232 _("Detected sgi disklabel with wrong checksum.\n"));
233 } 248 }
234 update_units(); 249 update_units();
235 current_label_type = label_sgi; 250 current_label_type = label_sgi;
@@ -274,12 +289,12 @@ sgi_list_table(int xtra)
274 int i, w, wd; 289 int i, w, wd;
275 int kpi = 0; /* kernel partition ID */ 290 int kpi = 0; /* kernel partition ID */
276 291
277 if(xtra) { 292 if (xtra) {
278 printf(_("\nDisk %s (SGI disk label): %d heads, %d sectors\n" 293 printf("\nDisk %s (SGI disk label): %d heads, %d sectors\n"
279 "%d cylinders, %d physical cylinders\n" 294 "%d cylinders, %d physical cylinders\n"
280 "%d extra sects/cyl, interleave %d:1\n" 295 "%d extra sects/cyl, interleave %d:1\n"
281 "%s\n" 296 "%s\n"
282 "Units = %s of %d * 512 bytes\n\n"), 297 "Units = %s of %d * 512 bytes\n\n",
283 disk_device, heads, sectors, cylinders, 298 disk_device, heads, sectors, cylinders,
284 SGI_SSWAP16(sgiparam.pcylcount), 299 SGI_SSWAP16(sgiparam.pcylcount),
285 SGI_SSWAP16(sgiparam.sparecyl), 300 SGI_SSWAP16(sgiparam.sparecyl),
@@ -287,23 +302,23 @@ sgi_list_table(int xtra)
287 (char *)sgilabel, 302 (char *)sgilabel,
288 str_units(PLURAL), units_per_sector); 303 str_units(PLURAL), units_per_sector);
289 } else { 304 } else {
290 printf( _("\nDisk %s (SGI disk label): " 305 printf("\nDisk %s (SGI disk label): "
291 "%d heads, %d sectors, %d cylinders\n" 306 "%d heads, %d sectors, %d cylinders\n"
292 "Units = %s of %d * 512 bytes\n\n"), 307 "Units = %s of %d * 512 bytes\n\n",
293 disk_device, heads, sectors, cylinders, 308 disk_device, heads, sectors, cylinders,
294 str_units(PLURAL), units_per_sector ); 309 str_units(PLURAL), units_per_sector );
295 } 310 }
296 311
297 w = strlen(disk_device); 312 w = strlen(disk_device);
298 wd = strlen(_("Device")); 313 wd = sizeof("Device") - 1;
299 if (w < wd) 314 if (w < wd)
300 w = wd; 315 w = wd;
301 316
302 printf(_("----- partitions -----\n" 317 printf("----- partitions -----\n"
303 "Pt# %*s Info Start End Sectors Id System\n"), 318 "Pt# %*s Info Start End Sectors Id System\n",
304 w + 2, _("Device")); 319 w + 2, "Device");
305 for (i = 0 ; i < partitions; i++) { 320 for (i = 0 ; i < partitions; i++) {
306 if( sgi_get_num_sectors(i) || debug ) { 321 if (sgi_get_num_sectors(i) || debug ) {
307 uint32_t start = sgi_get_start_sector(i); 322 uint32_t start = sgi_get_start_sector(i);
308 uint32_t len = sgi_get_num_sectors(i); 323 uint32_t len = sgi_get_num_sectors(i);
309 kpi++; /* only count nonempty partitions */ 324 kpi++; /* only count nonempty partitions */
@@ -320,8 +335,8 @@ sgi_list_table(int xtra)
320/* type name */ partition_type(sgi_get_sysid(i))); 335/* type name */ partition_type(sgi_get_sysid(i)));
321 } 336 }
322 } 337 }
323 printf(_("----- Bootinfo -----\nBootfile: %s\n" 338 printf("----- Bootinfo -----\nBootfile: %s\n"
324 "----- Directory Entries -----\n"), 339 "----- Directory Entries -----\n",
325 sgilabel->boot_file); 340 sgilabel->boot_file);
326 for (i = 0 ; i < sgi_volumes; i++) { 341 for (i = 0 ; i < sgi_volumes; i++) {
327 if (sgilabel->directory[i].vol_file_size) { 342 if (sgilabel->directory[i].vol_file_size) {
@@ -329,7 +344,7 @@ sgi_list_table(int xtra)
329 uint32_t len = SGI_SSWAP32(sgilabel->directory[i].vol_file_size); 344 uint32_t len = SGI_SSWAP32(sgilabel->directory[i].vol_file_size);
330 unsigned char *name = sgilabel->directory[i].vol_file_name; 345 unsigned char *name = sgilabel->directory[i].vol_file_name;
331 346
332 printf(_("%2d: %-10s sector%5u size%8u\n"), 347 printf("%2d: %-10s sector%5u size%8u\n",
333 i, (char*)name, (unsigned int) start, (unsigned int) len); 348 i, (char*)name, (unsigned int) start, (unsigned int) len);
334 } 349 }
335 } 350 }
@@ -357,26 +372,22 @@ static int
357sgi_check_bootfile(const char* aFile) 372sgi_check_bootfile(const char* aFile)
358{ 373{
359 if (strlen(aFile) < 3) /* "/a\n" is minimum */ { 374 if (strlen(aFile) < 3) /* "/a\n" is minimum */ {
360 printf(_("\nInvalid Bootfile!\n" 375 printf("\nInvalid Bootfile!\n"
361 "\tThe bootfile must be an absolute non-zero pathname,\n" 376 "\tThe bootfile must be an absolute non-zero pathname,\n"
362 "\te.g. \"/unix\" or \"/unix.save\".\n")); 377 "\te.g. \"/unix\" or \"/unix.save\".\n");
363 return 0; 378 return 0;
364 } else { 379 }
365 if (strlen(aFile) > 16) { 380 if (strlen(aFile) > 16) {
366 printf(_("\n\tName of Bootfile too long: " 381 printf("\nName of Bootfile too long (>16 bytes)\n");
367 "16 bytes maximum.\n")); 382 return 0;
368 return 0; 383 }
369 } else { 384 if (aFile[0] != '/') {
370 if (aFile[0] != '/') { 385 printf("\nBootfile must have a fully qualified pathname\n");
371 printf(_("\n\tBootfile must have a " 386 return 0;
372 "fully qualified pathname.\n")); 387 }
373 return 0;
374 }
375 }
376 }
377 if (strncmp(aFile, (char*)sgilabel->boot_file, 16)) { 388 if (strncmp(aFile, (char*)sgilabel->boot_file, 16)) {
378 printf(_("\n\tBe aware, that the bootfile is not checked for existence.\n\t" 389 printf("\nBe aware, that the bootfile is not checked for existence.\n"
379 "SGI's default is \"/unix\" and for backup \"/unix.save\".\n")); 390 "\tSGI's default is \"/unix\" and for backup \"/unix.save\".\n");
380 /* filename is correct and did change */ 391 /* filename is correct and did change */
381 return 1; 392 return 1;
382 } 393 }
@@ -403,7 +414,7 @@ sgi_set_bootfile(const char* aFile)
403 sgilabel->boot_file[i] = 0; 414 sgilabel->boot_file[i] = 0;
404 i++; 415 i++;
405 } 416 }
406 printf(_("\n\tBootfile is changed to \"%s\".\n"), sgilabel->boot_file); 417 printf("\n\tBootfile is changed to \"%s\"\n", sgilabel->boot_file);
407 } 418 }
408} 419}
409 420
@@ -484,34 +495,34 @@ verify_sgi(int verbose)
484 if (sgi_get_sysid(i) == SGI_ENTIRE_DISK) { 495 if (sgi_get_sysid(i) == SGI_ENTIRE_DISK) {
485 if (entire++ == 1) { 496 if (entire++ == 1) {
486 if (verbose) 497 if (verbose)
487 printf(_("More than one entire disk entry present.\n")); 498 printf("More than one entire disk entry present\n");
488 } 499 }
489 } 500 }
490 } 501 }
491 } 502 }
492 if (sortcount == 0) { 503 if (sortcount == 0) {
493 if (verbose) 504 if (verbose)
494 printf(_("No partitions defined\n")); 505 printf("No partitions defined\n");
495 return (lastblock > 0) ? 1 : (lastblock == 0) ? 0 : -1; 506 return (lastblock > 0) ? 1 : (lastblock == 0) ? 0 : -1;
496 } 507 }
497 qsort(Index, sortcount, sizeof(Index[0]), (void*)compare_start); 508 qsort(Index, sortcount, sizeof(Index[0]), (void*)compare_start);
498 if (sgi_get_sysid(Index[0]) == SGI_ENTIRE_DISK) { 509 if (sgi_get_sysid(Index[0]) == SGI_ENTIRE_DISK) {
499 if ((Index[0] != 10) && verbose) 510 if ((Index[0] != 10) && verbose)
500 printf(_("IRIX likes when Partition 11 covers the entire disk.\n")); 511 printf("IRIX likes when Partition 11 covers the entire disk\n");
501 if ((sgi_get_start_sector(Index[0]) != 0) && verbose) 512 if ((sgi_get_start_sector(Index[0]) != 0) && verbose)
502 printf(_("The entire disk partition should start " 513 printf("The entire disk partition should start "
503 "at block 0,\n" 514 "at block 0,\n"
504 "not at diskblock %d.\n"), 515 "not at diskblock %d\n",
505 sgi_get_start_sector(Index[0])); 516 sgi_get_start_sector(Index[0]));
506 if (debug) /* I do not understand how some disks fulfil it */ 517 if (debug) /* I do not understand how some disks fulfil it */
507 if ((sgi_get_num_sectors(Index[0]) != lastblock) && verbose) 518 if ((sgi_get_num_sectors(Index[0]) != lastblock) && verbose)
508 printf(_("The entire disk partition is only %d diskblock large,\n" 519 printf("The entire disk partition is only %d diskblock large,\n"
509 "but the disk is %d diskblocks long.\n"), 520 "but the disk is %d diskblocks long\n",
510 sgi_get_num_sectors(Index[0]), lastblock); 521 sgi_get_num_sectors(Index[0]), lastblock);
511 lastblock = sgi_get_num_sectors(Index[0]); 522 lastblock = sgi_get_num_sectors(Index[0]);
512 } else { 523 } else {
513 if (verbose) 524 if (verbose)
514 printf(_("One Partition (#11) should cover the entire disk.\n")); 525 printf("One Partition (#11) should cover the entire disk\n");
515 if (debug > 2) 526 if (debug > 2)
516 printf("sysid=%d\tpartition=%d\n", 527 printf("sysid=%d\tpartition=%d\n",
517 sgi_get_sysid(Index[0]), Index[0]+1); 528 sgi_get_sysid(Index[0]), Index[0]+1);
@@ -522,28 +533,28 @@ verify_sgi(int verbose)
522 if ((sgi_get_start_sector(Index[i]) % cylsize) != 0) { 533 if ((sgi_get_start_sector(Index[i]) % cylsize) != 0) {
523 if (debug) /* I do not understand how some disks fulfil it */ 534 if (debug) /* I do not understand how some disks fulfil it */
524 if (verbose) 535 if (verbose)
525 printf(_("Partition %d does not start on cylinder boundary.\n"), 536 printf("Partition %d does not start on cylinder boundary\n",
526 Index[i]+1); 537 Index[i]+1);
527 } 538 }
528 if (sgi_get_num_sectors(Index[i]) % cylsize != 0) { 539 if (sgi_get_num_sectors(Index[i]) % cylsize != 0) {
529 if (debug) /* I do not understand how some disks fulfil it */ 540 if (debug) /* I do not understand how some disks fulfil it */
530 if (verbose) 541 if (verbose)
531 printf(_("Partition %d does not end on cylinder boundary.\n"), 542 printf("Partition %d does not end on cylinder boundary\n",
532 Index[i]+1); 543 Index[i]+1);
533 } 544 }
534 /* We cannot handle several "entire disk" entries. */ 545 /* We cannot handle several "entire disk" entries. */
535 if (sgi_get_sysid(Index[i]) == SGI_ENTIRE_DISK) continue; 546 if (sgi_get_sysid(Index[i]) == SGI_ENTIRE_DISK) continue;
536 if (start > sgi_get_start_sector(Index[i])) { 547 if (start > sgi_get_start_sector(Index[i])) {
537 if (verbose) 548 if (verbose)
538 printf(_("The Partition %d and %d overlap by %d sectors.\n"), 549 printf("Partitions %d and %d overlap by %d sectors\n",
539 Index[i-1]+1, Index[i]+1, 550 Index[i-1]+1, Index[i]+1,
540 start - sgi_get_start_sector(Index[i])); 551 start - sgi_get_start_sector(Index[i]));
541 if (gap > 0) gap = -gap; 552 if (gap > 0) gap = -gap;
542 if (gap == 0) gap = -1; 553 if (gap == 0) gap = -1;
543 } 554 }
544 if (start < sgi_get_start_sector(Index[i])) { 555 if (start < sgi_get_start_sector(Index[i])) {
545 if (verbose) 556 if (verbose)
546 printf(_("Unused gap of %8u sectors - sectors %8u-%u\n"), 557 printf("Unused gap of %8u sectors - sectors %8u-%8u\n",
547 sgi_get_start_sector(Index[i]) - start, 558 sgi_get_start_sector(Index[i]) - start,
548 start, sgi_get_start_sector(Index[i])-1); 559 start, sgi_get_start_sector(Index[i])-1);
549 gap += sgi_get_start_sector(Index[i]) - start; 560 gap += sgi_get_start_sector(Index[i]) - start;
@@ -561,7 +572,7 @@ verify_sgi(int verbose)
561 } 572 }
562 if (start < lastblock) { 573 if (start < lastblock) {
563 if (verbose) 574 if (verbose)
564 printf(_("Unused gap of %8u sectors - sectors %8u-%u\n"), 575 printf("Unused gap of %8u sectors - sectors %8u-%8u\n",
565 lastblock - start, start, lastblock-1); 576 lastblock - start, start, lastblock-1);
566 gap += lastblock - start; 577 gap += lastblock - start;
567 add2freelist(start, lastblock); 578 add2freelist(start, lastblock);
@@ -572,17 +583,17 @@ verify_sgi(int verbose)
572 */ 583 */
573 if (verbose) { 584 if (verbose) {
574 if (!sgi_get_num_sectors(sgi_get_bootpartition())) { 585 if (!sgi_get_num_sectors(sgi_get_bootpartition())) {
575 printf(_("\nThe boot partition does not exist.\n")); 586 printf("\nThe boot partition does not exist\n");
576 } 587 }
577 if (!sgi_get_num_sectors(sgi_get_swappartition())) { 588 if (!sgi_get_num_sectors(sgi_get_swappartition())) {
578 printf(_("\nThe swap partition does not exist.\n")); 589 printf("\nThe swap partition does not exist\n");
579 } else { 590 } else {
580 if ((sgi_get_sysid(sgi_get_swappartition()) != SGI_SWAP) 591 if ((sgi_get_sysid(sgi_get_swappartition()) != SGI_SWAP)
581 && (sgi_get_sysid(sgi_get_swappartition()) != LINUX_SWAP)) 592 && (sgi_get_sysid(sgi_get_swappartition()) != LINUX_SWAP))
582 printf(_("\nThe swap partition has no swap type.\n")); 593 printf("\nThe swap partition has no swap type\n");
583 } 594 }
584 if (sgi_check_bootfile("/unix")) 595 if (sgi_check_bootfile("/unix"))
585 printf(_("\tYou have chosen an unusual boot file name.\n")); 596 printf("\tYou have chosen an unusual boot file name\n");
586 } 597 }
587 return (gap > 0) ? 1 : (gap == 0) ? 0 : -1; 598 return (gap > 0) ? 1 : (gap == 0) ? 0 : -1;
588} 599}
@@ -602,19 +613,20 @@ sgi_gaps(void)
602static void 613static void
603sgi_change_sysid(int i, int sys) 614sgi_change_sysid(int i, int sys)
604{ 615{
605 if( sgi_get_num_sectors(i) == 0 ) { /* caught already before, ... */ 616 if (sgi_get_num_sectors(i) == 0 ) { /* caught already before, ... */
606 printf(_("Sorry You may change the Tag of non-empty partitions.\n")); 617 printf("Sorry you may change the Tag of non-empty partitions\n");
607 return; 618 return;
608 } 619 }
609 if (((sys != SGI_ENTIRE_DISK) && (sys != SGI_VOLHDR)) 620 if ((sys != SGI_ENTIRE_DISK) && (sys != SGI_VOLHDR)
610 && (sgi_get_start_sector(i) < 1) ) { 621 && (sgi_get_start_sector(i) < 1)
622 ) {
611 read_maybe_empty( 623 read_maybe_empty(
612 _("It is highly recommended that the partition at offset 0\n" 624 "It is highly recommended that the partition at offset 0\n"
613 "is of type \"SGI volhdr\", the IRIX system will rely on it to\n" 625 "is of type \"SGI volhdr\", the IRIX system will rely on it to\n"
614 "retrieve from its directory standalone tools like sash and fx.\n" 626 "retrieve from its directory standalone tools like sash and fx.\n"
615 "Only the \"SGI volume\" entire disk section may violate this.\n" 627 "Only the \"SGI volume\" entire disk section may violate this.\n"
616 "Type YES if you are sure about tagging this partition differently.\n")); 628 "Type YES if you are sure about tagging this partition differently.\n");
617 if (strcmp(line_ptr, _("YES\n"))) 629 if (strcmp(line_ptr, "YES\n") != 0)
618 return; 630 return;
619 } 631 }
620 sgilabel->partitions[i].id = SGI_SSWAP32(sys); 632 sgilabel->partitions[i].id = SGI_SSWAP32(sys);
@@ -640,7 +652,7 @@ sgi_set_partition(int i, unsigned int start, unsigned int length, int sys)
640 sgilabel->partitions[i].start_sector = SGI_SSWAP32(start); 652 sgilabel->partitions[i].start_sector = SGI_SSWAP32(start);
641 set_changed(i); 653 set_changed(i);
642 if (sgi_gaps() < 0) /* rebuild freelist */ 654 if (sgi_gaps() < 0) /* rebuild freelist */
643 printf(_("Do You know, You got a partition overlap on the disk?\n")); 655 printf("Partition overlap detected\n");
644} 656}
645 657
646static void 658static void
@@ -649,7 +661,7 @@ sgi_set_entire(void)
649 int n; 661 int n;
650 662
651 for (n = 10; n < partitions; n++) { 663 for (n = 10; n < partitions; n++) {
652 if(!sgi_get_num_sectors(n) ) { 664 if (!sgi_get_num_sectors(n) ) {
653 sgi_set_partition(n, 0, sgi_get_lastblock(), SGI_VOLUME); 665 sgi_set_partition(n, 0, sgi_get_lastblock(), SGI_VOLUME);
654 break; 666 break;
655 } 667 }
@@ -693,32 +705,31 @@ sgi_add_partition(int n, int sys)
693 } else if (n == 8) { 705 } else if (n == 8) {
694 sys = 0; 706 sys = 0;
695 } 707 }
696 if(sgi_get_num_sectors(n)) { 708 if (sgi_get_num_sectors(n)) {
697 printf(_("Partition %d is already defined. Delete " 709 printf(msg_part_already_defined, n + 1);
698 "it before re-adding it.\n"), n + 1);
699 return; 710 return;
700 } 711 }
701 if ((sgi_entire() == -1) && (sys != SGI_VOLUME)) { 712 if ((sgi_entire() == -1) && (sys != SGI_VOLUME)) {
702 printf(_("Attempting to generate entire disk entry automatically.\n")); 713 printf("Attempting to generate entire disk entry automatically\n");
703 sgi_set_entire(); 714 sgi_set_entire();
704 sgi_set_volhdr(); 715 sgi_set_volhdr();
705 } 716 }
706 if ((sgi_gaps() == 0) && (sys != SGI_VOLUME)) { 717 if ((sgi_gaps() == 0) && (sys != SGI_VOLUME)) {
707 printf(_("The entire disk is already covered with partitions.\n")); 718 printf("The entire disk is already covered with partitions\n");
708 return; 719 return;
709 } 720 }
710 if (sgi_gaps() < 0) { 721 if (sgi_gaps() < 0) {
711 printf(_("You got a partition overlap on the disk. Fix it first!\n")); 722 printf("You got a partition overlap on the disk. Fix it first!\n");
712 return; 723 return;
713 } 724 }
714 snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); 725 snprintf(mesg, sizeof(mesg), "First %s", str_units(SINGULAR));
715 while (1) { 726 while (1) {
716 if(sys == SGI_VOLUME) { 727 if (sys == SGI_VOLUME) {
717 last = sgi_get_lastblock(); 728 last = sgi_get_lastblock();
718 first = read_int(0, 0, last-1, 0, mesg); 729 first = read_int(0, 0, last-1, 0, mesg);
719 if (first != 0) { 730 if (first != 0) {
720 printf(_("It is highly recommended that eleventh partition\n" 731 printf("It is highly recommended that eleventh partition\n"
721 "covers the entire disk and is of type 'SGI volume'\n")); 732 "covers the entire disk and is of type 'SGI volume'\n");
722 } 733 }
723 } else { 734 } else {
724 first = freelist[0].first; 735 first = freelist[0].first;
@@ -730,15 +741,14 @@ sgi_add_partition(int n, int sys)
730 first *= units_per_sector; 741 first *= units_per_sector;
731 else 742 else
732 first = first; /* align to cylinder if you know how ... */ 743 first = first; /* align to cylinder if you know how ... */
733 if(!last ) 744 if (!last )
734 last = isinfreelist(first); 745 last = isinfreelist(first);
735 if(last == 0) { 746 if (last != 0)
736 printf(_("You will get a partition overlap on the disk. "
737 "Fix it first!\n"));
738 } else
739 break; 747 break;
748 printf("You will get a partition overlap on the disk. "
749 "Fix it first!\n");
740 } 750 }
741 snprintf(mesg, sizeof(mesg), _(" Last %s"), str_units(SINGULAR)); 751 snprintf(mesg, sizeof(mesg), " Last %s", str_units(SINGULAR));
742 last = read_int(scround(first), scround(last)-1, scround(last)-1, 752 last = read_int(scround(first), scround(last)-1, scround(last)-1,
743 scround(first), mesg)+1; 753 scround(first), mesg)+1;
744 if (display_in_cyl_units) 754 if (display_in_cyl_units)
@@ -746,8 +756,8 @@ sgi_add_partition(int n, int sys)
746 else 756 else
747 last = last; /* align to cylinder if You know how ... */ 757 last = last; /* align to cylinder if You know how ... */
748 if ( (sys == SGI_VOLUME) && (first != 0 || last != sgi_get_lastblock() ) ) 758 if ( (sys == SGI_VOLUME) && (first != 0 || last != sgi_get_lastblock() ) )
749 printf(_("It is highly recommended that eleventh partition\n" 759 printf("It is highly recommended that eleventh partition\n"
750 "covers the entire disk and is of type 'SGI volume'\n")); 760 "covers the entire disk and is of type 'SGI volume'\n");
751 sgi_set_partition(n, first, last-first, sys); 761 sgi_set_partition(n, first, last-first, sys);
752} 762}
753 763
@@ -768,10 +778,7 @@ create_sgilabel(void)
768 778
769 sec_fac = sector_size / 512; /* determine the sector factor */ 779 sec_fac = sector_size / 512; /* determine the sector factor */
770 780
771 fprintf( stderr, 781 printf(msg_building_new_label, "SGI disklabel");
772 _("Building a new SGI disklabel. Changes will remain in memory only,\n"
773 "until you decide to write them. After that, of course, the previous\n"
774 "content will be unrecoverably lost.\n\n"));
775 782
776 sgi_other_endian = (BYTE_ORDER == LITTLE_ENDIAN); 783 sgi_other_endian = (BYTE_ORDER == LITTLE_ENDIAN);
777 res = ioctl(fd, BLKGETSIZE, &longsectors); 784 res = ioctl(fd, BLKGETSIZE, &longsectors);
@@ -785,23 +792,21 @@ create_sgilabel(void)
785 } else { 792 } else {
786 /* otherwise print error and use truncated version */ 793 /* otherwise print error and use truncated version */
787 cylinders = geometry.cylinders; 794 cylinders = geometry.cylinders;
788 fprintf(stderr, 795 printf(
789 _("Warning: BLKGETSIZE ioctl failed on %s. " 796"Warning: BLKGETSIZE ioctl failed on %s. Using geometry cylinder value of %d.\n"
790 "Using geometry cylinder value of %d.\n" 797"This value may be truncated for devices > 33.8 GB.\n", disk_device, cylinders);
791 "This value may be truncated for devices"
792 " > 33.8 GB.\n"), disk_device, cylinders);
793 } 798 }
794 } 799 }
795 for (i = 0; i < 4; i++) { 800 for (i = 0; i < 4; i++) {
796 old[i].sysid = 0; 801 old[i].sysid = 0;
797 if (valid_part_table_flag(MBRbuffer)) { 802 if (valid_part_table_flag(MBRbuffer)) {
798 if(get_part_table(i)->sys_ind) { 803 if (get_part_table(i)->sys_ind) {
799 old[i].sysid = get_part_table(i)->sys_ind; 804 old[i].sysid = get_part_table(i)->sys_ind;
800 old[i].start = get_start_sect(get_part_table(i)); 805 old[i].start = get_start_sect(get_part_table(i));
801 old[i].nsect = get_nr_sects(get_part_table(i)); 806 old[i].nsect = get_nr_sects(get_part_table(i));
802 printf(_("Trying to keep parameters of partition %d.\n"), i); 807 printf("Trying to keep parameters of partition %d\n", i);
803 if (debug) 808 if (debug)
804 printf(_("ID=%02x\tSTART=%d\tLENGTH=%d\n"), 809 printf("ID=%02x\tSTART=%d\tLENGTH=%d\n",
805 old[i].sysid, old[i].start, old[i].nsect); 810 old[i].sysid, old[i].start, old[i].nsect);
806 } 811 }
807 } 812 }
@@ -851,7 +856,7 @@ create_sgilabel(void)
851 sgi_set_entire(); 856 sgi_set_entire();
852 sgi_set_volhdr(); 857 sgi_set_volhdr();
853 for (i = 0; i < 4; i++) { 858 for (i = 0; i < 4; i++) {
854 if(old[i].sysid) { 859 if (old[i].sysid) {
855 sgi_set_partition(i, old[i].start, old[i].nsect, old[i].sysid); 860 sgi_set_partition(i, old[i].start, old[i].nsect, old[i].sysid);
856 } 861 }
857 } 862 }
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index 10107783e..2fa7b2b86 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -1,5 +1,8 @@
1#if ENABLE_FEATURE_SUN_LABEL 1#if ENABLE_FEATURE_SUN_LABEL
2 2
3#define SUNOS_SWAP 3
4#define SUN_WHOLE_DISK 5
5
3#define SUN_LABEL_MAGIC 0xDABE 6#define SUN_LABEL_MAGIC 0xDABE
4#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA 7#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA
5#define SUN_SSWAP16(x) (sun_other_endian ? fdisk_swap16(x) : (uint16_t)(x)) 8#define SUN_SSWAP16(x) (sun_other_endian ? fdisk_swap16(x) : (uint16_t)(x))
@@ -57,22 +60,22 @@ guess_device_type(void)
57 } 60 }
58} 61}
59 62
60static const struct systypes sun_sys_types[] = { 63static const char *const sun_sys_types[] = {
61 { "\x00" "Empty" }, /* 0 */ 64 "\x00" "Empty" , /* 0 */
62 { "\x01" "Boot" }, /* 1 */ 65 "\x01" "Boot" , /* 1 */
63 { "\x02" "SunOS root" }, /* 2 */ 66 "\x02" "SunOS root" , /* 2 */
64 { "\x03" "SunOS swap" }, /* SUNOS_SWAP */ 67 "\x03" "SunOS swap" , /* SUNOS_SWAP */
65 { "\x04" "SunOS usr" }, /* 4 */ 68 "\x04" "SunOS usr" , /* 4 */
66 { "\x05" "Whole disk" }, /* SUN_WHOLE_DISK */ 69 "\x05" "Whole disk" , /* SUN_WHOLE_DISK */
67 { "\x06" "SunOS stand" }, /* 6 */ 70 "\x06" "SunOS stand" , /* 6 */
68 { "\x07" "SunOS var" }, /* 7 */ 71 "\x07" "SunOS var" , /* 7 */
69 { "\x08" "SunOS home" }, /* 8 */ 72 "\x08" "SunOS home" , /* 8 */
70 { "\x82" "Linux swap" }, /* LINUX_SWAP */ 73 "\x82" "Linux swap" , /* LINUX_SWAP */
71 { "\x83" "Linux native" }, /* LINUX_NATIVE */ 74 "\x83" "Linux native", /* LINUX_NATIVE */
72 { "\x8e" "Linux LVM" }, /* 0x8e */ 75 "\x8e" "Linux LVM" , /* 0x8e */
73/* New (2.2.x) raid partition with autodetect using persistent superblock */ 76/* New (2.2.x) raid partition with autodetect using persistent superblock */
74 { "\xfd" "Linux raid autodetect" }, /* 0xfd */ 77 "\xfd" "Linux raid autodetect", /* 0xfd */
75 { NULL } 78 NULL
76}; 79};
77 80
78 81
@@ -103,10 +106,10 @@ check_sun_label(void)
103 ush = ((unsigned short *) (sunlabel + 1)) - 1; 106 ush = ((unsigned short *) (sunlabel + 1)) - 1;
104 for (csum = 0; ush >= (unsigned short *)sunlabel;) csum ^= *ush--; 107 for (csum = 0; ush >= (unsigned short *)sunlabel;) csum ^= *ush--;
105 if (csum) { 108 if (csum) {
106 fprintf(stderr,_("Detected sun disklabel with wrong checksum.\n" 109 printf("Detected sun disklabel with wrong checksum.\n"
107 "Probably you'll have to set all the values,\n" 110"Probably you'll have to set all the values,\n"
108 "e.g. heads, sectors, cylinders and partitions\n" 111"e.g. heads, sectors, cylinders and partitions\n"
109 "or force a fresh label (s command in main menu)\n")); 112"or force a fresh label (s command in main menu)\n");
110 } else { 113 } else {
111 heads = SUN_SSWAP16(sunlabel->ntrks); 114 heads = SUN_SSWAP16(sunlabel->ntrks);
112 cylinders = SUN_SSWAP16(sunlabel->ncyl); 115 cylinders = SUN_SSWAP16(sunlabel->ncyl);
@@ -209,7 +212,7 @@ sun_autoconfigure_scsi(void)
209 continue; 212 continue;
210 if (!strstr(model, sun_drives[i].model)) 213 if (!strstr(model, sun_drives[i].model))
211 continue; 214 continue;
212 printf(_("Autoconfigure found a %s%s%s\n"), 215 printf("Autoconfigure found a %s%s%s\n",
213 sun_drives[i].vendor, 216 sun_drives[i].vendor,
214 (*sun_drives[i].vendor) ? " " : "", 217 (*sun_drives[i].vendor) ? " " : "",
215 sun_drives[i].model); 218 sun_drives[i].model);
@@ -232,17 +235,15 @@ create_sunlabel(void)
232 unsigned char c; 235 unsigned char c;
233 const struct sun_predefined_drives *p = NULL; 236 const struct sun_predefined_drives *p = NULL;
234 237
235 fprintf(stderr, 238 printf(msg_building_new_label, "sun disklabel");
236 _("Building a new sun disklabel. Changes will remain in memory only,\n" 239
237 "until you decide to write them. After that, of course, the previous\n"
238 "content won't be recoverable.\n\n"));
239 sun_other_endian = BB_LITTLE_ENDIAN; 240 sun_other_endian = BB_LITTLE_ENDIAN;
240 memset(MBRbuffer, 0, sizeof(MBRbuffer)); 241 memset(MBRbuffer, 0, sizeof(MBRbuffer));
241 sunlabel->magic = SUN_SSWAP16(SUN_LABEL_MAGIC); 242 sunlabel->magic = SUN_SSWAP16(SUN_LABEL_MAGIC);
242 if (!floppy) { 243 if (!floppy) {
243 puts(_("Drive type\n" 244 puts("Drive type\n"
244 " ? auto configure\n" 245 " ? auto configure\n"
245 " 0 custom (with hardware detected defaults)")); 246 " 0 custom (with hardware detected defaults)");
246 for (i = 0; i < SIZE(sun_drives); i++) { 247 for (i = 0; i < SIZE(sun_drives); i++) {
247 printf(" %c %s%s%s\n", 248 printf(" %c %s%s%s\n",
248 i + 'a', sun_drives[i].vendor, 249 i + 'a', sun_drives[i].vendor,
@@ -250,21 +251,23 @@ create_sunlabel(void)
250 sun_drives[i].model); 251 sun_drives[i].model);
251 } 252 }
252 while (1) { 253 while (1) {
253 c = read_nonempty(_("Select type (? for auto, 0 for custom): ")); 254 c = read_nonempty("Select type (? for auto, 0 for custom): ");
255 if (c == '0') {
256 break;
257 }
254 if (c >= 'a' && c < 'a' + SIZE(sun_drives)) { 258 if (c >= 'a' && c < 'a' + SIZE(sun_drives)) {
255 p = sun_drives + c - 'a'; 259 p = sun_drives + c - 'a';
256 break; 260 break;
257 } else if (c >= 'A' && c < 'A' + SIZE(sun_drives)) { 261 }
262 if (c >= 'A' && c < 'A' + SIZE(sun_drives)) {
258 p = sun_drives + c - 'A'; 263 p = sun_drives + c - 'A';
259 break; 264 break;
260 } else if (c == '0') { 265 }
261 break; 266 if (c == '?' && scsi_disk) {
262 } else if (c == '?' && scsi_disk) {
263 p = sun_autoconfigure_scsi(); 267 p = sun_autoconfigure_scsi();
264 if (!p) 268 if (p)
265 printf(_("Autoconfigure failed.\n")); 269 break;
266 else 270 printf("Autoconfigure failed\n");
267 break;
268 } 271 }
269 } 272 }
270 } 273 }
@@ -285,17 +288,17 @@ create_sunlabel(void)
285 sunlabel->ilfact = SUN_SSWAP16(1); 288 sunlabel->ilfact = SUN_SSWAP16(1);
286 sunlabel->sparecyl = 0; 289 sunlabel->sparecyl = 0;
287 } else { 290 } else {
288 heads = read_int(1,heads,1024,0,_("Heads")); 291 heads = read_int(1, heads, 1024, 0, "Heads");
289 sectors = read_int(1,sectors,1024,0,_("Sectors/track")); 292 sectors = read_int(1, sectors, 1024, 0, "Sectors/track");
290 if (cylinders) 293 if (cylinders)
291 cylinders = read_int(1,cylinders-2,65535,0,_("Cylinders")); 294 cylinders = read_int(1, cylinders-2, 65535, 0, "Cylinders");
292 else 295 else
293 cylinders = read_int(1,0,65535,0,_("Cylinders")); 296 cylinders = read_int(1, 0, 65535, 0, "Cylinders");
294 sunlabel->nacyl = SUN_SSWAP16(read_int(0,2,65535,0, _("Alternate cylinders"))); 297 sunlabel->nacyl = SUN_SSWAP16(read_int(0, 2, 65535, 0, "Alternate cylinders"));
295 sunlabel->pcylcount = SUN_SSWAP16(read_int(0,cylinders+SUN_SSWAP16(sunlabel->nacyl), 65535,0, _("Physical cylinders"))); 298 sunlabel->pcylcount = SUN_SSWAP16(read_int(0, cylinders+SUN_SSWAP16(sunlabel->nacyl), 65535, 0, "Physical cylinders"));
296 sunlabel->rspeed = SUN_SSWAP16(read_int(1,5400,100000,0, _("Rotation speed (rpm)"))); 299 sunlabel->rspeed = SUN_SSWAP16(read_int(1, 5400, 100000, 0, "Rotation speed (rpm)"));
297 sunlabel->ilfact = SUN_SSWAP16(read_int(1,1,32,0, _("Interleave factor"))); 300 sunlabel->ilfact = SUN_SSWAP16(read_int(1, 1, 32, 0, "Interleave factor"));
298 sunlabel->sparecyl = SUN_SSWAP16(read_int(0,0,sectors,0, _("Extra sectors per cylinder"))); 301 sunlabel->sparecyl = SUN_SSWAP16(read_int(0, 0, sectors, 0, "Extra sectors per cylinder"));
299 } 302 }
300 } else { 303 } else {
301 sunlabel->sparecyl = SUN_SSWAP16(p->sparecyl); 304 sunlabel->sparecyl = SUN_SSWAP16(p->sparecyl);
@@ -309,13 +312,13 @@ create_sunlabel(void)
309 cylinders = p->ncyl; 312 cylinders = p->ncyl;
310 heads = p->ntrks; 313 heads = p->ntrks;
311 sectors = p->nsect; 314 sectors = p->nsect;
312 puts(_("You may change all the disk params from the x menu")); 315 puts("You may change all the disk params from the x menu");
313 } 316 }
314 317
315 snprintf((char *)(sunlabel->info), sizeof(sunlabel->info), 318 snprintf((char *)(sunlabel->info), sizeof(sunlabel->info),
316 "%s%s%s cyl %d alt %d hd %d sec %d", 319 "%s%s%s cyl %d alt %d hd %d sec %d",
317 p ? p->vendor : "", (p && *p->vendor) ? " " : "", 320 p ? p->vendor : "", (p && *p->vendor) ? " " : "",
318 p ? p->model : (floppy ? _("3,5\" floppy") : _("Linux custom")), 321 p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"),
319 cylinders, SUN_SSWAP16(sunlabel->nacyl), heads, sectors); 322 cylinders, SUN_SSWAP16(sunlabel->nacyl), heads, sectors);
320 323
321 sunlabel->ntrks = SUN_SSWAP16(heads); 324 sunlabel->ntrks = SUN_SSWAP16(heads);
@@ -409,7 +412,7 @@ verify_sun(void)
409 for (k = 0; k < 7; k++) { 412 for (k = 0; k < 7; k++) {
410 for (i = 0; i < 8; i++) { 413 for (i = 0; i < 8; i++) {
411 if (k && (lens[i] % (heads * sectors))) { 414 if (k && (lens[i] % (heads * sectors))) {
412 printf(_("Partition %d doesn't end on cylinder boundary\n"), i+1); 415 printf("Partition %d doesn't end on cylinder boundary\n", i+1);
413 } 416 }
414 if (lens[i]) { 417 if (lens[i]) {
415 for (j = 0; j < i; j++) 418 for (j = 0; j < i; j++)
@@ -429,8 +432,8 @@ verify_sun(void)
429 endo = starts[i]+lens[i]; 432 endo = starts[i]+lens[i];
430 if (starts[j]+lens[j] < endo) 433 if (starts[j]+lens[j] < endo)
431 endo = starts[j]+lens[j]; 434 endo = starts[j]+lens[j];
432 printf(_("Partition %d overlaps with others in " 435 printf("Partition %d overlaps with others in "
433 "sectors %d-%d\n"), i+1, starto, endo); 436 "sectors %d-%d\n", i+1, starto, endo);
434 } 437 }
435 } 438 }
436 } 439 }
@@ -446,18 +449,18 @@ verify_sun(void)
446 qsort(array,SIZE(array),sizeof(array[0]), 449 qsort(array,SIZE(array),sizeof(array[0]),
447 (int (*)(const void *,const void *)) verify_sun_cmp); 450 (int (*)(const void *,const void *)) verify_sun_cmp);
448 if (array[0] == -1) { 451 if (array[0] == -1) {
449 printf(_("No partitions defined\n")); 452 printf("No partitions defined\n");
450 return; 453 return;
451 } 454 }
452 stop = cylinders * heads * sectors; 455 stop = cylinders * heads * sectors;
453 if (starts[array[0]]) 456 if (starts[array[0]])
454 printf(_("Unused gap - sectors 0-%d\n"),starts[array[0]]); 457 printf("Unused gap - sectors 0-%d\n", starts[array[0]]);
455 for (i = 0; i < 7 && array[i+1] != -1; i++) { 458 for (i = 0; i < 7 && array[i+1] != -1; i++) {
456 printf(_("Unused gap - sectors %d-%d\n"),starts[array[i]]+lens[array[i]],starts[array[i+1]]); 459 printf("Unused gap - sectors %d-%d\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]);
457 } 460 }
458 start = starts[array[i]] + lens[array[i]]; 461 start = starts[array[i]] + lens[array[i]];
459 if (start < stop) 462 if (start < stop)
460 printf(_("Unused gap - sectors %d-%d\n"),start,stop); 463 printf("Unused gap - sectors %d-%d\n", start, stop);
461} 464}
462 465
463static void 466static void
@@ -471,8 +474,7 @@ add_sun_partition(int n, int sys)
471 int i, first, last; 474 int i, first, last;
472 475
473 if (sunlabel->partitions[n].num_sectors && sunlabel->infos[n].id) { 476 if (sunlabel->partitions[n].num_sectors && sunlabel->infos[n].id) {
474 printf(_("Partition %d is already defined. Delete " 477 printf(msg_part_already_defined, n + 1);
475 "it before re-adding it.\n"), n + 1);
476 return; 478 return;
477 } 479 }
478 480
@@ -481,12 +483,12 @@ add_sun_partition(int n, int sys)
481 if (n == 2) 483 if (n == 2)
482 whole_disk = 1; 484 whole_disk = 1;
483 else { 485 else {
484 printf(_("Other partitions already cover the whole disk.\nDelete " 486 printf("Other partitions already cover the whole disk.\n"
485 "some/shrink them before retry.\n")); 487 "Delete/shrink them before retry.\n");
486 return; 488 return;
487 } 489 }
488 } 490 }
489 snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); 491 snprintf(mesg, sizeof(mesg), "First %s", str_units(SINGULAR));
490 while (1) { 492 while (1) {
491 if (whole_disk) 493 if (whole_disk)
492 first = read_int(0, 0, 0, 0, mesg); 494 first = read_int(0, 0, 0, 0, mesg);
@@ -501,7 +503,7 @@ add_sun_partition(int n, int sys)
501 if (n == 2 && first != 0) 503 if (n == 2 && first != 0)
502 printf("\ 504 printf("\
503It is highly recommended that the third partition covers the whole disk\n\ 505It is highly recommended that the third partition covers the whole disk\n\
504and is of type `Whole disk'\n"); 506and is of type 'Whole disk'\n");
505 /* ewt asks to add: "don't start a partition at cyl 0" 507 /* ewt asks to add: "don't start a partition at cyl 0"
506 However, edmundo@rano.demon.co.uk writes: 508 However, edmundo@rano.demon.co.uk writes:
507 "In addition to having a Sun partition table, to be able to 509 "In addition to having a Sun partition table, to be able to
@@ -526,7 +528,7 @@ and is of type `Whole disk'\n");
526 whole_disk = 1; 528 whole_disk = 1;
527 break; 529 break;
528 } 530 }
529 printf(_("Sector %d is already allocated\n"), first); 531 printf("Sector %d is already allocated\n", first);
530 } else 532 } else
531 break; 533 break;
532 } 534 }
@@ -537,7 +539,7 @@ and is of type `Whole disk'\n");
537 stop = starts[i]; 539 stop = starts[i];
538 } 540 }
539 snprintf(mesg, sizeof(mesg), 541 snprintf(mesg, sizeof(mesg),
540 _("Last %s or +size or +sizeM or +sizeK"), 542 "Last %s or +size or +sizeM or +sizeK",
541 str_units(SINGULAR)); 543 str_units(SINGULAR));
542 if (whole_disk) 544 if (whole_disk)
543 last = read_int(scround(stop2), scround(stop2), scround(stop2), 545 last = read_int(scround(stop2), scround(stop2), scround(stop2),
@@ -555,11 +557,10 @@ and is of type `Whole disk'\n");
555 whole_disk = 1; 557 whole_disk = 1;
556 last = stop2; 558 last = stop2;
557 } else if (last > stop) { 559 } else if (last > stop) {
558 printf(_("You haven't covered the whole disk with " 560 printf(
559 "the 3rd partition, but your value\n" 561"You haven't covered the whole disk with the 3rd partition,\n"
560 "%d %s covers some other partition. " 562"but your value %d %s covers some other partition.\n"
561 "Your entry has been changed\n" 563"Your entry has been changed to %d %s\n",
562 "to %d %s\n"),
563 scround(last), str_units(SINGULAR), 564 scround(last), str_units(SINGULAR),
564 scround(stop), str_units(SINGULAR)); 565 scround(stop), str_units(SINGULAR));
565 last = stop; 566 last = stop;
@@ -581,10 +582,10 @@ sun_delete_partition(int i)
581 && sunlabel->infos[i].id == SUN_WHOLE_DISK 582 && sunlabel->infos[i].id == SUN_WHOLE_DISK
582 && !sunlabel->partitions[i].start_cylinder 583 && !sunlabel->partitions[i].start_cylinder
583 && (nsec = SUN_SSWAP32(sunlabel->partitions[i].num_sectors)) == heads * sectors * cylinders) 584 && (nsec = SUN_SSWAP32(sunlabel->partitions[i].num_sectors)) == heads * sectors * cylinders)
584 printf(_("If you want to maintain SunOS/Solaris compatibility, " 585 printf("If you want to maintain SunOS/Solaris compatibility, "
585 "consider leaving this\n" 586 "consider leaving this\n"
586 "partition as Whole disk (5), starting at 0, with %u " 587 "partition as Whole disk (5), starting at 0, with %u "
587 "sectors\n"), nsec); 588 "sectors\n", nsec);
588 sunlabel->infos[i].id = 0; 589 sunlabel->infos[i].id = 0;
589 sunlabel->partitions[i].num_sectors = 0; 590 sunlabel->partitions[i].num_sectors = 0;
590} 591}
@@ -594,12 +595,12 @@ sun_change_sysid(int i, int sys)
594{ 595{
595 if (sys == LINUX_SWAP && !sunlabel->partitions[i].start_cylinder) { 596 if (sys == LINUX_SWAP && !sunlabel->partitions[i].start_cylinder) {
596 read_maybe_empty( 597 read_maybe_empty(
597 _("It is highly recommended that the partition at offset 0\n" 598 "It is highly recommended that the partition at offset 0\n"
598 "is UFS, EXT2FS filesystem or SunOS swap. Putting Linux swap\n" 599 "is UFS, EXT2FS filesystem or SunOS swap. Putting Linux swap\n"
599 "there may destroy your partition table and bootblock.\n" 600 "there may destroy your partition table and bootblock.\n"
600 "Type YES if you're very sure you would like that partition\n" 601 "Type YES if you're very sure you would like that partition\n"
601 "tagged with 82 (Linux swap): ")); 602 "tagged with 82 (Linux swap): ");
602 if (strcmp (line_ptr, _("YES\n"))) 603 if (strcmp (line_ptr, "YES\n"))
603 return; 604 return;
604 } 605 }
605 switch (sys) { 606 switch (sys) {
@@ -625,11 +626,11 @@ sun_list_table(int xtra)
625 w = strlen(disk_device); 626 w = strlen(disk_device);
626 if (xtra) 627 if (xtra)
627 printf( 628 printf(
628 _("\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n" 629 "\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n"
629 "%d cylinders, %d alternate cylinders, %d physical cylinders\n" 630 "%d cylinders, %d alternate cylinders, %d physical cylinders\n"
630 "%d extra sects/cyl, interleave %d:1\n" 631 "%d extra sects/cyl, interleave %d:1\n"
631 "%s\n" 632 "%s\n"
632 "Units = %s of %d * 512 bytes\n\n"), 633 "Units = %s of %d * 512 bytes\n\n",
633 disk_device, heads, sectors, SUN_SSWAP16(sunlabel->rspeed), 634 disk_device, heads, sectors, SUN_SSWAP16(sunlabel->rspeed),
634 cylinders, SUN_SSWAP16(sunlabel->nacyl), 635 cylinders, SUN_SSWAP16(sunlabel->nacyl),
635 SUN_SSWAP16(sunlabel->pcylcount), 636 SUN_SSWAP16(sunlabel->pcylcount),
@@ -639,13 +640,13 @@ sun_list_table(int xtra)
639 str_units(PLURAL), units_per_sector); 640 str_units(PLURAL), units_per_sector);
640 else 641 else
641 printf( 642 printf(
642 _("\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n" 643 "\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n"
643 "Units = %s of %d * 512 bytes\n\n"), 644 "Units = %s of %d * 512 bytes\n\n",
644 disk_device, heads, sectors, cylinders, 645 disk_device, heads, sectors, cylinders,
645 str_units(PLURAL), units_per_sector); 646 str_units(PLURAL), units_per_sector);
646 647
647 printf(_("%*s Flag Start End Blocks Id System\n"), 648 printf("%*s Flag Start End Blocks Id System\n",
648 w + 1, _("Device")); 649 w + 1, "Device");
649 for (i = 0 ; i < partitions; i++) { 650 for (i = 0 ; i < partitions; i++) {
650 if (sunlabel->partitions[i].num_sectors) { 651 if (sunlabel->partitions[i].num_sectors) {
651 uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * heads * sectors; 652 uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * heads * sectors;
@@ -669,8 +670,8 @@ static void
669sun_set_alt_cyl(void) 670sun_set_alt_cyl(void)
670{ 671{
671 sunlabel->nacyl = 672 sunlabel->nacyl =
672 SUN_SSWAP16(read_int(0,SUN_SSWAP16(sunlabel->nacyl), 65535, 0, 673 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->nacyl), 65535, 0,
673 _("Number of alternate cylinders"))); 674 "Number of alternate cylinders"));
674} 675}
675 676
676static void 677static void
@@ -684,7 +685,7 @@ sun_set_xcyl(void)
684{ 685{
685 sunlabel->sparecyl = 686 sunlabel->sparecyl =
686 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->sparecyl), sectors, 0, 687 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->sparecyl), sectors, 0,
687 _("Extra sectors per cylinder"))); 688 "Extra sectors per cylinder"));
688} 689}
689 690
690static void 691static void
@@ -692,7 +693,7 @@ sun_set_ilfact(void)
692{ 693{
693 sunlabel->ilfact = 694 sunlabel->ilfact =
694 SUN_SSWAP16(read_int(1, SUN_SSWAP16(sunlabel->ilfact), 32, 0, 695 SUN_SSWAP16(read_int(1, SUN_SSWAP16(sunlabel->ilfact), 32, 0,
695 _("Interleave factor"))); 696 "Interleave factor"));
696} 697}
697 698
698static void 699static void
@@ -700,7 +701,7 @@ sun_set_rspeed(void)
700{ 701{
701 sunlabel->rspeed = 702 sunlabel->rspeed =
702 SUN_SSWAP16(read_int(1, SUN_SSWAP16(sunlabel->rspeed), 100000, 0, 703 SUN_SSWAP16(read_int(1, SUN_SSWAP16(sunlabel->rspeed), 100000, 0,
703 _("Rotation speed (rpm)"))); 704 "Rotation speed (rpm)"));
704} 705}
705 706
706static void 707static void
@@ -708,7 +709,7 @@ sun_set_pcylcount(void)
708{ 709{
709 sunlabel->pcylcount = 710 sunlabel->pcylcount =
710 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->pcylcount), 65535, 0, 711 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->pcylcount), 65535, 0,
711 _("Number of physical cylinders"))); 712 "Number of physical cylinders"));
712} 713}
713#endif /* FEATURE_FDISK_ADVANCED */ 714#endif /* FEATURE_FDISK_ADVANCED */
714 715