summaryrefslogtreecommitdiff
path: root/recipes-core/udev/udev-extraconf/mount.patch
blob: 4ed3bfd24736bbecbfe169a52c94dd9081b3960f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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
 	*)