diff --git a/kmod/src/ioctl.c b/kmod/src/ioctl.c index bee29df7..c1d64aa0 100644 --- a/kmod/src/ioctl.c +++ b/kmod/src/ioctl.c @@ -848,6 +848,27 @@ out: return ret ?: total; } +static long scoutfs_ioc_statfs_more(struct file *file, unsigned long arg) +{ + struct super_block *sb = file_inode(file)->i_sb; + struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); + struct scoutfs_super_block *super = &sbi->super; + struct scoutfs_ioctl_statfs_more sfm; + + if (get_user(sfm.valid_bytes, (__u64 __user *)arg)) + return -EFAULT; + + sfm.valid_bytes = min_t(u64, sfm.valid_bytes, + sizeof(struct scoutfs_ioctl_statfs_more)); + sfm.fsid = le64_to_cpu(super->hdr.fsid); + sfm.rid = sbi->rid; + + if (copy_to_user((void __user *)arg, &sfm, sfm.valid_bytes)) + return -EFAULT; + + return 0; +} + long scoutfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { switch (cmd) { @@ -871,6 +892,8 @@ long scoutfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return scoutfs_ioc_listxattr_hidden(file, arg); case SCOUTFS_IOC_FIND_XATTRS: return scoutfs_ioc_find_xattrs(file, arg); + case SCOUTFS_IOC_STATFS_MORE: + return scoutfs_ioc_statfs_more(file, arg); } return -ENOTTY; diff --git a/kmod/src/ioctl.h b/kmod/src/ioctl.h index 5aa057c0..5693668e 100644 --- a/kmod/src/ioctl.h +++ b/kmod/src/ioctl.h @@ -347,4 +347,26 @@ struct scoutfs_ioctl_find_xattrs { #define SCOUTFS_IOC_FIND_XATTRS _IOR(SCOUTFS_IOCTL_MAGIC, 10, \ struct scoutfs_ioctl_find_xattrs) +/* + * Give the user information about the filesystem. + * + * @valid_bytes stores the number of bytes that are valid in the + * structure. The caller sets this to the size of the struct that they + * understand. The kernel then fills and copies back the min of the + * size they and the user caller understand. The user can tell if a + * field is set if all of its bytes are within the valid_bytes that the + * kernel set on return. + * + * New fields are only added to the end of the struct. + */ +struct scoutfs_ioctl_statfs_more { + __u64 valid_bytes; + __u64 fsid; + __u64 rid; +} __packed; + +#define SCOUTFS_IOC_STATFS_MORE _IOR(SCOUTFS_IOCTL_MAGIC, 11, \ + struct scoutfs_ioctl_statfs_more) + + #endif