From owner-freebsd-bugs@FreeBSD.ORG Tue Apr 15 03:30:13 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BA9BB37B401 for ; Tue, 15 Apr 2003 03:30:13 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id EEFB143FAF for ; Tue, 15 Apr 2003 03:30:11 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h3FAUBUp055003 for ; Tue, 15 Apr 2003 03:30:11 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3FAUB7Z055002; Tue, 15 Apr 2003 03:30:11 -0700 (PDT) Resent-Date: Tue, 15 Apr 2003 03:30:11 -0700 (PDT) Resent-Message-Id: <200304151030.h3FAUB7Z055002@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Phil Pennock Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A404537B401 for ; Tue, 15 Apr 2003 03:22:38 -0700 (PDT) Received: from hermes.mail.nl.demon.net (hermes.mail.nl.demon.net [194.159.72.197]) by mx1.FreeBSD.org (Postfix) with ESMTP id A02C143FAF for ; Tue, 15 Apr 2003 03:22:37 -0700 (PDT) (envelope-from pdp@nl.demon.net) Received: from samhain.noc.nl.demon.net ([194.159.72.214]) by hermes.mail.nl.demon.net with esmtp (Exim 3.36 #1) id 195NaG-0002GR-00 for FreeBSD-gnats-submit@freebsd.org; Tue, 15 Apr 2003 12:22:36 +0200 Received: by samhain.noc.nl.demon.net with local id 195NaD-000AfS-00; Tue, 15 Apr 2003 10:22:33 +0000 Message-Id: Date: Tue, 15 Apr 2003 10:22:33 +0000 From: Phil Pennock To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/50971: du(1) doesn't understand UF_NODUMP flag X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Phil Pennock List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Apr 2003 10:30:14 -0000 >Number: 50971 >Category: bin >Synopsis: du(1) doesn't understand UF_NODUMP flag >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: Tue Apr 15 03:30:11 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Phil Pennock >Release: FreeBSD 4.7-RELEASE-p6 i386 >Organization: THUS Plc (Demon Internet Netherlands) >Environment: System: FreeBSD samhain.noc.nl.demon.net 4.7-RELEASE-p6 FreeBSD 4.7-RELEASE-p6 #0: Mon Feb 24 13:28:19 GMT 2003 root@samhain.noc.nl.demon.net:/usr/src/sys/compile/SAMHAIN i386 >Description: FreeBSD supports the user-flag "nodump" on files, to indicate to tools such as dump(8) that the file should not be backed up and, in recent FreeBSD, if set on a directory to indicate that the tree should be pruned at that point. There's no way to emulate this with du(1), which makes estimates of backup usage more tricky. This patch adds a -D flag to du(1) to honour UF_NODUMP and documents this in the man-page. du.c was 1.17.2.3 >How-To-Repeat: Take a directory tree, put some largish files in it, mark some nodump with chflags(1). Compare size with normal du(1) output, and output from this du(1) with and without the -D flag. >Fix: diff -Pru /usr/src/usr.bin/du/du.1 ./du.1 --- /usr/src/usr.bin/du/du.1 Tue Nov 12 18:43:18 2002 +++ ./du.1 Tue Apr 15 11:59:04 2003 @@ -65,6 +65,15 @@ .Pp The options are as follows: .Bl -tag -width indent +.It Fl D +Honor the user +.Dq nodump +flag, so that output is closer to figures for +.Xr dump 8 +usage; presence of the +.Pq Dv UF_NODUMP +flag on a directory truncates directory traversal, and on a file causes +the file size to not be included in the usage figures. .It Fl H Symbolic links on the command line are followed, symbolic links in file hierarchies are not followed. diff -Pru /usr/src/usr.bin/du/du.c ./du.c --- /usr/src/usr.bin/du/du.c Thu Jul 12 10:46:53 2001 +++ ./du.c Tue Apr 15 12:04:07 2003 @@ -115,18 +115,21 @@ int ftsoptions; int listall; int depth; - int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, ch, notused, rval; + int Dflag, Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, ch, notused, rval; char **save; - Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = 0; + Dflag = 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) + while ((ch = getopt(argc, argv, "DHI:LPasd:chkrx")) != -1) switch (ch) { + case 'D': + Dflag = 1; + break; case 'H': Hflag = 1; break; @@ -241,11 +244,18 @@ case FTS_D: /* Ignore. */ if (ignorep(p)) fts_set(fts, p, FTS_SKIP); + if (Dflag && + (p->fts_statp->st_flags & UF_NODUMP)) + fts_set(fts, p, FTS_SKIP); break; case FTS_DP: if (ignorep(p)) break; + if (Dflag && + (p->fts_statp->st_flags & UF_NODUMP)) + break; + p->fts_parent->fts_number += p->fts_number += p->fts_statp->st_blocks; @@ -270,6 +280,10 @@ break; default: if (ignorep(p)) + break; + + if (Dflag && + (p->fts_statp->st_flags & UF_NODUMP)) break; if (p->fts_statp->st_nlink > 1 && linkchk(p)) >Release-Note: >Audit-Trail: >Unformatted: