patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: Demi Marie Obenour <demiobenour@gmail.com>
Cc: devel@spectrum-os.org
Subject: Re: [PATCH 1/3] tools/mount-flatpak: init
Date: Sat, 15 Nov 2025 13:01:47 +0100	[thread overview]
Message-ID: <87fraf4i8k.fsf@alyssa.is> (raw)
In-Reply-To: <87ikfb4iat.fsf@alyssa.is>

[-- Attachment #1: Type: text/plain, Size: 2307 bytes --]

Alyssa Ross <hi@alyssa.is> writes:

> Demi Marie Obenour <demiobenour@gmail.com> writes:
>
>> On 11/14/25 06:12, Alyssa Ross wrote:
>>> Demi Marie Obenour <demiobenour@gmail.com> 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 <hi@alyssa.is>
>>>>> +
>>>>> +#include "config.h"
>>>>> +#include "metadata.h"
>>>>> +
>>>>> +#include <err.h>
>>>>> +#include <fcntl.h>
>>>>> +#include <stdlib.h>
>>>>> +#include <stdio.h>
>>>>> +#include <string.h>
>>>>> +#include <unistd.h>
>>>>> +
>>>>> +#include <sys/stat.h>
>>>>> +#include <sys/syscall.h>
>>>>> +
>>>>> +#include <linux/mount.h>
>>>>> +#include <linux/openat2.h>
>>>>> +
>>>>> +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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

  reply	other threads:[~2025-11-15 12:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 12:04 [PATCH 1/3] tools/mount-flatpak: init Alyssa Ross
2025-11-13 12:04 ` [PATCH 2/3] img/app: run Flatpak applications Alyssa Ross
2025-11-13 12:04 ` [PATCH 3/3] host/rootfs: add run-flatpak script Alyssa Ross
2025-11-14 19:36   ` Demi Marie Obenour
2025-11-24 15:25     ` Alyssa Ross
2025-11-13 19:25 ` [PATCH 1/3] tools/mount-flatpak: init Demi Marie Obenour
2025-11-14 11:12   ` Alyssa Ross
2025-11-14 22:52     ` Demi Marie Obenour
2025-11-15 12:00       ` Alyssa Ross
2025-11-15 12:01         ` Alyssa Ross [this message]
2025-11-18  1:37         ` Demi Marie Obenour
2025-11-14 19:11 ` Demi Marie Obenour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fraf4i8k.fsf@alyssa.is \
    --to=hi@alyssa.is \
    --cc=demiobenour@gmail.com \
    --cc=devel@spectrum-os.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).