X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=wait_for_sysfs.c;h=c1d7aa0a0c045fcb06b2ecec07c1cfc11996ad67;hp=5e8874cf7c800926ed5db019a03d8768266083cb;hb=91d55528e1cbea6a590b5f9298125c300be0fabf;hpb=1a13fcb3dd814107d20ff2d26659cb2d6e63b354 diff --git a/wait_for_sysfs.c b/wait_for_sysfs.c index 5e8874cf7..c1d7aa0a0 100644 --- a/wait_for_sysfs.c +++ b/wait_for_sysfs.c @@ -63,6 +63,10 @@ static int wait_for_class_device_attributes(struct sysfs_class_device *class_dev { .subsystem = "usb_host", .file = NULL }, { .subsystem = "bluetooth", .file = "address" }, { .subsystem = "i2c-adapter", .file = NULL }, + { .subsystem = "pci_bus", .file = NULL }, + { .subsystem = "ieee1394", .file = NULL }, + { .subsystem = "ieee1394_host", .file = NULL }, + { .subsystem = "ieee1394_node", .file = NULL }, { NULL, NULL } }; struct class_file *classfile; @@ -99,49 +103,79 @@ static int wait_for_class_device_attributes(struct sysfs_class_device *class_dev /* skip waiting for physical device */ static int class_device_expect_no_device_link(struct sysfs_class_device *class_dev) { - static char *devices_without_link[] = { - "nb", - "ram", - "loop", - "fd", - "md", - "dos_cd", - "double", - "flash", - "msd", - "rflash", - "rom", - "rrom", - "sbpcd", - "pcd", - "pf", - "scd", - "sit", - "lp", - "ubd", - "vcs", - "vcsa", - "console", - "tty", - "ttyS", - NULL + /* List of devices without a "device" symlink + * set .device to NULL to accept all devices in that subsystem */ + static struct class_device { + char *subsystem; + char *device; + } class_device[] = { + { .subsystem = "block", .device = "double" }, + { .subsystem = "block", .device = "nb" }, + { .subsystem = "block", .device = "ram" }, + { .subsystem = "block", .device = "loop" }, + { .subsystem = "block", .device = "fd" }, + { .subsystem = "block", .device = "md" }, + { .subsystem = "block", .device = "dos_cd" }, + { .subsystem = "block", .device = "rflash" }, + { .subsystem = "block", .device = "rom" }, + { .subsystem = "block", .device = "rrom" }, + { .subsystem = "block", .device = "flash" }, + { .subsystem = "block", .device = "msd" }, + { .subsystem = "block", .device = "sbpcd" }, + { .subsystem = "block", .device = "pcd" }, + { .subsystem = "block", .device = "pf" }, + { .subsystem = "block", .device = "scd" }, + { .subsystem = "block", .device = "ubd" }, + { .subsystem = "input", .device = "event" }, + { .subsystem = "input", .device = "mice" }, + { .subsystem = "input", .device = "mouse" }, + { .subsystem = "input", .device = "ts" }, + { .subsystem = "vc", .device = NULL }, + { .subsystem = "tty", .device = NULL }, + { .subsystem = "cpuid", .device = "cpu" }, + { .subsystem = "graphics", .device = "fb" }, + { .subsystem = "mem", .device = NULL }, + { .subsystem = "misc", .device = NULL }, + { .subsystem = "msr", .device = NULL }, + { .subsystem = "netlink", .device = NULL }, + { .subsystem = "net", .device = NULL }, + { .subsystem = "sound", .device = NULL }, + { .subsystem = "printer", .device = "lp" }, + { .subsystem = "nvidia", .device = NULL }, + { .subsystem = "video4linux", .device = NULL }, + { .subsystem = "lirc", .device = NULL }, + { .subsystem = "firmware", .device = NULL }, + { .subsystem = "drm", .device = NULL }, + { .subsystem = "pci_bus", .device = NULL }, + { .subsystem = "ieee1394", .device = NULL }, + { .subsystem = "ieee1394_host", .device = NULL }, + { .subsystem = "ieee1394_node", .device = NULL }, + { NULL, NULL } }; - char **device; + struct class_device *classdevice; + int len; - for (device = devices_without_link; *device != NULL; device++) { - int len = strlen(*device); + /* look if we want to look for another file instead of "dev" */ + for (classdevice = class_device; classdevice->subsystem != NULL; classdevice++) { + if (strcmp(class_dev->classname, classdevice->subsystem) == 0) { + /* if device is NULL, all devices in this class are ok */ + if (classdevice->device == NULL) + return 1; - /* look if name matches */ - if (strncmp(class_dev->name, *device, len) != 0) - continue; + len = strlen(classdevice->device); - /* exact match */ - if (strlen(class_dev->name) == len) - return 1; + /* see if device name matches */ + if (strncmp(class_dev->name, classdevice->device, len) != 0) + continue; - /* instance numbers are matching too */ - if (isdigit(class_dev->name[len])) - return 1; + /* exact match */ + if (strlen(class_dev->name) == len) + return 1; + + /* instance numbers are matching too */ + if (isdigit(class_dev->name[len])) + return 1; + } } return 0; @@ -182,6 +216,7 @@ static int wait_for_bus_device(struct sysfs_device *device_dev) { .bus = "ide", .file = "detach_state" }, { .bus = "pci", .file = "vendor" }, { .bus = "platform", .file = "detach_state" }, + { .bus = "i2c", .file = "detach_state" }, { NULL } }; struct bus_file *busfile; @@ -373,8 +408,8 @@ exit: dbg("result: waiting for sysfs successful '%s'", devpath); else info("error: wait_for_sysfs needs an update to handle the device '%s' " - "properly, please report to ", - devpath); + "properly (%d), please report to ", + devpath, rc); return rc; }