aboutsummaryrefslogtreecommitdiff
path: root/util-linux/fdisk_sun.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-16 17:22:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-16 17:22:33 +0000
commitf77f369ce89549ae3b0b70bfbac4e9c242ec5298 (patch)
treeb7b9979a4dc949a9bd7f8db90c48ba5491eb1844 /util-linux/fdisk_sun.c
parentc794c51a1aa23d2edcff8e1ab4edf96194d3208c (diff)
downloadbusybox-w32-f77f369ce89549ae3b0b70bfbac4e9c242ec5298.tar.gz
busybox-w32-f77f369ce89549ae3b0b70bfbac4e9c242ec5298.tar.bz2
busybox-w32-f77f369ce89549ae3b0b70bfbac4e9c242ec5298.zip
fdisk: reduce global data/bss usage. 8k data+bss build is achievable soon ;)
(add/remove: 0/13 grow/shrink: 6/19 up/down: 74/-492) Total: -418 bytes text data bss dec hex filename 778330 860 7408 786598 c00a6 busybox_old 777970 840 7376 786186 bff0a busybox_unstripped
Diffstat (limited to 'util-linux/fdisk_sun.c')
-rw-r--r--util-linux/fdisk_sun.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index 274b10345..fcd3818d2 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -84,7 +84,7 @@ set_sun_partition(int i, uint start, uint stop, int sysid)
84{ 84{
85 sunlabel->infos[i].id = sysid; 85 sunlabel->infos[i].id = sysid;
86 sunlabel->partitions[i].start_cylinder = 86 sunlabel->partitions[i].start_cylinder =
87 SUN_SSWAP32(start / (heads * sectors)); 87 SUN_SSWAP32(start / (g_heads * g_sectors));
88 sunlabel->partitions[i].num_sectors = 88 sunlabel->partitions[i].num_sectors =
89 SUN_SSWAP32(stop - start); 89 SUN_SSWAP32(stop - start);
90 set_changed(i); 90 set_changed(i);
@@ -111,13 +111,13 @@ check_sun_label(void)
111"e.g. heads, sectors, cylinders and partitions\n" 111"e.g. heads, sectors, cylinders and partitions\n"
112"or force a fresh label (s command in main menu)\n"); 112"or force a fresh label (s command in main menu)\n");
113 } else { 113 } else {
114 heads = SUN_SSWAP16(sunlabel->ntrks); 114 g_heads = SUN_SSWAP16(sunlabel->ntrks);
115 cylinders = SUN_SSWAP16(sunlabel->ncyl); 115 g_cylinders = SUN_SSWAP16(sunlabel->ncyl);
116 sectors = SUN_SSWAP16(sunlabel->nsect); 116 g_sectors = SUN_SSWAP16(sunlabel->nsect);
117 } 117 }
118 update_units(); 118 update_units();
119 current_label_type = label_sun; 119 current_label_type = label_sun;
120 partitions = 8; 120 g_partitions = 8;
121 return 1; 121 return 1;
122} 122}
123 123
@@ -273,32 +273,32 @@ create_sunlabel(void)
273 } 273 }
274 if (!p || floppy) { 274 if (!p || floppy) {
275 if (!ioctl(fd, HDIO_GETGEO, &geometry)) { 275 if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
276 heads = geometry.heads; 276 g_heads = geometry.heads;
277 sectors = geometry.sectors; 277 g_sectors = geometry.sectors;
278 cylinders = geometry.cylinders; 278 g_cylinders = geometry.cylinders;
279 } else { 279 } else {
280 heads = 0; 280 g_heads = 0;
281 sectors = 0; 281 g_sectors = 0;
282 cylinders = 0; 282 g_cylinders = 0;
283 } 283 }
284 if (floppy) { 284 if (floppy) {
285 sunlabel->nacyl = 0; 285 sunlabel->nacyl = 0;
286 sunlabel->pcylcount = SUN_SSWAP16(cylinders); 286 sunlabel->pcylcount = SUN_SSWAP16(g_cylinders);
287 sunlabel->rspeed = SUN_SSWAP16(300); 287 sunlabel->rspeed = SUN_SSWAP16(300);
288 sunlabel->ilfact = SUN_SSWAP16(1); 288 sunlabel->ilfact = SUN_SSWAP16(1);
289 sunlabel->sparecyl = 0; 289 sunlabel->sparecyl = 0;
290 } else { 290 } else {
291 heads = read_int(1, heads, 1024, 0, "Heads"); 291 g_heads = read_int(1, g_heads, 1024, 0, "Heads");
292 sectors = read_int(1, sectors, 1024, 0, "Sectors/track"); 292 g_sectors = read_int(1, g_sectors, 1024, 0, "Sectors/track");
293 if (cylinders) 293 if (g_cylinders)
294 cylinders = read_int(1, cylinders-2, 65535, 0, "Cylinders"); 294 g_cylinders = read_int(1, g_cylinders - 2, 65535, 0, "Cylinders");
295 else 295 else
296 cylinders = read_int(1, 0, 65535, 0, "Cylinders"); 296 g_cylinders = read_int(1, 0, 65535, 0, "Cylinders");
297 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"));
298 sunlabel->pcylcount = SUN_SSWAP16(read_int(0, cylinders+SUN_SSWAP16(sunlabel->nacyl), 65535, 0, "Physical cylinders")); 298 sunlabel->pcylcount = SUN_SSWAP16(read_int(0, g_cylinders + SUN_SSWAP16(sunlabel->nacyl), 65535, 0, "Physical cylinders"));
299 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)"));
300 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"));
301 sunlabel->sparecyl = SUN_SSWAP16(read_int(0, 0, sectors, 0, "Extra sectors per cylinder")); 301 sunlabel->sparecyl = SUN_SSWAP16(read_int(0, 0, g_sectors, 0, "Extra sectors per cylinder"));
302 } 302 }
303 } else { 303 } else {
304 sunlabel->sparecyl = SUN_SSWAP16(p->sparecyl); 304 sunlabel->sparecyl = SUN_SSWAP16(p->sparecyl);
@@ -309,9 +309,9 @@ create_sunlabel(void)
309 sunlabel->nsect = SUN_SSWAP16(p->nsect); 309 sunlabel->nsect = SUN_SSWAP16(p->nsect);
310 sunlabel->rspeed = SUN_SSWAP16(p->rspeed); 310 sunlabel->rspeed = SUN_SSWAP16(p->rspeed);
311 sunlabel->ilfact = SUN_SSWAP16(1); 311 sunlabel->ilfact = SUN_SSWAP16(1);
312 cylinders = p->ncyl; 312 g_cylinders = p->ncyl;
313 heads = p->ntrks; 313 g_heads = p->ntrks;
314 sectors = p->nsect; 314 g_sectors = p->nsect;
315 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");
316 } 316 }
317 317
@@ -319,23 +319,23 @@ create_sunlabel(void)
319 "%s%s%s cyl %d alt %d hd %d sec %d", 319 "%s%s%s cyl %d alt %d hd %d sec %d",
320 p ? p->vendor : "", (p && *p->vendor) ? " " : "", 320 p ? p->vendor : "", (p && *p->vendor) ? " " : "",
321 p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"), 321 p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"),
322 cylinders, SUN_SSWAP16(sunlabel->nacyl), heads, sectors); 322 g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors);
323 323
324 sunlabel->ntrks = SUN_SSWAP16(heads); 324 sunlabel->ntrks = SUN_SSWAP16(g_heads);
325 sunlabel->nsect = SUN_SSWAP16(sectors); 325 sunlabel->nsect = SUN_SSWAP16(g_sectors);
326 sunlabel->ncyl = SUN_SSWAP16(cylinders); 326 sunlabel->ncyl = SUN_SSWAP16(g_cylinders);
327 if (floppy) 327 if (floppy)
328 set_sun_partition(0, 0, cylinders * heads * sectors, LINUX_NATIVE); 328 set_sun_partition(0, 0, g_cylinders * g_heads * g_sectors, LINUX_NATIVE);
329 else { 329 else {
330 if (cylinders * heads * sectors >= 150 * 2048) { 330 if (g_cylinders * g_heads * g_sectors >= 150 * 2048) {
331 ndiv = cylinders - (50 * 2048 / (heads * sectors)); /* 50M swap */ 331 ndiv = g_cylinders - (50 * 2048 / (g_heads * g_sectors)); /* 50M swap */
332 } else 332 } else
333 ndiv = cylinders * 2 / 3; 333 ndiv = g_cylinders * 2 / 3;
334 set_sun_partition(0, 0, ndiv * heads * sectors, LINUX_NATIVE); 334 set_sun_partition(0, 0, ndiv * g_heads * g_sectors, LINUX_NATIVE);
335 set_sun_partition(1, ndiv * heads * sectors, cylinders * heads * sectors, LINUX_SWAP); 335 set_sun_partition(1, ndiv * g_heads * g_sectors, g_cylinders * g_heads * g_sectors, LINUX_SWAP);
336 sunlabel->infos[1].flags |= 0x01; /* Not mountable */ 336 sunlabel->infos[1].flags |= 0x01; /* Not mountable */
337 } 337 }
338 set_sun_partition(2, 0, cylinders * heads * sectors, SUN_WHOLE_DISK); 338 set_sun_partition(2, 0, g_cylinders * g_heads * g_sectors, SUN_WHOLE_DISK);
339 { 339 {
340 unsigned short *ush = (unsigned short *)sunlabel; 340 unsigned short *ush = (unsigned short *)sunlabel;
341 unsigned short csum = 0; 341 unsigned short csum = 0;
@@ -365,12 +365,12 @@ fetch_sun(uint *starts, uint *lens, uint *start, uint *stop)
365 int i, continuous = 1; 365 int i, continuous = 1;
366 366
367 *start = 0; 367 *start = 0;
368 *stop = cylinders * heads * sectors; 368 *stop = g_cylinders * g_heads * g_sectors;
369 for (i = 0; i < partitions; i++) { 369 for (i = 0; i < g_partitions; i++) {
370 if (sunlabel->partitions[i].num_sectors 370 if (sunlabel->partitions[i].num_sectors
371 && sunlabel->infos[i].id 371 && sunlabel->infos[i].id
372 && sunlabel->infos[i].id != SUN_WHOLE_DISK) { 372 && sunlabel->infos[i].id != SUN_WHOLE_DISK) {
373 starts[i] = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * heads * sectors; 373 starts[i] = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors;
374 lens[i] = SUN_SSWAP32(sunlabel->partitions[i].num_sectors); 374 lens[i] = SUN_SSWAP32(sunlabel->partitions[i].num_sectors);
375 if (continuous) { 375 if (continuous) {
376 if (starts[i] == *start) 376 if (starts[i] == *start)
@@ -408,10 +408,10 @@ verify_sun(void)
408 int array[8]; 408 int array[8];
409 409
410 verify_sun_starts = starts; 410 verify_sun_starts = starts;
411 fetch_sun(starts,lens,&start,&stop); 411 fetch_sun(starts, lens, &start, &stop);
412 for (k = 0; k < 7; k++) { 412 for (k = 0; k < 7; k++) {
413 for (i = 0; i < 8; i++) { 413 for (i = 0; i < 8; i++) {
414 if (k && (lens[i] % (heads * sectors))) { 414 if (k && (lens[i] % (g_heads * g_sectors))) {
415 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);
416 } 416 }
417 if (lens[i]) { 417 if (lens[i]) {
@@ -452,7 +452,7 @@ verify_sun(void)
452 printf("No partitions defined\n"); 452 printf("No partitions defined\n");
453 return; 453 return;
454 } 454 }
455 stop = cylinders * heads * sectors; 455 stop = g_cylinders * g_heads * g_sectors;
456 if (starts[array[0]]) 456 if (starts[array[0]])
457 printf("Unused gap - sectors 0-%d\n", starts[array[0]]); 457 printf("Unused gap - sectors 0-%d\n", starts[array[0]]);
458 for (i = 0; i < 7 && array[i+1] != -1; i++) { 458 for (i = 0; i < 7 && array[i+1] != -1; i++) {
@@ -499,7 +499,7 @@ add_sun_partition(int n, int sys)
499 first *= units_per_sector; 499 first *= units_per_sector;
500 else 500 else
501 /* Starting sector has to be properly aligned */ 501 /* Starting sector has to be properly aligned */
502 first = (first + heads * sectors - 1) / (heads * sectors); 502 first = (first + g_heads * g_sectors - 1) / (g_heads * g_sectors);
503 if (n == 2 && first != 0) 503 if (n == 2 && first != 0)
504 printf("\ 504 printf("\
505It 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\
@@ -520,10 +520,10 @@ and is of type 'Whole disk'\n");
520 /* On the other hand, one should not use partitions 520 /* On the other hand, one should not use partitions
521 starting at block 0 in an md, or the label will 521 starting at block 0 in an md, or the label will
522 be trashed. */ 522 be trashed. */
523 for (i = 0; i < partitions; i++) 523 for (i = 0; i < g_partitions; i++)
524 if (lens[i] && starts[i] <= first && starts[i] + lens[i] > first) 524 if (lens[i] && starts[i] <= first && starts[i] + lens[i] > first)
525 break; 525 break;
526 if (i < partitions && !whole_disk) { 526 if (i < g_partitions && !whole_disk) {
527 if (n == 2 && !first) { 527 if (n == 2 && !first) {
528 whole_disk = 1; 528 whole_disk = 1;
529 break; 529 break;
@@ -532,9 +532,9 @@ and is of type 'Whole disk'\n");
532 } else 532 } else
533 break; 533 break;
534 } 534 }
535 stop = cylinders * heads * sectors; 535 stop = g_cylinders * g_heads * g_sectors;
536 stop2 = stop; 536 stop2 = stop;
537 for (i = 0; i < partitions; i++) { 537 for (i = 0; i < g_partitions; i++) {
538 if (starts[i] > first && starts[i] < stop) 538 if (starts[i] > first && starts[i] < stop)
539 stop = starts[i]; 539 stop = starts[i];
540 } 540 }
@@ -581,7 +581,7 @@ sun_delete_partition(int i)
581 if (i == 2 581 if (i == 2
582 && sunlabel->infos[i].id == SUN_WHOLE_DISK 582 && sunlabel->infos[i].id == SUN_WHOLE_DISK
583 && !sunlabel->partitions[i].start_cylinder 583 && !sunlabel->partitions[i].start_cylinder
584 && (nsec = SUN_SSWAP32(sunlabel->partitions[i].num_sectors)) == heads * sectors * cylinders) 584 && (nsec = SUN_SSWAP32(sunlabel->partitions[i].num_sectors)) == g_heads * g_sectors * g_cylinders)
585 printf("If you want to maintain SunOS/Solaris compatibility, " 585 printf("If you want to maintain SunOS/Solaris compatibility, "
586 "consider leaving this\n" 586 "consider leaving this\n"
587 "partition as Whole disk (5), starting at 0, with %u " 587 "partition as Whole disk (5), starting at 0, with %u "
@@ -631,8 +631,8 @@ sun_list_table(int xtra)
631 "%d extra sects/cyl, interleave %d:1\n" 631 "%d extra sects/cyl, interleave %d:1\n"
632 "%s\n" 632 "%s\n"
633 "Units = %s of %d * 512 bytes\n\n", 633 "Units = %s of %d * 512 bytes\n\n",
634 disk_device, heads, sectors, SUN_SSWAP16(sunlabel->rspeed), 634 disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed),
635 cylinders, SUN_SSWAP16(sunlabel->nacyl), 635 g_cylinders, SUN_SSWAP16(sunlabel->nacyl),
636 SUN_SSWAP16(sunlabel->pcylcount), 636 SUN_SSWAP16(sunlabel->pcylcount),
637 SUN_SSWAP16(sunlabel->sparecyl), 637 SUN_SSWAP16(sunlabel->sparecyl),
638 SUN_SSWAP16(sunlabel->ilfact), 638 SUN_SSWAP16(sunlabel->ilfact),
@@ -642,14 +642,14 @@ sun_list_table(int xtra)
642 printf( 642 printf(
643 "\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"
644 "Units = %s of %d * 512 bytes\n\n", 644 "Units = %s of %d * 512 bytes\n\n",
645 disk_device, heads, sectors, cylinders, 645 disk_device, g_heads, g_sectors, g_cylinders,
646 str_units(PLURAL), units_per_sector); 646 str_units(PLURAL), units_per_sector);
647 647
648 printf("%*s Flag Start End Blocks Id System\n", 648 printf("%*s Flag Start End Blocks Id System\n",
649 w + 1, "Device"); 649 w + 1, "Device");
650 for (i = 0; i < partitions; i++) { 650 for (i = 0; i < g_partitions; i++) {
651 if (sunlabel->partitions[i].num_sectors) { 651 if (sunlabel->partitions[i].num_sectors) {
652 uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * heads * sectors; 652 uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors;
653 uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors); 653 uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors);
654 printf("%s %c%c %9ld %9ld %9ld%c %2x %s\n", 654 printf("%s %c%c %9ld %9ld %9ld%c %2x %s\n",
655 partname(disk_device, i+1, w), /* device */ 655 partname(disk_device, i+1, w), /* device */
@@ -684,7 +684,7 @@ static void
684sun_set_xcyl(void) 684sun_set_xcyl(void)
685{ 685{
686 sunlabel->sparecyl = 686 sunlabel->sparecyl =
687 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->sparecyl), sectors, 0, 687 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->sparecyl), g_sectors, 0,
688 "Extra sectors per cylinder")); 688 "Extra sectors per cylinder"));
689} 689}
690 690