GNU bug report logs -
#49335
v.8.32 - stat(1) | Symbolic link interpreted as hard link
Previous Next
Reported by: Ricky Tigg <ricky.tigg <at> gmail.com>
Date: Fri, 2 Jul 2021 16:34:02 UTC
Severity: normal
Tags: notabug
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
Message #10 received at control <at> debbugs.gnu.org (full text, mbox):
tag 49335 notabug
close 49335
stop
On 02/07/2021 17:32, Ricky Tigg wrote:
> Hello, symbolic link counted as hard link. To reproduce:
>
> $ touch t; ln -sr t l; stat -c '%i %h %n %F' t l
> 4172493 1 t regular empty file
> 4172494 1 l symbolic link
>
> '%h' reports *1* despite no hard link is involved. Isn't rather *0*
> expected?
1 is expected for any standard file as the names of those files are (hard)linked to an associated inode.
I.e. a hardlink is not a type of file, rather a structure of the file system.
One would only expect 0 for names unlinked from the file system,
which you could demonstrate like:
f=file.to.delete; touch "$f" && (rm "$f" && stat -L -c '%h' /dev/stdin) < "$f"
The following gives an overview of the various types of links:
https://www.pixelbeat.org/docs/unix_links.html
cheers,
Pádraig
This bug report was last modified 4 years and 53 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.