Subject: add -H hard link test for test(1)
To: None <tech-userlevel@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-userlevel
Date: 07/31/2002 01:09:34
I think it would be useful to have test(1) test if file has other hard
links. What do you all think?
(Or is there another tool to use?)
What does posix say about this? And does it matter?
Example:
$ mytest -H /usr/lib/libdes.a && echo hard link || echo
not hard link
hard link
Basically, it does:
return (s.st_nlink > 1);
Since ln(1) is said to work with directories, I don't check if not a
directory.
$ mytest -H /tmp && echo hard link || echo not hard link
hard link
$ mytest -H /netbsd && echo hard link || echo not hard
link
not hard link
(I started thinking about this, because I use pax to archive some files,
and then I saw it had two complete copies of two files with same inode
number. I'll have to play with pax's -l switch for that I guess.)
If this -H is useful, I'll send-pr diff for man page and code.
Jeremy C. Reed
http://bsd.reedmedia.net/