summaryrefslogtreecommitdiff
path: root/ubifs-utils/mkfs.ubifs
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2018-11-07 21:56:35 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2018-11-09 14:25:26 +0100
commitddeb70df91c0bf2574416279b4b6b9b36262b4c5 (patch)
tree4a4307b38a28d6deb9cb389ebbebdd228b5e1d8a /ubifs-utils/mkfs.ubifs
parenta20cdd234def1d7b400d76e81cad45b82e0c6215 (diff)
mkfs.ubifs: Don't compress by default if filesystem is encrypted
Encryption and compression are not friends. Enable compression in encryption mode only if the user explicitly sets a compressor. Signed-off-by: Richard Weinberger <richard@nod.at> Tested-by: Heiko Schocher <hsdenx.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/mkfs.ubifs')
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 5847b35..666dfe6 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -504,6 +504,20 @@ static int open_ubi(const char *node)
return 0;
}
+static void select_default_compr(void)
+{
+ if (c->encrypted) {
+ c->default_compr = UBIFS_COMPR_NONE;
+ return;
+ }
+
+#ifdef WITHOUT_LZO
+ c->default_compr = UBIFS_COMPR_ZLIB;
+#else
+ c->default_compr = UBIFS_COMPR_LZO;
+#endif
+}
+
static int get_options(int argc, char**argv)
{
int opt, i, fscrypt_flags = FS_POLICY_FLAGS_PAD_4;
@@ -519,11 +533,6 @@ static int get_options(int argc, char**argv)
c->orph_lebs = 1;
c->key_hash = key_r5_hash;
c->key_len = UBIFS_SK_LEN;
-#ifdef WITHOUT_LZO
- c->default_compr = UBIFS_COMPR_ZLIB;
-#else
- c->default_compr = UBIFS_COMPR_LZO;
-#endif
c->favor_percent = 20;
c->lsave_cnt = 256;
c->leb_size = -1;
@@ -533,6 +542,7 @@ static int get_options(int argc, char**argv)
c->log_lebs = -1;
c->double_hash = 0;
c->encrypted = 0;
+ c->default_compr = -1;
while (1) {
opt = getopt_long(argc, argv, optstring, longopts, &i);
@@ -645,12 +655,14 @@ static int get_options(int argc, char**argv)
else if (strcmp(optarg, "zlib") == 0)
c->default_compr = UBIFS_COMPR_ZLIB;
#ifndef WITHOUT_LZO
- else if (strcmp(optarg, "favor_lzo") == 0)
+ else if (strcmp(optarg, "favor_lzo") == 0) {
+ c->default_compr = UBIFS_COMPR_LZO;
c->favor_lzo = 1;
- else if (strcmp(optarg, "lzo") != 0)
-#else
- else
+ } else if (strcmp(optarg, "lzo") == 0) {
+ c->default_compr = UBIFS_COMPR_LZO;
+ }
#endif
+ else
return err_msg("bad compressor name");
break;
case 'X':
@@ -777,6 +789,9 @@ static int get_options(int argc, char**argv)
#endif
}
+ if (c->default_compr == -1)
+ select_default_compr();
+
if (c->min_io_size == -1)
return err_msg("min. I/O unit was not specified "
"(use -h for help)");
@@ -1787,7 +1802,7 @@ static int add_file(const char *path_name, struct stat *st, ino_t inum,
key_write(&key, &dn->key);
out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
if (c->default_compr == UBIFS_COMPR_NONE &&
- (flags & FS_COMPR_FL))
+ !c->encrypted && (flags & FS_COMPR_FL))
#ifdef WITHOUT_LZO
use_compr = UBIFS_COMPR_ZLIB;
#else