Check losetup capabilities before specifying to mount as read-only.
[live-boot-grml.git] / scripts / live-helpers
index cc73aa3..20952f3 100644 (file)
@@ -167,6 +167,7 @@ setup_loop ()
        local pattern=${3}
        local offset=${4}
        local encryption=${5}
+       local readonly=${6}
 
        modprobe -q -b "${module}"
        udevsettle
@@ -178,6 +179,14 @@ setup_loop ()
                        dev=$(sys2dev "${loopdev}")
                        options=''
 
+                       if [ -n ${readonly} ]
+                       then
+                               if /sbin/losetup --help 2>&1 | grep -q -- "-r\b"
+                               then
+                                       options="${options} -r"
+                               fi
+                       fi
+
                        if [ 0 -lt "${offset}" ]
                        then
                                options="${options} -o ${offset}"