From 16661be29497ce4940039fe49e3ebb71f72a2052 Mon Sep 17 00:00:00 2001 From: Roland Vet Date: Thu, 22 Feb 2024 22:12:40 +0100 Subject: [PATCH] bch2_sb_is_encrypted{,_and_locked} Specifically also mention locked Signed-off-by: Roland Vet --- c_src/cmd_key.c | 2 +- c_src/crypto.c | 2 +- c_src/crypto.h | 2 +- src/commands/cmd_mount.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/c_src/cmd_key.c b/c_src/cmd_key.c index adb0ac8d..552aa867 100644 --- a/c_src/cmd_key.c +++ b/c_src/cmd_key.c @@ -66,7 +66,7 @@ int cmd_unlock(int argc, char *argv[]) if (ret) die("Error opening %s: %s", dev, bch2_err_str(ret)); - if (!bch2_sb_is_encrypted(sb.sb)) + if (!bch2_sb_is_encrypted_and_locked(sb.sb)) die("%s is not encrypted", dev); if (check) diff --git a/c_src/crypto.c b/c_src/crypto.c index 32671bd8..bc4a9aee 100644 --- a/c_src/crypto.c +++ b/c_src/crypto.c @@ -101,7 +101,7 @@ struct bch_key derive_passphrase(struct bch_sb_field_crypt *crypt, return key; } -bool bch2_sb_is_encrypted(struct bch_sb *sb) +bool bch2_sb_is_encrypted_and_locked(struct bch_sb *sb) { struct bch_sb_field_crypt *crypt; diff --git a/c_src/crypto.h b/c_src/crypto.h index baea6d86..b93b1b08 100644 --- a/c_src/crypto.h +++ b/c_src/crypto.h @@ -12,7 +12,7 @@ char *read_passphrase(const char *); char *read_passphrase_twice(const char *); struct bch_key derive_passphrase(struct bch_sb_field_crypt *, const char *); -bool bch2_sb_is_encrypted(struct bch_sb *); +bool bch2_sb_is_encrypted_and_locked(struct bch_sb *); void bch2_passphrase_check(struct bch_sb *, const char *, struct bch_key *, struct bch_encrypted_key *); void bch2_add_key(struct bch_sb *, const char *, const char *, const char *); diff --git a/src/commands/cmd_mount.rs b/src/commands/cmd_mount.rs index 35b5462b..63998456 100644 --- a/src/commands/cmd_mount.rs +++ b/src/commands/cmd_mount.rs @@ -206,7 +206,7 @@ fn cmd_mount_inner(opt: Cli) -> anyhow::Result<()> { Err(anyhow::anyhow!("No device found from specified parameters"))?; } // Check if the filesystem's master key is encrypted - if unsafe { bcachefs::bch2_sb_is_encrypted(block_devices_to_mount[0].sb) } { + if unsafe { bcachefs::bch2_sb_is_encrypted_and_locked(block_devices_to_mount[0].sb) } { // First by password_file, if available let fallback_to_unlock_policy = if let Some(passphrase_file) = &opt.passphrase_file { match key::read_from_passphrase_file(&block_devices_to_mount[0], passphrase_file.as_path()) {