diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 18:29:54 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-31 12:18:37 -0400 |
commit | 6ddedca2180b095aacca0f628e0d03a32477f68f (patch) | |
tree | 5803ddaeb0620d622de35d9915308c774a8de4cb /fs/bcachefs/compress.c | |
parent | ef435abd6a99206d9bb93462a1b0508e0d876adb (diff) | |
download | linux-6ddedca2180b095aacca0f628e0d03a32477f68f.tar.gz linux-6ddedca2180b095aacca0f628e0d03a32477f68f.tar.bz2 linux-6ddedca2180b095aacca0f628e0d03a32477f68f.zip |
bcachefs: Guard against unknown compression options
Since compression options now include compression level, proper
validation is a bit more involved.
This adds bch2_compression_opt_valid(), and plumbs it around
appropriately.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/compress.c')
-rw-r--r-- | fs/bcachefs/compress.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c index 1480b64547b0..0e3981f42526 100644 --- a/fs/bcachefs/compress.c +++ b/fs/bcachefs/compress.c @@ -708,3 +708,13 @@ void bch2_opt_compression_to_text(struct printbuf *out, if (opt.level) prt_printf(out, ":%u", opt.level); } + +int bch2_opt_compression_validate(u64 v, struct printbuf *err) +{ + if (!bch2_compression_opt_valid(v)) { + prt_printf(err, "invalid compression opt %llu", v); + return -BCH_ERR_invalid_sb_opt_compression; + } + + return 0; +} |