nlink

Andrew Borodin aborodin at vmail.ru
Tue Jan 8 10:43:14 UTC 2013


On Tue, 08 Jan 2013 09:40:24 +0000 frank wrote:
> do the following: let nlink show up in MC, then set a (soft) symlink

softlink and symlink are synonyms.

> to any regular file: its nlink is incremented by 1.

That's impossible.

[andrew at myhost tmp]$ cd /tmp
[andrew at myhost tmp]$ touch zzzz
[andrew at myhost tmp]$ ls -l zzzz
-rw-r--r-- 1 andrew andrew 0 Jan  8 14:31 zzzz
[andrew at myhost tmp]$ ln -s -f zzzz zzzz_symlink     
[andrew at myhost tmp]$ ls -l zzz*
-rw-r--r-- 1 andrew andrew 0 Jan  8 14:31 zzzz
lrwxrwxrwx 1 andrew andrew 4 Jan  8 14:31 zzzz_symlink -> zzzz

> Thus nlink counts all links soft and hard, that's for sure.

No. File itself doesn't know anything about symlinks point to it.

> In my opinion, those minimum links for regular files and directories should
> actually not be counted by MC. MC should deduct them from the count reported
> by stat.

For local file systems, MC gets nlink value directly from stat(2):

>               nlink_t   st_nlink;   /* number of hard links */

-- 
Andrew



More information about the mc mailing list