diff options
-rw-r--r-- | README | 11 | ||||
-rw-r--r-- | include/erofs/defs.h | 4 | ||||
-rw-r--r-- | mkfs/main.c | 53 |
3 files changed, 67 insertions, 1 deletions
@@ -57,6 +57,17 @@ Currently lz4 and lz4hc are available for compression, e.g. Or leave all files uncompressed as a option: $ mkfs.erofs foo.erofs.img foo/ +How to generate legacy erofs images +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Decompression inplace and compacted indexes have been introduced in +linux-5.3, which are not backward-compatible with older kernels. + +In order to generate _legacy_ erofs images for old kernels, +add "-E legacy-compress" to the command line, e.g. + + $ mkfs.erofs -E legacy-compress -zlz4hc foo.erofs.img foo/ + Obsoleted erofs.mkfs ~~~~~~~~~~~~~~~~~~~~ diff --git a/include/erofs/defs.h b/include/erofs/defs.h index 111b703..0d9910c 100644 --- a/include/erofs/defs.h +++ b/include/erofs/defs.h @@ -155,5 +155,9 @@ typedef int64_t s64; #define DBG_BUGON(condition) BUG_ON(condition) #endif +#ifndef __maybe_unused +#define __maybe_unused __attribute__((__unused__)) +#endif + #endif diff --git a/mkfs/main.c b/mkfs/main.c index 17e4d09..1348587 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -27,6 +27,7 @@ static void usage(void) fprintf(stderr, "Generate erofs image from DIRECTORY to FILE, and [options] are:\n"); fprintf(stderr, " -zX[,Y] X=compressor (Y=compression level, optional)\n"); fprintf(stderr, " -d# set output message level to # (maximum 9)\n"); + fprintf(stderr, " -EX[,...] X=extended options\n"); } u64 parse_num_from_str(const char *str) @@ -39,11 +40,55 @@ u64 parse_num_from_str(const char *str) return num; } +static int parse_extended_opts(const char *opts) +{ +#define MATCH_EXTENTED_OPT(opt, token, keylen) \ + (keylen == sizeof(opt) && !memcmp(token, opt, sizeof(opt))) + + const char *token, *next, *tokenend, *value __maybe_unused; + unsigned int keylen, vallen; + + value = NULL; + for (token = opts; *token != '\0'; token = next) { + const char *p = strchr(token, ','); + + next = NULL; + if (p) + next = p + 1; + else { + p = token + strlen(token); + next = p; + } + + tokenend = memchr(token, '=', p - token); + if (tokenend) { + keylen = tokenend - token; + vallen = p - tokenend - 1; + if (!vallen) + return -EINVAL; + + value = tokenend + 1; + } else { + keylen = p - token; + vallen = 0; + } + + if (MATCH_EXTENTED_OPT("legacy-compress", token, keylen)) { + if (vallen) + return -EINVAL; + /* disable compacted indexes and 0padding */ + cfg.c_legacy_compress = true; + sbi.requirements &= ~EROFS_REQUIREMENT_LZ4_0PADDING; + } + } + return 0; +} + static int mkfs_parse_options_cfg(int argc, char *argv[]) { int opt, i; - while ((opt = getopt(argc, argv, "d:z:")) != -1) { + while ((opt = getopt(argc, argv, "d:z:E:")) != -1) { switch (opt) { case 'z': if (!optarg) { @@ -66,6 +111,12 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) cfg.c_dbg_lvl = parse_num_from_str(optarg); break; + case 'E': + opt = parse_extended_opts(optarg); + if (opt) + return opt; + break; + default: /* '?' */ return -EINVAL; } |