From a1d66032bd050b00964545b7a057847a9f7ab96e Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 20 Apr 2020 15:12:44 +0200 Subject: [PATCH] xbps-uchroot: support long options; update usage. --- bin/xbps-uchroot/main.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/bin/xbps-uchroot/main.c b/bin/xbps-uchroot/main.c index 1229711c..f6617a54 100644 --- a/bin/xbps-uchroot/main.c +++ b/bin/xbps-uchroot/main.c @@ -89,12 +89,14 @@ static SIMPLEQ_HEAD(bindmnt_head, bindmnt) bindmnt_queue = static void __attribute__((noreturn)) usage(const char *p) { - printf("Usage: %s [-[B|b] src:dest] [-O -t -o ] [--] []\n\n" - "-B src:dest Bind mounts into / (read-only)\n" - "-b src:dest Bind mounts into / (read-write)\n" - "-O Creates a tempdir and mounts read-only via overlayfs\n" - "-t Creates a tempdir and mounts on tmpfs (for use with -O)\n" - "-o opts Options to be passed to the tmpfs mount (for use with -t)\n", p); + printf("Usage: %s [OPTIONS] [--] []\n\n" + "-B, --bind-ro Bind mounts into / (read-only)\n" + "-b, --bind-rw Bind mounts into / (read-write)\n" + "-O, --overlayfs Creates a tempdir and mounts read-only via overlayfs\n" + "-t, --tmpfs Creates a tempdir and mounts on tmpfs (for use with -O)\n" + "-o, --options Options to be passed to the tmpfs mount (for use with -t)\n" + "-V, --version Show XBPS version\n" + "-h, --help Show usage\n\n", p); exit(EXIT_FAILURE); } @@ -329,13 +331,20 @@ main(int argc, char **argv) pid_t child; bool overlayfs = false; const struct option longopts[] = { + { "overlayfs", no_argument, NULL, 'O' }, + { "tmpfs", no_argument, NULL, 't' }, + { "options", required_argument, NULL, 'o' }, + { "bind-rw", required_argument, NULL, 'B' }, + { "bind-ro", required_argument, NULL, 'b' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; tmpfs_opts = rootdir = cmd = NULL; argv0 = argv[0]; - while ((c = getopt_long(argc, argv, "Oto:B:b:V", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "Oto:B:b:Vh", longopts, NULL)) != -1) { switch (c) { case 'O': overlayfs = true; @@ -359,6 +368,7 @@ main(int argc, char **argv) case 'V': printf("%s\n", XBPS_RELVER); exit(EXIT_SUCCESS); + case 'h': case '?': default: usage(argv0);