chiark / gitweb /
[PATCH] make the searched multiplex directories conditionally
[elogind.git] / wait_for_sysfs.c
index e7eed441eee628bfac670aae6988fbfd9282a54e..84a25adb976b10a82146513aa10734f85463bafb 100644 (file)
 #include <errno.h>
 #include <sys/stat.h>
 
-#include "logging.h"
+#include "libsysfs/sysfs/libsysfs.h"
+#include "udev_lib.h"
 #include "udev_version.h"
 #include "udev_sysfs.h"
-#include "libsysfs/sysfs/libsysfs.h"
+#include "logging.h"
 
 #ifdef LOG
 unsigned char logname[LOGNAME_SIZE];
@@ -96,11 +97,17 @@ int main(int argc, char *argv[], char *envp[])
        }
 
        if ((strncmp(devpath, "/block/", 7) == 0) || (strncmp(devpath, "/class/", 7) == 0)) {
-               snprintf(filename, SYSFS_PATH_MAX-1, "%s%s", sysfs_mnt_path, devpath);
+               snprintf(filename, SYSFS_PATH_MAX, "%s%s", sysfs_mnt_path, devpath);
                filename[SYSFS_PATH_MAX-1] = '\0';
 
+               /* skip bad events where we get no device for the class */
+               if (strncmp(devpath, "/class/", 7) == 0 && strchr(&devpath[7], '/') == NULL) {
+                       dbg("no device name for '%s', bad event", devpath);
+                       goto exit;
+               }
+
                /* open the class device we are called for */
-               class_dev = open_class_device_wait(filename);
+               class_dev = wait_class_device_open(filename);
                if (!class_dev) {
                        dbg("error: class device unavailable (probably remove has beaten us)");
                        goto exit;
@@ -110,22 +117,31 @@ int main(int argc, char *argv[], char *envp[])
                /* wait for the class device with possible physical device and bus */
                wait_for_class_device(class_dev, &error);
 
+               /*
+                * we got too many unfixable class/net errors, kernel later than 2.6.10-rc1 will
+                * solve this by exporting the needed information with the hotplug event
+                * until we use this just don't print any error for net devices, but still
+                * wait for it.
+                */
+               if (strncmp(devpath, "/class/net/", 11) == 0)
+                       error = NULL;
+
                sysfs_close_class_device(class_dev);
 
        } else if ((strncmp(devpath, "/devices/", 9) == 0)) {
-               snprintf(filename, SYSFS_PATH_MAX-1, "%s%s", sysfs_mnt_path, devpath);
+               snprintf(filename, SYSFS_PATH_MAX, "%s%s", sysfs_mnt_path, devpath);
                filename[SYSFS_PATH_MAX-1] = '\0';
 
                /* open the path we are called for */
-               devices_dev = open_devices_device_wait(filename);
+               devices_dev = wait_devices_device_open(filename);
                if (!devices_dev) {
                        dbg("error: devices device unavailable (probably remove has beaten us)");
                        goto exit;
                }
                dbg("devices device opened '%s'", filename);
 
-               /* wait for the bus value */
-               wait_for_bus_device(devices_dev, &error);
+               /* wait for the devices device */
+               wait_for_devices_device(devices_dev, &error);
 
                sysfs_close_device(devices_dev);