ISO_DEVICE=$(dirname ${ISO_DEVICE})
[ -b "$ISO_DEVICE" ] && break
i=$(($i -1))
- done
+ done
fi
if [ "$ISO_DEVICE" = "/" ]
return 1
fi
+ # get_fstype might report "unknown" or "swap", ignore it as no such kernel module exists
+ if [ "${fstype}" = "unknown" ] || [ "${fstype}" = "swap" ]
+ then
+ return 1
+ fi
+
# Try to look if it is already supported by the kernel
if grep -q ${fstype} /proc/filesystems
then
get_fstype ()
{
- /sbin/blkid -s TYPE -o value $1 2>/dev/null
+ blkid -s TYPE -o value $1 2>/dev/null
}
where_is_mounted ()
{
testpath="${1}"
mounts="$(awk '{print $2}' /proc/mounts)"
- testpath="$(busybox realpath ${testpath})"
+ testpath="$(realpath ${testpath})"
while true
do
echo "${passphrase}" > /tmp/passphrase
unset passphrase
exec 9</tmp/passphrase
- /sbin/losetup ${options} -e "${encryption}" -p 9 "${dev}" "${fspath}"
+ losetup ${options} -e "${encryption}" -p 9 "${dev}" "${fspath}"
error=${?}
exec 9<&-
rm -f /tmp/passphrase
fi
elif [ "${backing}" != "${old_backing}" ]
then
- if ! mount --move ${old_backing} ${backing} >/dev/null
+ if ! mount -o move ${old_backing} ${backing} >/dev/null
then
[ -z "${probe}" ] && log_warning_msg "Failed to move persistence media ${device}"
rmdir "${backing}"
if is_active_luks_mapping ${device}
then
- /sbin/cryptsetup luksClose ${device}
+ cryptsetup luksClose ${device}
fi
}
opts="${opts} --readonly"
fi
- if /sbin/cryptsetup status "${name}" >/dev/null 2>&1
+ if cryptsetup status "${name}" >/dev/null 2>&1
then
re="^[[:space:]]*device:[[:space:]]*\([^[:space:]]*\)$"
opened_dev=$(cryptsetup status ${name} 2>/dev/null | grep "${re}" | sed "s|${re}|\1|")
while true
do
$cryptkeyscript "$cryptkeyprompt" | \
- /sbin/cryptsetup -T 1 luksOpen ${dev} ${name} ${opts}
+ cryptsetup -T 1 luksOpen ${dev} ${name} ${opts}
if [ 0 -eq ${?} ]
then
{
local dev
dev="${1}"
- /sbin/blkid -s PART_ENTRY_NAME -p -o value ${dev} 2>/dev/null
+ blkid -s PART_ENTRY_NAME -p -o value ${dev} 2>/dev/null
}
is_gpt_device ()
{
local dev
dev="${1}"
- [ "$(/sbin/blkid -s PART_ENTRY_SCHEME -p -o value ${dev} 2>/dev/null)" = "gpt" ]
+ [ "$(blkid -s PART_ENTRY_SCHEME -p -o value ${dev} 2>/dev/null)" = "gpt" ]
}
probe_for_gpt_name ()
for label in ${overlays}
do
- if [ "$(/sbin/blkid -s LABEL -o value $dev 2>/dev/null)" = "${label}" ]
+ if [ "$(blkid -s LABEL -o value $dev 2>/dev/null)" = "${label}" ]
then
echo "${label}=${dev}"
fi
result=$(probe_for_file_name "${overlays}" ${dev})
if [ -n "${result}" ]
then
- local loopdevice
+ local loopdevice
loopdevice=${result##*=}
- if is_in_comma_sep_list luks ${PERSISTENCE_ENCRYPTION} && is_luks_partition ${loopdevice}
+ if is_in_comma_sep_list luks ${PERSISTENCE_ENCRYPTION} && is_luks_partition ${loopdevice}
then
- local luksfile
+ local luksfile
luksfile=""
if luksfile=$(open_luks_device "${loopdevice}")
then
- result=${result%%=*}
+ result=${result%%=*}
result="${result}=${luksfile}"
else
- losetup -d $loopdevice
+ losetup -d $loopdevice
result=""
fi
fi
# Close luks device if it isn't used
if [ -z "${result}" ] && [ -n "${luks_device}" ] && is_active_luks_mapping "${luks_device}"
then
- /sbin/cryptsetup luksClose "${luks_device}"
+ cryptsetup luksClose "${luks_device}"
fi
done
is_luks_partition ()
{
device="${1}"
- /sbin/cryptsetup isLuks "${device}" 1>/dev/null 2>&1
+ cryptsetup isLuks "${device}" 1>/dev/null 2>&1
}
is_active_luks_mapping ()
{
device="${1}"
- /sbin/cryptsetup status "${device}" 1>/dev/null 2>&1
+ cryptsetup status "${device}" 1>/dev/null 2>&1
}
get_luks_backing_device ()
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
do
+ if [ ! -d "${sysblock}" ]; then
+ continue
+ fi
+
dev_ok=
if [ "$(cat ${sysblock}/removable)" = "1" ]
then
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
do
+ if [ ! -d "${sysblock}" ]; then
+ continue
+ fi
+
if [ "$(cat ${sysblock}/removable)" = "0" ]
then
case "${output_format}" in
;;
overlay)
- # XXX: can multiple unionro be used? (overlay only handles two dirs, but perhaps they can be chained?)
- # XXX: and can unionro be optional? i.e. can overlay skip lowerdir?
- if echo ${unionro} | grep -q " "
- then
- panic "Multiple lower filesystems are currently not supported with overlay (unionro = ${unionro})."
- elif [ -z "${unionro}" ]
+ # XXX: can unionro be optional? i.e. can overlay skip lowerdir?
+ if [ -z "${unionro}" ]
then
panic "overlay needs at least one lower filesystem (read-only branch)."
fi
+ # Multiple lower layers can now be given using the the colon (":") as a
+ # separator character between the directory names.
+ unionro="$(echo ${unionro} | sed -e 's| |:|g')"
# overlayfs requires:
# + a workdir to become mounted
# + workdir and upperdir to reside under the same mount
do_union ${dest} ${source} ${rootfs_dest_backing}
elif [ -n "${opt_bind}" ] && [ -z "${PERSISTENCE_READONLY}" ]
then
- mount --bind "${source}" "${dest}"
+ mount -o bind "${source}" "${dest}"
elif [ -n "${opt_bind}" -o -n "${opt_union}" ] && [ -n "${PERSISTENCE_READONLY}" ]
then
# bind-mount and union mount are handled the same