mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
[PATCH] don't call dev.d/ scripts twice, if directory = subsystem
The /etc/dev.d/input/input.dev was called twice for /dev/input/mouse. Skip the execution if we get a directory named after the subsystem. Move UDEV_NO_DEVD where it belongs.
This commit is contained in:
parent
9aa0485c97
commit
7757db1f85
4
udev.c
4
udev.c
@ -180,7 +180,7 @@ int main(int argc, char *argv[], char *envp[])
|
||||
retval = udev_add_device(&udev, class_dev);
|
||||
|
||||
/* run dev.d/ scripts if we created a node or changed a netif name */
|
||||
if (udev.devname[0] != '\0') {
|
||||
if (udev_dev_d && udev.devname[0] != '\0') {
|
||||
setenv("DEVNAME", udev.devname, 1);
|
||||
udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
|
||||
}
|
||||
@ -198,7 +198,7 @@ int main(int argc, char *argv[], char *envp[])
|
||||
setenv("DEVNAME", udev.devname, 1);
|
||||
}
|
||||
/* run dev.d/ scripts if we're not instructed to ignore the event */
|
||||
if (udev.devname[0] != '\0') {
|
||||
if (udev_dev_d && udev.devname[0] != '\0') {
|
||||
setenv("DEVNAME", udev.devname, 1);
|
||||
udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
|
||||
}
|
||||
|
@ -74,26 +74,28 @@ static int run_program(const char *filename, void *data)
|
||||
void udev_multiplex_directory(struct udevice *udev, const char *basedir, const char *suffix)
|
||||
{
|
||||
char dirname[PATH_MAX];
|
||||
char devname[NAME_SIZE];
|
||||
char *temp;
|
||||
|
||||
/* skip if UDEV_NO_DEVD is set */
|
||||
if (udev_dev_d == 0)
|
||||
return;
|
||||
|
||||
strfieldcpy(devname, udev->name);
|
||||
|
||||
/* chop the device name up into pieces based on '/' */
|
||||
temp = strchr(devname, '/');
|
||||
while (temp != NULL) {
|
||||
temp[0] = '\0';
|
||||
snprintf(dirname, PATH_MAX, "%s/%s", basedir, devname);
|
||||
dirname[PATH_MAX-1] = '\0';
|
||||
call_foreach_file(run_program, dirname, suffix, udev);
|
||||
if (udev->name[0] != '\0') {
|
||||
char devname[NAME_SIZE];
|
||||
char *temp;
|
||||
|
||||
temp[0] = '/';
|
||||
++temp;
|
||||
temp = strchr(temp, '/');
|
||||
strfieldcpy(devname, udev->name);
|
||||
temp = strchr(devname, '/');
|
||||
while (temp != NULL) {
|
||||
temp[0] = '\0';
|
||||
|
||||
/* don't call the subsystem directory here */
|
||||
if (strcmp(devname, udev->subsystem) != 0) {
|
||||
snprintf(dirname, PATH_MAX, "%s/%s", basedir, devname);
|
||||
dirname[PATH_MAX-1] = '\0';
|
||||
call_foreach_file(run_program, dirname, suffix, udev);
|
||||
}
|
||||
|
||||
temp[0] = '/';
|
||||
++temp;
|
||||
temp = strchr(temp, '/');
|
||||
}
|
||||
}
|
||||
|
||||
if (udev->name[0] != '\0') {
|
||||
|
@ -109,7 +109,7 @@ static int add_device(char *devpath, char *subsystem)
|
||||
udev_add_device(&udev, class_dev);
|
||||
|
||||
/* run dev.d/ scripts if we created a node or changed a netif name */
|
||||
if (udev.devname[0] != '\0') {
|
||||
if (udev_dev_d && udev.devname[0] != '\0') {
|
||||
setenv("DEVNAME", udev.devname, 1);
|
||||
udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user