chiark / gitweb /
[PATCH] support SUBSYSTEM as a rule key
[elogind.git] / udev_sysfs.c
index 624f53586f65c51dc63b481d99d79d5af57b47ac..a11c430df0abe10559b364eba4f787a1fda82d83 100644 (file)
@@ -93,10 +93,8 @@ static int wait_for_class_device_attributes(struct sysfs_class_device *class_dev
                return 0;
        }
 
-       strcpy(filename, class_dev->path);
-       strcat(filename, "/");
-       strcat(filename, file);
-       dbg("looking at class '%s' for specific file '%s' with full name %s", class_dev->classname, file, filename);
+       snprintf(filename, SYSFS_PATH_MAX-1, "%s/%s", class_dev->path, file);
+       dbg("looking at class '%s' for specific file '%s'", class_dev->classname, filename);
 
        loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
        while (--loop) {
@@ -167,11 +165,16 @@ static int class_device_expect_no_device_link(struct sysfs_class_device *class_d
                { .subsystem = "net",           .device = "dummy" },
                { .subsystem = "net",           .device = "irda" },
                { .subsystem = "net",           .device = "ppp" },
+               { .subsystem = "net",           .device = "tun" },
+               { .subsystem = "net",           .device = "pan" },
+               { .subsystem = "net",           .device = "bnep" },
+               { .subsystem = "net",           .device = "vmnet" },
                { .subsystem = "ppp",           .device = NULL },
                { .subsystem = "sound",         .device = NULL },
                { .subsystem = "printer",       .device = "lp" },
                { .subsystem = "nvidia",        .device = NULL },
                { .subsystem = "video4linux",   .device = "vbi" },
+               { .subsystem = "dvb",           .device = NULL },
                { .subsystem = "lirc",          .device = NULL },
                { .subsystem = "firmware",      .device = NULL },
                { .subsystem = "drm",           .device = NULL },
@@ -180,6 +183,22 @@ static int class_device_expect_no_device_link(struct sysfs_class_device *class_d
                { .subsystem = "ieee1394_host", .device = NULL },
                { .subsystem = "ieee1394_node", .device = NULL },
                { .subsystem = "raw",           .device = NULL },
+               { .subsystem = "zaptel",        .device = NULL },
+               { .subsystem = "tiglusb",       .device = NULL },
+               { .subsystem = "ppdev",         .device = NULL },
+               { .subsystem = "ticables",      .device = NULL },
+               { .subsystem = "snsc",          .device = NULL },
+               { .subsystem = "staliomem",     .device = NULL },
+               { .subsystem = "tape",          .device = NULL },
+               { .subsystem = "ip2",           .device = NULL },
+               { .subsystem = "tpqic02",       .device = NULL },
+               { .subsystem = "dsp56k",        .device = NULL },
+               { .subsystem = "zft",           .device = NULL },
+               { .subsystem = "adb",           .device = NULL },
+               { .subsystem = "cosa",          .device = NULL },
+               { .subsystem = "pg",            .device = NULL },
+               { .subsystem = "pt",            .device = NULL },
+               { .subsystem = "capi",          .device = NULL },
                { NULL, NULL }
        };
        struct class_device *classdevice;
@@ -216,6 +235,7 @@ static int class_device_expect_no_bus(struct sysfs_class_device *class_dev)
        static char *devices_without_bus[] = {
                "scsi_host",
                "i2c-adapter",
+               "i2c-dev",
                NULL
        };
        char **device;
@@ -247,7 +267,10 @@ int wait_for_bus_device(struct sysfs_device *devices_dev,
                { .bus = "pci",         .file = "vendor" },
                { .bus = "platform",    .file = "detach_state" },
                { .bus = "i2c",         .file = "detach_state" },
-               { NULL }
+               { .bus = "ieee1394",    .file = "node_count" },
+               { .bus = "ieee1394",    .file = "nodeid" },
+               { .bus = "ieee1394",    .file = "address" },
+               { NULL, NULL }
        };
        struct bus_file *busfile;
        int loop;
@@ -271,19 +294,24 @@ int wait_for_bus_device(struct sysfs_device *devices_dev,
        /* wait for a bus specific file to show up */
        loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
        while (--loop) {
-               int found = 0;
+               int found_bus_type = 0;
 
                for (busfile = bus_files; busfile->bus != NULL; busfile++) {
                        if (strcmp(devices_dev->bus, busfile->bus) == 0) {
-                               found = 1;
-                               dbg("looking at bus '%s' for specific file '%s'", devices_dev->bus, busfile->file);
-                               if (sysfs_get_device_attr(devices_dev, busfile->file) != NULL) {
+                               char filename[SYSFS_PATH_MAX];
+                               struct stat stats;
+
+                               found_bus_type = 1;
+                               snprintf(filename, SYSFS_PATH_MAX-1, "%s/%s", devices_dev->path, busfile->file);
+                               dbg("looking at bus '%s' for specific file '%s'", devices_dev->bus, filename);
+
+                               if (stat(filename, &stats) == 0) {
                                        dbg("bus '%s' specific file '%s' found", devices_dev->bus, busfile->file);
                                        return 0;
                                }
                        }
                }
-               if (found == 0) {
+               if (found_bus_type == 0) {
                        if (error)
                                *error = "unknown bus";
                        info("error: unknown bus, please report to "