From c217921b976d31389b78e9e8747094312dc2c7ba Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 15 Jun 2017 04:56:36 +0300 Subject: udisks: automount USB devices on boot and insertion Change-Id: I1ded68d89799825286d085746fec778e1659d5d4 Bug-AGL: SPEC-634 SPEC-666 Signed-off-by: Matt Ranostay --- recipes-support/udisks/files/automount.sh | 19 +++++++++++++++++++ recipes-support/udisks/files/udisks.service | 1 + recipes-support/udisks/udisks_1.0.5.bbappend | 4 ++++ 3 files changed, 24 insertions(+) create mode 100755 recipes-support/udisks/files/automount.sh 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 diff --git a/recipes-support/udisks/udisks_1.0.5.bbappend b/recipes-support/udisks/udisks_1.0.5.bbappend index 2c6b11cc8..eee64eeec 100644 --- a/recipes-support/udisks/udisks_1.0.5.bbappend +++ b/recipes-support/udisks/udisks_1.0.5.bbappend @@ -1,5 +1,6 @@ SRC_URI += "file://org.freedesktop.UDisks.conf \ file://udisks.service \ + file://automount.sh \ " FILESEXTRAPATHS_prepend := "${THISDIR}/files:" @@ -11,4 +12,7 @@ do_install_append () { install -d ${D}${base_libdir}/systemd/system install -m 0644 ${WORKDIR}/udisks.service ${D}${base_libdir}/systemd/system + + install -d ${D}${libexecdir} + install -m 0755 ${WORKDIR}/automount.sh ${D}${libexecdir}/automount.sh } -- cgit 1.2.3-korg