bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: find inodes of a dir


From: Andrei Enshin
Subject: Re[2]: find inodes of a dir
Date: Sat, 15 Aug 2020 19:51:08 +0300

The
$ sudo find / -xdev -samefile /
/


Gives me only one however there are seems to be 24 hard links to the / 
(probably counting the «..» of subdirs as you mentioned):
$ ls -lid /
2 drwxr-xr-x 24 root root 4096 Jul 28 07:34 /



I’m using Ubuntu 18.04.5.

  
>Saturday, August 15, 2020 7:37 PM +03:00 from Tavian Barnes 
><tavianator@tavianator.com>:
> 
>On Sat, 15 Aug 2020 at 11:56, Andrei Enshin via Bug reports for the
>GNU find utilities < bug-findutils@gnu.org > wrote:
>>
>>
>> Hello,
>>
>> I’m trying to identify all hard links pointing to my root directory:
>> $ sudo ls -lid /
>> 2 drwxr-xr-x 23 root root 4096 Aug 11 20:58 /
>>
>> The inode number is 2 and count of hard links is 23.
>>
>> Then I run find:
>>
>> $ sudo find / -xdev -inum 2 2>/dev/null | wc -l
>> 15
>
>You can also use
>
>$ find / -xdev -samefile /
>
>> But the `find` finds only 15.
>
>I am surprised you found any, since most systems don't support
>directory hard links. Are you on macOS?
>
>> I checked on two different systems and result of find doesn’t match the 
>> number of hardlinks.
>
>Note that directory link counts usually equal 2 + the number of
>subdirectories, essentially treating each child's '..' dirent as if it
>were a link to the parent. See e.g.
>https://unix.stackexchange.com/a/101536/56202 for more info.
>
>> In detailed out —  https://pastebin.com/raw/JH6hW7n6 — you can see that 
>> -xdev option seems to be ignored since /dev is counted.
>
>-xdev will process mount points but nothing below them. A future
>POSIX version will specify that -mount should skip mount points
>entirely:  http://austingroupbugs.net/view.php?id=1133 .
>
>> But it is still doesn’t explain why the number is 15 — less than 23.
>>
>> May I ask for help to find all hard links to the directory within one 
>> filesystems using `find`?
>>
>>
>> ---
>> Best Regards,
>> Andrei Enshin
>
>--
>Tavian Barnes 
 
 
---
Best Regards,
Andrei Enshin
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]