aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-support/udisks/files
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-support/udisks/files')
-rwxr-xr-xrecipes-support/udisks/files/automount.sh19
-rw-r--r--recipes-support/udisks/files/udisks.service1
2 files changed, 20 insertions, 0 deletions
diff --git a/recipes-support/udisks/files/automount.sh b/recipes-support/udisks/files/automount.sh
new file mode 100755
index 000000000..8a3bc86d8
--- /dev/null
+++ b/recipes-support/udisks/files/automount.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+pathtoname() {
+ udevadm info -p /sys/"$1" | awk -v FS== '/DEVNAME/ {print $2}'
+}
+
+MOUNT_OPTIONS="ro,sync"
+
+rmdir /media/* || true &> /dev/null
+for DEVNAME in $(udisks --enumerate-device-files|grep -e sd[a-z][0-9]); do
+ udisks --mount-options $MOUNT_OPTIONS --mount $DEVNAME
+done
+
+stdbuf -oL -- udevadm monitor --udev -s block | while read -r -- _ _ event devpath _; do
+ if [ "$event" = add ]; then
+ DEVNAME=$(pathtoname "$devpath")
+ udisks --mount-options $MOUNT_OPTIONS --mount $DEVNAME
+ fi
+done
diff --git a/recipes-support/udisks/files/udisks.service b/recipes-support/udisks/files/udisks.service
index 75df55b3e..8b2981a97 100644
--- a/recipes-support/udisks/files/udisks.service
+++ b/recipes-support/udisks/files/udisks.service
@@ -6,6 +6,7 @@ Documentation=man:udisks(7)
Type=dbus
BusName=org.freedesktop.UDisks
ExecStart=/usr/libexec/udisks-daemon --no-debug
+ExecStartPost=/usr/libexec/automount.sh
[Install]
WantedBy=default.target