bch2_sb_is_encrypted{,_and_locked}

Specifically also mention locked

Signed-off-by: Roland Vet <RlndVt@protonmail.com>
This commit is contained in:
Roland Vet 2024-02-22 22:12:40 +01:00
parent 817e957697
commit 16661be294
4 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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 *);

View File

@ -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()) {