* mount.cc (struct opt): Add "bind" option.

(mount_info::from_fstab_line): Handle "bind" option.
	(fillout_mntent): Add "bind" option to mnt_opts.
	(mount): Handle "bind" option.
	* include/sys/mount.h (MOUNT_BIND): New mount flag.
This commit is contained in:
Corinna Vinschen 2010-08-11 10:58:06 +00:00
parent ac8050277c
commit a5fe426282
3 changed files with 50 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2010-08-11 Corinna Vinschen <corinna@vinschen.de>
* mount.cc (struct opt): Add "bind" option.
(mount_info::from_fstab_line): Handle "bind" option.
(fillout_mntent): Add "bind" option to mnt_opts.
(mount): Handle "bind" option.
* include/sys/mount.h (MOUNT_BIND): New mount flag.
2010-08-10 Christopher Faylor <me+cygwin@cgf.cx>
* sigproc.cc (init_sig_pipe): Add retry loop.

View File

@ -39,7 +39,8 @@ enum
MOUNT_AUTOMATIC = 0x20000, /* Mount point was added automatically */
MOUNT_DOS = 0x40000, /* convert leading spaces and trailing
dots and spaces to private use area */
MOUNT_IHASH = 0x80000 /* Enforce hash values for inode numbers */
MOUNT_IHASH = 0x80000, /* Enforce hash values for inode numbers */
MOUNT_BIND = 0x100000 /* Allows bind syntax in fstab file. */
};
int mount (const char *, const char *, unsigned __flags);

View File

@ -931,6 +931,7 @@ struct opt
{"acl", MOUNT_NOACL, 1},
{"auto", 0, 0},
{"binary", MOUNT_BINARY, 0},
{"bind", MOUNT_BIND, 0},
{"cygexec", MOUNT_CYGWIN_EXEC, 0},
{"dos", MOUNT_DOS, 0},
{"exec", MOUNT_EXEC, 0},
@ -1051,6 +1052,20 @@ mount_info::from_fstab_line (char *line, bool user)
return true;
if (user)
mount_flags &= ~MOUNT_SYSTEM;
if (mount_flags & MOUNT_BIND)
{
/* Prepend root path to bound path. */
char *bound_path = native_path;
device dev;
unsigned flags = 0;
native_path = (char *) alloca (PATH_MAX);
int error = conv_to_win32_path (bound_path, native_path, dev, &flags);
if (error || strlen (native_path) >= MAX_PATH)
return true;
if ((mount_flags & ~MOUNT_SYSTEM) == (MOUNT_BIND | MOUNT_BINARY))
mount_flags = (MOUNT_BIND | flags)
& ~(MOUNT_IMMUTABLE | MOUNT_AUTOMATIC);
}
if (!strcmp (fs_type, "cygdrive"))
{
cygdrive_flags = mount_flags | MOUNT_CYGDRIVE;
@ -1573,6 +1588,9 @@ fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
if (flags & (MOUNT_AUTOMATIC | MOUNT_CYGDRIVE))
strcat (_my_tls.locals.mnt_opts, (char *) ",auto");
if (flags & (MOUNT_BIND))
strcat (_my_tls.locals.mnt_opts, (char *) ",bind");
ret.mnt_opts = _my_tls.locals.mnt_opts;
ret.mnt_freq = 1;
@ -1672,7 +1690,28 @@ mount (const char *win32_path, const char *posix_path, unsigned flags)
else if (!*win32_path)
set_errno (EINVAL);
else
res = mount_table->add_item (win32_path, posix_path, flags);
{
char *w32_path = (char *) win32_path;
if (flags & MOUNT_BIND)
{
/* Prepend root path to bound path. */
tmp_pathbuf tp;
device dev;
unsigned conv_flags = 0;
const char *bound_path = w32_path;
w32_path = tp.c_get ();
int error = mount_table->conv_to_win32_path (bound_path, w32_path,
dev, &conv_flags);
if (error || strlen (w32_path) >= MAX_PATH)
return true;
if ((flags & ~MOUNT_SYSTEM) == (MOUNT_BIND | MOUNT_BINARY))
flags = (MOUNT_BIND | conv_flags)
& ~(MOUNT_IMMUTABLE | MOUNT_AUTOMATIC);
}
res = mount_table->add_item (w32_path, posix_path, flags);
}
syscall_printf ("%d = mount (%s, %s, %p)", res, win32_path, posix_path, flags);
return res;