darlinghq / darling

Darwin/macOS emulation layer for Linux
http://www.darlinghq.org
GNU General Public License v3.0
11.55k stars 446 forks source link

rm -r fails to remove directories #1383

Closed SomeDevHere closed 1 year ago

SomeDevHere commented 1 year ago

Expected Result Directory is deleted

Actual Result Directory is kept and rm fails with Is a directory

Steps To Reproduce

  1. Create an empty directory mkdir tmp
  2. Delete the directory rm -r tmp

Xtrace Log xtrace.log

Additional Information This error seems to happen because Darling is ignoring the flag AT_REMOVEDIR_DATALESS when passed to unlinkat.

System Information

Software Version
Linux Kernel 6.3.6-arch1-1
Darling 894d62c91d78d56e05708f40f2d7e490fce5f046
wjc404 commented 1 year ago

I got the same issue when using darling(built from master branch yesterday) on WSL2(ubuntu-22.04): image

bugaevc commented 1 year ago

atflags_bsd_to_linux needs to handle AT_REMOVEDIR_DATALESS

bugaevc commented 1 year ago

On top of that it should reject unknown flags with EINVAL, which is what rm expects to see if the kernel doesn't support AT_REMOVEDIR_DATALESS

bugaevc commented 1 year ago

XNU has these AT flags:

Anything else -> EINVAL

niansa commented 1 year ago

Maybe it should be checked how Darwin handles fat32 volumes which don't support dataless files either Just to make sure Darling does the same on volumes that don's support it (say, root volume).

mrhhug commented 1 year ago

Can confirm the fix at : https://github.com/darlinghq/darling-xnu/pull/2 remediates the rm -rf directory issue on my current kernel : 6.4.3-arch1-2