diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2004-04-10 19:24:55 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2004-04-10 19:24:55 +0000 |
commit | 7224437c6270910a02646147149aaa97de145217 (patch) | |
tree | 9760e4e810a3c7828e42e92d950331dfeec8da4b /winsup/cygwin/fhandler.cc | |
parent | 56551a9bfbb369e29b12d1b60dc810cd5a3356b9 (diff) | |
download | cygnal-7224437c6270910a02646147149aaa97de145217.tar.gz cygnal-7224437c6270910a02646147149aaa97de145217.tar.bz2 cygnal-7224437c6270910a02646147149aaa97de145217.zip |
* fhandler.cc (rootdir): Add and use second argument.
* winsup.h (rootdir): Add second argument in declaration.
* path.cc (fs_info::update): Modify call to rootdir.
* syscalls.cc (check_posix_perm): Ditto.
(statfs): Ditto. Move syscall_printf near top.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r-- | winsup/cygwin/fhandler.cc | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 682646057..a005e6109 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1028,36 +1028,40 @@ fhandler_base::lock (int, struct __flock64 *) } extern "C" char * __stdcall -rootdir (char *full_path) +rootdir (const char *full_path, char *root_path) { /* Possible choices: * d:... -> d:/ * \\server\share... -> \\server\share\ - * else current drive. */ - char *root = full_path; + int len; + char *rootp = root_path; if (full_path[1] == ':') - strcpy (full_path + 2, "\\"); + { + *rootp++ = *full_path++; + *rootp++ = ':'; + } else if (full_path[0] == '\\' && full_path[1] == '\\') { - char *cp = full_path + 2; - while (*cp && *cp != '\\') - cp++; - if (!*cp) - { - set_errno (ENOTDIR); - return NULL; - } - cp++; - while (*cp && *cp != '\\') - cp++; - strcpy (cp, "\\"); + const char *cp = strchr (full_path + 2, '\\'); + if (!cp) + goto error; + while (*++cp && *cp != '\\') + ; + memcpy (root_path, full_path, (len = cp - full_path)); + rootp = root_path + len; } else - root = NULL; + { + error: + set_errno (ENOTDIR); + return NULL; + } - return root; + *rootp++ = '\\'; + *rootp = '\0'; + return root_path; } int __stdcall |