| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
No functional change, as currently the function is always called with
non-NULL argument. Just a preparation for #26048 or #25839.
|
|
|
|
|
|
|
|
|
| |
The priority of device node symlink can be negative. So the
initialization is confusing.
Fortunately, this changes no functionality, as we only compare the
priorities of symlinks only when we parsed at least one device node and
its priority.
|
|
|
|
|
| |
And make the new format the one we expect as it should replace the old one
pretty quickly.
|
|
|
|
|
| |
That's usually the errno code we return when a device cannot be found because
it's been unplugged.
|
|
|
|
|
|
|
|
|
| |
We likely always want to open the directory via a slink.
There's currently only one caller so it doesn't make any difference in practice
but I think it's still nicer.
No functional change.
|
|
|
|
| |
These 2 operations are inseparable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-1 was used everywhere, but -EBADF or -EBADFD started being used in various
places. Let's make things consistent in the new style.
Note that there are two candidates:
EBADF 9 Bad file descriptor
EBADFD 77 File descriptor in bad state
Since we're initializating the fd, we're just assigning a value that means
"no fd yet", so it's just a bad file descriptor, and the first errno fits
better. If instead we had a valid file descriptor that became invalid because
of some operation or state change, the other errno would fit better.
In some places, initialization is dropped if unnecessary.
|
|\
| |
| | |
udev: introduce symlink_atomic_full() and use it
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the filename of a device symlink is too long, then the temporary
filename may become invalid, and we fail to create symlink.
The function `tempfn_random()` used in symlink_atomic_full() generates
a safe temporary filename.
Note that, thanks to the PR #23043, now only one worker can handle
the same symlink simultaneously. Hence, the device ID based temporary
filename is not necessary.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previously, the stack directory contains empty regular files named with
device ID, and we create sd_device object from the device name.
Hence, we implicitly checked the existence of the device node.
However, now the files in the stack directory are symlink, and we
retrieve the path to the device node and its priority from the symlink.
Hence, the existence of the device node is not checked.
Let's check if the device node is still exist.
|
|/
|
|
| |
No functional changes, just refactoring.
|
|
|
|
|
|
| |
By the previous commit, the stack directories are not removed even if
it is empty. To reduce the inode usage of /run, let's cleanup the
directories.
|
|
|
|
|
|
| |
By locking the stack directory, we can safely determine the device node
with the highest priority for a symlink. So, the multiple try-and-wait
loops can be dropped, and the code becomes quite simple.
|
| |
|
| |
|
|
|
|
|
|
| |
Also shorten code a bit.
Just for consistency with other part and readability of the code.
|
|
|
|
| |
And try to read it only when the file is symlink.
|
|
|
|
|
|
|
|
| |
Then, we can always assume the directory exists, and the code become
slightly simpler.
Note, unused directories are removed by the main udevd process in a
later commit.
|
|
|
|
| |
No functionality is changed.
|
|
|
|
| |
No functionality is changed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This merges the various labelling calls into a single label_fix_full(),
which can operate on paths, on inode fds, and in a dirfd/fname style
(i.e. like openat()). It also systematically separates the path to look
up in the db from the path we actually use to reference the inode to
relabel.
This then ports tmpfiles over to labelling by fd. This should make the
code a bit less racy, as we'll try hard to always operate on the very
same inode, pinning it via an fd.
User-visibly the behaviour should not change.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
No actual code changes, just splitting out of some dev_t handling
related calls from stat-util.[ch], they are quite a number already, and
deserve their own module now I think.
Also, try to settle on the name "devnum" as the name for the concept,
instead of "devno" or "dev" or "devid". "devnum" is the name exported in
udev APIs, hence probably best to stick to that. (this just renames a
few symbols to "devum", local variables are left untouched, to make the
patch not too invasive)
No actual code changes.
|
|
|
|
| |
and make it internally use udev_node_apply_permissions_impl().
|
| |
|
| |
|
|
|
|
| |
Follow-up for 78e278ad48e0d2854f950f261804fde70121820e.
|
| |
|
|
|
|
|
|
|
|
|
| |
The variable is not useful outside of the loop (it'll always be null
after the loop is finished), so we can declare it inline in the loop.
This saves one variable declaration and reduces the chances that somebody
tries to use the variable outside of the loop.
For consistency, 'de' is used everywhere for the var name.
|
|
|
|
|
|
|
|
|
|
| |
Previously the mkdir_label() family of calls was implemented in
src/shared/mkdir-label.c but its functions partly declared ins
src/shared/label.h and partly in src/basic/mkdir.h (!!). That's weird
(and wrong).
Let's clean this up, and add a proper mkdir-label.h matching the .c
file.
|
| |
|
|
|
|
|
|
| |
directory
Only acceptable error here is -ENOENT.
|
| |
|
|
|
|
|
|
|
|
|
| |
Previously, the devlink was created based on the priority saved in udev
database. So, we needed to reevaluate devlinks after database is saved.
But now the priority is stored in the symlink under /run/udev/links, and
the loop of devlink creation is controlled with the timestamp of the
directory. So, the double evaluation is not necessary anymore.
|
|
|
|
|
| |
To make multiple workers not update the same device node symlink
simultaneously.
|
| |
|
|
|
|
|
|
|
| |
Otherwise, when multiple device additions and removals occur
simultaneously, symlink to unexisting devnode may be created.
Hopefully fixes #19946.
|
|
|
|
|
|
|
|
|
|
|
| |
By the previous commit, it is not necessary to distinguish if the devlink
already exists. Also, I cannot find any significant advantages of the
previous complecated logic, that is, first try to create directly, and then
fallback to atomically creation. Moreover, such logic increases the chance
of conflicts between multiple udev workers.
This makes devlinks always created atomically. Hopefully, this reduces the
conflicts between the workers.
|
|
|
|
|
|
|
| |
During creating a symlink to a device node, if another device node which
requests the same symlink is added/removed, `stat_inode_unmodified()`
should always detects that. We do not need to continue the loop
unconditionally.
|
|
|
|
| |
Please see the comments in the code.
|
|
|
|
|
|
|
|
|
|
| |
Previously, we only store device IDs in /run/udev/links, and when
creating/removing device node symlink, we create sd_device object
corresponds to the IDs and read device node and priority from the
object. That requires parsing uevent and udev database files.
This makes link_find_prioritized() get the most prioritzed device node
without parsing the files.
|
| |
|
|
|
|
| |
And then merge udev_node_add() and udev_node_update_old_links().
|
|
|
|
|
|
|
| |
This makes the last 11 chars are always preserved for hashed string.
So, it is hard to generate a path which conflicts to another path.
Fixes an issue demonstrated in the previous commit.
|
| |
|
|
|
|
|
| |
Also, this makes the file in /run/udev/links/ is kept on failure, as the
target of the symbolic link may be belonging to another device.
|
|
|
|
| |
exist yet
|
|
|
|
| |
This also limits the number of trial.
|
| |
|
| |
|
| |
|