+/*
+ * fdisk_sun.c
+ *
+ * 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
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
#if ENABLE_FEATURE_SUN_LABEL
#define SUNOS_SWAP 3
#define SCSI_IOCTL_GET_IDLUN 0x5382
-/*
- * fdisksunlabel.c
- *
- * 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;
+static smallint sun_other_endian;
+static smallint scsi_disk;
+static smallint floppy;
#ifndef IDE0_MAJOR
#define IDE0_MAJOR 3
static void
-set_sun_partition(int i, uint start, uint stop, int sysid)
+set_sun_partition(int i, unsigned start, unsigned stop, int sysid)
{
sunlabel->infos[i].id = sysid;
sunlabel->partitions[i].start_cylinder =
int csum;
if (sunlabel->magic != SUN_LABEL_MAGIC
- && sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED) {
+ && sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED
+ ) {
current_label_type = LABEL_DOS;
sun_other_endian = 0;
return 0;
return NULL;
sprintf(buffer,
- "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n",
+ "Host: scsi%u Channel: %02u Id: %02u Lun: %02u\n",
/* This is very wrong (works only if you have one HBA),
but I haven't found a way how to get hostno
from the current kernel */
id[0] & 0xff,
(id[0]>>8) & 0xff
);
- pfd = fopen("/proc/scsi/scsi", "r");
+ pfd = fopen_for_read("/proc/scsi/scsi");
if (!pfd) {
return NULL;
}
}
snprintf((char *)(sunlabel->info), sizeof(sunlabel->info),
- "%s%s%s cyl %d alt %d hd %d sec %d",
+ "%s%s%s cyl %u alt %u hd %u sec %u",
p ? p->vendor : "", (p && *p->vendor) ? " " : "",
p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"),
g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors);
set_all_unchanged();
set_changed(0);
+ check_sun_label();
get_boot(CREATE_EMPTY_SUN);
}
}
static void
-fetch_sun(uint *starts, uint *lens, uint *start, uint *stop)
+fetch_sun(unsigned *starts, unsigned *lens, unsigned *start, unsigned *stop)
{
int i, continuous = 1;
}
}
-static uint *verify_sun_starts;
+static unsigned *verify_sun_starts;
static int
verify_sun_cmp(int *a, int *b)
static void
verify_sun(void)
{
- uint starts[8], lens[8], start, stop;
+ unsigned starts[8], lens[8], start, stop;
int i,j,k,starto,endo;
int array[8];
for (k = 0; k < 7; k++) {
for (i = 0; i < 8; i++) {
if (k && (lens[i] % (g_heads * g_sectors))) {
- printf("Partition %d doesn't end on cylinder boundary\n", i+1);
+ printf("Partition %u doesn't end on cylinder boundary\n", i+1);
}
if (lens[i]) {
for (j = 0; j < i; j++)
endo = starts[i]+lens[i];
if (starts[j]+lens[j] < endo)
endo = starts[j]+lens[j];
- printf("Partition %d overlaps with others in "
- "sectors %d-%d\n", i+1, starto, endo);
+ printf("Partition %u overlaps with others in "
+ "sectors %u-%u\n", i+1, starto, endo);
}
}
}
}
stop = g_cylinders * g_heads * g_sectors;
if (starts[array[0]])
- printf("Unused gap - sectors 0-%d\n", starts[array[0]]);
+ printf("Unused gap - sectors %u-%u\n", 0, starts[array[0]]);
for (i = 0; i < 7 && array[i+1] != -1; i++) {
- 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]]);
}
start = starts[array[i]] + lens[array[i]];
if (start < stop)
- printf("Unused gap - sectors %d-%d\n", start, stop);
+ printf("Unused gap - sectors %u-%u\n", start, stop);
}
static void
add_sun_partition(int n, int sys)
{
- uint start, stop, stop2;
- uint starts[8], lens[8];
+ unsigned start, stop, stop2;
+ unsigned starts[8], lens[8];
int whole_disk = 0;
char mesg[256];
return;
}
- fetch_sun(starts,lens,&start,&stop);
+ fetch_sun(starts, lens, &start, &stop);
if (stop <= start) {
if (n == 2)
whole_disk = 1;
else
first = read_int(scround(start), scround(stop)+1,
scround(stop), 0, mesg);
- if (display_in_cyl_units)
+ if (display_in_cyl_units) {
first *= units_per_sector;
- else
+ } else {
/* Starting sector has to be properly aligned */
- first = (first + g_heads * g_sectors - 1) / (g_heads * g_sectors);
+ first = (first + g_heads * g_sectors - 1) /
+ (g_heads * g_sectors);
+ first *= g_heads * g_sectors;
+ }
if (n == 2 && first != 0)
printf("\
It is highly recommended that the third partition covers the whole disk\n\
whole_disk = 1;
break;
}
- printf("Sector %d is already allocated\n", first);
+ printf("Sector %u is already allocated\n", first);
} else
break;
}
} else if (last > stop) {
printf(
"You haven't covered the whole disk with the 3rd partition,\n"
-"but your value %d %s covers some other partition.\n"
-"Your entry has been changed to %d %s\n",
+"but your value %u %s covers some other partition.\n"
+"Your entry has been changed to %u %s\n",
scround(last), str_units(SINGULAR),
scround(stop), str_units(SINGULAR));
last = stop;
"there may destroy your partition table and bootblock.\n"
"Type YES if you're very sure you would like that partition\n"
"tagged with 82 (Linux swap): ");
- if (strcmp (line_ptr, "YES\n"))
+ if (strcmp(line_ptr, "YES") != 0)
return;
}
switch (sys) {
w = strlen(disk_device);
if (xtra)
printf(
- "\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n"
- "%d cylinders, %d alternate cylinders, %d physical cylinders\n"
- "%d extra sects/cyl, interleave %d:1\n"
+ "\nDisk %s (Sun disk label): %u heads, %u sectors, %u rpm\n"
+ "%u cylinders, %u alternate cylinders, %u physical cylinders\n"
+ "%u extra sects/cyl, interleave %u:1\n"
"%s\n"
- "Units = %s of %d * 512 bytes\n\n",
+ "Units = %s of %u * 512 bytes\n\n",
disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed),
g_cylinders, SUN_SSWAP16(sunlabel->nacyl),
SUN_SSWAP16(sunlabel->pcylcount),
str_units(PLURAL), units_per_sector);
else
printf(
- "\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n"
- "Units = %s of %d * 512 bytes\n\n",
+ "\nDisk %s (Sun disk label): %u heads, %u sectors, %u cylinders\n"
+ "Units = %s of %u * 512 bytes\n\n",
disk_device, g_heads, g_sectors, g_cylinders,
str_units(PLURAL), units_per_sector);
if (sunlabel->partitions[i].num_sectors) {
uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors;
uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors);
- printf("%s %c%c %9ld %9ld %9ld%c %2x %s\n",
- partname(disk_device, i+1, w), /* device */
+ printf("%s %c%c %9lu %9lu %9lu%c %2x %s\n",
+ partname(disk_device, i+1, w), /* device */
(sunlabel->infos[i].flags & 0x01) ? 'u' : ' ', /* flags */
(sunlabel->infos[i].flags & 0x10) ? 'r' : ' ',
(long) scround(start), /* start */