mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-30 06:25:25 +03:00
udevd: use files instead of symlinks for /dev/.udev/queue,failed
This commit is contained in:
parent
11f1bb5ab4
commit
051445e078
4
TODO
4
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)
|
||||
|
9
udevd.c
9
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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user