diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2018-10-18 16:37:01 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2018-11-01 12:40:25 +0100 |
commit | f30898572bf28df8a58886ef521c413929fb8a03 (patch) | |
tree | d6e8845d35ffafc6f73c5091e5b20fa57d3e009e | |
parent | 41453928c0d3613b6ee6823d291b44dcd2f73126 (diff) |
mkfs.ubifs: Specify padding policy via command line
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r-- | ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index 70c306b..9935fce 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -217,7 +217,7 @@ static struct inum_mapping **hash_table; /* Inode creation sequence number */ static unsigned long long creat_sqnum; -static const char *optstring = "d:r:m:o:D:yh?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQqaK:b:"; +static const char *optstring = "d:r:m:o:D:yh?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQqaK:b:P:"; static const struct option longopts[] = { {"root", 1, NULL, 'r'}, @@ -245,6 +245,7 @@ static const struct option longopts[] = { {"selinux", 1, NULL, 's'}, {"key", 1, NULL, 'K'}, {"key-descriptor", 1, NULL, 'b'}, + {"padding", 1, NULL, 'P'}, {NULL, 0, NULL, 0} }; @@ -291,6 +292,8 @@ static const char *helptext = "-s, --selinux=FILE Selinux context file\n" "-K, --key=FILE load an encryption key from a specified file.\n" "-b, --key-descriptor=HEX specify the key descriptor as a hex string.\n" +"-P, --padding=NUM specify padding policy for encrypting filenames\n" +" (default = 4).\n" "-h, --help display this help text\n\n" "Note, SIZE is specified in bytes, but it may also be specified in Kilobytes,\n" "Megabytes, and Gigabytes if a KiB, MiB, or GiB suffix is used.\n\n" @@ -713,7 +716,7 @@ static int open_ubi(const char *node) static int get_options(int argc, char**argv) { - int opt, i; + int opt, i, fscrypt_flags = FS_POLICY_FLAGS_PAD_4; const char *key_file = NULL, *key_desc = NULL; const char *tbl_file = NULL; struct stat st; @@ -904,6 +907,35 @@ static int get_options(int argc, char**argv) } key_desc = optarg; break; + case 'P': { + int error = 0; + unsigned long num; + + num = simple_strtoul(optarg, &error); + if (error) + num = -1; + + fscrypt_flags &= ~FS_POLICY_FLAGS_PAD_MASK; + + switch (num) { + case 4: + fscrypt_flags |= FS_POLICY_FLAGS_PAD_4; + break; + case 8: + fscrypt_flags |= FS_POLICY_FLAGS_PAD_8; + break; + case 16: + fscrypt_flags |= FS_POLICY_FLAGS_PAD_16; + break; + case 32: + fscrypt_flags |= FS_POLICY_FLAGS_PAD_32; + break; + default: + return errmsg("invalid padding policy '%s'", + optarg); + } + break; + } } } @@ -931,7 +963,7 @@ static int get_options(int argc, char**argv) c->double_hash = 1; c->encrypted = 1; - root_fctx = init_fscrypt_context(FS_POLICY_FLAGS_PAD_4, + root_fctx = init_fscrypt_context(fscrypt_flags, key_file, key_desc); if (!root_fctx) return -1; |