From: Kay Sievers Date: Sun, 3 Sep 2006 02:44:33 +0000 (+0200) Subject: udevd: use files instead of symlinks for /dev/.udev/queue,failed X-Git-Tag: 174~2155 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=051445e078ab1a6d0cbbc1bd7f1a6fbd80e8bed1;p=platform%2Fupstream%2Fsystemd.git udevd: use files instead of symlinks for /dev/.udev/queue,failed --- diff --git a/TODO b/TODO index a08cb84..8667b87 100644 --- 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 0702f5e..a21d2ab 100644 --- 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: diff --git a/udevtrigger.c b/udevtrigger.c index 571bcad..64a2ebd 100644 --- a/udevtrigger.c +++ b/udevtrigger.c @@ -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; }