aboutsummaryrefslogtreecommitdiff
path: root/winsup/utils
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-05-23 04:19:07 +0000
committerChristopher Faylor <me@cgf.cx>2002-05-23 04:19:07 +0000
commit8704ad9da94b9ac31a6bc02630b780691bf13339 (patch)
tree58807d82eee396275da112f0d3c3b64f15289dd3 /winsup/utils
parentfc240f584b02d8bb1a2bb60927c3d13b583c68a1 (diff)
downloadnewlib-8704ad9da94b9ac31a6bc02630b780691bf13339.zip
newlib-8704ad9da94b9ac31a6bc02630b780691bf13339.tar.gz
newlib-8704ad9da94b9ac31a6bc02630b780691bf13339.tar.bz2
* mount.cc (version) New global variable.
(usage) Standardize usage output. Accomodate new version option. (print_version) New function. (longopts) Accomodate new version option. (opts) Ditto. (main) Ditto.
Diffstat (limited to 'winsup/utils')
-rw-r--r--winsup/utils/ChangeLog9
-rw-r--r--winsup/utils/mount.cc87
2 files changed, 73 insertions, 23 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index 0fb9441..fe82b95 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,12 @@
+2002-05-22 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
+
+ * mount.cc (version) New global variable.
+ (usage) Standardize usage output. Accomodate new version option.
+ (print_version) New function.
+ (longopts) Accomodate new version option.
+ (opts) Ditto.
+ (main) Ditto.
+
2002-05-22 Corinna Vinschen <corinna@vinschen.de>
* cygpath.cc (usage): Change usage output slightly.
diff --git a/winsup/utils/mount.cc b/winsup/utils/mount.cc
index 959cdf9..fca6a35 100644
--- a/winsup/utils/mount.cc
+++ b/winsup/utils/mount.cc
@@ -1,6 +1,6 @@
/* mount.cc
- Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
This file is part of Cygwin.
@@ -33,6 +33,7 @@ static int mount_already_exists (const char *posix_path, int flags);
// static short create_missing_dirs = FALSE;
static short force = FALSE;
+static const char version[] = "$Revision$";
static const char *progname;
static void
@@ -111,46 +112,73 @@ do_mount (const char *dev, const char *where, int flags)
static struct option longopts[] =
{
- {"help", no_argument, NULL, 'h' },
{"binary", no_argument, NULL, 'b'},
- {"force", no_argument, NULL, 'f'},
- {"system", no_argument, NULL, 's'},
- {"text", no_argument, NULL, 't'},
- {"user", no_argument, NULL, 'u'},
- {"executable", no_argument, NULL, 'x'},
- {"no-executable", no_argument, NULL, 'E'},
{"change-cygdrive-prefix", no_argument, NULL, 'c'},
{"cygwin-executable", no_argument, NULL, 'X'},
- {"show-cygdrive-prefix", no_argument, NULL, 'p'},
+ {"executable", no_argument, NULL, 'x'},
+ {"force", no_argument, NULL, 'f'},
+ {"help", no_argument, NULL, 'h' },
{"import-old-mounts", no_argument, NULL, 'i'},
{"mount-commands", no_argument, NULL, 'm'},
+ {"no-executable", no_argument, NULL, 'E'},
+ {"show-cygdrive-prefix", no_argument, NULL, 'p'},
+ {"system", no_argument, NULL, 's'},
+ {"text", no_argument, NULL, 't'},
+ {"user", no_argument, NULL, 'u'},
+ {"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
-static char opts[] = "hbfstuxXEpicm";
+static char opts[] = "bcfhimpstuvxEX";
static void
-usage (void)
+usage (FILE *where = stderr)
{
- fprintf (stderr, "Usage: %s [OPTION] [<win32path> <posixpath>]\n\
+ fprintf (where, "Usage: %s [OPTION] [<win32path> <posixpath>]\n\
-b, --binary text files are equivalent to binary files\n\
(newline = \\n)\n\
-c, --change-cygdrive-prefix change the cygdrive path prefix to <posixpath>\n\
-f, --force force mount, don't warn about missing mount\n\
point directories\n\
+ -h, --help output usage information and exit\n\
-i, --import-old-mounts copy old registry mount table mounts into the\n\
current mount areas\n\
+ -m, --mount-commands write mount commands to replace user and\n\
+ system mount points and cygdrive prefixes\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 (default) text files get \\r\\n line endings\n\
-u, --user add user-only mount point\n\
+ -v, --version output version information and exit\n\
-x, --executable treat all files under mount point as executables\n\
+ -E, --no-executable treat all files under mount point as \n\
+ non-executables\n\
-X, --cygwin-executable treat all files under mount point as cygwin\n\
executables\n\
- -m, --mount-commands write mount commands to replace user and\n\
- system mount points and cygdrive prefixes\n\
", progname);
- exit (1);
+ exit (where == stderr ? 1 : 0);
+}
+
+static void
+print_version ()
+{
+ const char *v = strchr (version, ':');
+ int len;
+ if (!v)
+ {
+ v = "?";
+ len = 1;
+ }
+ else
+ {
+ v += 2;
+ len = strchr (v, ' ') - v;
+ }
+ printf ("\
+%s (cygwin) %.*s\n\
+Filesystem Utility\n\
+Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
+Compiled on %s", progname, len, v, __DATE__);
}
int
@@ -168,7 +196,13 @@ main (int argc, char **argv)
saw_mount_commands
} do_what = nada;
- progname = argv[0];
+ progname = strrchr (argv[0], '/');
+ if (progname == NULL)
+ progname = strrchr (argv[0], '\\');
+ if (progname == NULL)
+ progname = argv[0];
+ else
+ progname++;
if (argc == 1)
{
@@ -191,12 +225,21 @@ main (int argc, char **argv)
case 'f':
force = TRUE;
break;
+ case 'h':
+ usage (stdout);
+ break;
case 'i':
if (do_what == nada)
do_what = saw_import_old_mounts;
else
usage ();
break;
+ case 'm':
+ if (do_what == nada)
+ do_what = saw_mount_commands;
+ else
+ usage ();
+ break;
case 'p':
if (do_what == nada)
do_what = saw_show_cygdrive_prefix;
@@ -213,8 +256,9 @@ main (int argc, char **argv)
flags &= ~MOUNT_SYSTEM;
default_flag = 0;
break;
- case 'X':
- flags |= MOUNT_CYGWIN_EXEC;
+ case 'v':
+ print_version ();
+ return 0;
break;
case 'x':
flags |= MOUNT_EXEC;
@@ -222,11 +266,8 @@ main (int argc, char **argv)
case 'E':
flags |= MOUNT_NOTEXEC;
break;
- case 'm':
- if (do_what == nada)
- do_what = saw_mount_commands;
- else
- usage ();
+ case 'X':
+ flags |= MOUNT_CYGWIN_EXEC;
break;
default:
usage ();