aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-09-19 03:22:45 +0000
committerChristopher Faylor <me@cgf.cx>2000-09-19 03:22:45 +0000
commit6e604fb15d9c0c05ab86b5a3135b4474bd52f807 (patch)
tree88e15e0cc89ec71d56fd2ef1f722c59b9053ae94 /winsup
parent45b80bb4ce0a6053bb3f2ce862eccf26cac96660 (diff)
downloadnewlib-6e604fb15d9c0c05ab86b5a3135b4474bd52f807.zip
newlib-6e604fb15d9c0c05ab86b5a3135b4474bd52f807.tar.gz
newlib-6e604fb15d9c0c05ab86b5a3135b4474bd52f807.tar.bz2
* path.h: Create new input path flag PATH_NEEDDIR.
* path.cc (path::check): Detect trailing slash before converting to windows path. Tell symlink_info::check to check for directory if one is found. (symlink_info::check): Set errno when path is not a directory if pflags & PATH_NEEDDIR.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/path.cc24
-rw-r--r--winsup/cygwin/path.h1
3 files changed, 31 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 366daf6..1fcf38f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,12 @@
+Mon Sep 18 23:17:19 2000 Christopher Faylor <cgf@cygnus.com>
+
+ * path.h: Create new input path flag PATH_NEEDDIR.
+ * path.cc (path::check): Detect trailing slash before converting to
+ windows path. Tell symlink_info::check to check for directory if one is
+ found.
+ (symlink_info::check): Set errno when path is not a directory if
+ pflags & PATH_NEEDDIR.
+
Mon Sep 18 19:44:08 2000 Christopher Faylor <cgf@cygnus.com>
* fhandler_tty.cc (fhandler_tty_slave::write): Correct typo which
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 5f40ee1..07e1829 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -189,6 +189,16 @@ path_conv::check (const char *src, unsigned opt,
for (;;)
{
MALLOC_CHECK;
+ DWORD need_directory = 0;
+ char *p = strrchr (src, '/');
+ if (p)
+ {
+ if (strcmp (p, "/") == 0 || strcmp (p, "/.") == 0)
+ need_directory = PATH_NEEDDIR;
+ }
+ else if ((p = strrchr (src, '\\')) &&
+ (strcmp (p, "\\") == 0 || strcmp (p, "\\.") == 0))
+ need_directory = PATH_NEEDDIR;
/* Must look up path in mount table, etc. */
error = cygwin_shared->mount.conv_to_win32_path (src, rel_path,
full_path,
@@ -247,7 +257,7 @@ path_conv::check (const char *src, unsigned opt,
else
{
suff = suffixes;
- sym.pflags = path_flags;
+ sym.pflags = path_flags | need_directory;
}
int len = sym.check (path_copy, suff);
@@ -317,7 +327,6 @@ path_conv::check (const char *src, unsigned opt,
}
/* Copy tail of full_path to discovered symlink. */
- char *p;
for (p = sym.contents + buflen; *tail; tail++)
*p++ = *tail == '\\' ? '/' : *tail;
*p = '\0';
@@ -2175,6 +2184,7 @@ symlink_info::check (const char *in_path, const suffix_info *suffixes)
HANDLE h;
int res = 0;
char extbuf[MAX_PATH + 5];
+ int needdir;
const char *path = in_path;
if (!suffixes)
@@ -2193,6 +2203,13 @@ symlink_info::check (const char *in_path, const suffix_info *suffixes)
is_symlink = TRUE;
error = 0;
+ if (!(pflags & PATH_NEEDDIR))
+ needdir = 0;
+ else
+ {
+ pflags &= ~PATH_NEEDDIR;
+ needdir = 1;
+ }
do
{
if (!next_suffix (ext_here, suffixes))
@@ -2217,7 +2234,8 @@ symlink_info::check (const char *in_path, const suffix_info *suffixes)
char *p = strrchr (path, '\\');
if (p && !(fileattr & FILE_ATTRIBUTE_DIRECTORY) &&
- (*++p == '\0' || (*p == '.' && (*++p == '\0' || (*p == '.' && p[1] == '\0')))))
+ (needdir || *++p == '\0' ||
+ (*p == '.' && (*++p == '\0' || (*p == '.' && p[1] == '\0')))))
{
debug_printf ("%s is a non-directory", path);
error = ENOTDIR;
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index 4c7f2c0..fdfbfdb 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -36,6 +36,7 @@ enum path_types
PATH_BINARY = MOUNT_BINARY,
PATH_EXEC = MOUNT_EXEC,
PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC,
+ PATH_NEEDDIR = 0x20000000,
PATH_SOCKET = 0x40000000,
PATH_HASACLS = 0x80000000
};