Date: Wed, 4 Sep 2002 15:19:54 -0700 (PDT) From: Fork <bouloumag@hotmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/42430: Add -m option to du(1) for compatibility to GNU [PATCH] Message-ID: <200209042219.g84MJsxW099190@www.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 42430
>Category: bin
>Synopsis: Add -m option to du(1) for compatibility to GNU [PATCH]
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Sep 04 15:20:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Fork
>Release: FreeBSD 4.6.2-RELEASE
>Organization:
>Environment:
FreeBSD asterix.local.qc 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #1: Tue Sep 3 00:25:58 EDT 2002 gaudrs@asterix.local.qc:/usr/obj/usr/src/sys/ASTERIX i386
>Description:
I have somes problem to port a script from our RedHat server to our new FreeBSD server. The problem is that FreeBSD does not have a -m option in the du(1) command. Since the same script will run the two plateforme, I need a -m option in FreeBSD.
The GNU version of du(1) had a -m option that display block counts in 1048576-byte (1-Mbyte) blocks. This is equivalent to set BLOCKSIZE=1048576.
>How-To-Repeat:
>Fix:
The following patch (against 4.6.2-RELEASE) add the -m option to du(1) :
diff -crN du.orig/du.1 du/du.1
*** du.orig/du.1 Wed Sep 4 18:06:28 2002
--- du/du.1 Wed Sep 4 18:02:45 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
***************
*** 98,103 ****
--- 98,105 ----
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
***************
*** 125,140 ****
.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 ,
--- 127,143 ----
.It Ev BLOCKSIZE
If the environment variable
.Ev BLOCKSIZE
! is set the block counts will be displayed in units of that
! size block, unless the
.Fl k
! ,
! .Fl m
! or
! .Fl h
! option is specified.
! If
.Ev BLOCKSIZE
! is not set, and the previous options are not specified, the block counts will be displayed in 512-byte blocks.
.Sh SEE ALSO
.Xr df 1 ,
.Xr fts 3 ,
diff -crN du.orig/du.c du/du.c
*** du.orig/du.c Wed Sep 4 18:06:28 2002
--- du/du.c Wed Sep 4 17:50:49 2002
***************
*** 125,131 ****
depth = INT_MAX;
SLIST_INIT(&ignores);
! while ((ch = getopt(argc, argv, "HI:LPasd:chkrx")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
--- 125,131 ----
depth = INT_MAX;
SLIST_INIT(&ignores);
! while ((ch = getopt(argc, argv, "HI:LPasd:chkmrx")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
***************
*** 169,174 ****
--- 169,177 ----
case 'k':
putenv("BLOCKSIZE=1024");
break;
+ case 'm': /* Compatibility with GNU */
+ putenv("BLOCKSIZE=1048576");
+ break;
case 'r': /* Compatibility. */
break;
case 'x':
***************
*** 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);
}
--- 393,399 ----
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);
}
>Release-Note:
>Audit-Trail:
>Unformatted:
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?200209042219.g84MJsxW099190>
