scripts/live-helpers: Search / use case
[live-boot-grml.git] / scripts / live-helpers
index 203ee4c..6c03751 100644 (file)
@@ -35,8 +35,8 @@ get_fstype ()
        local FSSIZE
 
        # fstype misreports LUKS devices
-       is_luks "${1}"
-       if [ $? -eq 0 ]; then
+       if is_luks "${1}"
+       then
            /lib/udev/vol_id -t ${1} 2>/dev/null
            return
        fi
@@ -244,20 +244,24 @@ find_cow_device ()
                        then
                                echo "${devname}"
                                return
-                       elif [ "$(get_fstype ${devname})" = "vfat" ]
-                       then
-                               # FIXME: all supported block devices should be scanned
-                               mkdir -p "${cow_backing}"
-                               try_mount "${devname}" "${cow_backing}" "rw"
-
-                               if [ -e "${cow_backing}/${pers_label}" ]
-                               then
-                                       echo $(setup_loop "${cow_backing}/${pers_label}" "loop" "/sys/block/loop*")
-                                       return 0
-                               else
-                                       umount ${cow_backing}
-                               fi
                        fi
+
+                       case "$(get_fstype ${devname})" in
+                               vfat|ext2|ext3|jffs2)
+                                       mkdir -p "${cow_backing}"
+                                       try_mount "${devname}" "${cow_backing}" "rw"
+
+                                       if [ -f "${cow_backing}/${pers_label}" ]
+                                       then
+                                               echo $(setup_loop "${cow_backing}/${pers_label}" "loop" "/sys/block/loop*")
+                                               return 0
+                                       else
+                                               umount ${cow_backing}
+                                       fi
+                                       ;;
+                               *)
+                                       ;;
+                       esac
                done
        done
 }
@@ -277,23 +281,24 @@ find_files ()
                        devname=$(sys2dev "${dev}")
                        devfstype="$(get_fstype ${devname})"
 
-                       if [ "${devfstype}" = "vfat" ] ||  [ "${devfstype}" = "ext2" ] || [ "${devfstype}" = "ext3" ] || [ "${devfstype}" = "jffs2" ]
-                       then
-                               # FIXME: all supported block devices should be scanned
-                               mkdir -p "${snap_backing}"
-                               try_mount "${devname}" "${snap_backing}" "ro"
-
-                               for filename in ${filenames}
-                               do
-                                       if [ -e "${snap_backing}/${filename}" ]
-                                       then
-                                               echo "${devname} ${snap_backing} ${filename}"
-                                               return 0
-                                       fi
-                               done
-
-                               umount ${snap_backing}
-                       fi
+                       case "${devfstype}" in
+                               vfat|ext2|ext3|jffs2)
+                                       # FIXME: all supported block devices should be scanned
+                                       mkdir -p "${snap_backing}"
+                                       try_mount "${devname}" "${snap_backing}" "ro"
+
+                                       for filename in ${filenames}
+                                       do
+                                               if [ -f "${snap_backing}/${filename}" ]
+                                               then
+                                                       echo "${devname} ${snap_backing} ${filename}"
+                                                       return 0
+                                               fi
+                                       done
+
+                                       umount ${snap_backing}
+                                       ;;
+                       esac
                done
        done
 }
@@ -321,8 +326,8 @@ is_luks()
     devname="${1}"
     if [ -x /sbin/cryptsetup ]
     then
-       /sbin/cryptsetup isLuks "${devname}" 2>/dev/null
-       return $?
+       /sbin/cryptsetup isLuks "${devname}" 2>/dev/null || ret=${?}
+       return ${ret}
     else
        return 1
     fi