summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-10-02 01:58:06 +0000
committerChristopher Faylor <me@cgf.cx>2001-10-02 01:58:06 +0000
commit4ab6034f50e5783151699f2c0b146f090980e183 (patch)
tree2c566fbf592daaff83e02ad049cad474442d0995 /winsup/cygwin/syscalls.cc
parent47af76d8c8e9979c5ddd42f17573b22b75a03117 (diff)
downloadcygnal-4ab6034f50e5783151699f2c0b146f090980e183.tar.gz
cygnal-4ab6034f50e5783151699f2c0b146f090980e183.tar.bz2
cygnal-4ab6034f50e5783151699f2c0b146f090980e183.zip
* dtable.h (dtable::build_fhandler): Make path_conv parameter non-optional.
(dtable::init_std_file_from_handle): Eliminate name parameter. * dtable.cc (stdio_init): Don't pass bogus name to init_std_file_from_handle. The function will figure out the name itself. (dtable::init_std_file_from_handle): Eliminate name parameter. Assume that we're always called with an appropriate fd. Pass name as NULL if we can't simply figure it out from context. (cygwin_attach_handle_to_fd): Pass path_conv argument to build_fhandler. (dtable::build_fhandler): Make path_conv argument mandatory. Eliminate specific call to get_device_number. With unknown device names, set name from handle context for parsing by path_conv. (dtable::build_fhandler): Pass path_conv argument to build_fhandler. * path.h (path_conv::set_isdisk): Set disk device type. (path_conv::is_device): Don't consider FH_DISK a "device". * syscalls.cc (_open): Pass path_conv argument by reference. (stat_worker): Ditto. (_rename): Use path_conv operators. Add bounds to DeleteFile/MoveFile for loop.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc20
1 files changed, 8 insertions, 12 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 9aa1dd739..f4e53db50 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -499,7 +499,7 @@ _open (const char *unix_path, int flags, ...)
else
{
path_conv pc;
- if (!(fh = cygheap->fdtab.build_fhandler (fd, unix_path, NULL, &pc)))
+ if (!(fh = cygheap->fdtab.build_fhandler (fd, unix_path, NULL, pc)))
res = -1; // errno already set
else if (!fh->open (pc, flags, (mode & 07777) & ~cygheap->umask))
{
@@ -1087,7 +1087,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
if (check_null_invalid_struct_errno (buf))
goto done;
- fh = cygheap->fdtab.build_fhandler (-1, name, NULL, &real_path,
+ fh = cygheap->fdtab.build_fhandler (-1, name, NULL, real_path,
(nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW)
| PC_FULL, stat_suffixes);
@@ -1327,8 +1327,7 @@ _rename (const char *oldpath, const char *newpath)
return -1;
}
- if (!writable_directory (real_old.get_win32 ())
- || !writable_directory (real_new.get_win32 ()))
+ if (!writable_directory (real_old) || !writable_directory (real_new))
{
syscall_printf ("-1 = rename (%s, %s)", oldpath, newpath);
set_errno (EACCES);
@@ -1353,7 +1352,7 @@ _rename (const char *oldpath, const char *newpath)
(lnk_suffix = strrchr (real_new.get_win32 (), '.')))
*lnk_suffix = '\0';
- if (!MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
+ if (!MoveFile (real_old, real_new))
res = -1;
if (res == 0 || (GetLastError () != ERROR_ALREADY_EXISTS
@@ -1369,7 +1368,7 @@ _rename (const char *oldpath, const char *newpath)
else
{
syscall_printf ("try win95 hack");
- for (;;)
+ for (int i = 0; i < 2; i++)
{
if (!DeleteFileA (real_new.get_win32 ()) &&
GetLastError () != ERROR_FILE_NOT_FOUND)
@@ -1378,13 +1377,10 @@ _rename (const char *oldpath, const char *newpath)
real_new.get_win32 ());
break;
}
- else
+ else if (MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
{
- if (MoveFile (real_old.get_win32 (), real_new.get_win32 ()))
- {
- res = 0;
- break;
- }
+ res = 0;
+ break;
}
}
}