summaryrefslogtreecommitdiff
path: root/cmd_key.c
blob: b22de8158f9200c2d3b835d8bc3a86c1a52d0b96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <errno.h>
#include <unistd.h>
#include <uuid/uuid.h>

#include "cmds.h"
#include "checksum.h"
#include "crypto.h"
#include "libbcachefs.h"

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]);

	passphrase = read_passphrase("Enter passphrase: ");

	bch2_add_key(sb, passphrase);

	memzero_explicit(passphrase, strlen(passphrase));
	free(passphrase);
	return 0;
}