1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

udev-node: make stack_directory_read_one() accept NULL for devnode

No functional change, as currently the function is always called with
non-NULL argument. Just a preparation for #26048 or #25839.
This commit is contained in:
Yu Watanabe 2023-02-20 14:43:58 +09:00
parent 0ba75bde5f
commit 135e5a201a

View File

@ -110,12 +110,14 @@ static int stack_directory_read_one(int dirfd, const char *id, char **devnode, i
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;
@ -139,6 +141,9 @@ static int stack_directory_read_one(int dirfd, const char *id, char **devnode, i
if (r < 0)
return r;
if (!devnode)
goto finalize;
if (*devnode && tmp_prio <= *priority)
return 0; /* Unchanged */
@ -160,6 +165,9 @@ static int stack_directory_read_one(int dirfd, const char *id, char **devnode, i
if (r < 0)
return r;
if (!devnode)
goto finalize;
if (*devnode && tmp_prio <= *priority)
return 0; /* Unchanged */
@ -174,6 +182,7 @@ static int stack_directory_read_one(int dirfd, const char *id, char **devnode, i
} else
return r == -ENOENT ? -ENODEV : r;
finalize:
*priority = tmp_prio;
return 1; /* Updated */
}