openzfsonwindows / openzfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
447 stars 15 forks source link

Symlinks To Directory Cannot Be Deleted (ENOTEMPTY) #395

Open BellCubeDev opened 3 weeks ago

BellCubeDev commented 3 weeks ago

System information

Type Version/Name
Distribution Name Microsoft Windows 10 Pro
Distribution Version 19045.4780
Kernel Version 22H2
Architecture x86
OpenZFS Version(s) zfswin-2.2.3rc5
zfs-kmod-zfswin-2.2.3rc5

zfswin-2.2.6rc1
zfs-kmod-zfswin-2.2.6rc1

Describe the problem you're observing

When a symbolic link to a directory exists, the symlink cannot be deleted from a ZFS pool, citing a "directory not empty" error. This applies to symlinks with targets on multiple file systems (tested NTFS and ZFS), whether the target actually exists, or whether an existing target actually has contents.

For example, a symbolic link from T:\CoolFolder\ to the non-existent C:\MichaelsoftBinbows\System32 could not be deleted until you created the folder C:\MichaelsoftBinbows\System32 This is an artifact from an old version of the bug report before I fully understood the scope of the bug (possibly through a one-off fluke?). This was not the case. Symlinks could only be deleted from a Linux system.

Describe how to reproduce the problem

  1. Open up either the Windows Command Prompt (CMD) or Powershell
  2. Create a new directory symlink
    • With CMD, you can use mklink /D link_to_create link_target syntax. The target directory does not need to exist.
    • With PowerShell, you can use the New-Item -Path link_to_create -ItemType SymbolicLink -Value link_target syntax. The target directory needs to exist already or else PowerShell will make a file symlink
  3. Attempt to delete the symlink
  4. See error

Include any warning/errors/backtraces from the system logs

File explorer gives the following:

An unexpected error is keeping you from deleting the folder. If you continue to recieve this error, you can use the error code to search for help with this problem.

Error 0x80070091: The directory is not empty

The following is returned when using Microsoft's Error Lookup Tool for error code 0x80070091:

# No results found for hex 0x80070091 / decimal -2147024751
# as an HRESULT: Severity: FAILURE (1), FACILITY_WIN32 (0x7), Code 0x91
# for hex 0x91 / decimal 145
  ERROR_DIR_NOT_EMPTY                                            winerror.h
# The directory is not empty.
# 1 matches found for "0x80070091"
lundman commented 1 week ago

Can you retest with 2.2.6rc1 - it worked here.

BellCubeDev commented 1 week ago

A test on zfswin-2.2.6rc1 / zfs-kmod-zfswin-2.2.6rc1 returned the same results

lundman commented 4 days ago

Oh directories! Way to read the ticket lundman. Ok yeah that didn't. a0c09d372adcbb6d1cb318372710bc62eb3ee535

BellCubeDev commented 9 hours ago

Just looked over this again and found an artifact from an old version of the bug report before I fully understood the scope of the bug (possibly through a one-off fluke?).

For example, a symbolic link from T:\CoolFolder\ to the non-existent C:\MichaelsoftBinbows\System32 could not be deleted until you created the folder C:\MichaelsoftBinbows\System32

This was not the case. Symlinks could only be deleted from a Linux system, even if the directory existed. For sanity, I've just checked on the latest version with both a filled and an empty directory and both returned a "not empty" error.

lundman commented 8 hours ago

What, even rc4?