diff options
author | Jan Blunck <jblunck@vyatta.com> | 2013-09-03 11:22:00 +0200 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2013-09-13 14:15:59 +0200 |
commit | 1ba79ed1eb5e2a52bdf226b0bbeaa3917f048778 (patch) | |
tree | b608571fe6c768a4da5feffa484fbfa2e71f0b6e /components | |
parent | e5904f5079fd4362c4dd63027075fce4b47c51c5 (diff) | |
download | live-boot-1ba79ed1eb5e2a52bdf226b0bbeaa3917f048778.tar.gz live-boot-1ba79ed1eb5e2a52bdf226b0bbeaa3917f048778.zip |
Add support for persistence-storage type "directory".
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.
Diffstat (limited to 'components')
-rwxr-xr-x | components/9990-misc-helpers.sh | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh index 2515ea1..2a3e6ad 100755 --- a/components/9990-misc-helpers.sh +++ b/components/9990-misc-helpers.sh @@ -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 () @@ -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 @@ -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 @@ -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 |