Skip to content

Commit

Permalink
storaged: Use private mounts for btrfs-tool poll
Browse files Browse the repository at this point in the history
This will re-use already existing mounts from monitoring, but avoid
extra additional mounts to become visible in the file system for
`btrfs-tool poll` commands.

Move the `--make-rprivate` into `unshare_mounts()` to avoid repetition.
  • Loading branch information
martinpitt committed Jan 11, 2025
1 parent c31ad5d commit 62da62b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/storaged/btrfs/btrfs-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def cmd_monitor(opt_mount):


def cmd_poll(opt_mount):
unshare_mounts()
infos = poll(opt_mount, opt_repair=True)
sys.stdout.write(json.dumps(infos) + "\n")
sys.stdout.flush()
Expand All @@ -245,6 +246,8 @@ def unshare_mounts():
errno = get_errno_loc()[0]
raise OSError(errno, os.strerror(errno))

subprocess.check_call(["mount", "--make-rprivate", "/"])


def cmd_do(uuid, cmd):
debug(f"DO {uuid} {cmd}")
Expand All @@ -255,7 +258,6 @@ def cmd_do(uuid, cmd):
dev = fs['devices'][0]
os.makedirs(path, mode=0o700, exist_ok=True)
unshare_mounts()
subprocess.check_call(["mount", "--make-rprivate", "/"])
subprocess.check_call(["mount", dev, path])
subprocess.check_call(cmd, cwd=path)

Expand Down

0 comments on commit 62da62b

Please sign in to comment.