Skip to content

Commit 3399f4b

Browse files
committed
Move dataset mountpoint to $BASE/environments/
Creating a directory tree for zpools / datasets rooted in $BASE could potentially lead to a conflict between one of the various files we create and a pool name. Moving the root of this to $BASE/environments/ means that there can't be a conflict, since imported pool names must be unique. Additionally, a helper was added to return a string with the path to a given filesystem on disk. This avoids manually constructing the path and having to update those individually should this directory location ever change.
1 parent 7eb7780 commit 3399f4b

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

zfsbootmenu/lib/zfsbootmenu-core.sh

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ mount_zfs() {
240240
return 1
241241
fi
242242

243-
mnt="${BASE}/${fs}/mnt"
243+
mnt="$( be_location "${fs}" )/mnt"
244244
mkdir -p "${mnt}"
245245

246246
# filesystems are readonly by default, but read-write mounts may be requested
@@ -782,7 +782,7 @@ find_be_kernels() {
782782
# returns: nothing
783783

784784
select_kernel() {
785-
local zfsbe specific_kernel kexec_args spec_kexec_args
785+
local zfsbe bepath specific_kernel kexec_args spec_kexec_args
786786

787787
zfsbe="${1}"
788788
if [ -z "${zfsbe}" ]; then
@@ -791,8 +791,10 @@ select_kernel() {
791791
fi
792792
zdebug "zfsbe set to ${zfsbe}"
793793

794+
bepath="$( be_location "${zfsbe}" )"
795+
794796
# By default, select the last kernel entry
795-
kexec_args="$( tail -1 "${BASE}/${zfsbe}/kernels" )"
797+
kexec_args="$( tail -1 "${bepath}/kernels" )"
796798

797799
# If a specific kernel is listed, prefer it when possible
798800
specific_kernel="$( zfs get -H -o value org.zfsbootmenu:kernel "${zfsbe}" )"
@@ -806,7 +808,7 @@ select_kernel() {
806808
kexec_args="${spec_kexec_args}"
807809
break
808810
fi
809-
done <<<"$( tac "${BASE}/${zfsbe}/kernels" )"
811+
done <<<"$( tac "${bepath}/kernels" )"
810812
fi
811813

812814
zdebug "using kexec args: ${kexec_args}"
@@ -921,7 +923,7 @@ load_be_cmdline() {
921923
fi
922924
zdebug "fs set to ${fs}"
923925

924-
cache="${BASE}/${fs}/cmdline"
926+
cache="$( be_location "${fs}" )/cmdline"
925927

926928
if [ -r "${BASE}/cmdline" ]; then
927929
# Always prefer a user-entered KCL
@@ -1743,6 +1745,24 @@ load_key() {
17431745
return $?
17441746
}
17451747

1748+
# arg1: ZFS filesystem
1749+
# prints: The base path to this filesystem for use by ZFSBootMenu functions, with out a trailing /
1750+
# returns: nothing
1751+
1752+
be_location() {
1753+
local fs beloc
1754+
fs="${1}"
1755+
if [ -z "${fs}" ]; then
1756+
zerror "fs is undefined"
1757+
return 1
1758+
fi
1759+
zdebug "fs set to ${fs}"
1760+
1761+
local beloc="${BASE}/environments/${fs}"
1762+
mkdir -p "${beloc}"
1763+
echo "${beloc}"
1764+
}
1765+
17461766
# arg1: ZFS filesystem
17471767
# prints: nothing
17481768
# returns: nothing

zfsbootmenu/lib/zfsbootmenu-lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ populate_be_list() {
589589
ret=1
590590
for fs in "${candidates[@]}"; do
591591
# Remove any existing cmdline cache
592-
rm -f "${BASE}/${fs}/cmdline"
592+
rm -f "$( be_location "${fs}" )/cmdline"
593593

594594
# Unlock if necessary
595595
load_key "${fs}" || continue

0 commit comments

Comments
 (0)