Skip to content

Commit

Permalink
Add support for persistence-storage type "directory".
Browse files Browse the repository at this point in the history
This adds support for mounting a plain writable directory as the
persistence storage layer. The $PERSISTENCE_PATH and the persistence-label
are taken into account when searching for the persistence.conf file.
  • Loading branch information
Jan Blunck authored and daniel-baumann committed Sep 13, 2013
1 parent e5904f5 commit 1ba79ed
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions components/9990-misc-helpers.sh
Expand Up @@ -684,8 +684,9 @@ try_mount ()
}

# Try to mount $device to the place expected by live-boot. If $device
# is already mounted somewhere, move it to the expected place. If
# we're only probing $device (to check if it has custom persistence)
# is already mounted somewhere, move it to the expected place. If $device
# ends with a "/" this is a directory path.
# If we're only probing $device (to check if it has custom persistence)
# $probe should be set, which suppresses warnings upon failure. On
# success, print the mount point for $device.
mount_persistence_media ()
Expand All @@ -694,6 +695,15 @@ mount_persistence_media ()
device=${1}
probe=${2}

# get_custom_mounts() might call this with a directory path instead
# of a block device path. This means we have found sub-directory path
# underneath /lib/live/mounts/persistence, so we're done
if [ -d "${device}" ]
then
echo "${device}"
return 0
fi

if [ ! -b "${device}" ]
then
return 1
Expand Down Expand Up @@ -908,6 +918,39 @@ probe_for_file_name ()
fi
}

probe_for_directory_name ()
{
local overlays dev ret backing
overlays="${1}"
dev="${2}"

ret=""
backing="$(mount_persistence_media ${dev} probe)"
if [ -z "${backing}" ]
then
return
fi

for label in ${overlays}
do
path=${backing}/${PERSISTENCE_PATH}/${label}
if [ -d "${path}" ]
then
# in this case the "device" ends with a "/"
ret="${ret} ${label}=${backing}/${PERSISTENCE_PATH}/${label%%/}/"
fi
done

if [ -n "${ret}" ]
then
echo ${ret}
else
# unmount and remove mountpoint
umount ${backing} > /dev/null 2>&1 || true
rmdir ${backing} > /dev/null 2>&1 || true
fi
}

find_persistence_media ()
{
# Scans devices for overlays, and returns a whitespace
Expand Down Expand Up @@ -1013,6 +1056,17 @@ find_persistence_media ()
fi
fi

# Probe for directory with matching name on mounted partition
if is_in_comma_sep_list directory ${PERSISTENCE_STORAGE}
then
result=$(probe_for_directory_name "${overlays}" ${dev})
if [ -n "${result}" ]
then
ret="${ret} ${result}"
continue
fi
fi

# Close luks device if it isn't used
if [ -z "${result}" ] && [ -n "${luks_device}" ] && is_active_luks_mapping "${luks_device}"
then
Expand Down

0 comments on commit 1ba79ed

Please sign in to comment.