btrfs: sysfs: replace direct access to feature set names with a helper
authorDavid Sterba <dsterba@suse.com>
Thu, 1 Aug 2019 17:07:55 +0000 (19:07 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 9 Sep 2019 12:59:07 +0000 (14:59 +0200)
In order to unexport the feature type array, add a helper for the
enum-to-string conversion.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c
fs/btrfs/sysfs.c
fs/btrfs/sysfs.h

index b431f7877e8861a3c3a4865b77afbb705afc1519..4eabd419aacab142b58927744ad2a645c41f1455 100644 (file)
@@ -5259,7 +5259,7 @@ static int check_feature_bits(struct btrfs_fs_info *fs_info,
                              u64 change_mask, u64 flags, u64 supported_flags,
                              u64 safe_set, u64 safe_clear)
 {
-       const char *type = btrfs_feature_set_names[set];
+       const char *type = btrfs_feature_set_name(set);
        char *names;
        u64 disallowed, unsupported;
        u64 set_mask = flags & change_mask;
index bc82ab66ba8f8ddce60e693f48ef9c1888736cb5..c7c29e5b38a0501da95730e8d526f7ed11ed0cd3 100644 (file)
@@ -675,12 +675,17 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
        btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL);
 }
 
-const char * const btrfs_feature_set_names[FEAT_MAX] = {
+static const char * const btrfs_feature_set_names[FEAT_MAX] = {
        [FEAT_COMPAT]    = "compat",
        [FEAT_COMPAT_RO] = "compat_ro",
        [FEAT_INCOMPAT]  = "incompat",
 };
 
+const char * const btrfs_feature_set_name(enum btrfs_feature_set set)
+{
+       return btrfs_feature_set_names[set];
+}
+
 char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags)
 {
        size_t bufsize = 4096; /* safe max, 64 names * 64 bytes */
index 0c06f2adfae87ec24db89b8df16140d8307e4443..d8a6ab1bfde7160f8b9d221ae54961b068de4102 100644 (file)
@@ -78,7 +78,7 @@ attr_to_btrfs_feature_attr(struct attribute *attr)
 }
 
 char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
-extern const char * const btrfs_feature_set_names[FEAT_MAX];
+const char * const btrfs_feature_set_name(enum btrfs_feature_set set);
 int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
                struct btrfs_device *one_device);
 int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices,