static int di_ioctl(struct lib_context *lc, int fd, struct dev_info *di) { unsigned int sector_size = 0; unsigned long size; /* Fetch sector size. */ if (ioctl(fd, BLKSSZGET, §or_size)) sector_size = DMRAID_SECTOR_SIZE; if (sector_size != DMRAID_SECTOR_SIZE) LOG_ERR(lc, 0, "unsupported sector size %d on %s.", sector_size, di->path); /* Use size device ioctl in case we didn't get the size from sysfs. */ if (!di->sectors && !ioctl(fd, BLKGETSIZE, &size)) di->sectors = size; #ifdef DMRAID_TEST /* Test with sparse mapped devices. */ if (dm_test_device(lc, di->path)) return get_dm_test_serial(lc, di, di->path); else #endif return get_device_serial(lc, fd, di); }
static void assign_device_serials(joy_hid_device_array_t *devices) { int num_devices = devices->num_devices; joy_hid_device_t *d = devices->devices; int i; for(i=0;i<num_devices;i++) { int serial = get_device_serial(i, devices->devices, d->vendor_id, d->product_id); d->serial = serial; d++; } }