Only in a/usr.bin/du: Makefile diff -u -r a/usr.bin/du/du.1 b/usr.bin/du/du.1 --- a/usr.bin/du/du.1 Mon Mar 24 02:56:25 2008 +++ b/usr.bin/du/du.1 Mon Mar 24 02:59:40 2008 @@ -43,7 +43,7 @@ .Op Fl H | L | P .Op Fl a | s | d Ar depth .Op Fl c -.Op Fl h | k | m +.Op Fl h | b | k | m .Op Fl n .Op Fl x .Op Fl I Ar mask @@ -92,6 +92,8 @@ directories deep. .It Fl c Display a grand total. +.It Fl b +Display block counts in bytes. .It Fl k Display block counts in 1024-byte (1-Kbyte) blocks. .It Fl m diff -u -r a/usr.bin/du/du.c b/usr.bin/du/du.c --- a/usr.bin/du/du.c Mon Mar 24 02:56:25 2008 +++ b/usr.bin/du/du.c Mon Mar 24 03:05:13 2008 @@ -90,20 +90,20 @@ int ftsoptions; int listall; int depth; - int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, ch, notused, rval; + int Hflag, Lflag, Pflag, aflag, bflag, sflag, dflag, cflag, hflag, ch, notused, rval; char **save; static char dot[] = "."; setlocale(LC_ALL, ""); - Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = 0; + Hflag = Lflag = Pflag = aflag = bflag = sflag = dflag = cflag = hflag = 0; save = argv; ftsoptions = 0; depth = INT_MAX; SLIST_INIT(&ignores); - while ((ch = getopt(argc, argv, "HI:LPasd:chkmnrx")) != -1) + while ((ch = getopt(argc, argv, "HI:LPabsd:chkmnrx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -143,11 +143,17 @@ putenv("BLOCKSIZE=512"); hflag = 1; break; + case 'b': + putenv("BLOCKSIZE=512"); + bflag = 1; + break; case 'k': + bflag = 0; hflag = 0; putenv("BLOCKSIZE=1024"); break; case 'm': + bflag = 0; hflag = 0; putenv("BLOCKSIZE=1048576"); break; @@ -213,8 +219,12 @@ argv[1] = NULL; } - (void) getbsize(¬used, &blocksize); - blocksize /= 512; + if (!bflag) { + (void) getbsize(¬used, &blocksize); + blocksize /= 512; + } else { + blocksize=1; + } rval = 0; @@ -231,8 +241,13 @@ if (ignorep(p)) break; - p->fts_parent->fts_bignum += - p->fts_bignum += p->fts_statp->st_blocks; + if (!bflag) { + p->fts_parent->fts_bignum += + p->fts_bignum += p->fts_statp->st_blocks; + } else { + p->fts_parent->fts_bignum += + p->fts_bignum += p->fts_statp->st_size; + } if (p->fts_level <= depth) { if (hflag) { @@ -261,18 +276,34 @@ break; if (listall || p->fts_level == 0) { - if (hflag) { - (void) prthumanval(howmany(p->fts_statp->st_blocks, - blocksize)); - (void) printf("\t%s\n", p->fts_path); + if (!bflag) { + if (hflag) { + (void) prthumanval(howmany(p->fts_statp->st_blocks, + blocksize)); + (void) printf("\t%s\n", p->fts_path); + } else { + (void) printf("%jd\t%s\n", + (intmax_t)howmany(p->fts_statp->st_blocks, blocksize), + p->fts_path); + } } else { - (void) printf("%jd\t%s\n", - (intmax_t)howmany(p->fts_statp->st_blocks, blocksize), - p->fts_path); + if (hflag) { + (void) prthumanval(howmany(p->fts_statp->st_size, + blocksize)); + (void) printf("\t%s\n", p->fts_path); + } else { + (void) printf("%jd\t%s\n", + (intmax_t)howmany(p->fts_statp->st_size, blocksize), + p->fts_path); + } } } - p->fts_parent->fts_bignum += p->fts_statp->st_blocks; + if (!bflag) { + p->fts_parent->fts_bignum += p->fts_statp->st_blocks; + } else { + p->fts_parent->fts_bignum += p->fts_statp->st_size; + } } savednumber = p->fts_parent->fts_bignum; } @@ -443,7 +474,7 @@ usage(void) { (void)fprintf(stderr, - "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n"); + "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -b | -m] [-n] [-x] [-I mask] [file ...]\n"); exit(EX_USAGE); }