filesystem visibililty ioctls
Subsystems (15)
v3 cover filesystem visibililty ioctls
ok, any further bikeshedding better be along the lines of "this will cause a gaping security hole unless addressed" ;)
changes since v2:
- now using nak (0x15) ioctl range; documentation updated
- new helpers for setting the sysfs name
- sysfs name uuid now has a length field
other notes:
- fscrypt usage of s_uuid has justification, so we don't need to be concerned about exporting that (more) to userspace
- i haven't updated btrfs for FS_IOC_SYSFS_NAME, less familiar with their code so they are cc'd
ext4 may want this too?
Kent Overstreet (7):
fs: super_set_uuid()
overlayfs: Convert to super_set_uuid()
fs: FS_IOC_GETUUID
fat: Hook up sb->s_uuid
fs: FS_IOC_GETSYSFSNAME
xfs: add support for FS_IOC_GETSYSFSNAME
bcachefs: add support for FS_IOC_GETSYSFSNAME
.../userspace-api/ioctl/ioctl-number.rst | 3 +- fs/bcachefs/fs.c | 3 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fat/inode.c | 3 ++ fs/gfs2/ops_fstype.c | 2 +- fs/ioctl.c | 33 ++++++++++++ fs/kernfs/mount.c | 4 +- fs/ocfs2/super.c | 4 +- fs/overlayfs/util.c | 14 +++-- fs/ubifs/super.c | 2 +- fs/xfs/xfs_mount.c | 4 +- include/linux/fs.h | 51 +++++++++++++++++++ include/uapi/linux/fs.h | 27 ++++++++++ mm/shmem.c | 4 +- 15 files changed, 142 insertions(+), 16 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/7 fs: super_set_uuid()
Some weird old filesytems have UUID-like things that we wish to expose as UUIDs, but are smaller; add a length field so that the new FS_IOC_(GET|SET)UUID ioctls can handle them in generic code.
And add a helper super_set_uuid(), for setting nonstandard length uuids.
Helper is now required for the new FS_IOC_GETUUID ioctl; if super_set_uuid() hasn't been called, the ioctl won't be supported.
--- fs/bcachefs/fs.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/gfs2/ops_fstype.c | 2 +- fs/kernfs/mount.c | 4 +++- fs/ocfs2/super.c | 4 ++-- fs/ubifs/super.c | 2 +- fs/xfs/xfs_mount.c | 2 +- include/linux/fs.h | 9 +++++++++ mm/shmem.c | 4 +++- 10 files changed, 23 insertions(+), 10 deletions(-)
fs/bcachefs/fs.c +1 -1
@@ -1946,7 +1946,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, sb->s_time_gran = c->sb.nsec_per_time_unit; sb->s_time_min =div_s64 (S64_MIN , c->sb.time_units_per_sec) +1 ; sb->s_time_max =div_s64 (S64_MAX , c->sb.time_units_per_sec); - sb->s_uuid = c->sb.user_uuid; +super_set_uuid (sb, c->sb.user_uuid.b,sizeof (c->sb.user_uuid)); c->vfs_sb = sb;strscpy (sb->s_id, c->name,sizeof (sb->s_id));
fs/ext4/super.c +1 -1
@@ -5346,7 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sb->s_qcop = &ext4_qctl_operations; sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP |QTYPE_MASK_PRJ ;#endif -memcpy (&sb->s_uuid, es->s_uuid,sizeof (es->s_uuid)); +super_set_uuid (sb, es->s_uuid,sizeof (es->s_uuid));INIT_LIST_HEAD (&sbi->s_orphan);/* unlinked but open files */ mutex_init (&sbi->s_orphan_lock);
fs/f2fs/super.c +1 -1
@@ -4496,7 +4496,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) sb->s_time_gran =1 ; sb->s_flags = (sb->s_flags & ~SB_POSIXACL ) | (test_opt (sbi,POSIX_ACL ) ?SB_POSIXACL :0 ); -memcpy (&sb->s_uuid, raw_super->uuid,sizeof (raw_super->uuid)); +super_set_uuid (&sb, (void *) raw_super->uuid,sizeof (raw_super->uuid)); sb->s_iflags |=SB_I_CGROUPWB ;/* init f2fs-specific super block info */
fs/gfs2/ops_fstype.c +1 -1
@@ -214,7 +214,7 @@ static void gfs2_sb_in(struct gfs2_sbd *sdp, const void *buf)memcpy (sb->sb_lockproto, str->sb_lockproto,GFS2_LOCKNAME_LEN );memcpy (sb->sb_locktable, str->sb_locktable,GFS2_LOCKNAME_LEN ); -memcpy (&s->s_uuid, str->sb_uuid,16 ); +super_set_uuid (s, str->sb_uuid,16 ); }/**
fs/kernfs/mount.c +3 -1
@@ -358,7 +358,9 @@ int kernfs_get_tree(struct fs_context *fc) } sb->s_flags |=SB_ACTIVE ; -uuid_gen (&sb->s_uuid); +uuid_t uuid; +uuid_gen (&uuid); +super_set_uuid (sb, uuid.b,sizeof (uuid));down_write (&root->kernfs_supers_rwsem);list_add (&info->node, &info->root->supers);
fs/ocfs2/super.c +2 -2
@@ -2027,8 +2027,8 @@ static int ocfs2_initialize_super(struct super_block *sb, cbits =le32_to_cpu (di->id2.i_super.s_clustersize_bits); bbits =le32_to_cpu (di->id2.i_super.s_blocksize_bits); sb->s_maxbytes =ocfs2_max_file_offset (bbits, cbits); -memcpy (&sb->s_uuid, di->id2.i_super.s_uuid, -sizeof (di->id2.i_super.s_uuid)); +super_set_uuid (sb, di->id2.i_super.s_uuid, +sizeof (di->id2.i_super.s_uuid)); osb->osb_dx_mask = (1 << (cbits - bbits)) -1 ;
fs/ubifs/super.c +1 -1
@@ -2245,7 +2245,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) goto out_umount; } -import_uuid (&sb->s_uuid, c->uuid); +super_set_uuid (sb, c->uuid,sizeof (c->uuid));mutex_unlock (&c->umount_mutex);return 0 ;
fs/xfs/xfs_mount.c +1 -1
@@ -62,7 +62,7 @@ xfs_uuid_mount(int hole, i;/* Publish UUID in struct super_block */ -uuid_copy (&mp->m_super->s_uuid, uuid); +super_set_uuid (mp->m_super, uuid->b,sizeof (*uuid));if (xfs_has_nouuid (mp))return 0 ;
include/linux/fs.h +9 -0
@@ -1257,6 +1257,7 @@ struct super_block {char s_id[32 ];/* Informational name */ uuid_t s_uuid;/* UUID */ +u8 s_uuid_len;/* Default 16, possibly smaller for weird filesystems */ unsigned int s_max_links;
@@ -2532,6 +2533,14 @@ extern __printf(2, 3)int super_setup_bdi_name (struct super_block *sb,char *fmt, ...);extern int super_setup_bdi (struct super_block *sb); +static inline void super_set_uuid (struct super_block *sb,const u8 *uuid,unsigned len) +{ +if (WARN_ON (len >sizeof (sb->s_uuid))) + len =sizeof (sb->s_uuid); + sb->s_uuid_len = len; +memcpy (&sb->s_uuid, uuid, len); +} +extern int current_umask (void );extern void ihold (struct inode * inode);
mm/shmem.c +3 -1
@@ -4355,7 +4355,9 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc)#ifdef CONFIG_TMPFS_POSIX_ACL sb->s_flags |=SB_POSIXACL ;#endif -uuid_gen (&sb->s_uuid); +uuid_t uuid; +uuid_gen (&uuid); +super_set_uuid (sb, uuid.b,sizeof (uuid));#ifdef CONFIG_TMPFS_QUOTA if (ctx->seen &SHMEM_SEEN_QUOTA ) {
Signature · 1 line
2.43.0
Christian Brauner
maintainerRe: [PATCH v3 1/7] fs: super_set_uuid()
fs/f2fs/super.c static int f2fs_fill_super(struct super_block *sb, void *data, int silent) · line 4499
Quoted 10 lines
fs/f2fs/super.c +1
-1@@ -4496,7 +4496,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) sb->s_time_gran =1 ; sb->s_flags = (sb->s_flags & ~SB_POSIXACL ) | (test_opt (sbi,POSIX_ACL ) ?SB_POSIXACL :0 ); -memcpy (&sb->s_uuid, raw_super->uuid,sizeof (raw_super->uuid)); +super_set_uuid (&sb, (void *) raw_super->uuid,sizeof (raw_super->uuid));
This won't compile because of &sb. This wants to be sb... I fixed that up.
PATCH v3 2/7 overlayfs: Convert to super_set_uuid()
In reply to Kent OverstreetWe don't want to be settingc sb->s_uuid directly anymore, as there's a length field that also has to be set, and this conversion was not completely trivial.
--- fs/overlayfs/util.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
fs/overlayfs/util.c +9 -5
@@ -760,13 +760,14 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs, const struct path *upperpath) {bool set = false; +uuid_t uuid;int res;/* Try to load existing persistent uuid */ - res =ovl_path_getxattr (ofs, upperpath,OVL_XATTR_UUID , sb->s_uuid.b, + res =ovl_path_getxattr (ofs, upperpath,OVL_XATTR_UUID , uuid.b,UUID_SIZE );if (res ==UUID_SIZE ) -return true; + goto success;if (res != -ENODATA ) goto fail;
@@ -794,14 +795,14 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs, }/* Generate overlay instance uuid */ -uuid_gen (&sb->s_uuid); +uuid_gen (&uuid);/* Try to store persistent uuid */ set = true; - res =ovl_setxattr (ofs, upperpath->dentry,OVL_XATTR_UUID , sb->s_uuid.b, + res =ovl_setxattr (ofs, upperpath->dentry,OVL_XATTR_UUID , uuid.b,UUID_SIZE );if (res ==0 ) -return true; + goto success; fail:memset (sb->s_uuid.b,0 ,UUID_SIZE );
@@ -809,6 +810,9 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs,pr_warn ("failed to %s uuid (%pd2, err=%i); falling back to uuid=null.\n" , set ?"set" :"get" , upperpath->dentry, res);return false; +success: +super_set_uuid (sb, uuid.b,sizeof (uuid)); +return true; } bool ovl_path_check_dir_xattr(struct ovl_fs *ofs, const struct path *path,
Signature · 1 line
2.43.0
PATCH v3 3/7 fs: FS_IOC_GETUUID
In reply to Kent OverstreetAdd a new generic ioctls for querying the filesystem UUID.
These are lifted versions of the ext4 ioctls, with one change: we're not using a flexible array member, because UUIDs will never be more than 16 bytes.
This patch adds a generic implementation of FS_IOC_GETFSUUID, which reads from super_block->s_uuid. We're not lifting SETFSUUID from ext4 - that can be done on offline filesystems by the people who need it, trying to do it online is just asking for too much trouble.
--- .../userspace-api/ioctl/ioctl-number.rst | 3 ++- fs/ioctl.c | 16 ++++++++++++++++ include/uapi/linux/fs.h | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-)
Documentation/userspace-api/ioctl/ioctl-number.rst +2 -1
@@ -82,8 +82,9 @@ Code Seq# Include File Comments 0x10 00-0F drivers/char/s390/vmcp.h 0x10 10-1F arch/s390/include/uapi/sclp_ctl.h 0x10 20-2F arch/s390/include/uapi/asm/hypfs.h -0x12 all linux/fs.h +0x12 all linux/fs.h BLK* ioctls linux/blkpg.h +0x15 all linux/fs.h FS_IOC_* ioctls 0x1b all InfiniBand Subsystem <http://infiniband.sourceforge.net/> 0x20 all drivers/cdrom/cm206.h
fs/ioctl.c +16 -0
@@ -763,6 +763,19 @@ static int ioctl_fssetxattr(struct file *file, void __user *argp)return err; } +static int ioctl_getfsuuid (struct file *file,void __user *argp) +{ +struct super_block *sb =file_inode (file)->i_sb; +struct fsuuid2 u = { .len = sb->s_uuid_len, }; + +if (!sb->s_uuid_len) +return -ENOIOCTLCMD ; + +memcpy (&u.uuid[0 ], &sb->s_uuid, sb->s_uuid_len); + +return copy_to_user (argp, &u,sizeof (u)) ? -EFAULT :0 ; +} +/* * do_vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d. * It's just a simple helper for sys_ioctl and compat_sys_ioctl.
@@ -845,6 +858,9 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,case FS_IOC_FSSETXATTR :return ioctl_fssetxattr (filp, argp); +case FS_IOC_GETFSUUID : +return ioctl_getfsuuid (filp, argp); +default :if (S_ISREG (inode->i_mode))return file_ioctl (filp, cmd, argp);
include/uapi/linux/fs.h +16 -0
@@ -64,6 +64,19 @@ struct fstrim_range {__u64 minlen; }; +/* +* We include a length field because some filesystems (vfat) have an identifier +* that we do want to expose as a UUID, but doesn't have the standard length. +* +* We use a fixed size buffer beacuse this interface will, by fiat, never +* support "UUIDs" longer than 16 bytes; we don't want to force all downstream +* users to have to deal with that. +*/ +struct fsuuid2 { +__u8 len; +__u8 uuid[16 ]; +}; +/* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */ #define FILE_DEDUPE_RANGE_SAME 0#define FILE_DEDUPE_RANGE_DIFFERS 1
@@ -190,6 +203,9 @@ struct fsxattr {* (see uapi/linux/blkzoned.h) */ +/* Returns the external filesystem UUID, the same one blkid returns */ +#define FS_IOC_GETFSUUID _IOR(0x15, 0, struct fsuuid2) +#define BMAP_IOCTL 1/* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1)/* bmap access */ #define FIGETBSZ _IO(0x00,2)/* get the block size used for bmap */
Signature · 1 line
2.43.0
Amir Goldstein
maintainerRe: [PATCH v3 3/7] fs: FS_IOC_GETUUID
Quoted 99 lines · Kent Overstreet
Add a new generic ioctls for querying the filesystem UUID.
These are lifted versions of the ext4 ioctls, with one change: we're not using a flexible array member, because UUIDs will never be more than 16 bytes.
This patch adds a generic implementation of
FS_IOC_GETFSUUID, which reads fromsuper_block->s_uuid. We're not lifting SETFSUUID from ext4 - that can be done on offline filesystems by the people who need it, trying to do it online is just asking for too much trouble.Cc Christian Brauner <[email protected]>Cc Jan Kara <[email protected]>Cc Dave Chinner <[email protected]>Cc "Darrick J. Wong" <[email protected]>Cc Theodore Ts'o <[email protected]>Signed-off-by Kent Overstreet <[email protected]>--- .../userspace-api/ioctl/ioctl-number.rst | 3 ++- fs/ioctl.c | 16 ++++++++++++++++ include/uapi/linux/fs.h | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-)Documentation/userspace-api/ioctl/ioctl-number.rst +2
-1@@ -82,8 +82,9 @@ Code Seq# Include File Comments 0x10 00-0F drivers/char/s390/vmcp.h 0x10 10-1F arch/s390/include/uapi/sclp_ctl.h 0x10 20-2F arch/s390/include/uapi/asm/hypfs.h -0x12 all linux/fs.h +0x12 all linux/fs.h BLK* ioctls linux/blkpg.h +0x15 all linux/fs.h FS_IOC_* ioctls 0x1b all InfiniBand Subsystem <http://infiniband.sourceforge.net/> 0x20 all drivers/cdrom/cm206.hfs/ioctl.c +16
-0@@ -763,6 +763,19 @@ static int ioctl_fssetxattr(struct file *file, void __user *argp)return err; } +static int ioctl_getfsuuid (struct file *file,void __user *argp) +{ +struct super_block *sb =file_inode (file)->i_sb; +struct fsuuid2 u = { .len = sb->s_uuid_len, }; + +if (!sb->s_uuid_len) +return -ENOIOCTLCMD ; + +memcpy (&u.uuid[0 ], &sb->s_uuid, sb->s_uuid_len); + +return copy_to_user (argp, &u,sizeof (u)) ? -EFAULT :0 ; +} +/* * do_vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d. * It's just a simple helper for sys_ioctl and compat_sys_ioctl. @@ -845,6 +858,9 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,case FS_IOC_FSSETXATTR :return ioctl_fssetxattr (filp, argp); +case FS_IOC_GETFSUUID : +return ioctl_getfsuuid (filp, argp); +default :if (S_ISREG (inode->i_mode))return file_ioctl (filp, cmd, argp);include/uapi/linux/fs.h +13
-0@@ -64,6 +64,19 @@ struct fstrim_range {__u64 minlen; }; +/* +* We include a length field because some filesystems (vfat) have an identifier +* that we do want to expose as a UUID, but doesn't have the standard length. +* +* We use a fixed size buffer beacuse this interface will, by fiat, never +* support "UUIDs" longer than 16 bytes; we don't want to force all downstream +* users to have to deal with that. +*/ +struct fsuuid2 { +__u8 len; +__u8 uuid[16 ]; +}; +/* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */ #define FILE_DEDUPE_RANGE_SAME 0#define FILE_DEDUPE_RANGE_DIFFERS 1
include/uapi/linux/fs.h struct fsxattr { · line 207
Quoted 5 lines
include/uapi/linux/fs.h +2
-0@@ -190,6 +203,9 @@ struct fsxattr {* (see uapi/linux/blkzoned.h) */ +/* Returns the external filesystem UUID, the same one blkid returns */ +#define FS_IOC_GETFSUUID _IOR(0x15, 0, struct fsuuid2)
Please move that to the end of FS_IOC_* ioctls block.
The fact that it started a new vfs ioctl namespace does not justify starting a different list IMO.
uapi readers don't care about the value of the ioctl. locality to FS_IOC_GETFSLABEL is more important IMO.
Thanks,
Amir.
Quoted 8 lines
include/uapi/linux/fs.h +1
-1+#define BMAP_IOCTL 1/* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1)/* bmap access */ #define FIGETBSZ _IO(0x00,2)/* get the block size used for bmap */ --2.43.0
Amir Goldstein
maintainerRe: [PATCH v3 3/7] fs: FS_IOC_GETUUID
Quoted 15 lines · Amir Goldstein
Quoted 12 lines · Kent Overstreet
Add a new generic ioctls for querying the filesystem UUID.
These are lifted versions of the ext4 ioctls, with one change: we're not using a flexible array member, because UUIDs will never be more than 16 bytes.
This patch adds a generic implementation of
FS_IOC_GETFSUUID, which reads fromsuper_block->s_uuid. We're not lifting SETFSUUID from ext4 - that can be done on offline filesystems by the people who need it, trying to do it online is just asking for too much trouble.
Quoted 6 lines
Quoted 6 lines
Cc Christian Brauner <[email protected]>Cc Jan Kara <[email protected]>Cc Dave Chinner <[email protected]>Cc "Darrick J. Wong" <[email protected]>Cc Theodore Ts'o <[email protected]>
typo in list address.
Thanks,
Amir.
Christian Brauner
maintainerRe: [PATCH v3 3/7] fs: FS_IOC_GETUUID
In reply to Amir GoldsteinQuoted 1 line
Please move that to the end of FS_IOC_* ioctls block.
Done by me during applying.
Quoted 1 line
typo in list address.
Fixed.
PATCH v3 4/7 fat: Hook up sb->s_uuid
In reply to Kent OverstreetNow that we have a standard ioctl for querying the filesystem UUID, initialize sb->s_uuid so that it works.
--- fs/fat/inode.c | 3 +++ 1 file changed, 3 insertions(+)
fs/fat/inode.c +3 -0
@@ -1762,6 +1762,9 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,else /* fat 16 or 12 */ sbi->vol_id = bpb.fat16_vol_id; +__le32 vol_id_le =cpu_to_le32 (sbi->vol_id); +super_set_uuid (sb, (void *) &vol_id_le,sizeof (vol_id_le)); + sbi->dir_per_block = sb->s_blocksize /sizeof (struct msdos_dir_entry ); sbi->dir_per_block_bits =ffs (sbi->dir_per_block) -1 ;
Signature · 1 line
2.43.0
PATCH v3 5/7 fs: FS_IOC_GETSYSFSNAME
In reply to Kent OverstreetAdd a new ioctl for getting the sysfs name of a filesystem - the path under /sys/fs.
This is going to let us standardize exporting data from sysfs across filesystems, e.g. time stats.
The returned path will always be of the form "$FSTYP/$SYSFS_IDENTIFIER", where the sysfs identifier may be a UUID (for bcachefs) or a device name (xfs).
--- fs/ioctl.c | 17 +++++++++++++++++ include/linux/fs.h | 42 +++++++++++++++++++++++++++++++++++++++++ include/uapi/linux/fs.h | 11 +++++++++++ 3 files changed, 70 insertions(+)
fs/ioctl.c +17 -0
@@ -776,6 +776,20 @@ static int ioctl_getfsuuid(struct file *file, void __user *argp)return copy_to_user (argp, &u,sizeof (u)) ? -EFAULT :0 ; } +static int ioctl_get_fs_sysfs_path (struct file *file,void __user *argp) +{ +struct super_block *sb =file_inode (file)->i_sb; + +if (!strlen (sb->s_sysfs_name)) +return -ENOIOCTLCMD ; + +struct fs_sysfs_path u = {}; + + u.len =scnprintf (u.name,sizeof (u.name),"%s/%s" , sb->s_type->name, sb->s_sysfs_name); + +return copy_to_user (argp, &u,sizeof (u)) ? -EFAULT :0 ; +} +/* * do_vfs_ioctl() is not for drivers and not intended to be EXPORT_SYMBOL()'d. * It's just a simple helper for sys_ioctl and compat_sys_ioctl.
@@ -861,6 +875,9 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,case FS_IOC_GETFSUUID :return ioctl_getfsuuid (filp, argp); +case FS_IOC_GETFSSYSFSPATH : +return ioctl_get_fs_sysfs_path (filp, argp); +default :if (S_ISREG (inode->i_mode))return file_ioctl (filp, cmd, argp);
include/linux/fs.h +42 -0
58 lines not on this page · raw message
include/uapi/linux/fs.h +11 -0
@@ -77,6 +77,11 @@ struct fsuuid2 {__u8 uuid[16 ]; }; +struct fs_sysfs_path { +__u8 len; +__u8 name[128 ]; +}; +/* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */ #define FILE_DEDUPE_RANGE_SAME 0#define FILE_DEDUPE_RANGE_DIFFERS 1
@@ -206,6 +211,12 @@ struct fsxattr {/* Returns the external filesystem UUID, the same one blkid returns */ #define FS_IOC_GETFSUUID _IOR(0x15, 0, struct fsuuid2) +/* +* Returns the path component under /sys/fs/ that refers to this filesystem; +* also /sys/kernel/debug/ for filesystems with debugfs exports +*/ +#define FS_IOC_GETFSSYSFSPATH _IOR(0x15, 1, struct fs_sysfs_path) +#define BMAP_IOCTL 1/* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1)/* bmap access */ #define FIGETBSZ _IO(0x00,2)/* get the block size used for bmap */
Signature · 1 line
2.43.0
Christian Brauner
maintainerRe: [PATCH v3 5/7] fs: FS_IOC_GETSYSFSNAME
Quoted 10 lines · Kent Overstreet
Add a new ioctl for getting the sysfs name of a filesystem - the path under
/sys/fs.This is going to let us standardize exporting data from sysfs across filesystems, e.g. time stats.
The returned path will always be of the form "$FSTYP/$SYSFS_IDENTIFIER", where the sysfs identifier may be a UUID (for bcachefs) or a device name (xfs).
Quoted 8 lines
Cc Christian Brauner <[email protected]>Cc Jan Kara <[email protected]>Cc Dave Chinner <[email protected]>Cc "Darrick J. Wong" <[email protected]>Cc Theodore Ts'o <[email protected]>Cc Josef Bacik <[email protected]>Signed-off-by Kent Overstreet <[email protected]>---
The ioctl is called FS_IOC_GETFSSYSFSPATH but commit message states FS_IOC_GETSYSFSNAME. Similar for the following commits. I fixed this up but please try to make sure that this matches.
It would also be really nice to see some additional ACKs from other fs maintainers for this ioctl.
PATCH v3 6/7 xfs: add support for FS_IOC_GETSYSFSNAME
In reply to Kent Overstreet--- fs/xfs/xfs_mount.c | 2 ++ 1 file changed, 2 insertions(+)
fs/xfs/xfs_mount.c +2 -0
@@ -706,6 +706,8 @@ xfs_mountfs(/* enable fail_at_unmount as default */ mp->m_fail_unmount = true; +super_set_sysfs_name_id (mp->m_super); + error =xfs_sysfs_init (&mp->m_kobj, &xfs_mp_ktype,NULL , mp->m_super->s_id);if (error)
Signature · 1 line
2.43.0
PATCH v3 7/7 bcachefs: add support for FS_IOC_GETSYSFSNAME
In reply to Kent Overstreet--- fs/bcachefs/fs.c | 1 + 1 file changed, 1 insertion(+)
fs/bcachefs/fs.c +1 -0
@@ -1947,6 +1947,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, sb->s_time_min =div_s64 (S64_MIN , c->sb.time_units_per_sec) +1 ; sb->s_time_max =div_s64 (S64_MAX , c->sb.time_units_per_sec);super_set_uuid (sb, c->sb.user_uuid.b,sizeof (c->sb.user_uuid)); +super_set_sysfs_name_uuid (sb); c->vfs_sb = sb;strscpy (sb->s_id, c->name,sizeof (sb->s_id));
Signature · 1 line
2.43.0
Quoted 9 lines · Kent Overstreet
ok, any further bikeshedding better be along the lines of "this will cause a gaping security hole unless addressed" ;)
changes since v2:
- now using nak (0x15) ioctl range; documentation updated
- new helpers for setting the sysfs name
- sysfs name uuid now has a length field[...]
I've merged that series and put it onto vfs.uuid. I think we should really see some more ACKs from other filesystems maintainers for the FS_IOC_GETFSSYSFSPATH bits. Once we have that we can declare that branch stable.
Note, I dropped the bcachefs changes because they're not upstream yet. But once this is a stable branch you can just pull in vfs.uuid and rely on that.
---
Applied to the vfs.uuid branch of the vfs/vfs.git tree. Patches in the vfs.uuid branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.uuid
[1/6] fs: super_set_uuid()
https://git.kernel.org/vfs/vfs/c/4d451351605f [2/6] overlayfs: Convert to super_set_uuid() https://git.kernel.org/vfs/vfs/c/5ad6ddd9c998 [3/6] fs: FS_IOC_GETUUID https://git.kernel.org/vfs/vfs/c/51ee9232f372 [4/6] fat: Hook up sb->s_uuid https://git.kernel.org/vfs/vfs/c/05dc73e146be [5/6] fs: add FS_IOC_GETFSSYSFSPATH https://git.kernel.org/vfs/vfs/c/3dad731c7a45 [6/6] xfs: add support for FS_IOC_GETFSSYSFSPATH https://git.kernel.org/vfs/vfs/c/aa4386d4df60