diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2007-08-09 10:32:25 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2007-08-09 10:32:25 +0000 |
commit | 7d5f6c188746c6682389cf8a7830d63fb3c9743b (patch) | |
tree | 024faa52d1da5211be0993634526823fbdadadee /winsup/cygwin/syscalls.cc | |
parent | 14e7bcfdc4f53d18ac6740a9204c09a156de4f5b (diff) | |
download | cygnal-7d5f6c188746c6682389cf8a7830d63fb3c9743b.tar.gz cygnal-7d5f6c188746c6682389cf8a7830d63fb3c9743b.tar.bz2 cygnal-7d5f6c188746c6682389cf8a7830d63fb3c9743b.zip |
* syscalls.cc (rename): Close oldpath file handle immediately after
trying to rename it. Use nfh handle when checking for non-empty
newpath directory. Only change status if check_dir_not_empty really
returns STATUS_DIRECTORY_NOT_EMPTY.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 4d6f94951..3db5daeee 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1577,6 +1577,7 @@ rename (const char *oldpath, const char *newpath) memcpy (&pfri->FileName, dstpc->get_nt_native_path ()->Buffer, pfri->FileNameLength); status = NtSetInformationFile (fh, &io, pfri, size, FileRenameInformation); + NtClose (fh); if (NT_SUCCESS (status)) { if (removepc) @@ -1589,18 +1590,18 @@ rename (const char *oldpath, const char *newpath) whether we tried to rename to an existing non-empty dir. In this case we have to set errno to EEXIST. */ if (status == STATUS_ACCESS_DENIED && dstpc->isdir () - && NT_SUCCESS (NtOpenFile (&fh, FILE_LIST_DIRECTORY | SYNCHRONIZE, + && NT_SUCCESS (NtOpenFile (&nfh, FILE_LIST_DIRECTORY | SYNCHRONIZE, dstpc->get_object_attr (attr, sec_none_nih), &io, FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT | FILE_SYNCHRONOUS_IO_NONALERT))) { - status = check_dir_not_empty (fh); - NtClose (fh); + if (check_dir_not_empty (nfh) == STATUS_DIRECTORY_NOT_EMPTY) + status = STATUS_DIRECTORY_NOT_EMPTY; + NtClose (nfh); } __seterrno_from_nt_status (status); } - NtClose (fh); out: syscall_printf ("%d = rename (%s, %s)", res, oldpath, newpath); |