udev-media-automount icon indicating copy to clipboard operation
udev-media-automount copied to clipboard

fix: race condition between cleanup and mounting

Open patrislav1 opened this issue 4 months ago • 1 comments

There's a race condition between the cleanup step (i.e. removing old/unused mountpoints with rmdir) and the mount step. Since udev launches multiple instances of the script in parallel, it's possible that one instance tries to mount a device just after another instance has deleted the associated mountpoint. (This is not a theoretical scenario, I had this actually happen on a system booting with multiple SD cards attached).

This patch fixes the race condition with a lock in /var/run, making the script execution sequential.

patrislav1 avatar Mar 14 '24 12:03 patrislav1