From 68a178b37ca1fb6c05b508a92314c22a00f6ebd9 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 11 Aug 2010 11:01:14 +0000 Subject: [PATCH] * mount.cc (do_mount): Don't treat "bind" mount as remote mount. (mount_entries): Drop the "bind" option from output. * utils.sgml (mount): Match examples to actual mount output. Add "bind" option and add example. --- winsup/utils/ChangeLog | 7 ++++++ winsup/utils/mount.cc | 8 +++++-- winsup/utils/utils.sgml | 49 +++++++++++++++++++++++++++-------------- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 1f0829104..8bcad9b43 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,10 @@ +2010-08-11 Corinna Vinschen + + * mount.cc (do_mount): Don't treat "bind" mount as remote mount. + (mount_entries): Drop the "bind" option from output. + * utils.sgml (mount): Match examples to actual mount output. Add + "bind" option and add example. + 2010-08-10 Yaakov Selkowitz * mingw: Use sysroot, if present, for mingw_dir. diff --git a/winsup/utils/mount.cc b/winsup/utils/mount.cc index 3e342af5d..be6ad03d0 100644 --- a/winsup/utils/mount.cc +++ b/winsup/utils/mount.cc @@ -86,7 +86,7 @@ do_mount (const char *dev, const char *where, int flags) fprintf (stderr, "%s: warning: %s is not a directory.\n", progname, where); } - if (!force && !(flags & EXEC_FLAGS) && strlen (dev)) + if (!force && !(flags & (EXEC_FLAGS | MOUNT_BIND)) && strlen (dev)) { char devtmp[1 + 2 * strlen (dev)]; strcpy (devtmp, dev); @@ -426,10 +426,14 @@ mount_entries (void) // write fstab entries for normal mount points while ((p = getmntent (m)) != NULL) - // Only list non-cygdrives + // Only list non-cygdrives and non-automounts if (!strstr (p->mnt_opts, ",noumount") && !strstr (p->mnt_opts, ",auto")) { char fsname[NT_MAX_PATH], dirname[NT_MAX_PATH]; + /* Drop the "bind" option since it can't be reverted. */ + char *c = strstr (p->mnt_opts, ",bind"); + if (c) + memmove (c, c + 5, strlen (c + 5) + 1); printf (format_mnt, convert_spaces (fsname, p->mnt_fsname), convert_spaces (dirname, p->mnt_dir), p->mnt_type, p->mnt_opts); diff --git a/winsup/utils/utils.sgml b/winsup/utils/utils.sgml index f25fc72f6..77cb17b2e 100644 --- a/winsup/utils/utils.sgml +++ b/winsup/utils/utils.sgml @@ -964,22 +964,22 @@ will display the current mount table for you. Displaying the current set of mount points $ mount -c:\cygwin\bin on /usr/bin type ntfs (binary) -c:\cygwin\lib on /usr/lib type ntfs (binary) -c:\cygwin on / type ntfs (binary) -c: on /c type ntfs (binary,user,noumount) -d: on /d type fat (binary,user,noumount) +C:/cygwin/bin on /usr/bin type ntfs (binary) +C:/cygwin/lib on /usr/lib type ntfs (binary) +C:/cygwin on / type ntfs (binary) +C: on /mnt/c type ntfs (binary,user,noumount) +D: on /mnt/d type fat (binary,user,noumount) -In this example, c:\cygwin is the POSIX root and D drive is mapped to -/d. Note that in this case, the root mount is a -system-wide mount point that is visible to all users running Cygwin -programs, whereas the /d mount is only visible -to the current user. +In this example, c:/cygwin is the POSIX root and the D drive is +mapped to /mnt/d. Note that in this case, the root +mount is a system-wide mount point that is visible to all users running +Cygwin programs, whereas the /mnt/d mount is only +visible to the current user. The mount utility is also the mechanism for -adding new mounts to the mount table. The following example +adding new mounts to the mount table in memory. The following example demonstrates how to mount the directory //pollux/home/joe/data to /data for the duration of the current session. @@ -994,11 +994,11 @@ ls: /data: No such file or directory mount: warning - /data does not exist! $ mount //pollux/home/joe/data on /data type smbfs (binary) -c:/cygwin/bin on /usr/bin type ntfs (binary) -c:/cygwin/lib on /usr/lib type ntfs (binary) -c:/cygwin on / type ntfs (binary) -c: on /c type ntfs (binary,user,noumount) -d: on /d type fat (binary,user,noumount) +C:/cygwin/bin on /usr/bin type ntfs (binary) +C:/cygwin/lib on /usr/lib type ntfs (binary) +C:/cygwin on / type ntfs (binary) +C: on /c type ntfs (binary,user,noumount) +D: on /d type fat (binary,user,noumount) @@ -1019,6 +1019,13 @@ most of the options are duplicates of other mount flags): acl - Use the filesystem's access control lists (ACLs) to implement real POSIX permissions (default). binary - Files default to binary mode (default). + bind - Allows to remount part of the file hierarchy somewhere else. + Different from other mount calls, the first argument + specifies an absolute POSIX path, rather than a Win32 path. + This POSIX path is remounted to the POSIX path specified as + the second parameter. The conversion to a Win32 path is done + within Cygwin immediately at the time of the call. Note that + symlinks are ignored while performing this path conversion. cygexec - Treat all files below mount point as cygwin executables. dos - Always convert leading spaces and trailing dots and spaces to characters in the UNICODE private use area. This allows to use @@ -1071,6 +1078,16 @@ all such added mount points are added as user mount points, and that the rule that system mount points can't be removed or replaced in a running session still applies. +To bind a POSIX path to another POSIX path, use the +bind mount flag. + + +$ mount -o bind /var /usr/var + + +This command makes the file hirarchy under /var +additionally available under /usr/var. + The -m option causes the mount utility to output the current mount table in a series of fstab entries.