bcachefs-tools/cmd_key.c

28 lines
489 B
C
Raw Normal View History

2016-10-04 06:22:17 +03:00
#include <errno.h>
#include <unistd.h>
#include <uuid/uuid.h>
#include "cmds.h"
#include "checksum.h"
#include "crypto.h"
#include "libbcachefs.h"
2016-10-04 06:22:17 +03:00
int cmd_unlock(int argc, char *argv[])
{
struct bch_sb *sb;
char *passphrase;
if (argc != 2)
die("please supply a single device");
sb = bch2_super_read(argv[1]);
2016-10-04 06:22:17 +03:00
passphrase = read_passphrase("Enter passphrase: ");
bch2_add_key(sb, passphrase);
2016-10-04 06:22:17 +03:00
memzero_explicit(passphrase, strlen(passphrase));
free(passphrase);
return 0;
}