diff options
Diffstat (limited to 'recipes-core/udev/udev-extraconf')
-rw-r--r-- | recipes-core/udev/udev-extraconf/automount.rules | 24 | ||||
-rw-r--r-- | recipes-core/udev/udev-extraconf/mount.patch | 136 |
2 files changed, 160 insertions, 0 deletions
diff --git a/recipes-core/udev/udev-extraconf/automount.rules b/recipes-core/udev/udev-extraconf/automount.rules new file mode 100644 index 0000000..b4a8f22 --- /dev/null +++ b/recipes-core/udev/udev-extraconf/automount.rules @@ -0,0 +1,24 @@ +# There are a number of modifiers that are allowed to be used in some +# of the different fields. They provide the following subsitutions: +# +# %n the "kernel number" of the device. +# For example, 'sda3' has a "kernel number" of '3' +# %e the smallest number for that name which does not matches an existing node +# %k the kernel name for the device +# %M the kernel major number for the device +# %m the kernel minor number for the device +# %b the bus id for the device +# %c the string returned by the PROGRAM +# %s{filename} the content of a sysfs attribute +# %% the '%' char itself +# + +SUBSYSTEM!="block", GOTO="automount_end" +# only mount SD cards and mass storage devices +KERNEL!="sd[a-z][0-9]*|mmcblk[0-9]p[0-9]*", GOTO="automount_end" + +# Media automounting +SUBSYSTEM=="block", ACTION=="add" RUN+="/etc/udev/scripts/mount.sh" +SUBSYSTEM=="block", ACTION=="remove" RUN+="/etc/udev/scripts/mount.sh" + +LABEL="automount_end" diff --git a/recipes-core/udev/udev-extraconf/mount.patch b/recipes-core/udev/udev-extraconf/mount.patch new file mode 100644 index 0000000..4ed3bfd --- /dev/null +++ b/recipes-core/udev/udev-extraconf/mount.patch @@ -0,0 +1,136 @@ +diff -Naru orig/mount.blacklist new/mount.blacklist +--- orig/mount.blacklist 2019-10-24 17:08:59.796796272 -0500 ++++ new/mount.blacklist 2019-10-24 17:16:31.768782892 -0500 +@@ -3,3 +3,16 @@ + /dev/mtdblock + /dev/md + /dev/dm-* ++# These should all be mounted in fstab or not at all. ++[PARTLABEL=uboot] ++[PARTLABEL=root] ++[PARTLABEL=root1] ++[PARTLABEL=root2] ++[PARTLABEL=uboot] ++[PARTLABEL=oem] ++[PARTLABEL=oem1] ++[PARTLABEL=oem2] ++[PARTLABEL=config] ++[PARTLABEL=config1] ++[PARTLABEL=config2] ++[PARTLABEL=user_data] +diff -Naru orig/mount.sh new/mount.sh +--- orig/mount.sh 2020-09-09 13:57:23.196157483 -0500 ++++ new/mount.sh 2020-09-09 14:59:40.344046845 -0500 +@@ -4,8 +4,8 @@ + # + # Attempt to mount any added block devices and umount any removed devices + +-BASE_INIT="`readlink -f "@base_sbindir@/init"`" +-INIT_SYSTEMD="@systemd_unitdir@/systemd" ++BASE_INIT="`readlink -f "/sbin/init"`" ++INIT_SYSTEMD="/lib/systemd/systemd" + + if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ];then + # systemd as init uses systemd-mount to mount block devices +@@ -23,11 +23,38 @@ + MOUNT="/bin/mount" + UMOUNT="/bin/umount" + fi ++LSBLK=$(type -p lsblk) ++if ((${#LSBLK} == 0)) ; then ++ LSBLK=true ++fi + + PMOUNT="/usr/bin/pmount" +- +-for line in `grep -h -v ^# /etc/udev/mount.blacklist /etc/udev/mount.blacklist.d/*` ++for line in `grep -h -v '^#$' /etc/udev/mount.blacklist /etc/udev/mount.blacklist.d/* 2>/dev/null` + do ++ if [[ $line =~ ^\[([^=]*)=([^\]]*)\] ]] ; then ++ fsspectype=${BASH_REMATCH[1]} ++ tmp="$(${LSBLK} -o $fsspectype $DEVNAME | sed -e '1d')" ++ case $fsspectype in ++ PARTLABEL) ++ if [[ ${BASH_REMATCH[2]} == $tmp ]] ; then ++ logger "udev/mount.sh $DEVNAME is blacklisted, ignoring" ++ logger "$line" ++ exit 0 ++ fi ++ ;; ++ ++ PARTUUID) ++ if [[ ${BASH_REMATCH[2]^^} == $tmp ]] ; then ++ logger "udev/mount.sh $DEVNAME is blacklisted, ignoring" ++ logger "$line" ++ exit 0 ++ fi ++ ;; ++ *) ++ logger "[$fsspectype] is unsupported in blacklist -- ignoring blacklist item" ++ ;; ++ esac ++ fi + if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ]; + then + logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring" +@@ -41,7 +68,7 @@ + # Skip the partition which are already in /etc/fstab + grep "^[[:space:]]*$DEVNAME" /etc/fstab && return + for n in LABEL PARTLABEL UUID PARTUUID; do +- tmp="$(lsblk -o $n $DEVNAME | sed -e '1d')" ++ tmp="$($LSBLK -o $n $DEVNAME | sed -e '1d')" + test -z "$tmp" && continue + tmp="$n=$tmp" + grep "^[[:space:]]*$tmp" /etc/fstab && return +@@ -49,13 +76,17 @@ + + [ -d "/run/media/$name" ] || mkdir -p "/run/media/$name" + ++ if [ "$name" = mmcblk0p1 ] ; then ++ ln -sf /run/media/$name /run/media/card ++ fi ++ + MOUNT="$MOUNT -o silent" + + # If filesystemtype is vfat, change the ownership group to 'disk', and + # grant it with w/r/x permissions. + case $ID_FS_TYPE in + vfat|fat) +- MOUNT="$MOUNT -o umask=007,gid=`awk -F':' '/^disk/{print $3}' /etc/group`" ++ MOUNT="$MOUNT -o errors=continue -o umask=007,gid=`awk -F':' '/^disk/{print $3}' /etc/group`" + ;; + # TODO + *) +@@ -78,7 +109,11 @@ + if [ -x "$PMOUNT" ]; then + $PMOUNT $DEVNAME 2> /dev/null + elif [ -x $MOUNT ]; then ++ if [[ $ID_FS_TYPE =~ fat ]] ; then ++ $MOUNT -o umask=002,gid=disk $DEVNAME 2> /dev/null ++ else + $MOUNT $DEVNAME 2> /dev/null ++ fi + fi + + # If the device isn't mounted at this point, it isn't +@@ -86,6 +121,11 @@ + grep -q "^$DEVNAME " /proc/mounts && return + + ! test -d "/run/media/$name" && mkdir -p "/run/media/$name" ++ ++ if [ "$name" = mmcblk0p1 ] ; then ++ ln -sf /run/media/$name /run/media/card ++ fi ++ + # Silent util-linux's version of mounting auto + if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ; + then +@@ -96,7 +136,7 @@ + # grant it with w/r/x permissions. + case $ID_FS_TYPE in + vfat|fat) +- MOUNT="$MOUNT -o umask=007,gid=`awk -F':' '/^disk/{print $3}' /etc/group`" ++ MOUNT="$MOUNT -o errors=continue -o umask=007,gid=`awk -F':' '/^disk/{print $3}' /etc/group`" + ;; + # TODO + *) |