summaryrefslogtreecommitdiff
path: root/c_src
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-03-31 17:23:46 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-03-31 18:40:18 -0400
commit3aa2a4c47ce57ff3965b75df9dde1a7b40ed6ae1 (patch)
tree6d8af05c072c28b7846ecfc9d09ed593a13db5d6 /c_src
parent33483738c63542ce110ef74866a0d2468d87795c (diff)
format: Ensure bcachefs module is loaded before checking version
this prevents accidentally formatting with a version unsupported by the running kernel Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src')
-rw-r--r--c_src/libbcachefs.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/c_src/libbcachefs.h b/c_src/libbcachefs.h
index 93a86db7..defdbe2b 100644
--- a/c_src/libbcachefs.h
+++ b/c_src/libbcachefs.h
@@ -54,6 +54,12 @@ static inline unsigned bcachefs_kernel_version(void)
static inline struct format_opts format_opts_default()
{
+ /*
+ * Ensure bcachefs module is loaded so we know the supported on disk
+ * format version:
+ */
+ system("modprobe bcachefs > /dev/null 2>&1");
+
return (struct format_opts) {
.version = bcachefs_kernel_version() ?:
bcachefs_metadata_version_current,