udev-media-automount
udev-media-automount copied to clipboard
fix: race condition between cleanup and mounting
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.