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)
{
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));
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:
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;
}