kernel: backport switch user API changes after r36283
[openwrt.git] / package / block-mount / files / mount.sh
index 1616ca7a139cc90393bb6c50d72467e359ded17e..e96174ce92ccc208e25ec1283ca39367b4ff030c 100644 (file)
@@ -5,8 +5,8 @@
 #
 
 
-. /lib/functions/block.sh
-. /lib/functions/fsck.sh
+pi_include /lib/functions/block.sh
+pi_include /lib/functions/fsck.sh
 
 config_mount_by_section() {
        local cfg="$1"
@@ -28,20 +28,30 @@ config_mount_by_section() {
                local is_rootfs="$9"
                shift
                local found_device=""
-               local fsck_type=""
                
                found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
                if [ -n "$found_device" ]; then
-                       if [ -z "$find_rootfs" ] || [ "$find_rootfs" -eq 0 ] || [ "$is_rootfs" -eq 1 ]; then
+                       if [ "$find_rootfs" != "1" ] || ( [ "$is_rootfs" -eq 1 ] || [ "$target" = "/" ] || [ "$target" = "/overlay" ] ); then
                                [ "$enabled_fsck" -eq 1 ] && {
                                        grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
-                                               libmount_fsck "$found_device" "$fsck_type" "$enabled_fsck"
+                                               libmount_fsck "$found_device" "$fstype" "$enabled_fsck"
                                        }
                                }                                                               
        
-                               [ "$is_rootfs" -eq 1 ] && [ "$find_rootfs" -eq 1 ] && {
+                               if [ "$find_rootfs" = "1" ]; then
+                                   if [ "$is_rootfs" -eq 1 ]; then
                                        target=/overlay
-                               }
+                                   elif [ "$target" = "/" ]; then
+                                       target=/rom
+                                   fi
+                               else
+                                   if [ "$is_rootfs" -eq 1 ] || [ "$target" = "/overlay" ]; then
+                                       target=/tmp/overlay-disabled
+                                   elif [ "$target" = "/" ] || [ "$target" = "/rom" ]; then
+                                       target="/tmp/whole_root-disabled"
+                                   fi
+                               fi
+                               
                                config_create_mount_fstab_entry "$found_device" "$target" "$fstype" "$options" "$enabled" 
                                grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
                                        [ "$enabled" -eq 1 ] && mkdir -p "$target" && mount "$target" 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
@@ -49,8 +59,13 @@ config_mount_by_section() {
                                
                        fi
                fi
-               [ "$is_rootfs" -eq 1 ] && [ "$find_rootfs" -eq 1 ] && {
+               [ "$find_rootfs" = "1" ] && {
+                   [ "$target" = "/overlay" ] && {
+                       rootfs_found=1
+                   }
+                   [ "$target" = "/rom" ] && {
                        rootfs_found=1
+                   }
                }
                return 0        
        }
@@ -72,7 +87,6 @@ config_swapon_by_section() {
                local label
                
                local found_device=""
-               local fsck_type=""
                
                found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"