4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-22 00:38:06 +08:00

* 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.
This commit is contained in:
Corinna Vinschen 2004-04-10 19:24:55 +00:00
parent 56551a9bfb
commit 7224437c62
5 changed files with 38 additions and 27 deletions

View File

@ -1,3 +1,11 @@
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> 2004-04-10 Corinna Vinschen <corinna@vinschen.de>
* Use new unified status_flag accessor methods from classes fhandler_*, * Use new unified status_flag accessor methods from classes fhandler_*,

View File

@ -1028,36 +1028,40 @@ fhandler_base::lock (int, struct __flock64 *)
} }
extern "C" char * __stdcall extern "C" char * __stdcall
rootdir (char *full_path) rootdir (const char *full_path, char *root_path)
{ {
/* Possible choices: /* Possible choices:
* d:... -> d:/ * d:... -> d:/
* \\server\share... -> \\server\share\ * \\server\share... -> \\server\share\
* else current drive.
*/ */
char *root = full_path; int len;
char *rootp = root_path;
if (full_path[1] == ':') if (full_path[1] == ':')
strcpy (full_path + 2, "\\"); {
*rootp++ = *full_path++;
*rootp++ = ':';
}
else if (full_path[0] == '\\' && full_path[1] == '\\') else if (full_path[0] == '\\' && full_path[1] == '\\')
{ {
char *cp = full_path + 2; const char *cp = strchr (full_path + 2, '\\');
while (*cp && *cp != '\\') if (!cp)
cp++; goto error;
if (!*cp) while (*++cp && *cp != '\\')
{ ;
set_errno (ENOTDIR); memcpy (root_path, full_path, (len = cp - full_path));
return NULL; rootp = root_path + len;
}
cp++;
while (*cp && *cp != '\\')
cp++;
strcpy (cp, "\\");
} }
else else
root = NULL; {
error:
set_errno (ENOTDIR);
return NULL;
}
return root; *rootp++ = '\\';
*rootp = '\0';
return root_path;
} }
int __stdcall int __stdcall

View File

@ -361,9 +361,8 @@ fs_info::update (const char *win32_path)
{ {
char fsname [CYG_MAX_PATH]; char fsname [CYG_MAX_PATH];
char root_dir [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); debug_printf ("Cannot get root component of path %s", win32_path);
clear (); clear ();

View File

@ -1457,7 +1457,7 @@ check_posix_perm (const char *fname, int v)
if (!allow_ntsec) if (!allow_ntsec)
return 0; return 0;
char *root = rootdir (strcpy ((char *)alloca (strlen (fname)), fname)); char *root = rootdir (fname, (char *)alloca (strlen (fname)));
if (!allow_smbntsec if (!allow_smbntsec
&& ((root[0] == '\\' && root[1] == '\\') && ((root[0] == '\\' && root[1] == '\\')
@ -1793,7 +1793,9 @@ get_osfhandle (int fd)
extern "C" int extern "C" int
statfs (const char *fname, struct statfs *sfs) 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) if (!sfs)
{ {
@ -1802,10 +1804,8 @@ statfs (const char *fname, struct statfs *sfs)
} }
path_conv full_path (fname, PC_SYM_FOLLOW | PC_FULL); path_conv full_path (fname, PC_SYM_FOLLOW | PC_FULL);
strncpy (root_dir, full_path, CYG_MAX_PATH); if (!rootdir (full_path, root))
const char *root = rootdir (root_dir); return -1;
syscall_printf ("statfs %s", root);
/* GetDiskFreeSpaceEx must be called before GetDiskFreeSpace on /* GetDiskFreeSpaceEx must be called before GetDiskFreeSpace on
WinME, to avoid the MS KB 314417 bug */ WinME, to avoid the MS KB 314417 bug */

View File

@ -240,7 +240,7 @@ int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
__ino64_t __stdcall hash_path_name (__ino64_t hash, const char *name) __attribute__ ((regparm(2))); __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))); 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 */ /* String manipulation */
extern "C" char *__stdcall strccpy (char *s1, const char **s2, char c); extern "C" char *__stdcall strccpy (char *s1, const char **s2, char c);