aboutsummaryrefslogtreecommitdiff
path: root/util-linux/fdisk_osf.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-19 14:43:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-19 14:43:38 +0000
commitbd852076b9f6600d039e75d646a6965b5b092606 (patch)
treeea133ee61be3857f3d7fa4c67302c52eb268391c /util-linux/fdisk_osf.c
parentde8a6a01d84ebb09a333104bf0fd5f6e251d9eb7 (diff)
downloadbusybox-w32-bd852076b9f6600d039e75d646a6965b5b092606.tar.gz
busybox-w32-bd852076b9f6600d039e75d646a6965b5b092606.tar.bz2
busybox-w32-bd852076b9f6600d039e75d646a6965b5b092606.zip
fdisk: get rid of _() macro.
Shorten some messages. Stop using stderr - anyone who tries to use fdisk no-interactively is "strange" anyway. Improve storage handling in bsd module. text data bss dec hex filename 728112 1488 33788 763388 ba5fc busybox.t0/busybox 727248 1488 33372 762108 ba0fc busybox.t1/busybox
Diffstat (limited to 'util-linux/fdisk_osf.c')
-rw-r--r--util-linux/fdisk_osf.c245
1 files changed, 131 insertions, 114 deletions
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 */