link count on dirs

link count on dirs

Post by System Administrat » Sat, 27 Aug 1994 06:13:30



I'm an ijit.  If I do an ls -l
...
drwxr-xr-x   2 root     wheel        2048 Mar 15  1991 bin
lrwxrwxrwx   1 root     wheel          11 Nov 19  1990 dev -> private/dev
lrwxrwxrwx   1 root     wheel          11 Nov 19  1990 etc -> private/etc
drwxr-xr-x   2 root     wheel        1024 Feb 21  1991 lib
drwxr-xr-x   2 root     wheel        8192 Nov 19  1990 lost+found
...
what do the link counts mean on a directory?
I did a find over the disk in question.  There are NOT extra hardlinks
to these directories.  Neither the man page for ls nor for gnuls mention
any special status for this field for directory entries.

--

=> University of Alberta         Lab Manager, Space Physics Group <=        
=> tel:403 492-3713                             fax: 403 492-4256 <=        

 
 
 

link count on dirs

Post by Bill Marc » Sun, 28 Aug 1994 02:09:11


Every directory contains a link to itself and (except the root directory)
a link to its parent.

--

"I'll spend my whole paycheck on some old wreck
And brother, I could name you a few..."

 
 
 

link count on dirs

Post by Alan Rollow - Dr. File System's Home for Wayward Inode » Sun, 28 Aug 1994 02:54:21



Quote:

>I'm an ijit.  If I do an ls -l
>...
>drwxr-xr-x   2 root     wheel        2048 Mar 15  1991 bin
> [ other examples deleted ]
>what do the link counts mean on a directory?

There is a link for every directory that a directory has in it.?  An
otherwise empty directory has two links; one for the directory itself (.)
and one for its parent (..).  If bin (lib or lost+found) had other
directories in them, this would be reflected in the link count.

>--

>=> University of Alberta         Lab Manager, Space Physics Group <=        
>=> tel:403 492-3713                             fax: 403 492-4256 <=        

--

 
 
 

link count on dirs

Post by System Administrat » Sun, 28 Aug 1994 04:18:59


: I'm an ijit.  If I do an ls -l
: ...
: drwxr-xr-x   2 root     wheel        2048 Mar 15  1991 bin
: lrwxrwxrwx   1 root     wheel          11 Nov 19  1990 dev -> private/dev
: lrwxrwxrwx   1 root     wheel          11 Nov 19  1990 etc -> private/etc
: drwxr-xr-x   2 root     wheel        1024 Feb 21  1991 lib
: drwxr-xr-x   2 root     wheel        8192 Nov 19  1990 lost+found
: ...
: what do the link counts mean on a directory?
: I did a find over the disk in question.  There are NOT extra hardlinks
: to these directories.  Neither the man page for ls nor for gnuls mention
: any special status for this field for directory entries.

ARG!  Of course find doesn't find the . and .. entries of the
directories themselves.  And those are links to itself and the parent
directory.

So any directory has at least 2 links, one from . and one from it's
parent directory.

And a parent directory will have one additional link from each
subdirectory.  

I should have known all this but the pieces didn't fit that day.  My
brain was totally ambiflexicated.

Thanks
--

=> University of Alberta         Lab Manager, Space Physics Group <=        
=> tel:403 492-3713                             fax: 403 492-4256 <=        

 
 
 

link count on dirs

Post by Dr J.D. Russe » Wed, 31 Aug 1994 20:03:59



Quote:>I'm an ijit.  If I do an ls -l
>...
>drwxr-xr-x   2 root     wheel        2048 Mar 15  1991 bin
>lrwxrwxrwx   1 root     wheel          11 Nov 19  1990 dev -> private/dev
>lrwxrwxrwx   1 root     wheel          11 Nov 19  1990 etc -> private/etc
>drwxr-xr-x   2 root     wheel        1024 Feb 21  1991 lib
>drwxr-xr-x   2 root     wheel        8192 Nov 19  1990 lost+found
>...
>what do the link counts mean on a directory?
>I did a find over the disk in question.  There are NOT extra hardlinks
>to these directories.  Neither the man page for ls nor for gnuls mention
>any special status for this field for directory entries.

Each directory has at least two hard links.
The first sits in the parent directory, and as filename has the actual
directory name.
The second sits in the directory itself, has the name "." and is a link
to the same directory.

Both these directory entries point to the same (directory) data.

Now, if your directory contains further directories, they will
each contain an entry called ".." which points back to your directory
as well.

try doing:
ls -l
ls -ld */.
ls -ld any_dir_name/*/..

Hope this helps
--
Dr. Jeremy D. Russell  

Imperial College                 Tel:     +44 (0)71 589 5111              
London, SW7 2BP                           off: #56736, lab: #56743

 
 
 

1. UNREF DIR and LINK COUNT

I have a new v210 on which I config'd apache/tomcat, but no users
accessing it yet, other than me to test a webapp.  I needed to cycle
the power down/up in order to place it in a rack.

Upon trying to restart tomcat, the system was telling me it could not
write to the catalina log file, even as root.  Tomcat (and the log
file) is in slice 5 and still had 2 GB of space.

Desperate after trying to figure this out for a while, I restarted the
machine and saw that when checking c1t0d0s5 the system said it was
"not fine" and suggested running fsck.  I ran fsck and got 3 or 4
dozen of each of these when looking at s5:
----------------------------
UNREF DIR  I=51406  OWNER=root MODE=40755
SIZE=512 MTIME=Aug 13 06:54 2004
RECONNECT? y

LINK COUNT DIR I=428678  OWNER=root MODE=40755
SIZE=512 MTIME=Aug 16 06:44 2004  COUNT 0 SHOULD BE 2
ADJUST? y
----------------------------

Can someone tell me what these messages would indicate, and knowing
this is a barely used system, if I should be weary of tossing it into
production?  I ran fsck twice until it didn't return any more
unfavorable messages, and cycled the power successfully without
errors, but I am wondering what happened?

Thanks,
Rob

2. sol 2.4 driver, > 128k r/w page locks

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

4. GS

5. Apache MultiViews: /dir returns /dir/, not dir.html

6. Mangled linux partition.

7. weird... can't put a cd \dir\dir\dir\ in a .csh file...

8. SPARC 5/Solaris2.3 & Internet?!

9. Better way to count files in dirs

10. Counting Files in Dir

11. count # of files in dir

12. count files in dirs

13. Count number of files in a dir?