#include <minix/config.h>
#include <minix/const.h>
+#include "mfs/const.h"
+
extern char *optarg;
extern int optind;
_PROTOTYPE(long dodir, (char *d, int thislev, dev_t dev));
char *prog; /* program name */
-char *optstr = "asxdl:"; /* options */
+char *optstr = "aFsxdl:"; /* options */
int silent = 0; /* silent mode */
int all = 0; /* all directory entries mode */
int crosschk = 0; /* do not cross device boundaries mode */
+int fsoverhead = 0; /* include FS overhead */
char *startdir = "."; /* starting from here */
int levels = 20000; /* # of directory levels to print */
ALREADY *already[NR_ALREADY];
{
register ALREADY **pap, *ap;
+ if (fsoverhead) return 0;
+
pap = &already[(unsigned) inum % NR_ALREADY];
while ((ap = *pap) != NULL) {
if (ap->al_inum == inum && ap->al_dev == dev) {
{
int maybe_print;
struct stat s;
- long total_kb;
+ long indir_blocks, indir2_blocks, indir_per_block;
+ long total_blocks, total_kb;
char dent[LINELEN];
DIR *dp;
struct dirent *entry;
prog, d, block_size);
return 0L;
}
- total_kb = ((s.st_size + (block_size - 1)) / block_size) * block_size / 1024;
+ total_blocks = (s.st_size + (block_size - 1)) / block_size;
+ if (fsoverhead) {
+ /* file system overhead: indirect blocks */
+ indir_per_block = block_size / sizeof(zone_t);
+ indir_blocks = (total_blocks - V2_NR_DZONES) / indir_per_block;
+ total_blocks += indir_blocks;
+ indir2_blocks = (indir_blocks - 1) / (indir_per_block * indir_per_block);
+ total_blocks += indir2_blocks;
+ }
+ total_kb = total_blocks * block_size / 1024;
switch (s.st_mode & S_IFMT) {
case S_IFDIR:
/* Directories should not be linked except to "." and "..", so this
case 's': silent = 1; break;
case 'x':
case 'd': crosschk = 1; break;
+ case 'F': fsoverhead = 1; break;
case 'l': levels = atoi(optarg); break;
default:
fprintf(stderr,
- "Usage: %s [-asx] [-l levels] [startdir]\n", prog);
+ "Usage: %s [-asxF] [-l levels] [startdir]\n", prog);
exit(1);
}
do {
inodes=`find $path | egrep -v ^$path/usr | wc -l`
inodes="`expr $inodes + $extra_inodes`"
- # Determine number of data zones using bc formula to transform file size in zone count
- # s - file size
- # d - number of direct blocks
- # i - number of indirect blocks
- # j - number of double indirect blocks
- dir=7
- indir="`expr $BS / 4`"
- indir2="`expr $indir \* $indir`"
- formula="s=\\0;d=(s+$BS-1)/$BS;i=(d-$dir+$indir-1)/$indir;j=(i-1+$indir2-1)/$indir2;d+i+j"
- zones=`( find $path | egrep -v ^$path/usr | xargs lstat -size | egrep '^[0-9]+$' | sed -r "s|.+|$formula|" | bc | tr '
-' +; echo 0 ) | bc`
- zones="`expr $zones + $extra_zones`"
+ # Determine number of data zones
+ zonekbs=`du -Fs $path | cut -d' ' -f1`
+ zonekbsignore=0
+ [ ! -d $path/usr ] || zonekbsignore=`du -Fs $path/usr | cut -d" " -f1`
+ zones="`expr \( $zonekbs - $zonekbsignore \) / \( $BS / 1024 \) + $extra_zones`"
# Determine file system size
BSBITS="`expr $BS \* 8`"