public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Yoshinao Muramatsu <ysno@ac.auone-net.jp>
To: cygwin-patches@cygwin.com
Cc: Yoshinao Muramatsu <ysno@ac.auone-net.jp>
Subject: [PATCH 2/3] fix rename in container
Date: Mon, 20 Mar 2023 20:51:01 +0900	[thread overview]
Message-ID: <20230320115102.1692-3-ysno@ac.auone-net.jp> (raw)
In-Reply-To: <20230320115102.1692-1-ysno@ac.auone-net.jp>

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>
---
 winsup/cygwin/syscalls.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 7430fad65..57bfab9d3 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2427,6 +2427,7 @@ rename2 (const char *oldpath, const char *newpath, unsigned int at2flags)
 			    && !oldpc.isremote ()
 			    && oldpc.fs_is_ntfs ();
 
+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
@@ -2671,6 +2672,15 @@ skip_pre_W10_checks:
 	    unlink_nt (*removepc);
 	  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);
     }
-- 
2.37.3.windows.1


  parent reply	other threads:[~2023-03-20 11:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 14:43 [PATCH 0/3] fix unlink/rename failure in hyper-v container YO4
2023-03-17 14:43 ` [PATCH 1/3] fix unlink in container YO4
2023-03-17 14:43 ` [PATCH 2/3] fix rename " YO4
2023-03-17 14:43 ` [PATCH 3/3] log disabling posix semantics YO4
2023-03-17 19:15 ` [PATCH 0/3] fix unlink/rename failure in hyper-v container Corinna Vinschen
2023-03-18  5:29   ` Yoshinao Muramatsu
2023-03-18 10:01     ` Corinna Vinschen
2023-03-20 13:06       ` Yoshinao Muramatsu
2023-03-20 14:51         ` Corinna Vinschen
2023-03-20 14:54           ` Corinna Vinschen
2023-03-20 20:37           ` Corinna Vinschen
2023-03-21 15:32             ` Yoshinao Muramatsu
2023-03-21 17:58               ` Corinna Vinschen
2023-03-23 16:40                 ` Yoshinao Muramatsu
2023-03-24 11:54                   ` Corinna Vinschen
2023-03-24 13:20                     ` Jon Turney
2023-03-24 13:22                       ` Corinna Vinschen
2023-03-24 14:20                         ` Jon Turney
2023-03-24 13:48                     ` Yoshinao Muramatsu
2023-03-20 11:50   ` [PATCH 0/3] fix unlink/rename failure in hyper-v container(regenerate) Yoshinao Muramatsu
2023-03-20 11:51     ` [PATCH 1/3] fix unlink in container Yoshinao Muramatsu
2023-03-20 11:51     ` Yoshinao Muramatsu [this message]
2023-03-20 11:51     ` [PATCH 3/3] log disabling posix semantics Yoshinao Muramatsu
2023-03-20 12:12     ` [PATCH 0/3] fix unlink/rename failure in hyper-v container(regenerate) Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230320115102.1692-3-ysno@ac.auone-net.jp \
    --to=ysno@ac.auone-net.jp \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).