From 88bc9d2b93de490d33f23244dca1e8ae7db7fb44 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Sun, 17 Jul 2022 14:56:41 +0200 Subject: udev-extraconf: let automount base directory configurable Dont hard-code automount base directory to '/run/media', introduce a variable MOUNT_BASE to let it configurable, like in udisks2 the mount base is also configurable by setting option: --enable-fhs-media. (From OE-Core rev: c021f5592c3d920eda1bfc10c099ad1484e9c0ce) Signed-off-by: Ming Liu Signed-off-by: Luca Ceresoli Signed-off-by: Richard Purdie (cherry picked from commit f077befd5f36ad88623aaf6a38b1a837ecb18650) Signed-off-by: Ming Liu Signed-off-by: Steve Sakoman Signed-off-by: Richard Purdie --- meta/recipes-core/udev/udev-extraconf/mount.sh | 25 +++++++++++++------------ meta/recipes-core/udev/udev-extraconf_1.1.bb | 2 ++ 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'meta/recipes-core') diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh index 5ba66e98e2..c8b773bc07 100644 --- a/meta/recipes-core/udev/udev-extraconf/mount.sh +++ b/meta/recipes-core/udev/udev-extraconf/mount.sh @@ -6,6 +6,7 @@ BASE_INIT="`readlink -f "@base_sbindir@/init"`" INIT_SYSTEMD="@systemd_unitdir@/systemd" +MOUNT_BASE="@MOUNT_BASE@" if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ];then # systemd as init uses systemd-mount to mount block devices @@ -40,7 +41,7 @@ automount_systemd() { # Skip already mounted partitions if [ -f /run/systemd/transient/run-media-$name.mount ]; then - logger "mount.sh/automount" "/run/media/$name already mounted" + logger "mount.sh/automount" "$MOUNT_BASE/$name already mounted" return fi @@ -53,7 +54,7 @@ automount_systemd() { grep "^[[:space:]]*$tmp" /etc/fstab && return done - [ -d "/run/media/$name" ] || mkdir -p "/run/media/$name" + [ -d "$MOUNT_BASE/$name" ] || mkdir -p "$MOUNT_BASE/$name" MOUNT="$MOUNT -o silent" @@ -70,12 +71,12 @@ automount_systemd() { ;; esac - if ! $MOUNT --no-block -t auto $DEVNAME "/run/media/$name" + if ! $MOUNT --no-block -t auto $DEVNAME "$MOUNT_BASE/$name" then - #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!" - rm_dir "/run/media/$name" + #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"$MOUNT_BASE/$name\" failed!" + rm_dir "$MOUNT_BASE/$name" else - logger "mount.sh/automount" "Auto-mount of [/run/media/$name] successful" + logger "mount.sh/automount" "Auto-mount of [$MOUNT_BASE/$name] successful" touch "/tmp/.automount-$name" fi } @@ -93,7 +94,7 @@ automount() { # configured in fstab grep -q "^$DEVNAME " /proc/mounts && return - ! test -d "/run/media/$name" && mkdir -p "/run/media/$name" + ! test -d "$MOUNT_BASE/$name" && mkdir -p "$MOUNT_BASE/$name" # Silent util-linux's version of mounting auto if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ; then @@ -113,12 +114,12 @@ automount() { ;; esac - if ! $MOUNT -t auto $DEVNAME "/run/media/$name" + if ! $MOUNT -t auto $DEVNAME "$MOUNT_BASE/$name" then - #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!" - rm_dir "/run/media/$name" + #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"$MOUNT_BASE/$name\" failed!" + rm_dir "$MOUNT_BASE/$name" else - logger "mount.sh/automount" "Auto-mount of [/run/media/$name] successful" + logger "mount.sh/automount" "Auto-mount of [$MOUNT_BASE/$name] successful" touch "/tmp/.automount-$name" fi } @@ -157,5 +158,5 @@ if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [ # Remove empty directories from auto-mounter name="`basename "$DEVNAME"`" - test -e "/tmp/.automount-$name" && rm_dir "/run/media/$name" + test -e "/tmp/.automount-$name" && rm_dir "$MOUNT_BASE/$name" fi diff --git a/meta/recipes-core/udev/udev-extraconf_1.1.bb b/meta/recipes-core/udev/udev-extraconf_1.1.bb index 7da04379c0..2b908ac05b 100644 --- a/meta/recipes-core/udev/udev-extraconf_1.1.bb +++ b/meta/recipes-core/udev/udev-extraconf_1.1.bb @@ -15,6 +15,7 @@ SRC_URI = " \ S = "${WORKDIR}" +MOUNT_BASE = "/run/media" do_install() { install -d ${D}${sysconfdir}/udev/rules.d @@ -31,6 +32,7 @@ do_install() { install -m 0755 ${WORKDIR}/mount.sh ${D}${sysconfdir}/udev/scripts/mount.sh sed -i 's|@systemd_unitdir@|${systemd_unitdir}|g' ${D}${sysconfdir}/udev/scripts/mount.sh sed -i 's|@base_sbindir@|${base_sbindir}|g' ${D}${sysconfdir}/udev/scripts/mount.sh + sed -i 's|@MOUNT_BASE@|${MOUNT_BASE}|g' ${D}${sysconfdir}/udev/scripts/mount.sh install -m 0755 ${WORKDIR}/network.sh ${D}${sysconfdir}/udev/scripts } -- cgit v1.2.3-54-g00ecf