* path.cc (oopts): Sort alphabetically, add missing "auto" and

"override" entries.
	(from_fstab_line): Handle mount points same as Cygwin itself.  Use
	"cygdrive prefix" as posix name of cygdrive prefix.
	(from_fstab): Add auto entries for /usr/bin and /usr/lib.  Add
	MOUNT_AUTOMATIC and MOUNT_IMMUTABLE flags to default root dir entry.
	Use "cygdrive prefix" as posix name of default cygdrive prefix.
	(getmntent): Allocate smaller buffers.  Align output closer to output
	of mount(1).
This commit is contained in:
Corinna Vinschen 2009-06-10 10:42:22 +00:00
parent 5c1939c8c4
commit 070a99e8aa
2 changed files with 71 additions and 32 deletions

View File

@ -1,3 +1,15 @@
2009-06-10 Corinna Vinschen <corinna@vinschen.de>
* path.cc (oopts): Sort alphabetically, add missing "auto" and
"override" entries.
(from_fstab_line): Handle mount points same as Cygwin itself. Use
"cygdrive prefix" as posix name of cygdrive prefix.
(from_fstab): Add auto entries for /usr/bin and /usr/lib. Add
MOUNT_AUTOMATIC and MOUNT_IMMUTABLE flags to default root dir entry.
Use "cygdrive prefix" as posix name of default cygdrive prefix.
(getmntent): Allocate smaller buffers. Align output closer to output
of mount(1).
2009-05-17 Corinna Vinschen <corinna@vinschen.de> 2009-05-17 Corinna Vinschen <corinna@vinschen.de>
* cygpath.cc (codepage): New variable. * cygpath.cc (codepage): New variable.

View File

