1 |
|
/* |
2 |
|
* fdisk_sun.c |
3 |
|
* |
4 |
|
* I think this is mostly, or entirely, due to |
5 |
|
* Jakub Jelinek (jj@sunsite.mff.cuni.cz), July 1996 |
6 |
|
* |
7 |
|
* Merged with fdisk for other architectures, aeb, June 1998. |
8 |
|
* |
9 |
|
* Sat Mar 20 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
10 |
|
* Internationalization |
11 |
|
* |
12 |
|
* Licensed under GPLv2, see file LICENSE in this tarball for details. |
13 |
|
*/ |
14 |
|
|
15 |
#if ENABLE_FEATURE_SUN_LABEL |
#if ENABLE_FEATURE_SUN_LABEL |
16 |
|
|
17 |
#define SUNOS_SWAP 3 |
#define SUNOS_SWAP 3 |
27 |
|
|
28 |
#define SCSI_IOCTL_GET_IDLUN 0x5382 |
#define SCSI_IOCTL_GET_IDLUN 0x5382 |
29 |
|
|
30 |
/* |
static smallint sun_other_endian; |
31 |
* fdisksunlabel.c |
static smallint scsi_disk; |
32 |
* |
static smallint floppy; |
|
* I think this is mostly, or entirely, due to |
|
|
* Jakub Jelinek (jj@sunsite.mff.cuni.cz), July 1996 |
|
|
* |
|
|
* Merged with fdisk for other architectures, aeb, June 1998. |
|
|
* |
|
|
* Sat Mar 20 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
|
|
* Internationalization |
|
|
*/ |
|
|
|
|
|
|
|
|
static int sun_other_endian; |
|
|
static int scsi_disk; |
|
|
static int floppy; |
|
33 |
|
|
34 |
#ifndef IDE0_MAJOR |
#ifndef IDE0_MAJOR |
35 |
#define IDE0_MAJOR 3 |
#define IDE0_MAJOR 3 |
81 |
|
|
82 |
|
|
83 |
static void |
static void |
84 |
set_sun_partition(int i, uint start, uint stop, int sysid) |
set_sun_partition(int i, unsigned start, unsigned stop, int sysid) |
85 |
{ |
{ |
86 |
sunlabel->infos[i].id = sysid; |
sunlabel->infos[i].id = sysid; |
87 |
sunlabel->partitions[i].start_cylinder = |
sunlabel->partitions[i].start_cylinder = |
98 |
int csum; |
int csum; |
99 |
|
|
100 |
if (sunlabel->magic != SUN_LABEL_MAGIC |
if (sunlabel->magic != SUN_LABEL_MAGIC |
101 |
&& sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED) { |
&& sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED |
102 |
|
) { |
103 |
current_label_type = LABEL_DOS; |
current_label_type = LABEL_DOS; |
104 |
sun_other_endian = 0; |
sun_other_endian = 0; |
105 |
return 0; |
return 0; |
174 |
return NULL; |
return NULL; |
175 |
|
|
176 |
sprintf(buffer, |
sprintf(buffer, |
177 |
"Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n", |
"Host: scsi%u Channel: %02u Id: %02u Lun: %02u\n", |
178 |
/* This is very wrong (works only if you have one HBA), |
/* This is very wrong (works only if you have one HBA), |
179 |
but I haven't found a way how to get hostno |
but I haven't found a way how to get hostno |
180 |
from the current kernel */ |
from the current kernel */ |
318 |
} |
} |
319 |
|
|
320 |
snprintf((char *)(sunlabel->info), sizeof(sunlabel->info), |
snprintf((char *)(sunlabel->info), sizeof(sunlabel->info), |
321 |
"%s%s%s cyl %d alt %d hd %d sec %d", |
"%s%s%s cyl %u alt %u hd %u sec %u", |
322 |
p ? p->vendor : "", (p && *p->vendor) ? " " : "", |
p ? p->vendor : "", (p && *p->vendor) ? " " : "", |
323 |
p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"), |
p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"), |
324 |
g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors); |
g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors); |
362 |
} |
} |
363 |
|
|
364 |
static void |
static void |
365 |
fetch_sun(uint *starts, uint *lens, uint *start, uint *stop) |
fetch_sun(unsigned *starts, unsigned *lens, unsigned *start, unsigned *stop) |
366 |
{ |
{ |
367 |
int i, continuous = 1; |
int i, continuous = 1; |
368 |
|
|
391 |
} |
} |
392 |
} |
} |
393 |
|
|
394 |
static uint *verify_sun_starts; |
static unsigned *verify_sun_starts; |
395 |
|
|
396 |
static int |
static int |
397 |
verify_sun_cmp(int *a, int *b) |
verify_sun_cmp(int *a, int *b) |
405 |
static void |
static void |
406 |
verify_sun(void) |
verify_sun(void) |
407 |
{ |
{ |
408 |
uint starts[8], lens[8], start, stop; |
unsigned starts[8], lens[8], start, stop; |
409 |
int i,j,k,starto,endo; |
int i,j,k,starto,endo; |
410 |
int array[8]; |
int array[8]; |
411 |
|
|
414 |
for (k = 0; k < 7; k++) { |
for (k = 0; k < 7; k++) { |
415 |
for (i = 0; i < 8; i++) { |
for (i = 0; i < 8; i++) { |
416 |
if (k && (lens[i] % (g_heads * g_sectors))) { |
if (k && (lens[i] % (g_heads * g_sectors))) { |
417 |
printf("Partition %d doesn't end on cylinder boundary\n", i+1); |
printf("Partition %u doesn't end on cylinder boundary\n", i+1); |
418 |
} |
} |
419 |
if (lens[i]) { |
if (lens[i]) { |
420 |
for (j = 0; j < i; j++) |
for (j = 0; j < i; j++) |
434 |
endo = starts[i]+lens[i]; |
endo = starts[i]+lens[i]; |
435 |
if (starts[j]+lens[j] < endo) |
if (starts[j]+lens[j] < endo) |
436 |
endo = starts[j]+lens[j]; |
endo = starts[j]+lens[j]; |
437 |
printf("Partition %d overlaps with others in " |
printf("Partition %u overlaps with others in " |
438 |
"sectors %d-%d\n", i+1, starto, endo); |
"sectors %u-%u\n", i+1, starto, endo); |
439 |
} |
} |
440 |
} |
} |
441 |
} |
} |
456 |
} |
} |
457 |
stop = g_cylinders * g_heads * g_sectors; |
stop = g_cylinders * g_heads * g_sectors; |
458 |
if (starts[array[0]]) |
if (starts[array[0]]) |
459 |
printf("Unused gap - sectors 0-%d\n", starts[array[0]]); |
printf("Unused gap - sectors %u-%u\n", 0, starts[array[0]]); |
460 |
for (i = 0; i < 7 && array[i+1] != -1; i++) { |
for (i = 0; i < 7 && array[i+1] != -1; i++) { |
461 |
printf("Unused gap - sectors %d-%d\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]); |
printf("Unused gap - sectors %u-%u\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]); |
462 |
} |
} |
463 |
start = starts[array[i]] + lens[array[i]]; |
start = starts[array[i]] + lens[array[i]]; |
464 |
if (start < stop) |
if (start < stop) |
465 |
printf("Unused gap - sectors %d-%d\n", start, stop); |
printf("Unused gap - sectors %u-%u\n", start, stop); |
466 |
} |
} |
467 |
|
|
468 |
static void |
static void |
469 |
add_sun_partition(int n, int sys) |
add_sun_partition(int n, int sys) |
470 |
{ |
{ |
471 |
uint start, stop, stop2; |
unsigned start, stop, stop2; |
472 |
uint starts[8], lens[8]; |
unsigned starts[8], lens[8]; |
473 |
int whole_disk = 0; |
int whole_disk = 0; |
474 |
|
|
475 |
char mesg[256]; |
char mesg[256]; |
530 |
whole_disk = 1; |
whole_disk = 1; |
531 |
break; |
break; |
532 |
} |
} |
533 |
printf("Sector %d is already allocated\n", first); |
printf("Sector %u is already allocated\n", first); |
534 |
} else |
} else |
535 |
break; |
break; |
536 |
} |
} |
561 |
} else if (last > stop) { |
} else if (last > stop) { |
562 |
printf( |
printf( |
563 |
"You haven't covered the whole disk with the 3rd partition,\n" |
"You haven't covered the whole disk with the 3rd partition,\n" |
564 |
"but your value %d %s covers some other partition.\n" |
"but your value %u %s covers some other partition.\n" |
565 |
"Your entry has been changed to %d %s\n", |
"Your entry has been changed to %u %s\n", |
566 |
scround(last), str_units(SINGULAR), |
scround(last), str_units(SINGULAR), |
567 |
scround(stop), str_units(SINGULAR)); |
scround(stop), str_units(SINGULAR)); |
568 |
last = stop; |
last = stop; |
628 |
w = strlen(disk_device); |
w = strlen(disk_device); |
629 |
if (xtra) |
if (xtra) |
630 |
printf( |
printf( |
631 |
"\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n" |
"\nDisk %s (Sun disk label): %u heads, %u sectors, %u rpm\n" |
632 |
"%d cylinders, %d alternate cylinders, %d physical cylinders\n" |
"%u cylinders, %u alternate cylinders, %u physical cylinders\n" |
633 |
"%d extra sects/cyl, interleave %d:1\n" |
"%u extra sects/cyl, interleave %u:1\n" |
634 |
"%s\n" |
"%s\n" |
635 |
"Units = %s of %d * 512 bytes\n\n", |
"Units = %s of %u * 512 bytes\n\n", |
636 |
disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed), |
disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed), |
637 |
g_cylinders, SUN_SSWAP16(sunlabel->nacyl), |
g_cylinders, SUN_SSWAP16(sunlabel->nacyl), |
638 |
SUN_SSWAP16(sunlabel->pcylcount), |
SUN_SSWAP16(sunlabel->pcylcount), |
642 |
str_units(PLURAL), units_per_sector); |
str_units(PLURAL), units_per_sector); |
643 |
else |
else |
644 |
printf( |
printf( |
645 |
"\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n" |
"\nDisk %s (Sun disk label): %u heads, %u sectors, %u cylinders\n" |
646 |
"Units = %s of %d * 512 bytes\n\n", |
"Units = %s of %u * 512 bytes\n\n", |
647 |
disk_device, g_heads, g_sectors, g_cylinders, |
disk_device, g_heads, g_sectors, g_cylinders, |
648 |
str_units(PLURAL), units_per_sector); |
str_units(PLURAL), units_per_sector); |
649 |
|
|
653 |
if (sunlabel->partitions[i].num_sectors) { |
if (sunlabel->partitions[i].num_sectors) { |
654 |
uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors; |
uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors; |
655 |
uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors); |
uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors); |
656 |
printf("%s %c%c %9ld %9ld %9ld%c %2x %s\n", |
printf("%s %c%c %9lu %9lu %9lu%c %2x %s\n", |
657 |
partname(disk_device, i+1, w), /* device */ |
partname(disk_device, i+1, w), /* device */ |
658 |
(sunlabel->infos[i].flags & 0x01) ? 'u' : ' ', /* flags */ |
(sunlabel->infos[i].flags & 0x01) ? 'u' : ' ', /* flags */ |
659 |
(sunlabel->infos[i].flags & 0x10) ? 'r' : ' ', |
(sunlabel->infos[i].flags & 0x10) ? 'r' : ' ', |