Closed SomeDevHere closed 1 year ago
I got the same issue when using darling(built from master branch yesterday) on WSL2(ubuntu-22.04):
atflags_bsd_to_linux
needs to handle AT_REMOVEDIR_DATALESS
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
XNU has these AT
flags:
AT_EACCESS
-- Linux has that too, we could just convert it, or ignore it, depending on what we want to do about UID/setuidAT_SYMLINK_NOFOLLOW
, AT_SYMLINK_FOLLOW
, AT_REMOVEDIR
-- these we handle alreadyAT_REMOVEDIR_DATALESS
, which is what this bug is about -- same as AT_REMOVEDIR
, but don't materialize the dir first if it's dataless. Dataless files are apparently some sort of placeholders for real files that can be "materialized" into full files with help from filecoordinationd
-- and by default, dataless files are automatically and transparently materialized, unless you explicitly ask not to, and AT_REMOVEDIR_DATALESS
is one way of doing that. Since we don't and are not going to have anything like dataless files in Darling, it's safe to treat AT_REMOVEDIR_DATALESS
just like AT_REMOVEDIR
AT_REALDEV
-- seems to impact what st_dev
gets returned for fstatat
, not sure how exactly; we could just ignore it since we virtualize VFS/mounts/devices anywayAT_FDONLY
is Linux's AT_EMPTY_PATH
Anything else -> EINVAL
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).
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
Expected Result Directory is deleted
Actual Result Directory is kept and rm fails with
Is a directory
Steps To Reproduce
mkdir tmp
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 tounlinkat
.System Information