* 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.
This commit is contained in:
parent
d108f312f9
commit
08604f02bc
@ -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>
|
2003-06-12 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* cygcheck.cc (pretty_id): Rework slightly to not rely on spaces.
|
* cygcheck.cc (pretty_id): Rework slightly to not rely on spaces.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* mount.cc
|
/* 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.
|
This file is part of Cygwin.
|
||||||
|
|
||||||
@ -120,6 +120,7 @@ static struct option longopts[] =
|
|||||||
{"help", no_argument, NULL, 'h' },
|
{"help", no_argument, NULL, 'h' },
|
||||||
{"mount-commands", no_argument, NULL, 'm'},
|
{"mount-commands", no_argument, NULL, 'm'},
|
||||||
{"no-executable", no_argument, NULL, 'E'},
|
{"no-executable", no_argument, NULL, 'E'},
|
||||||
|
{"options", required_argument, NULL, 'E'},
|
||||||
{"show-cygdrive-prefix", no_argument, NULL, 'p'},
|
{"show-cygdrive-prefix", no_argument, NULL, 'p'},
|
||||||
{"system", no_argument, NULL, 's'},
|
{"system", no_argument, NULL, 's'},
|
||||||
{"text", no_argument, NULL, 't'},
|
{"text", no_argument, NULL, 't'},
|
||||||
@ -128,7 +129,7 @@ static struct option longopts[] =
|
|||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static char opts[] = "bcfhmpstuvxEX";
|
static char opts[] = "bcfhmpstuvxEXo:";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage (FILE *where = stderr)
|
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\
|
-h, --help output usage information and exit\n\
|
||||||
-m, --mount-commands write mount commands to replace user and\n\
|
-m, --mount-commands write mount commands to replace user and\n\
|
||||||
system mount points and cygdrive prefixes\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\
|
-p, --show-cygdrive-prefix show user and/or system cygdrive path prefix\n\
|
||||||
-s, --system (default) add system-wide mount point\n\
|
-s, --system (default) add system-wide mount point\n\
|
||||||
-t, --text text files get \\r\\n line endings\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);
|
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
|
static void
|
||||||
print_version ()
|
print_version ()
|
||||||
{
|
{
|
||||||
@ -181,12 +202,21 @@ Compiled on %s\n\
|
|||||||
", progname, len, v, __DATE__);
|
", 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
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int flags = MOUNT_BINARY;
|
int flags = MOUNT_BINARY;
|
||||||
int default_flag = MOUNT_SYSTEM;
|
int default_flag = MOUNT_SYSTEM;
|
||||||
|
char *options = strdup ("");
|
||||||
enum do_what
|
enum do_what
|
||||||
{
|
{
|
||||||
nada,
|
nada,
|
||||||
@ -233,6 +263,12 @@ main (int argc, char **argv)
|
|||||||
else
|
else
|
||||||
usage ();
|
usage ();
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
if (*options)
|
||||||
|
options = concat3 (options, ",", optarg);
|
||||||
|
else
|
||||||
|
options = strdup (optarg);
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (do_what == nada)
|
if (do_what == nada)
|
||||||
do_what = saw_show_cygdrive_prefix;
|
do_what = saw_show_cygdrive_prefix;
|
||||||
@ -266,6 +302,30 @@ main (int argc, char **argv)
|
|||||||
usage ();
|
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))
|
if (flags & MOUNT_NOTEXEC && flags & (MOUNT_EXEC | MOUNT_CYGWIN_EXEC))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: invalid combination of executable options\n", progname);
|
fprintf (stderr, "%s: invalid combination of executable options\n", progname);
|
||||||
|
@ -534,6 +534,7 @@ Display information about mounted filesystems, or mount a filesystem
|
|||||||
-h, --help output usage information and exit
|
-h, --help output usage information and exit
|
||||||
-m, --mount-commands write mount commands to replace user and
|
-m, --mount-commands write mount commands to replace user and
|
||||||
system mount points and cygdrive prefixes
|
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
|
-p, --show-cygdrive-prefix show user and/or system cygdrive path prefix
|
||||||
-s, --system (default) add system-wide mount point
|
-s, --system (default) add system-wide mount point
|
||||||
-t, --text text files get \r\n line endings
|
-t, --text text files get \r\n line endings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user