Skip to content

Commit a1c35d1

Browse files
committed
python: sd_nspawn: Mount NAS into container
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent d00daa7 commit a1c35d1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

python/scripts/sd_nspawn.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ def __init__(self, name):
7676
lib.utils.chronic(['systemd-nspawn', '--version']).stdout.splitlines()[0].split()[1])
7777

7878
def _add_dynamic_mounts(self):
79-
rw_mounts = {
80-
'/dev/kvm',
79+
automounted_mounts = {
8180
# We may be in a virtual machine
8281
os.environ['HOST_FOLDER'],
82+
os.environ['NAS_FOLDER'],
83+
}
84+
rw_mounts = {
85+
'/dev/kvm',
86+
*automounted_mounts,
8387
os.environ['NVME_FOLDER'],
8488
# Allow 'fzf --tmux' to work properly
8589
'/var/tmp/fzf',
@@ -116,10 +120,10 @@ def _add_dynamic_mounts(self):
116120
# which needs to be written to as the host root user by the
117121
# container root user. For mounts where the current user can read
118122
# and write to, the mapping mentioned earlier makes everything work
119-
# as expeced without 'idmap'. We special case HOST_FOLDER because
120-
# the os.access check may not pass if the folder has not been
121-
# automounted yet.
122-
if mount == os.environ['HOST_FOLDER'] or os.access(mount, os.R_OK | os.W_OK):
123+
# as expeced without 'idmap'. We special case automounted mounts
124+
# because the os.access check may not pass if the folder has not
125+
# been automounted yet.
126+
if mount in automounted_mounts or os.access(mount, os.R_OK | os.W_OK):
123127
item = mount
124128
else:
125129
item = f"{mount}:{mount}:idmap"

0 commit comments

Comments
 (0)