Skip to content

Some file operations fail in mounted folders of Hyper-v containers #338

@YO4

Description

@YO4

Describe the bug
When running in hyperv isolated windows container, delete/rename operations using posix semantics fail
with STATUS_INVALID_PARAMETER (0xC000000D) on the (bind | volume) mounted directory.

delete operation is NtSetInformationFile with FileDispositionInformationEx that has FILE_DISPOSITION_POSIX_SEMANTICS flag.
rename operation is NtSetInformationFile with FileRenameInformationEx that has FILE_RENAME_POSIX_SEMANTICS flag.

This failure occurs only mounted folder in hyperv container
but it's not be able to determine this in advance so you only know when it fails.

To Reproduce
Prepare windows container image that is msys2 installed.

docker run -it --rm --isolation=hyperv -v c:\some_folder:c:\target  msys2_image

In the container. use msys2's rm.exe / mv.exe

Microsoft Windows [Version 10.0.19041.264]
(c) 2020 Microsoft Corporation. All rights reserved.

C:\>cd \target

C:\target>c:\msys64\msys2_shell.cmd -defterm -no-start -here

ContainerAdministrator@21f5fa9938da MSYS /c/target
# touch foo bar

ContainerAdministrator@21f5fa9938da MSYS /c/target
# rm foo
rm: cannot remove 'foo': Invalid argument

ContainerAdministrator@21f5fa9938da MSYS /c/target
# mv bar baz
mv: cannot move 'bar' to a subdirectory of itself, 'baz'

ContainerAdministrator@21f5fa9938da MSYS /c/target
# ls
bar  foo

Expected behavior
foo is deleted.
bar is renamed to baz.
so ls displays only baz.

Configuration:
The container base image seems to be applicable to any windows version that supports posix semantics delete/rename.
Container hosts are confirmed with Windows 10 Professional / Windows Server 2022.
for example

  • Edition: Windows Server [Version 10.0.20348.1547]
  • Base Image being used: mcr.microsoft.com/windows/servercore:ltsc2022 903e6f2eff2a

Additional context
You can see full test result in https://ci.appveyor.com/project/YO4/test-msys2-in-container/builds/46532757
For more details, see https://ci.appveyor.com/project/YO4/test-msys2-in-container/builds/46532757/job/qinojh64uo6el78s
and download trace log in artifacts.

Workaround patch for msys2 is here msys2/msys2-runtime#141
But it is desirable to eliminate the need for workaround.
Otherwise, I would like to know if it is possible to determine that posix semantics delete/rename cannot be used before failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions