* mount.cc (do_mount): Default to non-exec option for remote drives. Report

warnings before attempting a mount.
(longopts): Add no-executable option.
(mount_commands): Ditto.
(opts): Ditto.
(usage): Ditto.  Indicate that system mount is now the default.
(main): Accommodate no-executable option.  Make system mount the default.
* umount.cc (usage): Indicate that system umount is now the default.
(main): Make system umount the default.
This commit is contained in:
Christopher Faylor 2002-05-12 04:29:54 +00:00
parent 29ee580d07
commit 48897dfeb9
4 changed files with 70 additions and 16 deletions

View File

@ -1,3 +1,16 @@
2002-05-12 Christopher Faylor <cgf@redhat.com>
* mount.cc (do_mount): Default to non-exec option for remote drives.
Report warnings before attempting a mount.
(longopts): Add no-executable option.
(mount_commands): Ditto.
(opts): Ditto.
(usage): Ditto. Indicate that system mount is now the default.
(main): Accommodate no-executable option. Make system mount the
default.
* umount.cc (usage): Indicate that system umount is now the default.
(main): Make system umount the default.
2002-05-07 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
* dumper.cc (usage) Standardize usage output. Generalize to allow use
@ -359,7 +372,7 @@ Fri Dec 14 12:10:39 2001 Jason Tishler <jason@tishler.net>
Tue Oct 9 21:59:00 2001 Christopher Faylor <cgf@cygnus.com>
* Makefile.in (MINGW_INCLUDES): Accomodate changes in Makefile.common.
* Makefile.in (MINGW_INCLUDES): Accommodate changes in Makefile.common.
Sun Oct 7 23:06:39 2001 Christopher Faylor <cgf@cygnus.com>

View File

