hard link count number

hard link count number

Post by Wong Ching Kuen Frederic » Wed, 18 Jul 2001 11:49:29



the hard link count number shown in ls -l for a directory is always greater
than 1. is it because both the ../ and dir/ refer to the same inode so that
the count is 2? thanks.
 
 
 

hard link count number

Post by Swif » Wed, 18 Jul 2001 18:57:57


On Tue, 17 Jul 2001 10:49:29 +0800, Wong Ching Kuen Frederick


> the hard link count number shown in ls -l for a directory is always greater
> than 1. is it because both the ../ and dir/ refer to the same inode so that
> the count is 2? thanks.

Yes.

--
 SwifT                     -    Key-ID CDBA2FDB
 LUG: http://www.lugwv.be  -    http://www.keyserver.net

 
 
 

hard link count number

Post by Lew Pitche » Thu, 19 Jul 2001 11:24:24



Quote:

> the hard link count number shown in ls -l for a directory is always greater
> than 1. is it because both the ../ and dir/ refer to the same inode so that
> the count is 2? thanks.

Yes. But to give you a bit more to work with, let's look at a concrete
example: /home/ftp

1) In /home, there's a hard link to /home/ftp (path /home/ftp)
2) In /home/ftp, there's a hard link to /home/ftp (path /home/ftp/.)
3) In /home/ftp/bin, there's a hard link to /home/ftp (path
/home/ftp/bin/..)
4) In /home/ftp/etc, there's a hard link to /home/ftp (path
/home/ftp/etc/..)
5) In /home/ftp/incoming, there's a hard link to /home/ftp (path
/home/ftp/incoming/..)
6) In /home/ftp/lib, there's a hard link to /home/ftp (path
/home/ftp/lib/..)
7) In /home/ftp/pub, there's a hard link to /home/ftp (path
/home/ftp/pub/..)
8) In /home/ftp/usr, there's a hard link to /home/ftp (path
/home/ftp/usr/..)

~ $ ls -l /home    
...
drwxrwxrwx   8 root     wheel        1024 Aug  1  1994 ftp
...
~ $ ls -l /home/ftp
total 7
drwxrwxrwx   2 root     wheel        1024 Apr  7  1998 bin
drwxrwxrwx   2 root     wheel        1024 Aug 30  1993 etc
drwxrwxrwx   2 root     wheel        1024 Dec  3  1993 incoming
drwxrwxrwx   2 root     wheel        1024 Nov 16  1993 lib
drwxrwxrwx   2 root     wheel        1024 Aug 30  1993 pub
drwxrwxrwx   3 root     wheel        1024 Aug 30  1993 usr
-rwxrwxrwx   1 root     root          312 Aug  1  1994 welcome.msg

Well, we counted right

--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered Linux User #112576

 
 
 

1. Why can't one make a link to a file with link count of zero?

Ok, I wrote a syscall that (from userland) looks like:

   int flink(int fd, const char *topath);

and it works, but not in the most interesting case of when the link count
of the file referenced by fd is zero.  Internally, the part that actually
does the work (after all the error checking and housekeeping is done) looks
like:
   error=VOP_LINK(tovp,fromvp,topn.pn_path,CRED());

Can anyone give me a hint why that doesn't even work (when the link count
is zero) with an fd that is on a UFS filesystem?  I would expect it not to
work with a clone-opened device or a pipe (which live on the
pseudo-filesystems specfs and fifofs respectively), but there's no reason I
can think of why it shouldn't work on UFS (and maybe lofs and NFS), unless
someone copped out and put the test for linking to a file with zero link
count in the VFS code rather than in the individual filesystems that may
(or may not) be able to handle it.

Any hints?  Any hope this might work in some future Solaris version?

--
ftp> get |fortune
377 I/O error: smart remark generator failed

Bogonics: the primary language inside the Beltway


2. Newbie WAN questions

3. About Hard Link/soft link

4. Local net access to masqerading host.

5. how do I determine which file is linked to another (hard link)

6. Fcron 1.1.1 - a replacement for Vixie cron and anacron

7. Hard links vs. Soft links

8. 2.5.70 syncppp

9. Soft Link vs Hard Link

10. A hard link or a symbolic link?

11. Hard link to sym link - how to make?

12. hard links v soft links

13. hard links and symbolic links