uutils / findutils

Rust implementation of findutils
MIT License
280 stars 35 forks source link

Implement `-samefile` #373

Closed hanbings closed 1 week ago

hanbings commented 1 month ago

refer: https://www.gnu.org/software/findutils/manual/html_node/find_html/Hard-Links.html

Test: -samefile NAME
True if the file is a hard link to the same inode as name. 
This implies that name and the file reside on the same file system, i.e., 
they have the same device number.

Unless the ‘-L’ option is also given to follow symbolic links, 
one may confine the search to one file system by using the ‘-xdev’ option. 
This is useful because hard links cannot point outside a single file system, 
so this can cut down on needless searching.

If the ‘-L’ option is in effect, then dereferencing of symbolic links applies 
both to the name argument of the ‘-samefile’ primary and to each file examined 
during the traversal of the directory hierarchy. Therefore, ‘find -L -samefile NAME’ 
will find both hard links and symbolic links pointing to the file referenced by name.