{
struct stat bootstat;
- if (fstat(fd, &bootstat) < 0) {
+ if (fstat(dev_fd, &bootstat) < 0) {
scsi_disk = 0;
floppy = 0;
} else if (S_ISBLK(bootstat.st_mode)
if (sunlabel->magic != SUN_LABEL_MAGIC
&& sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED) {
- current_label_type = label_dos;
+ current_label_type = LABEL_DOS;
sun_other_endian = 0;
return 0;
}
g_sectors = SUN_SSWAP16(sunlabel->nsect);
}
update_units();
- current_label_type = label_sun;
+ current_label_type = LABEL_SUN;
g_partitions = 8;
return 1;
}
char *q;
int i;
- if (ioctl(fd, SCSI_IOCTL_GET_IDLUN, &id))
+ if (ioctl(dev_fd, SCSI_IOCTL_GET_IDLUN, &id))
return NULL;
sprintf(buffer,
id[0] & 0xff,
(id[0]>>8) & 0xff
);
- pfd = fopen("/proc/scsi/scsi", "r");
+ pfd = fopen_for_read("/proc/scsi/scsi");
if (!pfd) {
return NULL;
}
create_sunlabel(void)
{
struct hd_geometry geometry;
- unsigned int ndiv;
- int i;
+ unsigned ndiv;
unsigned char c;
const struct sun_predefined_drives *p = NULL;
memset(MBRbuffer, 0, sizeof(MBRbuffer));
sunlabel->magic = SUN_SSWAP16(SUN_LABEL_MAGIC);
if (!floppy) {
+ unsigned i;
puts("Drive type\n"
" ? auto configure\n"
" 0 custom (with hardware detected defaults)");
}
}
if (!p || floppy) {
- if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
+ if (!ioctl(dev_fd, HDIO_GETGEO, &geometry)) {
g_heads = geometry.heads;
g_sectors = geometry.sectors;
g_cylinders = geometry.cylinders;
set_all_unchanged();
set_changed(0);
- get_boot(create_empty_sun);
+ get_boot(CREATE_EMPTY_SUN);
}
static void
while (ush < (unsigned short *)(&sunlabel->csum))
csum ^= *ush++;
sunlabel->csum = csum;
- if (lseek(fd, 0, SEEK_SET) < 0)
- fdisk_fatal(unable_to_seek);
- if (write(fd, sunlabel, SECTOR_SIZE) != SECTOR_SIZE)
- fdisk_fatal(unable_to_write);
+ write_sector(0, sunlabel);
}
#endif /* SUN_LABEL */