udev: make newer event also blocked by DEVPATH_OLD
Previously, a device has DEVPATH_OLD is blocked by a previous event whose devpath is equivalent to the DEVPATH_OLD. This extends the condtion. 1. an event has DEVPATH_OLD is blocked by a previous event whose devpath is a parent of, child of, or equivalent to the DEVPATH_OLD. 2. an event is blocked by a previous event whose DEVPATH_OLD is a parent of, child of, or equivalent to the devpath of the new event. I am not sure such check is really necessary. But, the cost of the check is expected to be extremely small, as device renaming does not occur so frequently. Hence, it should not introduce any significant performance regression.
This commit is contained in:
@@ -568,6 +568,19 @@ int udev_resolve_subsys_kernel(const char *string, char *result, size_t maxsize,
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool devpath_conflict(const char *a, const char *b) {
|
||||
/* This returns true when two paths are equivalent, or one is a child of another. */
|
||||
|
||||
if (!a || !b)
|
||||
return false;
|
||||
|
||||
for (; *a != '\0' && *b != '\0'; a++, b++)
|
||||
if (*a != *b)
|
||||
return false;
|
||||
|
||||
return *a == '/' || *b == '/' || *a == *b;
|
||||
}
|
||||
|
||||
int udev_queue_is_empty(void) {
|
||||
return access("/run/udev/queue", F_OK) < 0 ?
|
||||
(errno == ENOENT ? true : -errno) : false;
|
||||
|
||||
Reference in New Issue
Block a user