From: Christian Brauner <brauner@kernel.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Miklos Szeredi <mszeredi@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-api@vger.kernel.org, linux-man@vger.kernel.org,
linux-security-module@vger.kernel.org,
Karel Zak <kzak@redhat.com>, Ian Kent <raven@themaw.net>,
David Howells <dhowells@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <christian@brauner.io>,
Amir Goldstein <amir73il@gmail.com>
Subject: Re: [RFC PATCH 2/3] add statmnt(2) syscall
Date: Mon, 18 Sep 2023 15:51:42 +0200 [thread overview]
Message-ID: <20230918-grafik-zutreffen-995b321017ae@brauner> (raw)
In-Reply-To: <CAJfpegt-VPZP3ou-TMQFs1Xupj_iWA5ttC2UUFKh3E43EyCOQQ@mail.gmail.com>
> Atomicity of getting a snapshot of the current mount tree with all of
> its attributes was never guaranteed, although reading
> /proc/self/mountinfo into a sufficiently large buffer would work that
> way. However, I don't see why mount trees would require stronger
> guarantees than dentry trees (for which we have basically none).
So atomicity was never put forward as a requirement. In that
session/recording I explicitly state that we won't guarantee atomicity.
And systemd agreed with this. So I think we're all on the same page.
> Even more type clean interface:
>
> struct statmnt *statmnt(u64 mnt_id, u64 mask, void *buf, size_t
> bufsize, unsigned int flags);
>
> Kernel would return a fully initialized struct with the numeric as
> well as string fields filled. That part is trivial for userspace to
> deal with.
I really would prefer a properly typed struct and that's what everyone
was happy with in the session as well. So I would not like to change the
main parameters.
> > Plus, the format for how to return arbitrary filesystem mount options
> > warrants a separate discussion imho as that's not really vfs level
> > information.
>
> Okay. Let's take fs options out of this.
Thanks.
>
> That leaves:
>
> - fs type and optionally subtype
So since subtype is FUSE specific it might be better to move this to
filesystem specific options imho.
> - root of mount within fs
> - mountpoint path
>
> The type and subtype are naturally limited to sane sizes, those are
> not an issue.
What's the limit for fstype actually? I don't think there is one.
There's one by chance but not by design afaict?
Maybe crazy idea:
That magic number thing that we do in include/uapi/linux/magic.h
is there a good reason for this or why don't we just add a proper,
simple enum:
enum {
FS_TYPE_ADFS 1
FS_TYPE_AFFS 2
FS_TYPE_AFS 3
FS_TYPE_AUTOFS 4
FS_TYPE_EXT2 5
FS_TYPE_EXT3 6
FS_TYPE_EXT4 7
.
.
.
FS_TYPE_MAX
}
that we start returning from statmount(). We can still return both the
old and the new fstype? It always felt a bit odd that fs developers to
just select a magic number.
>
> For paths the evolution of the relevant system/library calls was:
>
> char *getwd(char buf[PATH_MAX]);
> char *getcwd(char *buf, size_t size);
> char *get_current_dir_name(void);
>
> It started out using a fixed size buffer, then a variable sized
> buffer, then an automatically allocated buffer by the library, hiding
> the need to resize on overflow.
>
> The latest style is suitable for the statmnt() call as well, if we
> worry about pleasantness of the API.
So, can we then do the following struct:
struct statmnt {
__u64 mask; /* What results were written [uncond] */
__u32 sb_dev_major; /* Device ID */
__u32 sb_dev_minor;
__u64 sb_magic; /* ..._SUPER_MAGIC */
__u32 sb_flags; /* MS_{RDONLY,SYNCHRONOUS,DIRSYNC,LAZYTIME} */
__u32 __spare1;
__u64 mnt_id; /* Unique ID of mount */
__u64 mnt_parent_id; /* Unique ID of parent (for root == mnt_id) */
__u32 mnt_id_old; /* Reused IDs used in proc/.../mountinfo */
__u32 mnt_parent_id_old;
__u64 mnt_attr; /* MOUNT_ATTR_... */
__u64 mnt_propagation; /* MS_{SHARED,SLAVE,PRIVATE,UNBINDABLE} */
__u64 mnt_peer_group; /* ID of shared peer group */
__u64 mnt_master; /* Mount receives propagation from this ID */
__u64 propagate_from; /* Propagation from in current namespace */
__aligned_u64 mountpoint;
__u32 mountpoint_len;
__aligned_u64 mountroot;
__u32 mountroot_len;
__u64 __spare[20];
};
Userspace knows already how to deal with that because of bpf and other
structs (e.g., both systemd and LXC have ptr_to_u64() helpers and so
on). Libmount and glibc can hide this away internally as well.
next prev parent reply other threads:[~2023-09-18 16:20 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 15:22 [RFC PATCH 0/3] quering mount attributes Miklos Szeredi
2023-09-13 15:22 ` [RFC PATCH 1/3] add unique mount ID Miklos Szeredi
2023-09-14 9:03 ` Christian Brauner
2023-09-14 9:30 ` Miklos Szeredi
2023-09-14 9:36 ` Christian Brauner
2023-09-14 9:43 ` Miklos Szeredi
2023-09-14 10:06 ` Christian Brauner
2023-09-15 1:31 ` Ian Kent
2023-09-13 15:22 ` [RFC PATCH 2/3] add statmnt(2) syscall Miklos Szeredi
2023-09-14 6:11 ` Amir Goldstein
2023-09-15 1:05 ` Ian Kent
2023-09-14 9:27 ` Christian Brauner
2023-09-14 10:13 ` Miklos Szeredi
2023-09-14 15:26 ` Christian Brauner
2023-09-15 8:56 ` Miklos Szeredi
2023-09-18 13:51 ` Christian Brauner [this message]
2023-09-18 14:14 ` Miklos Szeredi
2023-09-18 14:24 ` Christian Brauner
2023-09-18 14:32 ` Miklos Szeredi
2023-09-18 14:40 ` Christian Brauner
2023-09-18 14:51 ` Miklos Szeredi
2023-09-18 15:22 ` Christian Brauner
2023-09-18 15:39 ` Miklos Szeredi
2023-09-19 0:37 ` Matthew House
2023-09-19 8:02 ` Miklos Szeredi
2023-09-19 9:07 ` Christian Brauner
2023-09-19 10:51 ` Miklos Szeredi
2023-09-19 12:41 ` Christian Brauner
2023-09-19 12:59 ` Miklos Szeredi
2023-09-19 13:18 ` Christian Brauner
2023-09-19 21:28 ` Matthew House
2023-09-20 9:42 ` Miklos Szeredi
2023-09-20 13:26 ` Matthew House
2023-09-21 7:34 ` Miklos Szeredi
2023-09-26 13:48 ` Florian Weimer
2023-09-26 14:06 ` Miklos Szeredi
2023-09-26 14:19 ` Florian Weimer
2023-09-26 14:33 ` Miklos Szeredi
2023-09-26 14:39 ` Florian Weimer
2023-09-26 14:36 ` Christian Brauner
2023-09-26 14:13 ` Christian Brauner
2023-09-18 20:58 ` Andreas Dilger
2023-09-19 12:50 ` Christian Brauner
2023-09-20 0:33 ` Dave Chinner
2023-09-18 14:29 ` Jeff Layton
2023-09-18 14:35 ` Christian Brauner
2023-09-20 9:43 ` David Laight
2023-09-14 20:39 ` Paul Moore
2023-09-15 9:10 ` Miklos Szeredi
2023-09-17 18:18 ` Sargun Dhillon
2023-09-17 23:36 ` Ian Kent
2023-09-18 13:05 ` Christian Brauner
2023-09-25 12:57 ` Arnd Bergmann
2023-09-25 13:04 ` Christian Brauner
2023-09-25 13:13 ` Miklos Szeredi
2023-09-25 13:19 ` Christian Brauner
2023-09-25 13:20 ` Miklos Szeredi
2023-09-25 15:46 ` Arnd Bergmann
2023-09-26 10:05 ` Christian Brauner
2023-09-27 8:46 ` Miklos Szeredi
2023-09-13 15:22 ` [RFC PATCH 3/3] add listmnt(2) syscall Miklos Szeredi
2023-09-14 6:00 ` Amir Goldstein
2023-09-14 8:50 ` Miklos Szeredi
2023-09-14 10:01 ` Christian Brauner
2023-09-15 1:00 ` Ian Kent
2023-09-17 0:54 ` Matthew House
2023-09-17 14:32 ` Miklos Szeredi
2023-09-18 13:15 ` Christian Brauner
2023-09-19 16:47 ` Paul Moore
2023-09-28 10:07 ` Miklos Szeredi
2023-10-04 19:22 ` Paul Moore
2023-09-14 6:47 ` [RFC PATCH 0/3] quering mount attributes Amir Goldstein
2023-09-15 1:20 ` Ian Kent
2023-09-15 3:06 ` Amir Goldstein
2023-09-16 2:04 ` Ian Kent
2023-09-16 2:19 ` Ian Kent
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=20230918-grafik-zutreffen-995b321017ae@brauner \
--to=brauner@kernel.org \
--cc=amir73il@gmail.com \
--cc=christian@brauner.io \
--cc=dhowells@redhat.com \
--cc=kzak@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mszeredi@redhat.com \
--cc=raven@themaw.net \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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.
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).