[RFC PATCH] getting misc stats/attributes via xattr API
Karel Zak
kzak at redhat.com
Wed May 11 08:58:37 UTC 2022
On Wed, May 11, 2022 at 09:25:52AM +1000, Dave Chinner wrote:
> > 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;
> > }
>
> That's pretty much what a multi-xattr get operation looks like.
> It's a bit more more intricate in the setup of the request/return
> buffer, but otherwise the structure of the code is the same.
>
> I just don't see why we need special purpose interfaces like this
> for key/value information when small tweaks to the existing
> generic key/value interfaces can provide exactly the same
> functionality....
I don't say we need a new interface ;-) I'd be happy with whatever as
long as:
* minimal strings parsing (wish than a requirement)
* one syscall returns multiple key/value
* can address mount table entries by ID
* can ask for list of children (submounts)
* extensible
if this will be possible with xattr (listxattr2(), or so) when great.
Karel
--
Karel Zak <kzak at redhat.com>
http://karelzak.blogspot.com
More information about the Linux-security-module-archive
mailing list