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"
|
2017-03-20 02:56:34 +03:00
|
|
|
#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");
|
|
|
|
|
2017-04-03 06:43:35 +03:00
|
|
|
sb = bch2_super_read(argv[1]);
|
2016-10-04 06:22:17 +03:00
|
|
|
|
|
|
|
passphrase = read_passphrase("Enter passphrase: ");
|
|
|
|
|
2017-04-03 06:43:35 +03:00
|
|
|
bch2_add_key(sb, passphrase);
|
2016-10-04 06:22:17 +03:00
|
|
|
|
|
|
|
memzero_explicit(passphrase, strlen(passphrase));
|
|
|
|
free(passphrase);
|
|
|
|
return 0;
|
|
|
|
}
|