assert(dirfd >= 0);
assert(id);
- assert(devnode);
assert(priority);
+ /* This reads priority and device node from the symlink under /run/udev/links (or udev database).
+ * If 'devnode' is NULL, obtained priority is always set to '*priority'. If 'devnode' is non-NULL,
+ * this updates '*devnode' and '*priority'. */
+
/* First, let's try to read the entry with the new format, which should replace the old format pretty
* quickly. */
-
r = readlinkat_malloc(dirfd, id, &buf);
if (r >= 0) {
char *colon;
if (r < 0)
return r;
+ if (!devnode)
+ goto finalize;
+
if (*devnode && tmp_prio <= *priority)
return 0; /* Unchanged */
if (r < 0)
return r;
+ if (!devnode)
+ goto finalize;
+
if (*devnode && tmp_prio <= *priority)
return 0; /* Unchanged */
} else
return r == -ENOENT ? -ENODEV : r;
+finalize:
*priority = tmp_prio;
return 1; /* Updated */
}