udevtrigger: check presence of dev attribute
authorGabor Juhos <juhosg@openwrt.org>
Tue, 10 Sep 2013 10:59:22 +0000 (12:59 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 10 Sep 2013 11:25:35 +0000 (13:25 +0200)
The presence of the 'uevent' attribute file
does not always mean that a corresponding
device node can be created under '/dev'.

For valid device nodes, a 'dev' attribute
file must be present which cntains the major
and minor numbers of the device.

Modify the code to check the presence of the
dev attribute as well. This allows to avoid
superfluous trigger_uevent calls. On a test
system, the patch reduced the number of the
triegger_uevent calls from 144 to 70.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
udevtrigger.c

index c5628bdce03147b2420010f6320028ce258433bc..af620c24db0ac00f63113d6443a2a459a129ba88 100644 (file)
@@ -161,8 +161,9 @@ static int device_list_insert(const char *path)
 
        dbg("add '%s'" , path);
 
 
        dbg("add '%s'" , path);
 
-       /* we only have a device, if we have an uevent file */
-       if (!device_has_attribute(path, "/uevent", S_IWUSR))
+       /* we only have a device, if we have a dev and an uevent file */
+       if (!device_has_attribute(path, "/dev", S_IRUSR) ||
+           !device_has_attribute(path, "/uevent", S_IWUSR))
                return -1;
 
        strlcpy(devpath, &path[4], sizeof(devpath));
                return -1;
 
        strlcpy(devpath, &path[4], sizeof(devpath));