Closed james-cook closed 2 years ago
One of those files shows "Links: 1024" (1023 hardlinks if you consider one the original). From the Win32 docs: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createhardlinka
The maximum number of hard links that can be created with this function is 1023 per file. If more than 1023 links are created for a file, an error results.
I don't know whether this is a limitation of Windows or NTFS. Do you think this should be better documented, or that the script should try to detect this situation and provide a more specific error message?
That's a great find! I mentioned the underlying fs as I thought this might be system specific.
The error message "invalid argument" is the same on the command line... not very useful but not the fault of rmlint.
If rmlint could check the count and make a suggestion that would be excellent.
The/one suggestion could be to move to WSL2 and ext4. ext4 has a limit of 65000. (https://unix.stackexchange.com/questions/5629/is-there-a-limit-of-hardlinks-for-one-file)
I haven't had a chance to move to WSL2 yet - when I do I'll see if mounting ext4 etc. makes a difference (should do I'd say) So, closing this - I will report back when I get WSL2/ext4 up...
For now, for windows/NTFS - cp_hardlink could be speeded up (in rmlint.sh) by checking the inode count before doing anything else.
Pseudo code:
number_of_links=$(stat -c %h '<filename>' )
if $number_of_links == 1024 then skip hardlinking else continue
I mostly run rmlint.sh with -p so the idea is to stop resource heavy compares if no hardlink can be made anyway
@james-cook AFAIK there is no hardlink limit on WSL2 with ext4 since it's a virtual machine running the actual Linux kernel. I tested ntfs-3g and it does not have this limitation, but I am still curious whether Ext2Fsd/Ext4Fsd or OpenZFS on Windows does - if not, it's just the Windows NTFS driver in the way.
This is probably a glaringly obvious error on my side, but i could use some hints.
rmlint is a recent dev version (2 weeks or so old):
Underlying filesystem is NTFS, running in WSL(1) on W10.
The initial run was:
(all files are on the same device)
Running the script from the above run "-pxd" - looks fine but I have noticed that the hardlinking sometimes fails and returns an error:
If I run ls, stat and file on these files I get: ls:
stat:
file: