diff options
author | Christopher Faylor <me@cgf.cx> | 2003-07-04 07:11:18 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-07-04 07:11:18 +0400 |
commit | 08604f02bcbcd954c601cd46f68d45321f3ee164 (patch) | |
tree | 67558e2f82df58526250d3caecc223f50daf5ebb /winsup | |
parent | d108f312f9d0485a5decc719a2fade8d0ed03dca (diff) |
* mount.cc (longopts): Add long "options" keyword.
(opts): Add -o option.
(usage): Display -o option.
(struct opt): New.
(concat3): New function.
(main): Handle -o flag.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/utils/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/utils/mount.cc | 64 | ||||
-rw-r--r-- | winsup/utils/utils.sgml | 1 |
3 files changed, 72 insertions, 2 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 2aac863b2..728c64758 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,12 @@ +2003-07-03 Christopher Faylor <cgf@redhat.com> + + * mount.cc (longopts): Add long "options" keyword. + (opts): Add -o option. + (usage): Display -o option. + (struct opt): New. + (concat3): New function. + (main): Handle -o flag. + 2003-06-12 Christopher Faylor <cgf@redhat.com> * cygcheck.cc (pretty_id): Rework slightly to not rely on spaces. diff --git a/winsup/utils/mount.cc b/winsup/utils/mount.cc index 62509c5cc..0900ed1eb 100644 --- a/winsup/utils/mount.cc +++ b/winsup/utils/mount.cc @@ -1,6 +1,6 @@ /* mount.cc - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. This file is part of Cygwin. @@ -120,6 +120,7 @@ static struct option longopts[] = {"help", no_argument, NULL, 'h' }, {"mount-commands", no_argument, NULL, 'm'}, {"no-executable", no_argument, NULL, 'E'}, + {"options", required_argument, NULL, 'E'}, {"show-cygdrive-prefix", no_argument, NULL, 'p'}, {"system", no_argument, NULL, 's'}, {"text", no_argument, NULL, 't'}, @@ -128,7 +129,7 @@ static struct option longopts[] = {NULL, 0, NULL, 0} }; -static char opts[] = "bcfhmpstuvxEX"; +static char opts[] = "bcfhmpstuvxEXo:"; static void usage (FILE *where = stderr) @@ -144,6 +145,7 @@ Display information about mounted filesystems, or mount a filesystem\n\ -h, --help output usage information and exit\n\ -m, --mount-commands write mount commands to replace user and\n\ system mount points and cygdrive prefixes\n\ + -o, --options X[,X...] specify mount options\n\ -p, --show-cygdrive-prefix show user and/or system cygdrive path prefix\n\ -s, --system (default) add system-wide mount point\n\ -t, --text text files get \\r\\n line endings\n\ @@ -158,6 +160,25 @@ Display information about mounted filesystems, or mount a filesystem\n\ exit (where == stderr ? 1 : 0); } +struct opt +{ + const char *name; + unsigned val; + bool clear; +} oopts[] = +{ + {"user", MOUNT_SYSTEM, 1}, + {"system", MOUNT_SYSTEM, 0}, + {"binary", MOUNT_BINARY, 0}, + {"text", MOUNT_BINARY, 1}, + {"exec", MOUNT_EXEC, 0}, + {"notexec", MOUNT_NOTEXEC, 0}, + {"cygexec", MOUNT_CYGWIN_EXEC, 0}, + {"suid", 0, 0}, + {"posix", MOUNT_ENC, 0}, + {"managed", MOUNT_ENC, 0} +}; + static void print_version () { @@ -181,12 +202,21 @@ Compiled on %s\n\ ", progname, len, v, __DATE__); } +static char * +concat3 (char *a, const char *b, const char *c) +{ + size_t totlen = strlen (a) + strlen (b) + strlen (c) + 1; + a = (char *) realloc (a, totlen); + return strcat (strcat (a, b), c); +} + int main (int argc, char **argv) { int i; int flags = MOUNT_BINARY; int default_flag = MOUNT_SYSTEM; + char *options = strdup (""); enum do_what { nada, @@ -233,6 +263,12 @@ main (int argc, char **argv) else usage (); break; + case 'o': + if (*options) + options = concat3 (options, ",", optarg); + else + options = strdup (optarg); + break; case 'p': if (do_what == nada) do_what = saw_show_cygdrive_prefix; @@ -266,6 +302,30 @@ main (int argc, char **argv) usage (); } + while (*options) + { + char *p = strchr (options, ','); + if (p) + *p++ = '\0'; + else + p = strchr (options, '\0'); + + for (opt *o = oopts; o < (oopts + (sizeof (oopts) / sizeof (oopts[0]))); o++) + if (strcmp (options, o->name) == 0) + { + if (o->clear) + flags &= ~o->val; + else + flags |= o->val; + goto gotit; + } + fprintf (stderr, "%s: invalid option - '%s'\n", progname, options); + exit (1); + + gotit: + options = p; + } + if (flags & MOUNT_NOTEXEC && flags & (MOUNT_EXEC | MOUNT_CYGWIN_EXEC)) { fprintf (stderr, "%s: invalid combination of executable options\n", progname); diff --git a/winsup/utils/utils.sgml b/winsup/utils/utils.sgml index 8f7c40bc1..8aa0fd63f 100644 --- a/winsup/utils/utils.sgml +++ b/winsup/utils/utils.sgml @@ -534,6 +534,7 @@ Display information about mounted filesystems, or mount a filesystem -h, --help output usage information and exit -m, --mount-commands write mount commands to replace user and system mount points and cygdrive prefixes + -o, --options X[,X...] specify mount options -p, --show-cygdrive-prefix show user and/or system cygdrive path prefix -s, --system (default) add system-wide mount point -t, --text text files get \r\n line endings |