[OE-core] [PATCH 2/3] udev-extraconf/mount.sh: Fix the recursively dependency for the systemd-mount

2018-09-15 Thread Hongzhi.Song
If systemd is used, using the systemd-mount to mount the new added disk
partitions forgets to move the codes which tries to mount the partition
by using the configuration in /etc/fstab to the non-systemd function.

And it will cause the systemd-mount try to mount the partition
synchronously and trigger a recursively dependency like the following:
dev-sda1.device -> run-media-sda1.mount -> dev-sda1.device

Signed-off-by: Kevin Hao 
Signed-off-by: Hongzhi.Song 
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 27 +++---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh 
b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 5a877dd7ed..4cb5db3a9b 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -60,7 +60,17 @@ automount_systemd() {
 automount() {
name="`basename "$DEVNAME"`"
 
-   ! test -d "/run/media/$name" && mkdir -p "/run/media/$name"
+if [ -x "$PMOUNT" ]; then
+$PMOUNT $DEVNAME 2> /dev/null
+elif [ -x $MOUNT ]; then
+$MOUNT $DEVNAME 2> /dev/null
+fi
+
+# If the device isn't mounted at this point, it isn't
+# configured in fstab
+grep -q "^$DEVNAME " /proc/mounts && return
+
+! test -d "/run/media/$name" && mkdir -p "/run/media/$name"
# Silent util-linux's version of mounting auto
if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
then
@@ -102,19 +112,14 @@ rm_dir() {
 name="`basename "$DEVNAME"`"
 [ -e /sys/block/$name/device/media ] && media_type=`cat 
/sys/block/$name/device/media`
 if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" -o 
"$media_type" = "cdrom" ]; then
-   if [ -x "$PMOUNT" ]; then
-   $PMOUNT $DEVNAME 2> /dev/null
-   elif [ -x $MOUNT ]; then
-   $MOUNT $DEVNAME 2> /dev/null
-   fi
-   # If the device isn't mounted at this point, it isn't
-   # configured in fstab (note the root filesystem can show up as
-   # /dev/root in /proc/mounts, so check the device number too)
+
+# Note the root filesystem can show up as /dev/root in /proc/mounts,
+# so check the device number too
if expr $MAJOR "*" 256 + $MINOR != `stat -c %d /`; then
if [ "`basename $MOUNT`" = "systemd-mount" ];then
-   grep -q "^$DEVNAME " /proc/mounts || automount_systemd
+   automount_systemd
else
-   grep -q "^$DEVNAME " /proc/mounts || automount
+   automount
fi
fi
 fi
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [oe-core][PATCH 2/3] udev-extraconf/mount.sh: Fix the recursively dependency for the systemd-mount

2018-08-01 Thread Hongzhi.Song
If systemd is used, using the systemd-mount to mount the new added disk
partitions forgets to move the codes which tries to mount the partition
by using the configuration in /etc/fstab to the non-systemd function.

And it will cause the systemd-mount try to mount the partition
synchronously and trigger a recursively dependency like the following:
dev-sda1.device -> run-media-sda1.mount -> dev-sda1.device

Signed-off-by: Kevin Hao 
Signed-off-by: Hongzhi.Song 
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh 
b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 3a72c455e0..816d975e5e 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -63,6 +63,16 @@ automount_systemd() {
 automount() {  
name="`basename "$DEVNAME"`"
 
+   if [ -x "$PMOUNT" ]; then
+   $PMOUNT $DEVNAME 2> /dev/null
+   elif [ -x $MOUNT ]; then
+   $MOUNT $DEVNAME 2> /dev/null
+   fi
+
+   # If the device isn't mounted at this point, it isn't
+   # configured in fstab
+   grep -q "^$DEVNAME " /proc/mounts && return
+
! test -d "/run/media/$name" && mkdir -p "/run/media/$name"
# Silent util-linux's version of mounting auto
if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
@@ -105,19 +115,13 @@ rm_dir() {
 name="`basename "$DEVNAME"`"
 [ -e /sys/block/$name/device/media ] && media_type=`cat 
/sys/block/$name/device/media`
 if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" -o 
"$media_type" = "cdrom" ]; then
-   if [ -x "$PMOUNT" ]; then
-   $PMOUNT $DEVNAME 2> /dev/null
-   elif [ -x $MOUNT ]; then
-   $MOUNT $DEVNAME 2> /dev/null
-   fi
-   # If the device isn't mounted at this point, it isn't
-   # configured in fstab (note the root filesystem can show up as
-   # /dev/root in /proc/mounts, so check the device number too)
+   # Note the root filesystem can show up as /dev/root in /proc/mounts,
+   # so check the device number too
if expr $MAJOR "*" 256 + $MINOR != `stat -c %d /`; then
if [ "`basename $MOUNT`" = "systemd-mount" ];then
-   grep -q "^$DEVNAME " /proc/mounts || automount_systemd
+   automount_systemd
else
-   grep -q "^$DEVNAME " /proc/mounts || automount
+   automount
fi
fi
 fi
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core