btrfs: add GET_SUPPORTED_FEATURES to the control device ioctls
authorDavid Sterba <dsterba@suse.com>
Wed, 17 Feb 2016 14:24:14 +0000 (15:24 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Feb 2016 11:56:21 +0000 (12:56 +0100)
The control device is accessible when no filesystem is mounted and we
may want to query features supported by the module. This is already
possible using the sysfs files, this ioctl is for parity and
convenience.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/ioctl.c
fs/btrfs/super.c

index bfe4a337fb4d13a058446265b7baf4a1437aa602..47bc50fd4f55fee3dbc70450a650b6a43127739f 100644 (file)
@@ -4089,6 +4089,7 @@ void btrfs_test_inode_set_ops(struct inode *inode);
 
 /* ioctl.c */
 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+int btrfs_ioctl_get_supported_features(struct file *file, void __user *arg);
 void btrfs_update_iflags(struct inode *inode);
 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
 int btrfs_is_empty_uuid(u8 *uuid);
index 952172ca7e455633c28a79292d18ebbfd68c4d18..f4c6ed5c530069f5fa3b7b9419c93659f829f449 100644 (file)
@@ -5187,8 +5187,7 @@ out_unlock:
          .compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_##suffix, \
          .incompat_flags = BTRFS_FEATURE_INCOMPAT_##suffix }
 
-static int btrfs_ioctl_get_supported_features(struct file *file,
-                                             void __user *arg)
+int btrfs_ioctl_get_supported_features(struct file *file, void __user *arg)
 {
        static const struct btrfs_ioctl_feature_flags features[3] = {
                INIT_FEATURE_FLAGS(SUPP),
index d41e09fe8e38d77674862c7fe61f610a81d1159d..dda6f64dfd738e4619f540aecf9915363573508b 100644 (file)
@@ -2163,6 +2163,10 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
                        break;
                ret = !(fs_devices->num_devices == fs_devices->total_devices);
                break;
+       case BTRFS_IOC_GET_SUPPORTED_FEATURES:
+               ret = btrfs_ioctl_get_supported_features(NULL,
+                               (void __user*)arg);
+               break;
        }
 
        kfree(vol);