Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 May 2006 14:04:49 GMT
From:      Dmitry Kazarov <kazarov@mcm.ru>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/96864: nodump parameter for du
Message-ID:  <200605061404.k46E4nVa027013@www.freebsd.org>
Resent-Message-ID: <200605061410.k46EADuH072170@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         96864
>Category:       bin
>Synopsis:       nodump parameter for du
>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:   Sat May 06 14:10:13 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Kazarov
>Release:        FreeBSD 6.1-RC
>Organization:
Telecom Service T
>Environment:
FreeBSD CE.multicom.ru 6.1-RC FreeBSD 6.1-RC #0: Fri May  5 12:18:36 MSD 2006     root@CE.multicom.ru:/var/tmp/obj/usr/src/sys/CE  i386

>Description:
It's very hard to estimate dump size if some files or dirs are marked with NODUMP flag. I've added flag to du to omit such files.
>How-To-Repeat:

>Fix:
--- du.1.orig	Sat May  6 17:56:02 2006
+++ du.1	Sat May  6 17:55:02 2006
@@ -43,6 +43,7 @@
 .Op Fl H | L | P
 .Op Fl a | s | d Ar depth
 .Op Fl c
+.Op Fl n
 .Op Fl h | k | m
 .Op Fl x
 .Op Fl I Ar mask
@@ -91,6 +92,8 @@
 directories deep.
 .It Fl c
 Display a grand total.
+.It Fl n
+Omit files and directories with nodump flag set.
 .It Fl k
 Display block counts in 1024-byte (1-Kbyte) blocks.
 .It Fl m

--- du.c.orig	Sat May  6 17:52:33 2006
+++ du.c	Sat May  6 17:53:10 2006
@@ -71,6 +71,8 @@
 	SLIST_ENTRY(ignentry)	next;
 };
 
+int		nodumpflag = 0;
+
 static int	linkchk(FTSENT *);
 static void	usage(void);
 void		prthumanval(int64_t);
@@ -101,7 +103,7 @@
 	depth = INT_MAX;
 	SLIST_INIT(&ignores);
 
-	while ((ch = getopt(argc, argv, "HI:LPasd:chkmrx")) != -1)
+	while ((ch = getopt(argc, argv, "HI:LPasd:chkmnrx")) != -1)
 		switch (ch) {
 			case 'H':
 				Hflag = 1;
@@ -149,6 +151,9 @@
 				hflag = 0;
 				putenv("BLOCKSIZE=1048576");
 				break;
+			case 'n':
+				nodumpflag = 1;
+				break;
 			case 'r':		 /* Compatibility. */
 				break;
 			case 'x':
@@ -438,7 +443,7 @@
 usage(void)
 {
 	(void)fprintf(stderr,
-		"usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m] [-x] [-I mask] [file ...]\n");
+		"usage: du [-H | -L | -P] [-a | -s | -d depth] [-n] [-c] [-h | -k | -m] [-x] [-I mask] [file ...]\n");
 	exit(EX_USAGE);
 }
 
@@ -473,6 +478,9 @@
 ignorep(FTSENT *ent)
 {
 	struct ignentry *ign;
+
+	if( nodumpflag && ( ent->fts_statp->st_flags & UF_NODUMP ) )
+	    return 1;
 
 	SLIST_FOREACH(ign, &ignores, next)
 		if (fnmatch(ign->mask, ent->fts_name, 0) != FNM_NOMATCH)

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605061404.k46E4nVa027013>