[comp.bugs.sys5] A du

hybl@mbph.UUCP (Albert Hybl Dept of Biophysics SM) (11/05/88)

In messages <1064@motmpl.UUCP> ron@motmpl.UUCP (Ron Widell),
<5167@cbmvax.UUCP> ditto@cbmvax.UUCP (Michael "Ford" Ditto) and
<580@mbph.UUCP> hybl@mbph.UUCP (Albert Hybl  Dept of Biophysics  SM) 
it was written:

>>>           For example, today fsck reports that 5976 files are
>>>being used; df says that 216 inodes are available and hence
>>>there are a total of 6192 inodes assigned to the file system.
>>>That is as it should be.  However, the du|wc count reports 6368
>>>files/directories!       A Hybl

Note: an excess of 392 inodes, (6368 - 5976).

>>"du -a" will count each link (directory entry) once, even if it refers
>>to an inode that was already counted, . . .  M Ford

>hmm, in looking at the description of du(1) for both Vr2 and Vr3 I see:
>
>"A file with two or more links is counted only once."
>
>But then, looking at BUGS I see:
>for Vr3- "If there are links between files in different directories
>where the directories are on separate branches of the file system
>hierarchy, du will count the excess files more than once."
>
>So the problem *may* be due to the links, but maybe not.
>It all depends ;-).     R Widell

Today (Nov 4) the 'du -a /usr4/ | wc -l' value is 4422 and the
'df /usr4' available inode value is 1769; their sum is 6191.
It certainly is not counting links today.  (I assume that
block 0 was not counted causing the sum to be one less than
the number of assigned inodes.  I have also decreased the number
days that the news is retained by one day.)

It seems unlikely that the pattern of linking within the current
retained news would swing from 392 to zero in so dramatic a
way.  To ascertain the number of links, I did the following:
I redirected the output from 'ls -iR /usr4' into a file; used
an awk program to create a one-line:one-name listing looking like
a du output.  This file, containing all file, directory and link
names, was sorted into ascending order by inode number and saved.
'cut -c1-5 file | uniq | wc -l' was used to obtain a count of the
unique inode numbers.  I got 4420 (block 0, the supper block and
the /usr4 base directory were not counted).  The number of links
must be 555.

What triggered the 'du|wc' team to produce an erroneous count
before but not today?  The next time I get an bad count, I'll
try to identify the errant files or links.

The awk program I used follows:----------------------
# Created: 1Sep88 by A Hybl
BEGIN {DIR="/usr4/"}
{ NL = length($0)
  if (substr($0,1,1)=="/") {
    DIR = substr($0,1,NL-1) "/"
  } else {
      if (NL>1) {
        line = substr($0,1,6) DIR substr($0,7,NL)
        print line
      }
  }
}

----------------------------------------------------------------------
Albert Hybl, PhD.              Office UUCP: uunet!mimsy!mbph!hybl
Department of Biophysics       Home   UUCP: uunet!mimsy!mbph!hybl!ah
University of Maryland                CoSy: ahybl
School of Medicine
Baltimore, MD  21201                 Phone: (301) 328-7940 (Office)
----------------------------------------------------------------------