Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-01-21 16:13:00 +0300
committerCorinna Vinschen <corinna@vinschen.de>2011-01-21 16:13:00 +0300
commita1c35b8b65fadc52c8654a74ae60422ad15f4002 (patch)
tree6e7f22854ea57a91e6f1662aa15bbf850c3e2122 /winsup/cygwin/syscalls.cc
parent2aba945c95bcdd1fdedb77d6828ad726eaaa58c7 (diff)
* syscalls.cc (rename): Fix permission problem with symlinks on NFS.
Rework how NtOpenFile gets called to make it more readable. Change comment.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index c38671f39..6ea3c2803 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2053,18 +2053,25 @@ rename (const char *oldpath, const char *newpath)
int retry_count;
retry_count = 0;
retry:
- /* DELETE is required to rename a file. At least one cifs FS (Tru64) needs
- FILE_READ_ATTRIBUTE, otherwise the FileRenameInformation call fails with
- STATUS_ACCESS_DENIED. Samba (only some versions?) doesn't like the
- FILE_SHARE_DELETE mode if the file has the R/O attribute set and returns
- STATUS_ACCESS_DENIED in that case. */
- status = NtOpenFile (&fh, DELETE | FILE_READ_ATTRIBUTES,
- oldpc.get_object_attr (attr, sec_none_nih),
- &io,
- oldpc.fs_is_samba () ? FILE_SHARE_READ | FILE_SHARE_WRITE
- : FILE_SHARE_VALID_FLAGS,
- FILE_OPEN_FOR_BACKUP_INTENT
- | (oldpc.is_rep_symlink () ? FILE_OPEN_REPARSE_POINT : 0));
+ /* Talking about inconsistent behaviour...
+ - DELETE is required to rename a file. So far, so good.
+ - At least one cifs FS (Tru64) needs FILE_READ_ATTRIBUTE, otherwise the
+ FileRenameInformation call fails with STATUS_ACCESS_DENIED. However,
+ on NFS we get a STATUS_ACCESS_DENIED if FILE_READ_ATTRIBUTE is used
+ and the file we try to rename is a symlink. Urgh.
+ - Samba (only some versions?) doesn't like the FILE_SHARE_DELETE mode if
+ the file has the R/O attribute set and returns STATUS_ACCESS_DENIED in
+ that case. */
+ {
+ ULONG access = DELETE | (oldpc.fs_is_cifs () ? FILE_READ_ATTRIBUTES : 0);
+ ULONG sharing = FILE_SHARE_READ | FILE_SHARE_WRITE
+ | (oldpc.fs_is_samba () ? 0 : FILE_SHARE_DELETE);
+ ULONG flags = FILE_OPEN_FOR_BACKUP_INTENT
+ | (oldpc.is_rep_symlink () ? FILE_OPEN_REPARSE_POINT : 0);
+ status = NtOpenFile (&fh, access,
+ oldpc.get_object_attr (attr, sec_none_nih),
+ &io, sharing, flags);
+ }
if (!NT_SUCCESS (status))
{
debug_printf ("status %p", status);