diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-01-04 19:05:08 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:21 -0400 |
commit | 03ea3962ab99adf0cf7de9949716e6baeda230f3 (patch) | |
tree | 1d1a8140f3b43772591ad33ffd49a0b76d7b8b55 /fs/bcachefs/checksum.c | |
parent | 57cfdd8b54b945fe80191767e36595b46893e5e0 (diff) | |
download | linux-03ea3962ab99adf0cf7de9949716e6baeda230f3.tar.gz linux-03ea3962ab99adf0cf7de9949716e6baeda230f3.tar.bz2 linux-03ea3962ab99adf0cf7de9949716e6baeda230f3.zip |
bcachefs: Log & error message improvements
- Add a shim uuid_unparse_lower() in the kernel, since %pU doesn't work
in userspace
- We don't need to print the bcachefs: or the filesystem name prefix in
userspace
- Improve a few error messages
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/checksum.c')
-rw-r--r-- | fs/bcachefs/checksum.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/fs/bcachefs/checksum.c b/fs/bcachefs/checksum.c index fbe8603cfb30..a1d89923d361 100644 --- a/fs/bcachefs/checksum.c +++ b/fs/bcachefs/checksum.c @@ -407,16 +407,12 @@ int bch2_rechecksum_bio(struct bch_fs *c, struct bio *bio, } #ifdef __KERNEL__ -int bch2_request_key(struct bch_sb *sb, struct bch_key *key) +static int __bch2_request_key(char *key_description, struct bch_key *key) { - char key_description[60]; struct key *keyring_key; const struct user_key_payload *ukp; int ret; - snprintf(key_description, sizeof(key_description), - "bcachefs:%pUb", &sb->user_uuid); - keyring_key = request_key(&key_type_logon, key_description, NULL); if (IS_ERR(keyring_key)) return PTR_ERR(keyring_key); @@ -436,16 +432,10 @@ int bch2_request_key(struct bch_sb *sb, struct bch_key *key) } #else #include <keyutils.h> -#include <uuid/uuid.h> -int bch2_request_key(struct bch_sb *sb, struct bch_key *key) +static int __bch2_request_key(char *key_description, struct bch_key *key) { key_serial_t key_id; - char key_description[60]; - char uuid[40]; - - uuid_unparse_lower(sb->user_uuid.b, uuid); - sprintf(key_description, "bcachefs:%s", uuid); key_id = request_key("user", key_description, NULL, KEY_SPEC_USER_KEYRING); @@ -459,6 +449,17 @@ int bch2_request_key(struct bch_sb *sb, struct bch_key *key) } #endif +int bch2_request_key(struct bch_sb *sb, struct bch_key *key) +{ + char key_description[60]; + char uuid[40]; + + uuid_unparse_lower(sb->user_uuid.b, uuid); + sprintf(key_description, "bcachefs:%s", uuid); + + return __bch2_request_key(key_description, key); +} + int bch2_decrypt_sb_key(struct bch_fs *c, struct bch_sb_field_crypt *crypt, struct bch_key *key) |