Skip to content

Commit 502dc8e

Browse files
committed
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.
1 parent c0bb20c commit 502dc8e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

winsup/cygwin/syscalls.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,7 @@ rename2 (const char *oldpath, const char *newpath, unsigned int at2flags)
24382438
&& !oldpc.isremote ()
24392439
&& oldpc.fs_is_ntfs ();
24402440

2441+
ignore_posix_semantics_retry:
24412442
/* Opening the file must be part of the transaction. It's not sufficient
24422443
to call only NtSetInformationFile under the transaction. Therefore we
24432444
have to start the transaction here, if necessary. Don't start
@@ -2682,6 +2683,15 @@ rename2 (const char *oldpath, const char *newpath, unsigned int at2flags)
26822683
unlink_nt (*removepc);
26832684
res = 0;
26842685
}
2686+
else if (use_posix_semantics && status == STATUS_INVALID_PARAMETER)
2687+
{
2688+
/* NtSetInformationFile returns STATUS_INVALID_PARAMETER
2689+
on a bind mounted file system in hyper-v container
2690+
with FILE_RENAME_POSIX_SEMANTICS.
2691+
Disable the use_posix semntics flag and retry. */
2692+
use_posix_semantics = 0;
2693+
goto ignore_posix_semantics_retry;
2694+
}
26852695
else
26862696
__seterrno_from_nt_status (status);
26872697
}

0 commit comments

Comments
 (0)