@ -22,6 +22,8 @@ details. */
#endif
#include <errno.h>
#define EXEC_FLAGS (MOUNT_EXEC | MOUNT_NOTEXEC | MOUNT_CYGWIN_EXEC)
static void mount_commands (void);
static void show_mounts (void);
static void show_cygdrive_info (void);
@ -69,20 +71,41 @@ do_mount (const char *dev, const char *where, int flags)
}
#endif
if (mount (dev, where, flags))
error (where);
if (statres == -1)
{
if (force == FALSE)
if (!force)
fprintf (stderr, "%s: warning - %s does not exist.\n", progname, where);
}
else if (!(statbuf.st_mode & S_IFDIR))
{
if (force == FALSE)
if (!force)
fprintf (stderr, "%s: warning: %s is not a directory.\n", progname, where);
}
if (!force && !(flags & EXEC_FLAGS) && strlen (dev))
{
char devtmp[1 + 2 * strlen (dev)];
strcpy (devtmp, dev);
char c = strchr (devtmp, '\0')[-1];
if (c == '/' || c == '\\')
strcat (devtmp, ".");
/* Use a curious property of Windows which allows the use of \.. even
on non-directory paths. */
for (const char *p = dev; (p = strpbrk (p, "/\\")); p++)
strcat (devtmp, "\\..");
strcat (devtmp, "\\");
if (GetDriveType (devtmp) == DRIVE_REMOTE)
{
fprintf (stderr, "%s: defaulting to '--no-executable' flag for speed since native path\n"
"%*creferences a remote share. Use '-f' option to override.\n", progname,
strlen(progname) + 2, ' ');
flags |= MOUNT_NOTEXEC;
}
}
if (mount (dev, where, flags))
error (where);
exit (0);
}
@ -95,6 +118,7 @@ struct option longopts[] =
{"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'},
@ -103,7 +127,7 @@ struct option longopts[] =
{NULL, 0, NULL, 0}
};
char opts[] = "hbfstuxXpicm";
char opts[] = "hbfstuxXEpicm";
static void
usage (void)
@ -117,9 +141,9 @@ usage (void)
-i, --import-old-mounts copy old registry mount table mounts into the\n\
current mount areas\n\
-p, --show-cygdrive-prefix show user and/or system cygdrive path prefix\n\
-s, --system add mount point to system-wide registry location\n\
-s, --system (default) add system-wide mount point\n\
-t, --text (default) text files get \\r\\n line endings\n\
-u, --user (default) add mount point to user registry location\n\
-u, --user add user-only mount point\n\
-x, --executable treat all files under mount point as executables\n\
-X, --cygwin-executable treat all files under mount point as cygwin\n\
executables\n\
@ -134,6 +158,7 @@ main (int argc, char **argv)
{
int i;
int flags = 0;
int default_flag = MOUNT_SYSTEM;
enum do_what
{
nada,
@ -186,6 +211,7 @@ main (int argc, char **argv)
break;
case 'u':
flags &= ~MOUNT_SYSTEM;
default_flag = 0;
break;
case 'X':
flags |= MOUNT_CYGWIN_EXEC;
@ -193,6 +219,9 @@ main (int argc, char **argv)
case 'x':
flags |= MOUNT_EXEC;
break;
case 'E':
flags |= MOUNT_NOTEXEC;
break;
case 'm':
if (do_what == nada)
do_what = saw_mount_commands;
@ -203,6 +232,12 @@ main (int argc, char **argv)
usage ();
}
if (flags & MOUNT_NOTEXEC && flags & (MOUNT_EXEC | MOUNT_CYGWIN_EXEC))
{
fprintf (stderr, "%s: invalid combination of executable options\n", progname);
exit (1);
}
argc--;
switch (do_what)
{
@ -237,7 +272,7 @@ main (int argc, char **argv)
usage ();
}
if (force || !mount_already_exists (argv[optind + 1], flags))
do_mount (argv[optind], argv[optind + 1], flags);
do_mount (argv[optind], argv[optind + 1], flags | default_flag);
else
{
errno = EBUSY;
@ -278,6 +313,8 @@ mount_commands (void)
strcat (opts, " -t");
if (strstr (p->mnt_opts, ",exec"))
strcat (opts, " -x");
if (strstr (p->mnt_opts, ",noexec"))
strcat (opts, " -E");
while ((c = strchr (p->mnt_fsname, '\\')) != NULL)
*c = '/';
printf (format_mnt, opts, p->mnt_fsname, p->mnt_dir);

View File

@ -43,7 +43,7 @@ usage (void)
fprintf (stderr, "Usage %s [OPTION] [<posixpath>]\n\
-A, --remove-all-mounts remove all mounts\n\
-c, --remove-cygdrive-prefix remove cygdrive prefix\n\
-s, --system remove system mount\n\
-s, --system remove system mount (default)\n\
-S, --remove-system-mounts remove all system mounts\n\
-u, --user remove user mount\n\
-U, --remove-user-mounts remove all user mounts\n\
@ -63,6 +63,7 @@ main (int argc, char **argv)
{
int i;
int flags = 0;
int default_flag = MOUNT_SYSTEM;
progname = argv[0];
enum do_what
{
@ -99,6 +100,7 @@ main (int argc, char **argv)
break;
case 'u':
flags &= ~MOUNT_SYSTEM;
default_flag = 0;
break;
case 'U':
if (do_what != nada)
@ -134,7 +136,7 @@ main (int argc, char **argv)
default:
if (optind != argc - 1)
usage ();
if (cygwin_umount (argv[optind], flags) != 0)
if (cygwin_umount (argv[optind], flags | default_flag) != 0)
error (argv[optind]);
}

View File

@ -387,12 +387,14 @@ Usage mount
-i, --import-old-mounts copy old registry mount table mounts into the current
mount areas
-p, --show-cygdrive-prefix show user and/or system cygdrive path prefix
-s, --system add mount point to system-wide registry location
-s, --system (default) add mount point to system-wide registry location
-t, --text (default) text files get \r\n line endings
-u, --user (default) add mount point to user registry location
-u, --user add mount point to user registry location
-x, --executable treat all files under mount point as executables
-X, --cygwin-executable treat all files under mount point as cygwin
executables
executables. Use to speed up file access.
-E, --no-executable don't open files to see if they contain executable
magic. Use to speed up file access.
-m, --mount-commands write mount commands to replace user and
system mount points and cygdrive prefixes
@ -592,7 +594,7 @@ program.</para>
Usage umount [options] &lt;posixpath&gt;
-A, --remove-all-mounts remove all mounts
-c, --remove-cygdrive-prefix remove cygdrive prefix
-s, --system remove system mount
-s, --system remove system mount (default)
-S, --remove-system-mounts remove all system mounts
-u, --user remove user mount
-U, --remove-user-mounts remove all user mounts