-/* device.c - Device access */
-/*
-Copyright 1992-1997 Werner Almesberger.
-Copyright 1999-2006 John Coffman.
-All rights reserved.
-
-Licensed under the terms contained in the file 'COPYING' in the
-source directory.
-
-*/
+/* device.c - Device access
+ *
+ * Copyright 1992-1997 Werner Almesberger
+ * Copyright 1999-2006 John Coffman
+ * Copyright 2009-2011 Joachim Wiedorn
+ * All rights reserved.
+ *
+ * Licensed under the terms contained in the file 'COPYING'
+ * in the source directory.
+ */
#define _GNU_SOURCE
#include <unistd.h>
char name[PATH_MAX];
ST_BUF st;
int count;
+ int err;
if (lookup_dev(name,dev,number)) dev->delete = 0;
else {
#endif
if (flags == O_BYPASS) dev->fd = -1;
else if ((dev->fd = open(name,flags)) < 0) {
- fprintf (errstd, "Cannot proceed. Maybe you need to add "
+ err = errno;
+ fprintf (errstd, "Cannot proceed. Maybe you need to add "
"this to your lilo.conf:\n"
"\tdisk=%s inaccessible\n"
"(real error shown below)\n", name);
- die("open %s: %s",name,strerror(errno));
+ die("open %s: %s",name,strerror(err));
}
dev->name = stralloc(name);
return dev->fd;
*(int*)&buff.sector[PART_TABLE_OFFSET-6] = serial;
if (*(short*)&buff.sector[PART_TABLE_OFFSET - 2] == 0)
- *(short*)&buff.sector[PART_TABLE_OFFSET - 2] = MAGIC_SERIAL;
+ *(unsigned short*)&buff.sector[PART_TABLE_OFFSET - 2] = MAGIC_SERIAL;
if (verbose)
printf("Assigning new Volume ID to (%04X) '%s' ID = %08X\n",
device, dev.name, (int)serial);
if (device_code[i]==device)
die("register_bios: device code duplicated: %04X", device);
if (serial_no[i]==serial)
- die("register_bios: volume ID serial no. duplicated: %08lX", serial);
+ die("register_bios: volume ID serial no. duplicated: %08X", serial);
}
device_code[bios] = device;
serial_no[bios] = serial;
fd = dev_open(&dev, device, option ? O_RDWR : O_RDONLY);
if (read(fd, &buf, sizeof(buf)) != sizeof(buf)) {
- fprintf (errstd, "Cannot proceed. Maybe you need to add "
+ fprintf (errstd, "Cannot proceed. Maybe you need to add "
"this to your lilo.conf:\n"
"\tdisk=%s inaccessible\n"
"(real error shown below)\n", dev.name);
- die("VolumeID read error: sector 0 of %s not readable", dev.name);
+ die("VolumeID read error: sector 0 of %s not readable", dev.name);
}
if (option==ID_SET) {
make_backup(NULL, 0, &buf, device,