From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id D14D0384D1BE; Fri, 24 Mar 2023 11:51:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D14D0384D1BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679658706; bh=MD6XI2yBlSrQ9a+HFWfWfsrnNQHjAMSjXEzZzjqSVSE=; h=From:To:Subject:Date:From; b=W6Ky2gxg8uSglar3jDmwY2GMDbCFdyUREd4R/RV0y5iE7iBTGTbms4v2yGeXe6anu NF/bj0kVuVyaT836StuwkIlOqbWZmo4+uu0QSnQ8B4DDZHR/qupm0x/Aekqgnc00+M zf0aSwCHwmV3IcedGsavgLr0gLeqUELEqLyrulFo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: fix rename in container X-Act-Checkin: newlib-cygwin X-Git-Author: Yoshinao Muramatsu X-Git-Refname: refs/heads/main X-Git-Oldrev: 527dd1b407e7d74037a19aed6e25aa36578da2f7 X-Git-Newrev: 7666e248dd08ba96c12748fc4781388f57671ae5 Message-Id: <20230324115146.D14D0384D1BE@sourceware.org> Date: Fri, 24 Mar 2023 11:51:46 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D7666e248dd0= 8ba96c12748fc4781388f57671ae5 commit 7666e248dd08ba96c12748fc4781388f57671ae5 Author: Yoshinao Muramatsu AuthorDate: Mon Mar 20 20:51:01 2023 +0900 Commit: Corinna Vinschen CommitDate: Tue Mar 21 18:56:52 2023 +0100 Cygwin: fix rename in container =20 Renaming files returns STATUS_INVALID_PARAMETE on a bind mounted file s= ystem in hyper-v container with FILE_RENAME_POSIX_SEMANTICS. =20 Disable the use_posix_semantics flag and retry. =20 Signed-off-by: Yoshinao Muramatsu 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, un= signed int at2flags) && oldpc.fs_is_ntfs () && oldpc.has_attribute (FILE_SUPPORTS_OPEN_BY_FILE_ID); =20 +ignore_posix_semantics_retry: /* Opening the file must be part of the transaction. It's not suffi= cient 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 =3D 0; } + else if (use_posix_semantics && status =3D=3D STATUS_INVALID_PARAMET= ER) + { + /* 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 =3D 0; + goto ignore_posix_semantics_retry; + } else __seterrno_from_nt_status (status); }