[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220510123512.h6jjqgowex6gnjh5@ws.net.home>
Date: Tue, 10 May 2022 14:35:12 +0200
From: Karel Zak <kzak@...hat.com>
To: Christian Brauner <brauner@...nel.org>
Cc: Miklos Szeredi <miklos@...redi.hu>, linux-fsdevel@...r.kernel.org,
Dave Chinner <david@...morbit.com>,
Theodore Ts'o <tytso@....edu>,
Greg KH <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org,
Linux API <linux-api@...r.kernel.org>,
linux-man <linux-man@...r.kernel.org>,
LSM <linux-security-module@...r.kernel.org>,
Ian Kent <raven@...maw.net>,
David Howells <dhowells@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>,
Christian Brauner <christian@...uner.io>,
Amir Goldstein <amir73il@...il.com>,
James Bottomley <James.Bottomley@...senpartnership.com>
Subject: Re: [RFC PATCH] getting misc stats/attributes via xattr API
On Mon, May 09, 2022 at 02:48:15PM +0200, Christian Brauner wrote:
> One comment about this. We really need to have this interface support
> giving us mount options like "relatime" back in numeric form (I assume
> this will be possible.). It is royally annoying having to maintain a
> mapping table in userspace just to do:
>
> relatime -> MS_RELATIME/MOUNT_ATTR_RELATIME
> ro -> MS_RDONLY/MOUNT_ATTR_RDONLY
>
> A library shouldn't be required to use this interface. Conservative
> low-level software that keeps its shared library dependencies minimal
> will need to be able to use that interface without having to go to an
> external library that transforms text-based output to binary form (Which
> I'm very sure will need to happen if we go with a text-based
> interface.).
Sounds like David's fsinfo() :-)
We need an interface where the kernel returns a consistent mount table
entry (more syscalls to get more key=value could be a way how to get
inconsistent data).
IMHO all the attempts to make a trivial interface will be unsuccessful
because the mount table is complex (tree) and mixes strings, paths,
and flags. We will always end with a complex interface or complex
strings (like the last xatts attempt). There is no 3rd path to go ...
The best would be simplified fsinfo() where userspace defines
a request (wanted "keys"), and the kernel fills a buffer with data
separated by some header metadata struct. In this case, the kernel can
return strings and structs with binary data.
I'd love something like:
ssize_t sz;
fsinfo_query query[] = {
{ .request = FSINFO_MOUNT_PATH },
{ .request = FSINFO_PROPAGATION },
{ .request = FSINFO_CHILDREN_IDS },
};
sz = fsinfo(dfd, "", AT_EMPTY_PATH,
&query, ARRAY_SIZE(query),
buf, sizeof(buf));
for (p = buf; p < buf + sz; ) {
{
fsinfo_entry *e = (struct fsinfo_entry) p;
char *data = p + sizeof(struct fsinfo_entry);
switch(e->request) {
case FSINFO_MOUNT_PATH:
printf("mountpoint %s\n", data);
break;
case FSINFO_PROPAGATION:
printf("propagation %x\n", (uintptr_t) data);
break;
case FSINFO_CHILDREN_IDS:
fsinfo_child *x = (fsinfo_child *) data;
for (i = 0; i < e->count; i++) {
printf("child: %d\n", x[i].mnt_id);
}
break;
...
}
p += sizeof(struct fsinfo_entry) + e->len;
}
... my two cents :-)
Karel
--
Karel Zak <kzak@...hat.com>
http://karelzak.blogspot.com
Powered by blists - more mailing lists