Remove dependency of release.sh on bc, du option to give overhead totals
This commit is contained in:
parent
a8cf207549
commit
65764218f7
4 changed files with 27 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
||||||
PROG= du
|
PROG= du
|
||||||
|
CPPFLAGS+= -I${MINIXSRCDIR}/servers
|
||||||
MAN=
|
MAN=
|
||||||
|
|
||||||
.include <minix.prog.mk>
|
.include <minix.prog.mk>
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include <minix/config.h>
|
#include <minix/config.h>
|
||||||
#include <minix/const.h>
|
#include <minix/const.h>
|
||||||
|
|
||||||
|
#include "mfs/const.h"
|
||||||
|
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind;
|
extern int optind;
|
||||||
|
|
||||||
|
@ -71,10 +73,11 @@ _PROTOTYPE(int done, (dev_t dev, ino_t inum, nlink_t nlink));
|
||||||
_PROTOTYPE(long dodir, (char *d, int thislev, dev_t dev));
|
_PROTOTYPE(long dodir, (char *d, int thislev, dev_t dev));
|
||||||
|
|
||||||
char *prog; /* program name */
|
char *prog; /* program name */
|
||||||
char *optstr = "asxdl:"; /* options */
|
char *optstr = "aFsxdl:"; /* options */
|
||||||
int silent = 0; /* silent mode */
|
int silent = 0; /* silent mode */
|
||||||
int all = 0; /* all directory entries mode */
|
int all = 0; /* all directory entries mode */
|
||||||
int crosschk = 0; /* do not cross device boundaries mode */
|
int crosschk = 0; /* do not cross device boundaries mode */
|
||||||
|
int fsoverhead = 0; /* include FS overhead */
|
||||||
char *startdir = "."; /* starting from here */
|
char *startdir = "."; /* starting from here */
|
||||||
int levels = 20000; /* # of directory levels to print */
|
int levels = 20000; /* # of directory levels to print */
|
||||||
ALREADY *already[NR_ALREADY];
|
ALREADY *already[NR_ALREADY];
|
||||||
|
@ -107,6 +110,8 @@ int done(dev_t dev, ino_t inum, nlink_t nlink)
|
||||||
{
|
{
|
||||||
register ALREADY **pap, *ap;
|
register ALREADY **pap, *ap;
|
||||||
|
|
||||||
|
if (fsoverhead) return 0;
|
||||||
|
|
||||||
pap = &already[(unsigned) inum % NR_ALREADY];
|
pap = &already[(unsigned) inum % NR_ALREADY];
|
||||||
while ((ap = *pap) != NULL) {
|
while ((ap = *pap) != NULL) {
|
||||||
if (ap->al_inum == inum && ap->al_dev == dev) {
|
if (ap->al_inum == inum && ap->al_dev == dev) {
|
||||||
|
@ -164,7 +169,8 @@ long dodir(char *d, int thislev, dev_t dev)
|
||||||
{
|
{
|
||||||
int maybe_print;
|
int maybe_print;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
long total_kb;
|
long indir_blocks, indir2_blocks, indir_per_block;
|
||||||
|
long total_blocks, total_kb;
|
||||||
char dent[LINELEN];
|
char dent[LINELEN];
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
|
@ -183,7 +189,16 @@ long dodir(char *d, int thislev, dev_t dev)
|
||||||
prog, d, block_size);
|
prog, d, block_size);
|
||||||
return 0L;
|
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) {
|
switch (s.st_mode & S_IFMT) {
|
||||||
case S_IFDIR:
|
case S_IFDIR:
|
||||||
/* Directories should not be linked except to "." and "..", so this
|
/* Directories should not be linked except to "." and "..", so this
|
||||||
|
@ -228,10 +243,11 @@ char **argv;
|
||||||
case 's': silent = 1; break;
|
case 's': silent = 1; break;
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'd': crosschk = 1; break;
|
case 'd': crosschk = 1; break;
|
||||||
|
case 'F': fsoverhead = 1; break;
|
||||||
case 'l': levels = atoi(optarg); break;
|
case 'l': levels = atoi(optarg); break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: %s [-asx] [-l levels] [startdir]\n", prog);
|
"Usage: %s [-asxF] [-l levels] [startdir]\n", prog);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -16,6 +16,7 @@ du \- print disk usage
|
||||||
..
|
..
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.FL "\-a" "Give usage for all files"
|
.FL "\-a" "Give usage for all files"
|
||||||
|
.FL "\-F" "Include filesystem overhead for indirect blocks"
|
||||||
.FL "\-l" "List up to \fIn\fR levels of subdirectories"
|
.FL "\-l" "List up to \fIn\fR levels of subdirectories"
|
||||||
.FL "\-d" "Do not cross file system boundaries"
|
.FL "\-d" "Do not cross file system boundaries"
|
||||||
.FL "\-s" "Summary only"
|
.FL "\-s" "Summary only"
|
||||||
|
|
|
@ -122,18 +122,11 @@ fitfs()
|
||||||
inodes=`find $path | egrep -v ^$path/usr | wc -l`
|
inodes=`find $path | egrep -v ^$path/usr | wc -l`
|
||||||
inodes="`expr $inodes + $extra_inodes`"
|
inodes="`expr $inodes + $extra_inodes`"
|
||||||
|
|
||||||
# Determine number of data zones using bc formula to transform file size in zone count
|
# Determine number of data zones
|
||||||
# s - file size
|
zonekbs=`du -Fs $path | cut -d' ' -f1`
|
||||||
# d - number of direct blocks
|
zonekbsignore=0
|
||||||
# i - number of indirect blocks
|
[ ! -d $path/usr ] || zonekbsignore=`du -Fs $path/usr | cut -d" " -f1`
|
||||||
# j - number of double indirect blocks
|
zones="`expr \( $zonekbs - $zonekbsignore \) / \( $BS / 1024 \) + $extra_zones`"
|
||||||
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 file system size
|
# Determine file system size
|
||||||
BSBITS="`expr $BS \* 8`"
|
BSBITS="`expr $BS \* 8`"
|
||||||
|
|
Loading…
Reference in a new issue