On Wed, 6 Nov 2024 at 20:53, Jeff Layton <jlayton@xxxxxxxxxx> wrote: > > /proc/self/mountinfo displays the devicename for the mount, but > statmount() doesn't yet have a way to return it. Add a new > STATMOUNT_MNT_DEVNAME flag, claim the 32-bit __spare1 field to hold the > offset into the str[] array. STATMOUNT_MNT_DEVNAME will only be set in > the return mask if there is a device string. > > Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx> > --- > fs/namespace.c | 25 ++++++++++++++++++++++++- > include/uapi/linux/mount.h | 3 ++- > 2 files changed, 26 insertions(+), 2 deletions(-) > > diff --git a/fs/namespace.c b/fs/namespace.c > index 52ab892088f08ad71647eff533dd6f3025bbae03..d4ed2cb5de12c86b4da58626441e072fc109b2ff 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -5014,6 +5014,19 @@ static void statmount_fs_subtype(struct kstatmount *s, struct seq_file *seq) > seq_puts(seq, sb->s_subtype); > } > > +static int statmount_mnt_devname(struct kstatmount *s, struct seq_file *seq) > +{ > + struct super_block *sb = s->mnt->mnt_sb; > + struct mount *r = real_mount(s->mnt); > + > + if (sb->s_op->show_devname) > + return sb->s_op->show_devname(seq, s->mnt->mnt_root); I think the resulting string should be unescaped just like statmount_mnt_root(). The same goes for the option strings, which went in last cycle. I see no reason to require users of this interface to implement unescaping themselves. Others beside libmount probably won't do it and will be surprised when encountering escaped strings because they are rare. Thanks, Miklos