Skip to content

Commit

Permalink
systemd: update_state_probe: Use a file mutex to avoid race condition
Browse files Browse the repository at this point in the history
As soon as the UUID is modified udev re-runs the rules for the partition.
However, the rule expects the new root UUID to be cached in a file, and
if the udev rule gets there before the file is created it fails.

This commit waits on a lock file mutex before accessing said file.

Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
  • Loading branch information
alexgg committed May 11, 2024
1 parent bb77f62 commit ef51b29
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ valid_device() {
# If the UUIDs have been regenerated in this boot, the root UUID is stored
# on a temporary file, otherwise fetch from the kernel command line
if [ -d "/run/initramfs" ]; then
# Avoid a race condition between udev and writing the file
wait4rm "/run/initramfs/bootparam_root.mux" 30
new_root="/run/initramfs/bootparam_root"
else
# Older releases do not create /run and use /tmp instead
Expand Down

0 comments on commit ef51b29

Please sign in to comment.