chiark / gitweb /
udevd: use files instead of symlinks for /dev/.udev/queue,failed
authorKay Sievers <kay.sievers@suse.de>
Sun, 3 Sep 2006 02:44:33 +0000 (04:44 +0200)
committerKay Sievers <kay.sievers@suse.de>
Sun, 3 Sep 2006 02:44:33 +0000 (04:44 +0200)
TODO
udevd.c
udevtrigger.c

diff --git a/TODO b/TODO
index a08cb84f7bbb9cc2257aa5bdd7509b8b72eec88c..8667b87e917606b5fec73757aac0430ecd09c5ac 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,10 +4,6 @@ These things would be nice to have:
     any of the links at that time
 
 These things will change in future udev versions:
-  o use zero sized files instead of symlinks in /dev/.udev/{queue,failed}
-    (broken tools search /dev for files and get lost following to /sys
-     and stat() sysfs files million times)
-
   o make DRIVER== to match only the event device
     (DRIVERS must be used, we currently translate it to DRIVERS and print
      a warning if DRIVER is used)
diff --git a/udevd.c b/udevd.c
index 0702f5e2cbf88c07d0b29cec826aa41df063080a..a21d2ab77d6cfe050bad776f66ca96be9948d80b 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -155,9 +155,9 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st
 {
        char filename[PATH_SIZE];
        char filename_failed[PATH_SIZE];
-       char target[PATH_SIZE];
        size_t start, end, i;
        struct udevd_uevent_msg *loop_msg;
+       int fd;
 
        /* add location of queue files */
        strlcpy(filename, udev_root, sizeof(filename));
@@ -189,11 +189,10 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st
        case EVENT_QUEUED:
                unlink(filename_failed);
                delete_path(filename_failed);
-
-               strlcpy(target, sysfs_path, sizeof(target));
-               strlcat(target, msg->devpath, sizeof(target));
                create_path(filename);
-               symlink(target, filename);
+               fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644);
+               if (fd > 0)
+                       close(fd);
                return;
        case EVENT_FINISHED:
        case EVENT_FAILED:
index 571bcadfc5323a844fdb8b260202d45ebe3a8c0b..64a2ebdd725c9d9cfc6515dab869374ebdf8ab87 100644 (file)
@@ -433,30 +433,30 @@ static void scan_failed(void)
        struct dirent *dent;
 
        strlcpy(base, udev_root, sizeof(base));
-       strlcat(base, "/", sizeof(base));
-       strlcat(base, EVENT_FAILED_DIR, sizeof(base));
+       strlcat(base, "/" EVENT_FAILED_DIR, sizeof(base));
 
        dir = opendir(base);
        if (dir != NULL) {
                for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
-                       char linkname[PATH_SIZE];
-                       char target[PATH_SIZE];
-                       int len;
+                       char device[PATH_SIZE];
+                       size_t start, end, i;
 
                        if (dent->d_name[0] == '.')
                                continue;
 
-                       strlcpy(linkname, base, sizeof(linkname));
-                       strlcat(linkname, "/", sizeof(linkname));
-                       strlcat(linkname, dent->d_name, sizeof(linkname));
+                       strlcpy(device, sysfs_path, sizeof(device));
+                       start = strlcat(device, "/", sizeof(device));
+                       end = strlcat(device, dent->d_name, sizeof(device));
+                       if (end > sizeof(device))
+                               end = sizeof(device);
 
-                       len = readlink(linkname, target, sizeof(target));
-                       if (len <= 0)
-                               continue;
-                       target[len] = '\0';
+                       /* replace PATH_TO_NAME_CHAR with '/' */
+                       for (i = start; i < end; i++)
+                               if (device[i] == PATH_TO_NAME_CHAR)
+                                       device[i] = '/';
 
-                       if (is_device(target))
-                               device_list_insert(target);
+                       if (is_device(device))
+                               device_list_insert(device);
                        else
                                continue;
                }