-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 02/01/2012 10:45 AM, John Reiser wrote:
> Give me a mechanism to know how many files are on the file
system
> and I might be able to give you an idea.
Yes, hardlinks are a complication. However, a useful progress
measure can be computed as the percentage of _known_ total
.st_nlink that have been seen so far. The numerator starts at
zero. The denominator starts at (total_inodes - free_inodes).
Update the denominator upon seeing each inode for the first time.
Update the numerator upon seeing each hardlink in turn, including
the first time for each inode. So, if 2==.st_nlink, then the first
directory entry for any particular .st_ino results in numerator +=
1; denominator += .st_nlink - 1; and the remnaining directory
entries for that .st_ino do just numerator += 1;
The fraction will wobble (go "backwards") upon first encounter with
each inode that has (1 < .st_nlink), but the wobble will be small
after 10% of duration. This method requires one additional stat()
per inode [to check .st_nlink], assuming that a directory entry
already gives you the .st_ino. It also requires a bit table to
track the first encounter of each inode.
Patches accepted...
Or an example C program.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla -
http://enigmail.mozdev.org/
iEYEARECAAYFAk8pZ4sACgkQrlYvE4MpobPUdwCeN3lbPwozWNiE1mCyVvDpi6r+
mA8AoMnyHhXRTD23WyvMCjZ2jSzPr2Pc
=9rzD
-----END PGP SIGNATURE-----