From 20b0d509f67dea802706cd6b80b5e20d14988931 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 27 Apr 2020 11:59:02 +0200 Subject: Cleanup directory structure of the binary programs Instead of having the binary programs in randomly named subdirectories, move all of them to a "bin" subdirectory, similar to the utility libraries that have subdirectories within "lib" and give the subdirectories the propper names (e.g. have gensquashfs source in a directory *actually* named "gensquashfs"). Signed-off-by: David Oberhollenzer --- mkfs/options.c | 289 --------------------------------------------------------- 1 file changed, 289 deletions(-) delete mode 100644 mkfs/options.c (limited to 'mkfs/options.c') diff --git a/mkfs/options.c b/mkfs/options.c deleted file mode 100644 index 2369787..0000000 --- a/mkfs/options.c +++ /dev/null @@ -1,289 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * options.c - * - * Copyright (C) 2019 David Oberhollenzer - */ -#include "mkfs.h" - -static struct option long_opts[] = { - { "compressor", required_argument, NULL, 'c' }, - { "block-size", required_argument, NULL, 'b' }, - { "dev-block-size", required_argument, NULL, 'B' }, - { "defaults", required_argument, NULL, 'd' }, - { "comp-extra", required_argument, NULL, 'X' }, - { "pack-file", required_argument, NULL, 'F' }, - { "pack-dir", required_argument, NULL, 'D' }, - { "num-jobs", required_argument, NULL, 'j' }, - { "queue-backlog", required_argument, NULL, 'Q' }, - { "keep-time", no_argument, NULL, 'k' }, -#ifdef HAVE_SYS_XATTR_H - { "keep-xattr", no_argument, NULL, 'x' }, -#endif - { "one-file-system", no_argument, NULL, 'o' }, - { "exportable", no_argument, NULL, 'e' }, - { "no-tail-packing", no_argument, NULL, 'T' }, - { "force", no_argument, NULL, 'f' }, - { "quiet", no_argument, NULL, 'q' }, -#ifdef WITH_SELINUX - { "selinux", required_argument, NULL, 's' }, -#endif - { "version", no_argument, NULL, 'V' }, - { "help", no_argument, NULL, 'h' }, - { NULL, 0, NULL, 0 }, -}; - -static const char *short_opts = "F:D:X:c:b:B:d:j:Q:kxoefqThV" -#ifdef WITH_SELINUX -"s:" -#endif -#ifdef HAVE_SYS_XATTR_H -"x" -#endif -; - -static const char *help_string = -"Usage: gensquashfs [OPTIONS...] \n" -"\n" -"Possible options:\n" -"\n" -" --pack-file, -F Use a `gen_init_cpio` style description file.\n" -" The file format is specified below.\n" -" If --pack-dir is used, input file paths are\n" -" relative to the pack directory, otherwise\n" -" they are relative to the directory the pack\n" -" file is in.\n" -" --pack-dir, -D If --pack-file is used, this is the root path\n" -" relative to which to read files. If no pack\n" -" file is specified, pack the contents of the\n" -" given directory into a SquashFS image. The\n" -" directory becomes the root of the file\n" -" system.\n" -"\n" -" --compressor, -c Select the compressor to use.\n" -" A list of available compressors is below.\n" -" --comp-extra, -X A comma separated list of extra options for\n" -" the selected compressor. Specify 'help' to\n" -" get a list of available options.\n" -" --num-jobs, -j Number of compressor jobs to create.\n" -" --queue-backlog, -Q Maximum number of data blocks in the thread\n" -" worker queue before the packer starts waiting\n" -" for the block processors to catch up.\n" -" Defaults to 10 times the number of jobs.\n" -" --block-size, -b Block size to use for Squashfs image.\n" -" Defaults to %u.\n" -" --dev-block-size, -B Device block size to padd the image to.\n" -" Defaults to %u.\n" -" --defaults, -d A comma separated list of default values for\n" -" implicitly created directories.\n" -"\n" -" Possible options:\n" -" uid= 0 if not set.\n" -" gid= 0 if not set.\n" -" mode= 0755 if not set.\n" -" mtime= 0 if not set.\n" -"\n" -#ifdef WITH_SELINUX -" --selinux, -s Specify an SELinux label file to get context\n" -" attributes from.\n" -#endif -" --keep-time, -k When using --pack-dir only, use the timestamps\n" -" from the input files instead of setting\n" -" defaults on all input paths.\n" -" --keep-xattr, -x When using --pack-dir only, read and pack the\n" -" extended attributes from the input files.\n" -" --one-file-system, -o When using --pack-dir only, stay in local file\n" -" system and do not cross mount points.\n" -" --exportable, -e Generate an export table for NFS support.\n" -" --no-tail-packing, -T Do not perform tail end packing on files that\n" -" are larger than block size.\n" -" --force, -f Overwrite the output file if it exists.\n" -" --quiet, -q Do not print out progress reports.\n" -" --help, -h Print help text and exit.\n" -" --version, -V Print version information and exit.\n" -"\n"; - -const char *help_details = -"When using the pack file option, the given file is expected to contain\n" -"newline separated entries that describe the files to be included in the\n" -"SquashFS image. The following entry types can be specified:\n" -"\n" -"# a comment\n" -"file []\n" -"dir \n" -"nod \n" -"slink \n" -"link \n" -"pipe \n" -"sock \n" -"\n" -" Absolute path of the entry in the image. Can be put in quotes\n" -" if some components contain spaces.\n" -" If given, location of the input file. Either absolute or relative\n" -" to the description file. If omitted, the image path is used,\n" -" relative to the description file.\n" -" Symlink or hardlink target.\n" -" Mode/permissions of the entry.\n" -" Numeric user id.\n" -" Numeric group id.\n" -" Device type (b=block, c=character).\n" -" Major number of a device special file.\n" -" Minor number of a device special file.\n" -"\n" -"Example:\n" -" # A simple squashfs image\n" -" dir /dev 0755 0 0\n" -" nod /dev/console 0600 0 0 c 5 1\n" -" dir /root 0700 0 0\n" -" dir /sbin 0755 0 0\n" -" \n" -" # Add a file. Input is relative to listing or pack dir.\n" -" file /sbin/init 0755 0 0 ../init/sbin/init\n" -" \n" -" # Read bin/bash, relative to listing or pack dir.\n" -" # Implicitly create /bin.\n" -" file /bin/bash 0755 0 0\n" -" \n" -" # file name with a space in it.\n" -" file \"/opt/my app/\\\"special\\\"/data\" 0600 0 0\n" -"\n\n"; - -void process_command_line(options_t *opt, int argc, char **argv) -{ - bool have_compressor; - int i, ret; - - memset(opt, 0, sizeof(*opt)); - sqfs_writer_cfg_init(&opt->cfg); - - for (;;) { - i = getopt_long(argc, argv, short_opts, long_opts, NULL); - if (i == -1) - break; - - switch (i) { - case 'T': - opt->no_tail_packing = true; - break; - case 'c': - have_compressor = true; - ret = sqfs_compressor_id_from_name(optarg); - - if (ret < 0) { - have_compressor = false; -#ifdef WITH_LZO - if (opt->cfg.comp_id == SQFS_COMP_LZO) - have_compressor = true; -#endif - } - - if (!have_compressor) { - fprintf(stderr, "Unsupported compressor '%s'\n", - optarg); - exit(EXIT_FAILURE); - } - - opt->cfg.comp_id = ret; - break; - case 'b': - if (parse_size("Block size", &opt->cfg.block_size, - optarg, 0)) { - exit(EXIT_FAILURE); - } - break; - case 'j': - opt->cfg.num_jobs = strtol(optarg, NULL, 0); - break; - case 'Q': - opt->cfg.max_backlog = strtol(optarg, NULL, 0); - break; - case 'B': - if (parse_size("Device block size", - &opt->cfg.devblksize, optarg, 0)) { - exit(EXIT_FAILURE); - } - if (opt->cfg.devblksize < 1024) { - fputs("Device block size must be at " - "least 1024\n", stderr); - exit(EXIT_FAILURE); - } - break; - case 'd': - opt->cfg.fs_defaults = optarg; - break; - case 'k': - opt->dirscan_flags |= DIR_SCAN_KEEP_TIME; - break; -#ifdef HAVE_SYS_XATTR_H - case 'x': - opt->dirscan_flags |= DIR_SCAN_READ_XATTR; - break; -#endif - case 'o': - opt->dirscan_flags |= DIR_SCAN_ONE_FILESYSTEM; - break; - case 'e': - opt->cfg.exportable = true; - break; - case 'f': - opt->cfg.outmode |= SQFS_FILE_OPEN_OVERWRITE; - break; - case 'q': - opt->cfg.quiet = true; - break; - case 'X': - opt->cfg.comp_extra = optarg; - break; - case 'F': - opt->infile = optarg; - break; - case 'D': - opt->packdir = optarg; - break; -#ifdef WITH_SELINUX - case 's': - opt->selinux = optarg; - break; -#endif - case 'h': - printf(help_string, - SQFS_DEFAULT_BLOCK_SIZE, SQFS_DEVBLK_SIZE); - fputs(help_details, stdout); - compressor_print_available(); - exit(EXIT_SUCCESS); - case 'V': - print_version("gensquashfs"); - exit(EXIT_SUCCESS); - default: - goto fail_arg; - } - } - - if (opt->cfg.num_jobs < 1) - opt->cfg.num_jobs = 1; - - if (opt->cfg.max_backlog < 1) - opt->cfg.max_backlog = 10 * opt->cfg.num_jobs; - - if (opt->cfg.comp_extra != NULL && - strcmp(opt->cfg.comp_extra, "help") == 0) { - compressor_print_help(opt->cfg.comp_id); - exit(EXIT_SUCCESS); - } - - if (opt->infile == NULL && opt->packdir == NULL) { - fputs("No input file or directory specified.\n", stderr); - goto fail_arg; - } - - if (optind >= argc) { - fputs("No output file specified.\n", stderr); - goto fail_arg; - } - - opt->cfg.filename = argv[optind++]; - return; -fail_arg: - fputs("Try `gensquashfs --help' for more information.\n", stderr); - exit(EXIT_FAILURE); -} -- cgit v1.2.3