public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: fix rename in container
@ 2023-03-24 11:51 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-03-24 11:51 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7666e248dd08ba96c12748fc4781388f57671ae5

commit 7666e248dd08ba96c12748fc4781388f57671ae5
Author:     Yoshinao Muramatsu <ysno@ac.auone-net.jp>
AuthorDate: Mon Mar 20 20:51:01 2023 +0900
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Mar 21 18:56:52 2023 +0100

    Cygwin: fix rename in container
    
    Renaming files returns STATUS_INVALID_PARAMETE on a bind mounted file system
    in hyper-v container with FILE_RENAME_POSIX_SEMANTICS.
    
    Disable the use_posix_semantics flag and retry.
    
    Signed-off-by: Yoshinao Muramatsu <ysno@ac.auone-net.jp>

Diff:
---
 winsup/cygwin/syscalls.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 4e278808a02b..4843502c6847 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2419,6 +2419,7 @@ rename2 (const char *oldpath, const char *newpath, unsigned int at2flags)
 			    && oldpc.fs_is_ntfs ()
 			    && oldpc.has_attribute (FILE_SUPPORTS_OPEN_BY_FILE_ID);
 
+ignore_posix_semantics_retry:
       /* Opening the file must be part of the transaction.  It's not sufficient
 	 to call only NtSetInformationFile under the transaction.  Therefore we
 	 have to start the transaction here, if necessary.  Don't start
@@ -2663,6 +2664,15 @@ skip_pre_W10_checks:
 	    unlink_nt (*removepc, false);
 	  res = 0;
 	}
+      else if (use_posix_semantics && status == STATUS_INVALID_PARAMETER)
+        {
+          /* NtSetInformationFile returns STATUS_INVALID_PARAMETER
+             on a bind mounted file system in hyper-v container
+             with FILE_RENAME_POSIX_SEMANTICS.
+             Disable the use_posix semntics flag and retry. */
+          use_posix_semantics = 0;
+          goto ignore_posix_semantics_retry;
+        }
       else
 	__seterrno_from_nt_status (status);
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-24 11:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 11:51 [newlib-cygwin/main] Cygwin: fix rename in container Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).