@ -309,18 +309,20 @@ static struct opt
bool clear; bool clear;
} oopts[] = } oopts[] =
{ {
{"user", MOUNT_SYSTEM, 1},
{"nouser", MOUNT_SYSTEM, 0},
{"binary", MOUNT_BINARY, 0},
{"text", MOUNT_BINARY, 1},
{"exec", MOUNT_EXEC, 0},
{"notexec", MOUNT_NOTEXEC, 0},
{"cygexec", MOUNT_CYGWIN_EXEC, 0},
{"nosuid", 0, 0},
{"acl", MOUNT_NOACL, 1}, {"acl", MOUNT_NOACL, 1},
{"auto", 0, 0},
{"binary", MOUNT_BINARY, 0},
{"cygexec", MOUNT_CYGWIN_EXEC, 0},
{"exec", MOUNT_EXEC, 0},
{"noacl", MOUNT_NOACL, 0}, {"noacl", MOUNT_NOACL, 0},
{"nosuid", 0, 0},
{"notexec", MOUNT_NOTEXEC, 0},
{"nouser", MOUNT_SYSTEM, 0},
{"override", MOUNT_OVERRIDE, 0},
{"posix=0", MOUNT_NOPOSIX, 0},
{"posix=1", MOUNT_NOPOSIX, 1}, {"posix=1", MOUNT_NOPOSIX, 1},
{"posix=0", MOUNT_NOPOSIX, 0} {"text", MOUNT_BINARY, 1},
{"user", MOUNT_SYSTEM, 1}
}; };
static bool static bool
@ -405,21 +407,29 @@ from_fstab_line (mnt_t *m, char *line, bool user)
return false; return false;
} }
m->posix = strdup (posix_path); m->posix = strdup (posix_path);
m->native = strdup ("."); m->native = strdup ("cygdrive prefix");
m->flags = mount_flags | MOUNT_CYGDRIVE; m->flags = mount_flags | MOUNT_CYGDRIVE;
} }
else else
{ {
for (mnt_t *sm = mount_table; sm < m; ++sm) for (mnt_t *sm = mount_table; sm < m; ++sm)
if (!strcasecmp (sm->posix, posix_path)) if (!strcmp (sm->posix, posix_path))
{ {
if ((mount_flags & MOUNT_SYSTEM) || !(sm->flags & MOUNT_SYSTEM)) /* Don't allow overriding of a system mount with a user mount. */
{ if ((sm->flags & MOUNT_SYSTEM) && !(mount_flags & MOUNT_SYSTEM))
if (sm->native) return false;
free (sm->native); if ((sm->flags & MOUNT_SYSTEM) != (mount_flags & MOUNT_SYSTEM))
sm->native = strdup (native_path); continue;
sm->flags = mount_flags; /* Changing immutable mount points require the override flag. */
} if ((sm->flags & MOUNT_IMMUTABLE)
&& !(mount_flags & MOUNT_OVERRIDE))
return false;
if (mount_flags & MOUNT_OVERRIDE)
mount_flags |= MOUNT_IMMUTABLE;
if (sm->native)
free (sm->native);
sm->native = strdup (native_path);
sm->flags = mount_flags;
return false; return false;
} }
m->posix = strdup (posix_path); m->posix = strdup (posix_path);
@ -462,13 +472,26 @@ from_fstab (bool user, PWCHAR path, PWCHAR path_end)
*(native_path += 2) = '\\'; *(native_path += 2) = '\\';
m->posix = strdup ("/"); m->posix = strdup ("/");
m->native = strdup (native_path); m->native = strdup (native_path);
m->flags = MOUNT_SYSTEM | MOUNT_BINARY; m->flags = MOUNT_SYSTEM | MOUNT_BINARY | MOUNT_IMMUTABLE
| MOUNT_AUTOMATIC;
++m;
/* Create default /usr/bin and /usr/lib entries. */
char *trail = strchr (native_path, '\0');
strcpy (trail, "\\bin");
m->posix = strdup ("/usr/bin");
m->native = strdup (native_path);
m->flags = MOUNT_SYSTEM | MOUNT_BINARY | MOUNT_AUTOMATIC;
++m;
strcpy (trail, "\\lib");
m->posix = strdup ("/usr/lib");
m->native = strdup (native_path);
m->flags = MOUNT_SYSTEM | MOUNT_BINARY | MOUNT_AUTOMATIC;
++m; ++m;
/* Create a default cygdrive entry. Note that this is a user entry. /* Create a default cygdrive entry. Note that this is a user entry.
This allows to override it with mount, unless the sysadmin created This allows to override it with mount, unless the sysadmin created
a cygdrive entry in /etc/fstab. */ a cygdrive entry in /etc/fstab. */
m->posix = strdup (CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX); m->posix = strdup (CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX);
m->native = strdup ("."); m->native = strdup ("cygdrive prefix");
m->flags = MOUNT_BINARY | MOUNT_CYGDRIVE; m->flags = MOUNT_BINARY | MOUNT_CYGDRIVE;
++m; ++m;
max_mount_entry = m - mount_table; max_mount_entry = m - mount_table;
@ -845,29 +868,33 @@ getmntent (FILE *)
mnt.mnt_fsname = (char *) m->native; mnt.mnt_fsname = (char *) m->native;
mnt.mnt_dir = (char *) m->posix; mnt.mnt_dir = (char *) m->posix;
if (!mnt.mnt_type) if (!mnt.mnt_type)
mnt.mnt_type = (char *) malloc (1024); mnt.mnt_type = (char *) malloc (16);
if (!mnt.mnt_opts) if (!mnt.mnt_opts)
mnt.mnt_opts = (char *) malloc (1024); mnt.mnt_opts = (char *) malloc (64);
if (m->flags & MOUNT_SYSTEM)
strcpy (mnt.mnt_type, (char *) "system"); strcpy (mnt.mnt_type, (char *) (m->flags & MOUNT_SYSTEM) ? "system" : "user");
else
strcpy (mnt.mnt_type, (char *) "user");
if (!(m->flags & MOUNT_BINARY)) if (!(m->flags & MOUNT_BINARY))
strcpy (mnt.mnt_opts, (char *) "textmode"); strcpy (mnt.mnt_opts, (char *) "text");
else else
strcpy (mnt.mnt_opts, (char *) "binmode"); strcpy (mnt.mnt_opts, (char *) "binary");
if (m->flags & MOUNT_CYGWIN_EXEC) if (m->flags & MOUNT_CYGWIN_EXEC)
strcat (mnt.mnt_opts, (char *) ",cygexec"); strcat (mnt.mnt_opts, (char *) ",cygexec");
else if (m->flags & MOUNT_EXEC) else if (m->flags & MOUNT_EXEC)
strcat (mnt.mnt_opts, (char *) ",exec"); strcat (mnt.mnt_opts, (char *) ",exec");
else if (m->flags & MOUNT_NOTEXEC) else if (m->flags & MOUNT_NOTEXEC)
strcat (mnt.mnt_opts, (char *) ",noexec"); strcat (mnt.mnt_opts, (char *) ",noexec");
if ((m->flags & MOUNT_CYGDRIVE)) /* cygdrive */
strcat (mnt.mnt_opts, (char *) ",cygdrive"); if (m->flags & MOUNT_NOACL)
if ((m->flags & MOUNT_NOACL))
strcat (mnt.mnt_opts, (char *) ",noacl"); strcat (mnt.mnt_opts, (char *) ",noacl");
if ((m->flags & MOUNT_NOPOSIX))
if (m->flags & MOUNT_NOPOSIX)
strcat (mnt.mnt_opts, (char *) ",posix=0"); strcat (mnt.mnt_opts, (char *) ",posix=0");
if (m->flags & (MOUNT_AUTOMATIC | MOUNT_CYGDRIVE))
strcat (mnt.mnt_opts, (char *) ",auto");
mnt.mnt_freq = 1; mnt.mnt_freq = 1;
mnt.mnt_passno = 1; mnt.mnt_passno = 1;
m++; m++;