@@ -3222,3 +3222,26 @@ int btrfs_features_allowed_by_sysfs(u64 *features)
closedir(dir);
return 0;
}
+
+int btrfs_features_allowed_by_version(char *version, u64 *features)
+{
+ int i;
+ int code;
+ char *ver = strdup(version);
+
+ *features = 0;
+ code = version_to_code(ver);
+ free(ver);
+ if (code < 0)
+ return code;
+
+ for (i = 0; i < ARRAY_SIZE(mkfs_features) - 1; i++) {
+ ver = strdup(mkfs_features[i].min_ker_ver);
+
+ if (code >= version_to_code(ver))
+ *features |= mkfs_features[i].flag;
+
+ free(ver);
+ }
+ return 0;
+}
@@ -106,6 +106,7 @@ void btrfs_process_fs_features(u64 flags);
void btrfs_parse_features_to_string(char *buf, u64 flags);
u64 btrfs_features_allowed_by_kernel(void);
int btrfs_features_allowed_by_sysfs(u64 *features);
+int btrfs_features_allowed_by_version(char *version, u64 *features);
struct btrfs_mkfs_config {
char *label;
As discussed in the mailing list this provides a framework to introduce the feature where mkfs and btrfs-convert can set the default features as per the given mainline kernel version. Suggested-by: David Sterba <dsterba@suse.cz> Signed-off-by: Anand Jain <anand.jain@oracle.com> --- utils.c | 23 +++++++++++++++++++++++ utils.h | 1 + 2 files changed, 24 insertions(+)