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 *)