mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-03-02 13:05:42 +08:00
2004-05-30 Pierre Humblet <pierre.humblet@ieee.org>
* path.cc (mount_info::add_item): Make sure native path has drive or UNC form. Call normalize_xxx_path instead of [back]slashify. Remove test for double slashes. Reorganize to always debug_print.
This commit is contained in:
parent
e3c1b77980
commit
2d5afa98a2
@ -1,3 +1,9 @@
|
|||||||
|
2004-05-30 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
|
* path.cc (mount_info::add_item): Make sure native path has drive
|
||||||
|
or UNC form. Call normalize_xxx_path instead of [back]slashify.
|
||||||
|
Remove test for double slashes. Reorganize to always debug_print.
|
||||||
|
|
||||||
2004-05-28 Pierre Humblet <Pierre.Humblet@ieee.org>
|
2004-05-28 Pierre Humblet <Pierre.Humblet@ieee.org>
|
||||||
|
|
||||||
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Only try to open
|
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Only try to open
|
||||||
|
@ -2176,40 +2176,41 @@ mount_info::sort ()
|
|||||||
int
|
int
|
||||||
mount_info::add_item (const char *native, const char *posix, unsigned mountflags, int reg_p)
|
mount_info::add_item (const char *native, const char *posix, unsigned mountflags, int reg_p)
|
||||||
{
|
{
|
||||||
|
char nativetmp[CYG_MAX_PATH];
|
||||||
|
char posixtmp[CYG_MAX_PATH];
|
||||||
|
char *nativetail, *posixtail, error[] = "error";
|
||||||
|
int nativeerr, posixerr;
|
||||||
|
|
||||||
/* Something's wrong if either path is NULL or empty, or if it's
|
/* Something's wrong if either path is NULL or empty, or if it's
|
||||||
not a UNC or absolute path. */
|
not a UNC or absolute path. */
|
||||||
|
|
||||||
if ((native == NULL) || (*native == 0) ||
|
if (native == NULL || !isabspath (native) ||
|
||||||
(posix == NULL) || (*posix == 0) ||
|
!(is_unc_share (native) || isdrive (native)))
|
||||||
!isabspath (native) || !isabspath (posix) ||
|
nativeerr = EINVAL;
|
||||||
|
else
|
||||||
|
nativeerr = normalize_win32_path (native, nativetmp, &nativetail);
|
||||||
|
|
||||||
|
if (posix == NULL || !isabspath (posix) ||
|
||||||
is_unc_share (posix) || isdrive (posix))
|
is_unc_share (posix) || isdrive (posix))
|
||||||
{
|
posixerr = EINVAL;
|
||||||
set_errno (EINVAL);
|
else
|
||||||
return -1;
|
posixerr = normalize_posix_path (posix, posixtmp, &posixtail);
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure both paths do not end in /. */
|
|
||||||
char nativetmp[CYG_MAX_PATH];
|
|
||||||
char posixtmp[CYG_MAX_PATH];
|
|
||||||
|
|
||||||
backslashify (native, nativetmp, 0);
|
|
||||||
nofinalslash (nativetmp, nativetmp);
|
|
||||||
|
|
||||||
slashify (posix, posixtmp, 0);
|
|
||||||
nofinalslash (posixtmp, posixtmp);
|
|
||||||
|
|
||||||
debug_printf ("%s[%s], %s[%s], %p",
|
debug_printf ("%s[%s], %s[%s], %p",
|
||||||
native, nativetmp, posix, posixtmp, mountflags);
|
native, nativeerr?error:nativetmp,
|
||||||
|
posix, posixerr?error:posixtmp, mountflags);
|
||||||
|
|
||||||
/* Duplicate /'s in path are an error. */
|
if (nativeerr || posixerr)
|
||||||
for (char *p = posixtmp + 1; *p; ++p)
|
|
||||||
{
|
{
|
||||||
if (p[-1] == '/' && p[0] == '/')
|
set_errno (nativeerr?:posixerr);
|
||||||
{
|
|
||||||
set_errno (EINVAL);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/* Make sure both paths do not end in /. */
|
||||||
|
if (nativetail > nativetmp + 1 && nativetail[-1] == '\\')
|
||||||
|
nativetail[-1] = '\0';
|
||||||
|
if (posixtail > posixtmp + 1 && posixtail[-1] == '/')
|
||||||
|
posixtail[-1] = '\0';
|
||||||
|
|
||||||
/* Write over an existing mount item with the same POSIX path if
|
/* Write over an existing mount item with the same POSIX path if
|
||||||
it exists and is from the same registry area. */
|
it exists and is from the same registry area. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user