summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
authorPierre Humblet <phumblet@phumblet.no-ip.org>2004-05-31 02:20:39 +0000
committerPierre Humblet <phumblet@phumblet.no-ip.org>2004-05-31 02:20:39 +0000
commit2d5afa98a2181ddcea7387d983e98e2eb16ef5c3 (patch)
tree60493c7a1b21f0ed9f1048ec87aee1f233081017 /winsup/cygwin/path.cc
parente3c1b779800acdae8bf2194b757809c1d45f35b4 (diff)
downloadcygnal-2d5afa98a2181ddcea7387d983e98e2eb16ef5c3.tar.gz
cygnal-2d5afa98a2181ddcea7387d983e98e2eb16ef5c3.tar.bz2
cygnal-2d5afa98a2181ddcea7387d983e98e2eb16ef5c3.zip
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.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc49
1 files changed, 25 insertions, 24 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 102f51338..b09450476 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2176,40 +2176,41 @@ mount_info::sort ()
int
mount_info::add_item (const char *native, const char *posix, unsigned mountflags, int reg_p)
{
- /* Something's wrong if either path is NULL or empty, or if it's
- not a UNC or absolute path. */
-
- if ((native == NULL) || (*native == 0) ||
- (posix == NULL) || (*posix == 0) ||
- !isabspath (native) || !isabspath (posix) ||
- is_unc_share (posix) || isdrive (posix))
- {
- set_errno (EINVAL);
- return -1;
- }
-
- /* Make sure both paths do not end in /. */
char nativetmp[CYG_MAX_PATH];
char posixtmp[CYG_MAX_PATH];
+ char *nativetail, *posixtail, error[] = "error";
+ int nativeerr, posixerr;
- backslashify (native, nativetmp, 0);
- nofinalslash (nativetmp, nativetmp);
+ /* Something's wrong if either path is NULL or empty, or if it's
+ not a UNC or absolute path. */
- slashify (posix, posixtmp, 0);
- nofinalslash (posixtmp, posixtmp);
+ if (native == NULL || !isabspath (native) ||
+ !(is_unc_share (native) || isdrive (native)))
+ nativeerr = EINVAL;
+ else
+ nativeerr = normalize_win32_path (native, nativetmp, &nativetail);
+
+ if (posix == NULL || !isabspath (posix) ||
+ is_unc_share (posix) || isdrive (posix))
+ posixerr = EINVAL;
+ else
+ posixerr = normalize_posix_path (posix, posixtmp, &posixtail);
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. */
- for (char *p = posixtmp + 1; *p; ++p)
+ if (nativeerr || posixerr)
{
- if (p[-1] == '/' && p[0] == '/')
- {
- set_errno (EINVAL);
+ set_errno (nativeerr?:posixerr);
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
it exists and is from the same registry area. */