If I can't resolve the range, maybe it'd be better to just not return the info at all? Are the first and third fields of any value without the second? > Note that statmount() requires that the whole range must be resolvable > in the caller's user namespace. If a subrange fails to map it will still > list the map as not resolvable. This is a practical compromise to avoid > having to find which subranges are resovable and wich aren't. > > Idmappings are listed as a string array with each mapping separated by > zero bytes. This allows to retrieve the idmappings and immediately use > them for writing to e.g., /proc/<pid>/{g,u}id_map and it also allow for > simple iteration like: > > if (stmnt->mask & STATMOUNT_MNT_UIDMAP) { > const char *idmap = stmnt->str + stmnt->mnt_uidmap; > > for (size_t idx = 0; idx < stmnt->mnt_uidmap_nr; idx++) { > printf("mnt_uidmap[%lu]: %s\n", idx, idmap); > idmap += strlen(idmap) + 1; > } > } > > Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx> > --- > Christian Brauner (4): > uidgid: add map_id_range_up() > statmount: allow to retrieve idmappings > samples/vfs: check whether flag was raised > samples/vfs: add STATMOUNT_MNT_{G,U}IDMAP > > fs/internal.h | 1 + > fs/mnt_idmapping.c | 49 ++++++++++++++++++++++++++++++++++++++ > fs/namespace.c | 43 ++++++++++++++++++++++++++++++++- > include/linux/uidgid.h | 6 +++++ > include/uapi/linux/mount.h | 8 ++++++- > kernel/user_namespace.c | 26 +++++++++++++------- > samples/vfs/samples-vfs.h | 14 ++++++++++- > samples/vfs/test-list-all-mounts.c | 35 ++++++++++++++++++++++----- > 8 files changed, 164 insertions(+), 18 deletions(-) > --- > base-commit: 6d61a53dd6f55405ebcaea6ee38d1ab5a8856c2c > change-id: 20250129-work-mnt_idmap-statmount-e57f258fef8e > -- Jeff Layton <jlayton@xxxxxxxxxx>