From owner-svn-src-stable-7@FreeBSD.ORG Thu Jan 15 03:48:49 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C510106564A; Thu, 15 Jan 2009 03:48:49 +0000 (UTC) (envelope-from keramida@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 893F78FC08; Thu, 15 Jan 2009 03:48:49 +0000 (UTC) (envelope-from keramida@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0F3mn9x063033; Thu, 15 Jan 2009 03:48:49 GMT (envelope-from keramida@svn.freebsd.org) Received: (from keramida@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0F3mnsH063031; Thu, 15 Jan 2009 03:48:49 GMT (envelope-from keramida@svn.freebsd.org) Message-Id: <200901150348.n0F3mnsH063031@svn.freebsd.org> From: Giorgos Keramidas Date: Thu, 15 Jan 2009 03:48:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187272 - stable/7/usr.bin/du X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jan 2009 03:48:50 -0000 Author: keramida (doc committer) Date: Thu Jan 15 03:48:49 2009 New Revision: 187272 URL: http://svn.freebsd.org/changeset/base/187272 Log: 176561 | keramida | 2008-02-25 21:06:43 +0200 (Mon, 25 Feb 2008) | 11 lines Implement from scratch a -l option for du(1), to match the same option of the GNU utility. The default behavior of our original `du' is to count hardlinked files only once for each invocation of the utility. With the new -l option they count towards the final size every time they are found. Modified: stable/7/usr.bin/du/ (props changed) stable/7/usr.bin/du/du.1 stable/7/usr.bin/du/du.c Modified: stable/7/usr.bin/du/du.1 ============================================================================== --- stable/7/usr.bin/du/du.1 Thu Jan 15 03:46:14 2009 (r187271) +++ stable/7/usr.bin/du/du.1 Thu Jan 15 03:48:49 2009 (r187272) @@ -32,7 +32,7 @@ .\" @(#)du.1 8.2 (Berkeley) 4/1/94 .\" $FreeBSD$ .\" -.Dd May 6, 2006 +.Dd February 25, 2008 .Dt DU 1 .Os .Sh NAME @@ -43,6 +43,7 @@ .Op Fl H | L | P .Op Fl a | s | d Ar depth .Op Fl c +.Op Fl l .Op Fl h | k | m .Op Fl n .Op Fl x @@ -94,6 +95,15 @@ directories deep. Display a grand total. .It Fl k Display block counts in 1024-byte (1-Kbyte) blocks. +.It Fl l +If a file has multiple hard links, count its size many times. +The default behavior of +.Nm +is to count files with multiple hard links only once. +When the +.Fl l +option is specified, the hard link checks are disabled, and these files +are counted (and displayed) as many times as they are found. .It Fl m Display block counts in 1048576-byte (1-Mbyte) blocks. .It Fl n @@ -120,11 +130,6 @@ or .Fl L options are specified, storage used by any symbolic links which are followed is not counted or displayed. -.Pp -Files having multiple hard links are counted (and displayed) a single -time per -.Nm -execution. .Sh ENVIRONMENT .Bl -tag -width BLOCKSIZE .It Ev BLOCKSIZE Modified: stable/7/usr.bin/du/du.c ============================================================================== --- stable/7/usr.bin/du/du.c Thu Jan 15 03:46:14 2009 (r187271) +++ stable/7/usr.bin/du/du.c Thu Jan 15 03:48:49 2009 (r187272) @@ -90,20 +90,22 @@ main(int argc, char *argv[]) int ftsoptions; int listall; int depth; - int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, ch, notused, rval; + int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag; + int hflag, lflag, ch, notused, rval; char **save; static char dot[] = "."; setlocale(LC_ALL, ""); - Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = 0; + Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = + lflag = 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:LPasd:chklmnrx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -147,6 +149,9 @@ main(int argc, char *argv[]) hflag = 0; setenv("BLOCKSIZE", "1024", 1); break; + case 'l': + lflag = 1; + break; case 'm': hflag = 0; setenv("BLOCKSIZE", "1048576", 1); @@ -257,7 +262,8 @@ main(int argc, char *argv[]) if (ignorep(p)) break; - if (p->fts_statp->st_nlink > 1 && linkchk(p)) + if (lflag == 0 && + p->fts_statp->st_nlink > 1 && linkchk(p)) break; if (listall || p->fts_level == 0) { @@ -443,7 +449,8 @@ static void 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] " + "[-l] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n"); exit(EX_USAGE); }