]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - cmd_key.c
Upload to unstable
[bcachefs-tools-debian] / cmd_key.c
index 63b0541cb15a038ff879d5873d9ca0f311f8636f..96206c4c36b5a62cce4cc27fd445a383bdfa87df 100644 (file)
--- a/cmd_key.c
+++ b/cmd_key.c
@@ -55,7 +55,7 @@ int cmd_unlock(int argc, char *argv[])
        struct bch_sb_handle sb;
        int ret = bch2_read_super(dev, &opts, &sb);
        if (ret)
-               die("Error opening %s: %s", dev, strerror(-ret));
+               die("Error opening %s: %s", dev, bch2_err_str(ret));
 
        if (!bch2_sb_is_encrypted(sb.sb))
                die("%s is not encrypted", dev);
@@ -90,9 +90,9 @@ int cmd_set_passphrase(int argc, char *argv[])
 
        c = bch2_fs_open(argv + 1, argc - 1, opts);
        if (IS_ERR(c))
-               die("Error opening %s: %s", argv[1], strerror(-PTR_ERR(c)));
+               die("Error opening %s: %s", argv[1], bch2_err_str(PTR_ERR(c)));
 
-       struct bch_sb_field_crypt *crypt = bch2_sb_get_crypt(c->disk_sb.sb);
+       struct bch_sb_field_crypt *crypt = bch2_sb_field_get(c->disk_sb.sb, crypt);
        if (!crypt)
                die("Filesystem does not have encryption enabled");
 
@@ -111,6 +111,7 @@ int cmd_set_passphrase(int argc, char *argv[])
                die("error encrypting key");
        crypt->key = new_key;
 
+       bch2_revoke_key(c->disk_sb.sb);
        bch2_write_super(c);
        bch2_fs_stop(c);
        return 0;
@@ -127,9 +128,9 @@ int cmd_remove_passphrase(int argc, char *argv[])
        opt_set(opts, nostart, true);
        c = bch2_fs_open(argv + 1, argc - 1, opts);
        if (IS_ERR(c))
-               die("Error opening %s: %s", argv[1], strerror(-PTR_ERR(c)));
+               die("Error opening %s: %s", argv[1], bch2_err_str(PTR_ERR(c)));
 
-       struct bch_sb_field_crypt *crypt = bch2_sb_get_crypt(c->disk_sb.sb);
+       struct bch_sb_field_crypt *crypt = bch2_sb_field_get(c->disk_sb.sb, crypt);
        if (!crypt)
                die("Filesystem does not have encryption enabled");