*/
static struct hd_driveid hd;
int fd;
- char *device;
+ const char *device = NULL;
if (!PyArg_ParseTuple(args, "s", &device))
return NULL;
- if ((fd = open(device, O_RDONLY | O_NONBLOCK)) < 0)
+ if ((fd = open(device, O_RDONLY | O_NONBLOCK)) < 0) {
+ PyErr_Format(PyExc_OSError, "Could not open block device: %s", device);
return NULL;
+ }
if (!ioctl(fd, HDIO_GET_IDENTITY, &hd)) {
char serial[21];
"""
Return the serial number of the root disk (if any).
"""
- serial = _fireinfo.get_harddisk_serial("/dev/%s" % self.root_disk)
+ try:
+ serial = _fireinfo.get_harddisk_serial("/dev/%s" % self.root_disk)
+ except OSError:
+ return
if serial:
# Strip all spaces