Date: Tue, 15 Apr 2003 10:22:33 +0000 From: Phil Pennock <pdp@nl.demon.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/50971: du(1) doesn't understand UF_NODUMP flag Message-ID: <E195NaD-000AfS-00@samhain.noc.nl.demon.net> Resent-Message-ID: <200304151030.h3FAUB7Z055002@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E195NaD-000AfS-00>