]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - cmd_key.c
New upstream release
[bcachefs-tools-debian] / cmd_key.c
index 6052cb0061762b8ed8d6a1f4c56dfc8c7e54ee41..63b0541cb15a038ff879d5873d9ca0f311f8636f 100644 (file)
--- a/cmd_key.c
+++ b/cmd_key.c
@@ -14,20 +14,26 @@ static void unlock_usage(void)
             "\n"
             "Options:\n"
             "  -c                     Check if a device is encrypted\n"
+            "  -k (session|user|user_session)\n"
+            "                         Keyring to add to (default: user)\n"
             "  -h                     Display this help and exit\n"
-            "Report bugs to <linux-bcache@vger.kernel.org>");
+            "Report bugs to <linux-bcachefs@vger.kernel.org>");
 }
 
 int cmd_unlock(int argc, char *argv[])
 {
+       const char *keyring = "user";
        bool check = false;
        int opt;
 
-       while ((opt = getopt(argc, argv, "ch")) != -1)
+       while ((opt = getopt(argc, argv, "ck:h")) != -1)
                switch (opt) {
                case 'c':
                        check = true;
                        break;
+               case 'k':
+                       keyring = strdup(optarg);
+                       break;
                case 'h':
                        unlock_usage();
                        exit(EXIT_SUCCESS);
@@ -59,7 +65,7 @@ int cmd_unlock(int argc, char *argv[])
 
        char *passphrase = read_passphrase("Enter passphrase: ");
 
-       bch2_add_key(sb.sb, passphrase);
+       bch2_add_key(sb.sb, "user", keyring, passphrase);
 
        bch2_free_super(&sb);
        memzero_explicit(passphrase, strlen(passphrase));