# is non-empty, remove mask from all source paths when
# creating links (will be necessary if we change root, which
# live-boot normally does (into $rootmnt)).
# is non-empty, remove mask from all source paths when
# creating links (will be necessary if we change root, which
# live-boot normally does (into $rootmnt)).
# remove multiple /:s and ensure ending on /
src_dir="$(trim_path ${1})/"
dest_dir="$(trim_path ${2})/"
# remove multiple /:s and ensure ending on /
src_dir="$(trim_path ${1})/"
dest_dir="$(trim_path ${2})/"
# This check can only trigger on the inital, non-recursive call since
# we create the destination before recursive calls
# This check can only trigger on the inital, non-recursive call since
# we create the destination before recursive calls
elif [ -n "${opt_link}" ] && [ -n "${PERSISTENCE_READONLY}" ]
then
mkdir -p ${rootmnt}/lib/live/mount/persistence
elif [ -n "${opt_link}" ] && [ -n "${PERSISTENCE_READONLY}" ]
then
mkdir -p ${rootmnt}/lib/live/mount/persistence
# has its own directory and isn't nested with some
# other custom mount (if so that mount's files would
# be linked, causing breakage.
# has its own directory and isn't nested with some
# other custom mount (if so that mount's files would
# be linked, causing breakage.
mkdir -p ${cow_dir}
chown_ref "${source}" "${cow_dir}"
chmod_ref "${source}" "${cow_dir}"
do_union ${links_source} ${cow_dir} ${source} ${rootfs_dest_backing}
mkdir -p ${cow_dir}
chown_ref "${source}" "${cow_dir}"
chmod_ref "${source}" "${cow_dir}"
do_union ${links_source} ${cow_dir} ${source} ${rootfs_dest_backing}
elif [ -n "${opt_union}" ] && [ -z "${PERSISTENCE_READONLY}" ]
then
do_union ${dest} ${source} ${rootfs_dest_backing}
elif [ -n "${opt_union}" ] && [ -z "${PERSISTENCE_READONLY}" ]
then
do_union ${dest} ${source} ${rootfs_dest_backing}
# bind-mount and union mount are handled the same
# in read-only mode, but note that rootfs_dest_backing
# is non-empty (and necessary) only for unions
# bind-mount and union mount are handled the same
# in read-only mode, but note that rootfs_dest_backing
# is non-empty (and necessary) only for unions