Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Nov 2001 14:18:42 +0000
From:      "Walter C. Pelissero" <walter@pelissero.org>
To:        hackers@FreeBSD.ORG
Subject:   tar and nodump flag
Message-ID:  <15355.47042.573852.420151@hyde.lpds.sublink.org>

next in thread | raw e-mail | index | archive | help
How about adding the nodump flag processing in tar?

Something like:

--- /usr/src/gnu/usr.bin/tar/create.c	Wed Aug 11 09:03:39 1999
+++ create.c	Wed Nov 21 13:52:54 2001
@@ -817,6 +817,8 @@
 	  strcpy (namebuf + len, d->d_name);
 	  if (f_exclude && check_exclude (namebuf))
 	    continue;
+	  if (hstat.st_flags & UF_NODUMP)
+	    continue;
 	  dump_file (namebuf, our_device, 0);
 	}
 
Or something like this patch I've submited to the GNU tar mailing
list:

diff -r -u tar-1.13.orig/src/common.h tar-1.13/src/common.h
--- tar-1.13.orig/src/common.h	Tue Nov 20 15:04:26 2001
+++ tar-1.13/src/common.h	Tue Nov 20 15:14:49 2001
@@ -143,6 +143,9 @@
 /* Boolean value.  */
 GLOBAL int dereference_option;
 
+/* Boolean value.  */
+GLOBAL int honor_nodump_option;
+
 /* Patterns that match file names to be excluded.  */
 GLOBAL struct exclude *excluded;
 
diff -r -u tar-1.13.orig/src/create.c tar-1.13/src/create.c
--- tar-1.13.orig/src/create.c	Tue Nov 20 15:04:25 2001
+++ tar-1.13/src/create.c	Tue Nov 20 15:18:14 2001
@@ -1483,6 +1483,12 @@
 	  if (is_dot_or_dotdot (entry->d_name)
 	      || excluded_filename (excluded, entry->d_name))
 	    continue;
+#ifdef __FreeBSD__
+	  /* If file has NODUMP flag set, ignore it.  Accordingly skip
+	     the whole tree under a directory. */
+	  if (honor_nodump_option && (current_stat.st_flags & UF_NODUMP))
+	    continue;
+#endif
 
 	  if ((int) NAMLEN (entry) + len >= buflen)
 	    {
diff -r -u tar-1.13.orig/src/tar.c tar-1.13/src/tar.c
--- tar-1.13.orig/src/tar.c	Tue Nov 20 15:04:26 2001
+++ tar-1.13/src/tar.c	Tue Nov 20 15:21:57 2001
@@ -187,6 +187,7 @@
   {"gunzip", no_argument, NULL, 'z'},
   {"gzip", no_argument, NULL, 'z'},
   {"help", no_argument, &show_help, 1},
+  {"honor-nodump", no_argument, NULL, 'H'},
   {"ignore-failed-read", no_argument, &ignore_failed_read_option, 1},
   {"ignore-zeros", no_argument, NULL, 'i'},
   /* FIXME: --ignore-end as a new name for --ignore-zeros?  */
@@ -416,7 +417,7 @@
    Y  per-block gzip compression */
 
 #define OPTION_STRING \
-  "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxz"
+  "-01234567ABC:F:GHK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxz"
 
 static void
 set_subcommand_option (enum subcommand subcommand)
@@ -623,6 +624,12 @@
 	/* Follow symbolic links.  */
 
 	dereference_option = 1;
+	break;
+
+      case 'H':
+	/* Honor NODUMP flag.  */
+
+	honor_nodump_option = 1;
 	break;
 
       case 'i':


BTW, the ancient GNU tar (1.11.2) FreeBSD has bundled with the system
happens to have a bug that makes it inconvenient with modern tapes.
The tape length (option -L) is stored in a signed integer; a DAT DDS-2
is already too big for that.

I would recommend to upgrade to the new 1.13, which, together with a
brand new set of bugs, introduces the TARLONG type to store such
informations as tape length.


-- 
walter pelissero
http://www.pelissero.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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