Alyssa Ross writes: > Demi Marie Obenour writes: > >> On 11/14/25 06:12, Alyssa Ross wrote: >>> Demi Marie Obenour writes: >>> >>>> On 11/13/25 07:04, Alyssa Ross wrote: >>>>> diff --git a/tools/mount-flatpak/mount-flatpak.c b/tools/mount-flatpak/mount-flatpak.c >>>>> new file mode 100644 >>>>> index 0000000..8e09d1d >>>>> --- /dev/null >>>>> +++ b/tools/mount-flatpak/mount-flatpak.c >>>>> @@ -0,0 +1,294 @@ >>>>> +// SPDX-License-Identifier: EUPL-1.2+ >>>>> +// SPDX-FileCopyrightText: 2025 Alyssa Ross >>>>> + >>>>> +#include "config.h" >>>>> +#include "metadata.h" >>>>> + >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> +#include >>>>> + >>>>> +#include >>>>> +#include >>>>> + >>>>> +#include >>>>> +#include >>>>> + >>>>> +static void bind_mount(int source_fd, const char *source, >>>>> + int target_fd, const char *target) >>>>> +{ >>>>> + int source_tree = syscall(SYS_open_tree, source_fd, source, >>>>> + AT_EMPTY_PATH | OPEN_TREE_CLOEXEC | >>>>> + OPEN_TREE_CLONE | AT_RECURSIVE); >>>>> + if (source_tree == -1) >>>>> + err(EXIT_FAILURE, "open_tree %s", source); >>>>> + if (syscall(SYS_move_mount, source_tree, "", target_fd, target, >>>>> + MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH) == -1) >>>>> + err(EXIT_FAILURE, "move_mount"); >>>> >>>> Missing checks that target does not contain "/" and is not "." or "..". >>> >>> Right, yes, move_mount doesn't have RESOLVE_BENEATH semantics. Ideally >>> I suppose we can leave target empty and only use an fd, but I don't >>> think that works in all circumstances. >> >> Which ones does it fail in? Also, should this set the mount read-only? > > I had it that way originally, but I decided to replace it with one > read-only self-bind-mount at the end because making just these read-only > and not the parent directories felt a bit ad-hoc. Oh and as for where it fails, I wasn't able to remount a directory over itself using empty paths for both.