Skip to content

Commit

Permalink
Update batocera-usbmount
Browse files Browse the repository at this point in the history
fix issue with potential of having race condition with sequential numbering

Update batocera-usbmount
  • Loading branch information
Mikhailzrick committed Nov 27, 2024
1 parent d54b718 commit b336954
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions package/batocera/core/batocera-scripts/scripts/batocera-usbmount
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@
# 3) for some others actions, such as /dev/mmcblk0p3 fs growing, it must not be mounted

# if share is already mounted, just use the basic usbmount
if test -e /var/run/batocera.share.mounted
then
if test -e /var/run/batocera.share.mounted; then
/usr/share/usbmount/usbmount "$1"
exit $?
fi

# if not, delay the automounting by saving the context for later
# it will be played by the S11share script after the mounting of /userdata
if mkdir -p /var/run/usbmount.delay
then
N=$(ls /var/run/usbmount.delay | wc -l)
N=$((N+1))
if mkdir -p /var/run/usbmount.delay; then
TIMESTAMP=$(date +%s%N) # Generate timestamp to use as a unique identifier
set |
grep -E '^DEVNAME=|^ID_FS_USAGE=|^ID_FS_UUID=|^ID_FS_TYPE=|^ID_FS_LABEL=' |
sed -e s+'^'+'export '+ > /var/run/usbmount.delay/"$N"."$1"
grep -E '^DEVNAME=|^ID_FS_USAGE=|^ID_FS_UUID=|^ID_FS_TYPE=|^ID_FS_LABEL=' |
sed -e s+'^'+'export '+ > /var/run/usbmount.delay/"$TIMESTAMP"."$1"
fi

0 comments on commit b336954

Please sign in to comment.