mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Get current metadata version from sysfs
This changes the default version for the format command to be the currently supported version, via /sys/modules/bcachefs/parameters/version. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
e314b39c63
commit
0417560649
@ -219,6 +219,9 @@ int cmd_format(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.version != bcachefs_metadata_version_current)
|
||||||
|
initialize = false;
|
||||||
|
|
||||||
if (!devices.nr)
|
if (!devices.nr)
|
||||||
die("Please supply a device");
|
die("Please supply a device");
|
||||||
|
|
||||||
|
@ -41,8 +41,12 @@ struct format_opts {
|
|||||||
|
|
||||||
static inline struct format_opts format_opts_default()
|
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) {
|
return (struct format_opts) {
|
||||||
.version = bcachefs_metadata_version_current,
|
.version = version,
|
||||||
.superblock_size = SUPERBLOCK_SIZE_DEFAULT,
|
.superblock_size = SUPERBLOCK_SIZE_DEFAULT,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user