summaryrefslogtreecommitdiff
path: root/libbcachefs.h
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs.h')
-rw-r--r--libbcachefs.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/libbcachefs.h b/libbcachefs.h
index 17e8eef3..4bb51bd8 100644
--- a/libbcachefs.h
+++ b/libbcachefs.h
@@ -41,8 +41,12 @@ struct format_opts {
static inline struct format_opts format_opts_default()
{
+ unsigned version = !access( "/sys/module/bcachefs/parameters/version", R_OK)
+ ? read_file_u64(AT_FDCWD, "/sys/module/bcachefs/parameters/version")
+ : bcachefs_metadata_version_current;
+
return (struct format_opts) {
- .version = bcachefs_metadata_version_current,
+ .version = version,
.superblock_size = SUPERBLOCK_SIZE_DEFAULT,
};
}