aboutsummaryrefslogtreecommitdiff
path: root/util-linux/fdisk_osf.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-02 16:45:05 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-02 16:45:05 +0000
commit2a85676fa5b7884400d7c2cc2170e14f995cf73d (patch)
tree9766fc625f3c3f6d750778ba35ad458f934a3d5e /util-linux/fdisk_osf.c
parentace35eeb889757b1d6ebc54fc2c7a9492a00c0c3 (diff)
downloadbusybox-w32-2a85676fa5b7884400d7c2cc2170e14f995cf73d.tar.gz
busybox-w32-2a85676fa5b7884400d7c2cc2170e14f995cf73d.tar.bz2
busybox-w32-2a85676fa5b7884400d7c2cc2170e14f995cf73d.zip
silly style fixes
Diffstat (limited to 'util-linux/fdisk_osf.c')
-rw-r--r--util-linux/fdisk_osf.c123
1 files changed, 61 insertions, 62 deletions
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
index 2daafe6c7..17acd1977 100644
--- a/util-linux/fdisk_osf.c
+++ b/util-linux/fdisk_osf.c
@@ -43,13 +43,16 @@
43 43
44#define BSD_LINUX_BOOTDIR "/usr/ucb/mdec" 44#define BSD_LINUX_BOOTDIR "/usr/ucb/mdec"
45 45
46#if defined (i386) || defined (__sparc__) || defined (__arm__) || defined (__m68k__) || defined (__mips__) || defined (__s390__) || defined (__sh__) || defined(__x86_64__) 46#if defined(i386) || defined(__sparc__) || defined(__arm__) \
47 || defined(__m68k__) || defined(__mips__) || defined(__s390__) \
48 || defined(__sh__) || defined(__x86_64__)
47#define BSD_LABELSECTOR 1 49#define BSD_LABELSECTOR 1
48#define BSD_LABELOFFSET 0 50#define BSD_LABELOFFSET 0
49#elif defined (__alpha__) || defined (__powerpc__) || defined (__ia64__) || defined (__hppa__) 51#elif defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \
52 || defined(__hppa__)
50#define BSD_LABELSECTOR 0 53#define BSD_LABELSECTOR 0
51#define BSD_LABELOFFSET 64 54#define BSD_LABELOFFSET 64
52#elif defined (__s390__) || defined (__s390x__) 55#elif defined(__s390__) || defined(__s390x__)
53#define BSD_LABELSECTOR 1 56#define BSD_LABELSECTOR 1
54#define BSD_LABELOFFSET 0 57#define BSD_LABELOFFSET 0
55#else 58#else
@@ -258,18 +261,18 @@ static int xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d);
258static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d); 261static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d);
259static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d); 262static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d);
260 263
261#if defined (__alpha__) 264#if defined(__alpha__)
262static void alpha_bootblock_checksum(char *boot); 265static void alpha_bootblock_checksum(char *boot);
263#endif 266#endif
264 267
265#if !defined (__alpha__) 268#if !defined(__alpha__)
266static int xbsd_translate_fstype(int linux_type); 269static int xbsd_translate_fstype(int linux_type);
267static void xbsd_link_part(void); 270static void xbsd_link_part(void);
268static struct partition *xbsd_part; 271static struct partition *xbsd_part;
269static int xbsd_part_index; 272static int xbsd_part_index;
270#endif 273#endif
271 274
272#if defined (__alpha__) 275#if defined(__alpha__)
273/* We access this through a uint64_t * when checksumming */ 276/* We access this through a uint64_t * when checksumming */
274static char disklabelbuffer[BSD_BBSIZE] ATTRIBUTE_ALIGNED(8); 277static char disklabelbuffer[BSD_BBSIZE] ATTRIBUTE_ALIGNED(8);
275#else 278#else
@@ -298,36 +301,36 @@ check_osf_label(void)
298static int 301static int
299btrydev(const char * dev) 302btrydev(const char * dev)
300{ 303{
301 if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0) 304 if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0)
302 return -1; 305 return -1;
303 printf(_("\nBSD label for device: %s\n"), dev); 306 printf(_("\nBSD label for device: %s\n"), dev);
304 xbsd_print_disklabel (0); 307 xbsd_print_disklabel(0);
305 return 0; 308 return 0;
306} 309}
307 310
308static void 311static void
309bmenu(void) 312bmenu(void)
310{ 313{
311 puts (_("Command action")); 314 puts(_("Command action"));
312 puts (_("\td\tdelete a BSD partition")); 315 puts(_("\td\tdelete a BSD partition"));
313 puts (_("\te\tedit drive data")); 316 puts(_("\te\tedit drive data"));
314 puts (_("\ti\tinstall bootstrap")); 317 puts(_("\ti\tinstall bootstrap"));
315 puts (_("\tl\tlist known filesystem types")); 318 puts(_("\tl\tlist known filesystem types"));
316 puts (_("\tm\tprint this menu")); 319 puts(_("\tm\tprint this menu"));
317 puts (_("\tn\tadd a new BSD partition")); 320 puts(_("\tn\tadd a new BSD partition"));
318 puts (_("\tp\tprint BSD partition table")); 321 puts(_("\tp\tprint BSD partition table"));
319 puts (_("\tq\tquit without saving changes")); 322 puts(_("\tq\tquit without saving changes"));
320 puts (_("\tr\treturn to main menu")); 323 puts(_("\tr\treturn to main menu"));
321 puts (_("\ts\tshow complete disklabel")); 324 puts(_("\ts\tshow complete disklabel"));
322 puts (_("\tt\tchange a partition's filesystem id")); 325 puts(_("\tt\tchange a partition's filesystem id"));
323 puts (_("\tu\tchange units (cylinders/sectors)")); 326 puts(_("\tu\tchange units (cylinders/sectors)"));
324 puts (_("\tw\twrite disklabel to disk")); 327 puts(_("\tw\twrite disklabel to disk"));
325#if !defined (__alpha__) 328#if !defined(__alpha__)
326 puts (_("\tx\tlink BSD partition to non-BSD partition")); 329 puts(_("\tx\tlink BSD partition to non-BSD partition"));
327#endif 330#endif
328} 331}
329 332
330#if !defined (__alpha__) 333#if !defined(__alpha__)
331static int 334static int
332hidden(int type) 335hidden(int type)
333{ 336{
@@ -347,7 +350,7 @@ is_bsd_partition_type(int type)
347static void 350static void
348bsd_select(void) 351bsd_select(void)
349{ 352{
350#if !defined (__alpha__) 353#if !defined(__alpha__)
351 int t, ss; 354 int t, ss;
352 struct partition *p; 355 struct partition *p;
353 356
@@ -376,11 +379,11 @@ bsd_select(void)
376 return; 379 return;
377 } 380 }
378 381
379#elif defined (__alpha__) 382#elif defined(__alpha__)
380 383
381 if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0) 384 if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0)
382 if (xbsd_create_disklabel() == 0) 385 if (xbsd_create_disklabel() == 0)
383 exit (EXIT_SUCCESS); 386 exit(EXIT_SUCCESS);
384 387
385#endif 388#endif
386 389
@@ -422,7 +425,7 @@ bsd_select(void)
422 case 'w': 425 case 'w':
423 xbsd_write_disklabel(); 426 xbsd_write_disklabel();
424 break; 427 break;
425#if !defined (__alpha__) 428#if !defined(__alpha__)
426 case 'x': 429 case 'x':
427 xbsd_link_part(); 430 xbsd_link_part();
428 break; 431 break;
@@ -458,7 +461,7 @@ xbsd_new_part(void)
458 if (!xbsd_check_new_partition(&i)) 461 if (!xbsd_check_new_partition(&i))
459 return; 462 return;
460 463
461#if !defined (__alpha__) && !defined (__powerpc__) && !defined (__hppa__) 464#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__hppa__)
462 begin = get_start_sect(xbsd_part); 465 begin = get_start_sect(xbsd_part);
463 end = begin + get_nr_sects(xbsd_part) - 1; 466 end = begin + get_nr_sects(xbsd_part) - 1;
464#else 467#else
@@ -475,8 +478,8 @@ xbsd_new_part(void)
475 478
476 snprintf(mesg, sizeof(mesg), _("Last %s or +size or +sizeM or +sizeK"), 479 snprintf(mesg, sizeof(mesg), _("Last %s or +size or +sizeM or +sizeK"),
477 str_units(SINGULAR)); 480 str_units(SINGULAR));
478 end = read_int(bsd_cround (begin), bsd_cround (end), bsd_cround (end), 481 end = read_int(bsd_cround(begin), bsd_cround(end), bsd_cround(end),
479 bsd_cround (begin), mesg); 482 bsd_cround(begin), mesg);
480 483
481 if (display_in_cyl_units) 484 if (display_in_cyl_units)
482 end = end * xbsd_dlabel.d_secpercyl - 1; 485 end = end * xbsd_dlabel.d_secpercyl - 1;
@@ -494,7 +497,7 @@ xbsd_print_disklabel(int show_all)
494 int i, j; 497 int i, j;
495 498
496 if (show_all) { 499 if (show_all) {
497#if defined (__alpha__) 500#if defined(__alpha__)
498 printf("# %s:\n", disk_device); 501 printf("# %s:\n", disk_device);
499#else 502#else
500 printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0)); 503 printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0));
@@ -587,7 +590,7 @@ xbsd_print_disklabel(int show_all)
587static void 590static void
588xbsd_write_disklabel(void) 591xbsd_write_disklabel(void)
589{ 592{
590#if defined (__alpha__) 593#if defined(__alpha__)
591 printf(_("Writing disklabel to %s.\n"), disk_device); 594 printf(_("Writing disklabel to %s.\n"), disk_device);
592 xbsd_writelabel(NULL, &xbsd_dlabel); 595 xbsd_writelabel(NULL, &xbsd_dlabel);
593#else 596#else
@@ -603,7 +606,7 @@ xbsd_create_disklabel(void)
603{ 606{
604 char c; 607 char c;
605 608
606#if defined (__alpha__) 609#if defined(__alpha__)
607 fprintf(stderr, _("%s contains no disklabel.\n"), disk_device); 610 fprintf(stderr, _("%s contains no disklabel.\n"), disk_device);
608#else 611#else
609 fprintf(stderr, _("%s contains no disklabel.\n"), 612 fprintf(stderr, _("%s contains no disklabel.\n"),
@@ -614,14 +617,14 @@ xbsd_create_disklabel(void)
614 c = read_nonempty(_("Do you want to create a disklabel? (y/n) ")); 617 c = read_nonempty(_("Do you want to create a disklabel? (y/n) "));
615 if (c == 'y' || c == 'Y') { 618 if (c == 'y' || c == 'Y') {
616 if (xbsd_initlabel( 619 if (xbsd_initlabel(
617#if defined (__alpha__) || defined (__powerpc__) || defined (__hppa__) || \ 620#if defined(__alpha__) || defined(__powerpc__) || defined(__hppa__) || \
618 defined (__s390__) || defined (__s390x__) 621 defined(__s390__) || defined(__s390x__)
619 NULL, &xbsd_dlabel 622 NULL, &xbsd_dlabel
620#else 623#else
621 xbsd_part, &xbsd_dlabel/* not used, xbsd_part_index*/ 624 xbsd_part, &xbsd_dlabel/* not used, xbsd_part_index*/
622#endif 625#endif
623 ) == 1) { 626 ) == 1) {
624 xbsd_print_disklabel (1); 627 xbsd_print_disklabel(1);
625 return 1; 628 return 1;
626 } else 629 } else
627 return 0; 630 return 0;
@@ -649,7 +652,7 @@ xbsd_edit_disklabel(void)
649 652
650 d = &xbsd_dlabel; 653 d = &xbsd_dlabel;
651 654
652#if defined (__alpha__) || defined (__ia64__) 655#if defined(__alpha__) || defined(__ia64__)
653 d->d_secsize = edit_int(d->d_secsize ,_("bytes/sector")); 656 d->d_secsize = edit_int(d->d_secsize ,_("bytes/sector"));
654 d->d_nsectors = edit_int(d->d_nsectors ,_("sectors/track")); 657 d->d_nsectors = edit_int(d->d_nsectors ,_("sectors/track"));
655 d->d_ntracks = edit_int(d->d_ntracks ,_("tracks/cylinder")); 658 d->d_ntracks = edit_int(d->d_ntracks ,_("tracks/cylinder"));
@@ -860,16 +863,16 @@ xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d)
860 else 863 else
861 d->d_type = BSD_DTYPE_ST506; 864 d->d_type = BSD_DTYPE_ST506;
862 865
863#if !defined (__alpha__) 866#if !defined(__alpha__)
864 d->d_flags = BSD_D_DOSPART; 867 d->d_flags = BSD_D_DOSPART;
865#else 868#else
866 d->d_flags = 0; 869 d->d_flags = 0;
867#endif 870#endif
868 d->d_secsize = SECTOR_SIZE; /* bytes/sector */ 871 d->d_secsize = SECTOR_SIZE; /* bytes/sector */
869 d->d_nsectors = sectors; /* sectors/track */ 872 d->d_nsectors = sectors; /* sectors/track */
870 d->d_ntracks = heads; /* tracks/cylinder (heads) */ 873 d->d_ntracks = heads; /* tracks/cylinder (heads) */
871 d->d_ncylinders = cylinders; 874 d->d_ncylinders = cylinders;
872 d->d_secpercyl = sectors * heads;/* sectors/cylinder */ 875 d->d_secpercyl = sectors * heads; /* sectors/cylinder */
873 if (d->d_secpercyl == 0) 876 if (d->d_secpercyl == 0)
874 d->d_secpercyl = 1; /* avoid segfaults */ 877 d->d_secpercyl = 1; /* avoid segfaults */
875 d->d_secperunit = d->d_secpercyl * d->d_ncylinders; 878 d->d_secperunit = d->d_secpercyl * d->d_ncylinders;
@@ -885,19 +888,19 @@ xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d)
885 d->d_bbsize = BSD_BBSIZE; 888 d->d_bbsize = BSD_BBSIZE;
886 d->d_sbsize = BSD_SBSIZE; 889 d->d_sbsize = BSD_SBSIZE;
887 890
888#if !defined (__alpha__) 891#if !defined(__alpha__)
889 d->d_npartitions = 4; 892 d->d_npartitions = 4;
890 pp = &d->d_partitions[2]; /* Partition C should be 893 pp = &d->d_partitions[2]; /* Partition C should be NetBSD partition */
891 the NetBSD partition */ 894
892 pp->p_offset = get_start_sect(p); 895 pp->p_offset = get_start_sect(p);
893 pp->p_size = get_nr_sects(p); 896 pp->p_size = get_nr_sects(p);
894 pp->p_fstype = BSD_FS_UNUSED; 897 pp->p_fstype = BSD_FS_UNUSED;
895 pp = &d->d_partitions[3]; /* Partition D should be 898 pp = &d->d_partitions[3]; /* Partition D should be whole disk */
896 the whole disk */ 899
897 pp->p_offset = 0; 900 pp->p_offset = 0;
898 pp->p_size = d->d_secperunit; 901 pp->p_size = d->d_secperunit;
899 pp->p_fstype = BSD_FS_UNUSED; 902 pp->p_fstype = BSD_FS_UNUSED;
900#elif defined (__alpha__) 903#elif defined(__alpha__)
901 d->d_npartitions = 3; 904 d->d_npartitions = 3;
902 pp = &d->d_partitions[2]; /* Partition C should be 905 pp = &d->d_partitions[2]; /* Partition C should be
903 the whole disk */ 906 the whole disk */
@@ -914,14 +917,14 @@ xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d)
914 * If it has the right magic, return 1. 917 * If it has the right magic, return 1.
915 */ 918 */
916static int 919static int
917xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d) 920xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d)
918{ 921{
919 int t, sector; 922 int t, sector;
920 923
921 /* p is used only to get the starting sector */ 924 /* p is used only to get the starting sector */
922#if !defined (__alpha__) 925#if !defined(__alpha__)
923 sector = (p ? get_start_sect(p) : 0); 926 sector = (p ? get_start_sect(p) : 0);
924#elif defined (__alpha__) 927#elif defined(__alpha__)
925 sector = 0; 928 sector = 0;
926#endif 929#endif
927 930
@@ -950,18 +953,18 @@ xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d)
950} 953}
951 954
952static int 955static int
953xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d) 956xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d)
954{ 957{
955 unsigned int sector; 958 unsigned int sector;
956 959
957#if !defined (__alpha__) && !defined (__powerpc__) && !defined (__hppa__) 960#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__hppa__)
958 sector = get_start_sect(p) + BSD_LABELSECTOR; 961 sector = get_start_sect(p) + BSD_LABELSECTOR;
959#else 962#else
960 sector = BSD_LABELSECTOR; 963 sector = BSD_LABELSECTOR;
961#endif 964#endif
962 965
963 d->d_checksum = 0; 966 d->d_checksum = 0;
964 d->d_checksum = xbsd_dkcksum (d); 967 d->d_checksum = xbsd_dkcksum(d);
965 968
966 /* This is necessary if we want to write the bootstrap later, 969 /* This is necessary if we want to write the bootstrap later,
967 otherwise we'd write the old disklabel with the bootstrap. 970 otherwise we'd write the old disklabel with the bootstrap.
@@ -969,7 +972,7 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d)
969 memmove(&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], 972 memmove(&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
970 d, sizeof(struct xbsd_disklabel)); 973 d, sizeof(struct xbsd_disklabel));
971 974
972#if defined (__alpha__) && BSD_LABELSECTOR == 0 975#if defined(__alpha__) && BSD_LABELSECTOR == 0
973 alpha_bootblock_checksum(disklabelbuffer); 976 alpha_bootblock_checksum(disklabelbuffer);
974 if (lseek(fd, 0, SEEK_SET) == -1) 977 if (lseek(fd, 0, SEEK_SET) == -1)
975 fdisk_fatal(unable_to_seek); 978 fdisk_fatal(unable_to_seek);
@@ -986,7 +989,7 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d)
986} 989}
987 990
988 991
989#if !defined (__alpha__) 992#if !defined(__alpha__)
990static int 993static int
991xbsd_translate_fstype(int linux_type) 994xbsd_translate_fstype(int linux_type)
992{ 995{
@@ -1024,11 +1027,7 @@ xbsd_link_part(void)
1024} 1027}
1025#endif 1028#endif
1026 1029
1027#if defined (__alpha__) 1030#if defined(__alpha__)
1028
1029#if !defined(__GLIBC__)
1030typedef unsigned long long uint64_t;
1031#endif
1032 1031
1033static void 1032static void
1034alpha_bootblock_checksum(char *boot) 1033alpha_bootblock_checksum(char *boot)