* 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.
+2004-04-10 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * 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.
+
2004-04-10 Corinna Vinschen <corinna@vinschen.de>
* Use new unified status_flag accessor methods from classes fhandler_*,
}
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
{
char fsname [CYG_MAX_PATH];
char root_dir [CYG_MAX_PATH];
- strncpy (root_dir, win32_path, CYG_MAX_PATH);
- if (!rootdir (root_dir))
+ if (!rootdir (win32_path, root_dir))
{
debug_printf ("Cannot get root component of path %s", win32_path);
clear ();
if (!allow_ntsec)
return 0;
- char *root = rootdir (strcpy ((char *)alloca (strlen (fname)), fname));
+ char *root = rootdir (fname, (char *)alloca (strlen (fname)));
if (!allow_smbntsec
&& ((root[0] == '\\' && root[1] == '\\')
extern "C" int
statfs (const char *fname, struct statfs *sfs)
{
- char root_dir[CYG_MAX_PATH];
+ char root[CYG_MAX_PATH];
+
+ syscall_printf ("statfs %s", fname);
if (!sfs)
{
}
path_conv full_path (fname, PC_SYM_FOLLOW | PC_FULL);
- strncpy (root_dir, full_path, CYG_MAX_PATH);
- const char *root = rootdir (root_dir);
-
- syscall_printf ("statfs %s", root);
+ if (!rootdir (full_path, root))
+ return -1;
/* GetDiskFreeSpaceEx must be called before GetDiskFreeSpace on
WinME, to avoid the MS KB 314417 bug */
__ino64_t __stdcall hash_path_name (__ino64_t hash, const char *name) __attribute__ ((regparm(2)));
void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2)));
-extern "C" char *__stdcall rootdir (char *full_path) __attribute__ ((regparm(1)));
+extern "C" char *__stdcall rootdir (const char *full_path, char *root_path) __attribute__ ((regparm(2)));
/* String manipulation */
extern "C" char *__stdcall strccpy (char *s1, const char **s2, char c);