Re: [RFC PATCH] getting misc stats/attributes via xattr API
From: Karel Zak <kzak@redhat.com>
Date: 2022-05-11 08:59:00
Also in:
linux-api, linux-fsdevel, linux-man, lkml
On Wed, May 11, 2022 at 09:25:52AM +1000, Dave Chinner wrote:
quoted
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 [off-list ref] http://karelzak.blogspot.com