diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-23 10:32:13 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-23 10:32:13 +0200 |
commit | b7267b9552555d557ff7e42ed5373be769eef4bf (patch) | |
tree | 81cb2295b570698d290963bd143461e501d4b1a7 /mkfs | |
parent | 7e77d17e005ef85142aaec37a730825d27500d15 (diff) |
gensquashfs: Remove rest of read_number from options parser
Use a simple strtol for block size and device block size:
- We don't need to check the block size, sqfs_super_init does that.
- We only need to make sure the device block size is at least 1k.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r-- | mkfs/options.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/mkfs/options.c b/mkfs/options.c index 8d724a8..78c6a88 100644 --- a/mkfs/options.c +++ b/mkfs/options.c @@ -110,23 +110,6 @@ static const char *help_string = " file /bin/bash 0755 0 0" "\n\n"; -static long read_number(const char *name, const char *str, long min, long max) -{ - long result = strtol(str, NULL, 0); - - if (result < min) { - fprintf(stderr, "%s: number too small\n", name); - exit(EXIT_FAILURE); - } - - if (result > max) { - fprintf(stderr, "%s: number too large\n", name); - exit(EXIT_FAILURE); - } - - return result; -} - void process_command_line(options_t *opt, int argc, char **argv) { bool have_compressor; @@ -165,12 +148,15 @@ void process_command_line(options_t *opt, int argc, char **argv) } break; case 'b': - opt->blksz = read_number("Block size", optarg, - 4096, (1 << 20) - 1); + opt->blksz = strtol(optarg, NULL, 0); break; case 'B': - opt->devblksz = read_number("Device block size", optarg, - 4096, 0xFFFFFFFF); + opt->devblksz = strtol(optarg, NULL, 0); + if (opt->devblksz < 1024) { + fputs("Device block size must be at " + "least 1024\n", stderr); + exit(EXIT_FAILURE); + } break; case 'd': opt->fs_defaults = optarg; |