GNU bug report logs - #49335
v.8.32 - stat(1) | Symbolic link interpreted as hard link

Previous Next

Package: coreutils;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49335 in the body.
You can then email your comments to 49335 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#49335; Package coreutils. (Fri, 02 Jul 2021 16:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ricky Tigg <ricky.tigg <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 02 Jul 2021 16:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ricky Tigg <ricky.tigg <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: v.8.32 - stat(1) | Symbolic link interpreted as hard link
Date: Fri, 2 Jul 2021 19:32:58 +0300
[Message part 1 (text/plain, inline)]
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?
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#49335; Package coreutils. (Fri, 02 Jul 2021 16:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 49335 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Ricky Tigg <ricky.tigg <at> gmail.com>, 49335 <at> debbugs.gnu.org
Subject: Re: bug#49335: v.8.32 - stat(1) | Symbolic link interpreted as hard
 link
Date: Fri, 2 Jul 2021 17:51:47 +0100
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




Added tag(s) notabug. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Fri, 02 Jul 2021 16:52:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 49335 <at> debbugs.gnu.org and Ricky Tigg <ricky.tigg <at> gmail.com> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Fri, 02 Jul 2021 16:52:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 31 Jul 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 268 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.