summaryrefslogtreecommitdiff
path: root/c_src/cmd_fs.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-03-28 11:38:55 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-03-28 11:38:55 -0400
commit7c47145f6cdf9826f9dc24c935195b58268b1ec6 (patch)
treef63e7951cbddcde3db8e0058e70dc0604abc4a74 /c_src/cmd_fs.c
parent396545c2ea073144d5cd905bc8bcfb0080549f6d (diff)
cmd_fs_usage: Fix kernel version check
This needed an access() check, like the other uses, instead of exiting if it can't be read. Factor out a small common helper for this. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src/cmd_fs.c')
-rw-r--r--c_src/cmd_fs.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/c_src/cmd_fs.c b/c_src/cmd_fs.c
index cda9a755..06f797b9 100644
--- a/c_src/cmd_fs.c
+++ b/c_src/cmd_fs.c
@@ -239,9 +239,10 @@ static void accounting_sort(darray_accounting_p *sorted,
static void accounting_swab_if_old(struct bch_ioctl_query_accounting *in)
{
- u64 kernel_version = read_file_u64(AT_FDCWD, "/sys/module/bcachefs/parameters/version");
+ unsigned kernel_version = bcachefs_kernel_version();
- if (kernel_version < bcachefs_metadata_version_disk_accounting_big_endian)
+ if (kernel_version &&
+ kernel_version < bcachefs_metadata_version_disk_accounting_big_endian)
for (struct bkey_i_accounting *a = in->accounting;
a < (struct bkey_i_accounting *) ((u64 *) in->accounting + in->accounting_u64s);
a = bkey_i_to_accounting(bkey_next(&a->k_i)))