X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=components%2F9990-misc-helpers.sh;h=2515ea1ea15988131e3aaa0f1e696966944be8a8;hb=e5904f5079fd4362c4dd63027075fce4b47c51c5;hp=7cb276240a6768c4c1a630033a5a7d0848e92627;hpb=4fe3c74f01f235ffff782cee513db638c8de2375;p=live-boot-grml.git diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh index 7cb2762..2515ea1 100755 --- a/components/9990-misc-helpers.sh +++ b/components/9990-misc-helpers.sh @@ -2,17 +2,12 @@ #set -e -file_pattern_matches() -{ - [ -e "$1" ] -} - is_live_path() { DIRECTORY="${1}/${LIVE_MEDIA_PATH}" for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs do - if file_pattern_matches "${DIRECTORY}/"*.${FILESYSTEM} + if ls "${DIRECTORY}/"*.${FILESYSTEM} > /dev/null 2>&1 then return 0 fi @@ -334,21 +329,6 @@ find_livefs () return 1 } -really_export () -{ - STRING="${1}" - VALUE="$(eval echo -n \${$STRING})" - - if [ -f /live.vars ] && grep -sq "export ${STRING}" /live.vars - then - sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars - else - echo "export ${STRING}=\"${VALUE}\"" >> /live.vars - fi - - eval export "${STRING}"="${VALUE}" -} - is_in_list_separator_helper () { local sep element list @@ -714,6 +694,11 @@ mount_persistence_media () device=${1} probe=${2} + if [ ! -b "${device}" ] + then + return 1 + fi + backing="/live/persistence/$(basename ${device})" mkdir -p "${backing}" @@ -737,15 +722,24 @@ mount_persistence_media () fi elif [ "${backing}" != "${old_backing}" ] then - if mount --move ${old_backing} ${backing} >/dev/null + if ! mount --move ${old_backing} ${backing} >/dev/null then - echo ${backing} - return 0 - else [ -z "${probe}" ] && log_warning_msg "Failed to move persistence media ${device}" rmdir "${backing}" return 1 fi + mount_opts="rw,noatime" + if [ -n "${PERSISTENCE_READONLY}" ] + then + mount_opts="ro,noatime" + fi + if ! mount -o "remount,${mount_opts}" "${backing}" >/dev/null + then + log_warning_msg "Failed to remount persistence media ${device} writable" + # Don't unmount or rmdir the new mountpoint in this case + fi + echo ${backing} + return 0 else # This means that $device has already been mounted on # the place expected by live-boot, so we're done. @@ -895,7 +889,7 @@ probe_for_file_name () for label in ${overlays} do - path=${backing}/${PERSISTENCE_PATH}${label} + path=${backing}/${PERSISTENCE_PATH}/${label} if [ -f "${path}" ] then local loopdev @@ -938,7 +932,17 @@ find_persistence_media () white_listed_devices="${2}" ret="" - black_listed_devices="$(what_is_mounted_on /live/medium) $(what_is_mounted_on /live/findiso) $(what_is_mounted_on /live/fromiso)" + # + # The devices that are hosting the actual live rootfs should not be + # used for persistence storage since otherwise you might mount a + # parent directory on top of a sub-directory of the same filesystem + # in one union together. + # + black_listed_devices="" + for d in /live/rootfs/* /live/findiso /live/fromiso + do + black_listed_devices="${black_listed_devices} $(what_is_mounted_on d)" + done for dev in $(storage_devices "${black_listed_devices}" "${white_listed_devices}") do @@ -1270,11 +1274,6 @@ get_custom_mounts () for device in ${devices} do - if [ ! -b "${device}" ] - then - continue - fi - local device_name backing include_list device_name="$(basename ${device})" backing=$(mount_persistence_media ${device})