* Align usage output, version output, as well as usage and version

option handling to use the same style throughout all Cygwin utils.
	Throughout use program_invocation_short_name to refer to current
	process name in Cygwin executables.
	* utils.sgml: Align documentation to above change.  Add missing
	sections for getconf, ldd, and setmetamode.
	* strace.cc (proc_child): Avoid compiler warning.
This commit is contained in:
Corinna Vinschen
2011-10-10 14:57:48 +00:00
parent 4fc8a5c90a
commit 92b499acff
21 changed files with 687 additions and 611 deletions

View File

@@ -1,7 +1,7 @@
/* mount.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005,
2008, 2009, 2010 Red Hat, Inc.
2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin.
@@ -15,6 +15,7 @@ details. */
#include <mntent.h>
#include <windows.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
@@ -39,7 +40,6 @@ static int mount_already_exists (const char *posix_path, int flags);
// static short create_missing_dirs = FALSE;
static bool force = false;
static const char version[] = "$Revision$";
static const char *progname;
static void
@@ -83,7 +83,8 @@ do_mount (const char *dev, const char *where, int flags)
else if (!(statbuf.st_mode & S_IFDIR))
{
if (!force)
fprintf (stderr, "%s: warning: %s is not a directory.\n", progname, where);
fprintf (stderr, "%s: warning: %s is not a directory.\n",
progname, where);
}
if (!force && !(flags & (EXEC_FLAGS | MOUNT_BIND)) && strlen (dev))
@@ -100,9 +101,10 @@ do_mount (const char *dev, const char *where, int flags)
strcat (devtmp, "\\");
if (GetDriveType (devtmp) == DRIVE_REMOTE)
{
fprintf (stderr, "%s: defaulting to 'notexec' mount option for speed since native path\n"
"%*creferences a remote share. Use '-f' option to override.\n", progname,
strlen(progname) + 2, ' ');
fprintf (stderr,
"%s: defaulting to 'notexec' mount option for speed since native path\n"
"%*creferences a remote share. Use '-f' option to override.\n",
progname, strlen(progname) + 2, ' ');
flags |= MOUNT_NOTEXEC;
}
}
@@ -201,20 +203,21 @@ static struct option longopts[] =
{"mount-entries", no_argument, NULL, 'm'},
{"options", required_argument, NULL, 'o'},
{"show-cygdrive-prefix", no_argument, NULL, 'p'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
static char opts[] = "acfhmpvo:";
static char opts[] = "acfhmpVo:";
static void
usage (FILE *where = stderr)
{
char *options;
fprintf (where, "Usage: %s [OPTION] [<win32path> <posixpath>]\n\
%s -a\n\
%s <posixpath>\n\
fprintf (where, "Usage: %1$s [OPTION] [<win32path> <posixpath>]\n\
%1$s -a\n\
%1$s <posixpath>\n\
\n\
Display information about mounted filesystems, or mount a filesystem\n\
\n\
-a, --all mount all filesystems mentioned in fstab\n\
@@ -226,8 +229,8 @@ Display information about mounted filesystems, or mount a filesystem\n\
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\
-v, --version output version information and exit\n\n",
progname, progname, progname);
-V, --version output version information and exit\n\n",
progname);
if (!cygwin_internal (CW_LST_MNT_OPTS, &options))
fprintf (where, "Valid options are: %s\n\n", options);
exit (where == stderr ? 1 : 0);
@@ -236,24 +239,15 @@ Display information about mounted filesystems, or mount a filesystem\n\
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-2010 Red Hat, Inc.\n\
Compiled on %s\n\
", progname, len, v, __DATE__);
printf ("mount (cygwin) %d.%d.%d\n"
"Mount filesystem utility\n"
"Copyright (C) 1996 - %s Red Hat, Inc.\n"
"This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
CYGWIN_VERSION_DLL_MAJOR / 1000,
CYGWIN_VERSION_DLL_MAJOR % 1000,
CYGWIN_VERSION_DLL_MINOR,
strrchr (__DATE__, ' ') + 1);
}
static char *
@@ -279,13 +273,7 @@ main (int argc, char **argv)
saw_mount_all,
} do_what = nada;
progname = strrchr (argv[0], '/');
if (progname == NULL)
progname = strrchr (argv[0], '\\');
if (progname == NULL)
progname = argv[0];
else
progname++;
progname = program_invocation_short_name;
if (argc == 1)
{
@@ -334,12 +322,13 @@ main (int argc, char **argv)
else
usage ();
break;
case 'v':
case 'V':
print_version ();
return 0;
break;
default:
usage ();
fprintf (stderr, "Try `%s --help' for more information.\n", progname);
return 1;
}
if (cygwin_internal (CW_CVT_MNT_OPTS, &options, &flags))
@@ -350,7 +339,8 @@ main (int argc, char **argv)
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);
exit (1);
}
@@ -516,13 +506,13 @@ mount_already_exists (const char *posix_path, int flags)
else
fprintf (stderr,
"%s: warning: user mount point of '%s' "
"masks system mount.\n",
progname, posix_path);
"masks system mount.\n", progname, posix_path);
break;
}
else
{
fprintf (stderr, "%s: warning: couldn't determine mount type.\n", progname);
fprintf (stderr, "%s: warning: couldn't determine mount type.\n",
progname);
break;
}
}