Date: Wed, 4 Sep 2002 22:40:05 -0700 (PDT) From: "fork __" <bouloumag@hotmail.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/42430: Add -m option to du(1) for compatibility to GNU [PATCH] Message-ID: <200209050540.g855e54t019893@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/42430; it has been noted by GNATS. From: "fork __" <bouloumag@hotmail.com> To: freebsd-gnats-submit@FreeBSD.org Cc: Subject: Re: bin/42430: Add -m option to du(1) for compatibility to GNU [PATCH] Date: Thu, 05 Sep 2002 05:35:34 +0000 Hi, I think that the version is more clean. I had remove the putenv call, and replace it by the use of the "blocksize" variable. Also, I had do some cleanout on the manpage (sorry, my english is a little poor ... ) Anyway, this is the new patch against FreeBSD 4.6.2-RELEASE -=========================================- diff -crN du.orig/du.1 du/du.1 *** du.orig/du.1 Thu Sep 5 00:35:41 2002 --- du/du.1 Thu Sep 5 01:24:54 2002 *************** *** 44,50 **** .Op Fl I Ar mask .Op Fl a | s | d Ar depth .Op Fl c ! .Op Fl h | k .Op Fl x .Op Ar .Sh DESCRIPTION --- 44,50 ---- .Op Fl I Ar mask .Op Fl a | s | d Ar depth .Op Fl c ! .Op Fl h | k | m .Op Fl x .Op Ar .Sh DESCRIPTION *************** *** 55,66 **** argument. If no file is specified, the block usage of the hierarchy rooted in the current directory is displayed. If the .Fl k ! flag is specified, the number of 1024-byte ! blocks used by the file is displayed, otherwise ! .Xr getbsize 3 ! is used to determine the preferred block size. Partial numbers of blocks are rounded up. .Pp The options are as follows: --- 55,71 ---- argument. If no file is specified, the block usage of the hierarchy rooted in the current directory is displayed. + By default, the preferred block size is determined by the value + returned by the + .Xr getbsize 3 + system call, i.e., 512-byte blocks. If the .Fl k ! flag is specified, the number displayed is the number of 1024-byte ! blocks. By the same way, if the ! .Fl m ! flag is specified, the number displayed is the number of 1048576-byte ! blocks. Partial numbers of blocks are rounded up. .Pp The options are as follows: *************** *** 79,86 **** .It Fl a Display an entry for each file in a file hierarchy. .It Fl h ! "Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte, ! Gigabyte, Terabyte and Petabyte .It Fl r Generate messages about directories that cannot be read, files that cannot be opened, and so on. This is the default case. --- 84,92 ---- .It Fl a Display an entry for each file in a file hierarchy. .It Fl h ! Display numbers in a human readable form. ! Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte in order to ! reduce the number of digits to four or less. .It Fl r Generate messages about directories that cannot be read, files that cannot be opened, and so on. This is the default case. *************** *** 98,103 **** --- 104,111 ---- Display a grand total. .It Fl k Display block counts in 1024-byte (1-Kbyte) blocks. + .It Fl m + Display block counts in 1048576-byte (1-Mbyte) blocks. .It Fl x Filesystem mount points are not traversed. .El *************** *** 123,140 **** .Sh ENVIRONMENT .Bl -tag -width BLOCKSIZE .It Ev BLOCKSIZE ! If the environment variable ! .Ev BLOCKSIZE ! is set, and the ! .Fl k ! option is not specified, the block counts will be displayed in units of that ! size block. ! If ! .Ev BLOCKSIZE ! is not set, and the .Fl k ! option is not specified, the block counts will be displayed in 512-byte blocks. ! .El .Sh SEE ALSO .Xr df 1 , .Xr fts 3 , --- 131,143 ---- .Sh ENVIRONMENT .Bl -tag -width BLOCKSIZE .It Ev BLOCKSIZE ! Block counts will be displayed in units of this size block, unless the .Fl k ! , the ! .Fl m ! or ! .Fl h ! option is specified. .Sh SEE ALSO .Xr df 1 , .Xr fts 3 , diff -crN du.orig/du.c du/du.c *** du.orig/du.c Thu Sep 5 00:35:41 2002 --- du/du.c Thu Sep 5 01:06:18 2002 *************** *** 115,131 **** int ftsoptions; int listall; int depth; ! int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, ch, notused, rval; char **save; ! Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = 0; save = argv; ftsoptions = 0; depth = INT_MAX; SLIST_INIT(&ignores); ! while ((ch = getopt(argc, argv, "HI:LPasd:chkrx")) != -1) switch (ch) { case 'H': Hflag = 1; --- 115,131 ---- int ftsoptions; int listall; int depth; ! int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, mflag, kflag, ch, notused, rval; char **save; ! Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = mflag = kflag = 0; save = argv; ftsoptions = 0; depth = INT_MAX; SLIST_INIT(&ignores); ! while ((ch = getopt(argc, argv, "HI:LPasd:chkmrx")) != -1) switch (ch) { case 'H': Hflag = 1; *************** *** 161,173 **** case 'c': cflag = 1; break; ! case 'h': ! putenv("BLOCKSIZE=512"); hflag = 1; valp = vals_base2; break; case 'k': ! putenv("BLOCKSIZE=1024"); break; case 'r': /* Compatibility. */ break; --- 161,175 ---- case 'c': cflag = 1; break; ! case 'h': hflag = 1; valp = vals_base2; break; case 'k': ! kflag = 1; ! break; ! case 'm': /* Compatibility with GNU */ ! mflag = 1; break; case 'r': /* Compatibility. */ break; *************** *** 228,234 **** argv[1] = NULL; } ! (void) getbsize(¬used, &blocksize); blocksize /= 512; rval = 0; --- 230,243 ---- argv[1] = NULL; } ! if (hflag) ! blocksize = 512; ! else if (kflag) ! blocksize = 1024; ! else if (mflag) ! blocksize = 1048576; ! else ! (void)getbsize(¬used, &blocksize); blocksize /= 512; rval = 0; *************** *** 390,396 **** usage() { (void)fprintf(stderr, ! "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k] [-x] [-I mask] [file ...]\n"); exit(EX_USAGE); } --- 399,405 ---- usage() { (void)fprintf(stderr, ! "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m] [-x] [-I mask] [file ...]\n"); exit(EX_USAGE); } _________________________________________________________________ Affichez, modifiez et partagez gratuitement vos photos en ligne: http://photos.msn.com/support/worldwide.aspx To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209050540.g855e54t019893>