]> git.wh0rd.org - dump.git/commitdiff
Unlimited fast inode exclusion.
authorStelian Pop <stelian@popies.net>
Mon, 12 May 2003 14:16:35 +0000 (14:16 +0000)
committerStelian Pop <stelian@popies.net>
Mon, 12 May 2003 14:16:35 +0000 (14:16 +0000)
CHANGES
THANKS
dump/dump.h
dump/main.c

diff --git a/CHANGES b/CHANGES
index 47eead29167a5670fbf94a677b6c64f37e5f5e1a..e4ec918150ed9690bc7692f5d03decacdef5e3d0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.230 2003/05/08 21:11:33 stelian Exp $
+$Id: CHANGES,v 1.231 2003/05/12 14:16:35 stelian Exp $
 
 Changes between versions 0.4b34 and 0.4b35 (released ??????????????)
 ====================================================================
 
 Changes between versions 0.4b34 and 0.4b35 (released ??????????????)
 ====================================================================
@@ -12,6 +12,10 @@ Changes between versions 0.4b34 and 0.4b35 (released ??????????????)
        LDFLAGS environment variables. Thanks to Arcady Genkin
        <antipode@users.sourceforge.net> for reporting the bug.
 
        LDFLAGS environment variables. Thanks to Arcady Genkin
        <antipode@users.sourceforge.net> for reporting the bug.
 
+3.     Make -e/-E options of dump accept an unlimited number of inodes
+       to be excluded, rather than a hardcoded maximum. Thanks to 
+       Dietrich Rothe <d-rothe@users.sourceforge.net> for the patch.
+
 Changes between versions 0.4b33 and 0.4b34 (released April 18, 2003)
 ====================================================================
 
 Changes between versions 0.4b33 and 0.4b34 (released April 18, 2003)
 ====================================================================
 
diff --git a/THANKS b/THANKS
index cd3a3ad142492df0f789886dbcc07df9df19b917..031d70a955f35c983faf92bc214becfe55b91d8e 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -1,4 +1,4 @@
-$Id: THANKS,v 1.82 2003/05/08 21:11:33 stelian Exp $
+$Id: THANKS,v 1.83 2003/05/12 14:16:35 stelian Exp $
 
 Dump and restore were written by the people of the CSRG at the University
 of California, Berkeley.
 
 Dump and restore were written by the people of the CSRG at the University
 of California, Berkeley.
@@ -93,6 +93,7 @@ Eric S. Raymond               esr@minx.thyrsus.com
 Graham Reed            greed@users.sourceforge.net
 Gunther Reiszig                gunther@mit.edu
 David Ronis            ronis@ronispc.chem.mcgill.ca
 Graham Reed            greed@users.sourceforge.net
 Gunther Reiszig                gunther@mit.edu
 David Ronis            ronis@ronispc.chem.mcgill.ca
+Dietrich Rothe         d-rothe@users.sourceforge.net
 Bernhard Sadlowski     sadlowsk@Mathematik.Uni-Bielefeld.DE
 Peter Samuel           peters@e-smith.com
 Jan Sanislo            oystr@cs.washington.edu
 Bernhard Sadlowski     sadlowsk@Mathematik.Uni-Bielefeld.DE
 Peter Samuel           peters@e-smith.com
 Jan Sanislo            oystr@cs.washington.edu
index 8fb157a32a06d292b62b810cbb87f9ad2ecc51f0..1c3c42572a663995eef30aae52daddac4e9091ec 100644 (file)
@@ -5,7 +5,7 @@
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  *
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  *
- *     $Id: dump.h,v 1.45 2003/03/31 09:42:58 stelian Exp $
+ *     $Id: dump.h,v 1.46 2003/05/12 14:16:39 stelian Exp $
  */
 
 /*-
  */
 
 /*-
@@ -277,6 +277,3 @@ extern off_t lseek();
 extern const char *strerror();
 #endif
 
 extern const char *strerror();
 #endif
 
-                               /* 04-Feb-00 ILC */
-#define IEXCLUDE_MAXNUM 256    /* max size of inode exclude list */
-
index 379e876c4bd922c248c587889434323d342aaa43..007a37d8b0fbc97171de505be17f4fe4d07e3cdd 100644 (file)
@@ -37,7 +37,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.85 2003/03/31 09:42:58 stelian Exp $";
+       "$Id: main.c,v 1.86 2003/05/12 14:16:39 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -186,8 +186,8 @@ static void do_exclude_from_file __P((char *));
 static void do_exclude_ino_str __P((char *));
 static void incompat_flags __P((int, char, char));
 
 static void do_exclude_ino_str __P((char *));
 static void incompat_flags __P((int, char, char));
 
-static dump_ino_t iexclude_list[IEXCLUDE_MAXNUM];/* the inode exclude list */
-static int iexclude_num = 0;                   /* number of elements in the list */
+static char* iexclude_bitmap = NULL;   /* the inode exclude bitmap */
+static int iexclude_bitmap_bytes = 0;  /* size of bitmap in bytes */
 
 int
 main(int argc, char *argv[])
 
 int
 main(int argc, char *argv[])
@@ -1224,40 +1224,66 @@ obsolete(int *argcp, char **argvp[])
 }
 
 /*
 }
 
 /*
- * This tests whether an inode is in the exclude list
+ * This tests whether an inode is in the exclude bitmap
  */
 int
 exclude_ino(dump_ino_t ino)
 {
  */
 int
 exclude_ino(dump_ino_t ino)
 {
-       /* 04-Feb-00 ILC */
-       if (iexclude_num) {     /* if there are inodes in the exclude list */
-               int idx;        /* then check this inode against it */
-               for (idx = 0; idx < iexclude_num; idx++)
-                       if (ino == iexclude_list[idx])
-                               return 1;
+       /* if the inode exclude bitmap exists and covers given inode */
+       if (iexclude_bitmap && iexclude_bitmap_bytes > ino / 8) {
+               /* then check this inode against it */
+               int idx = iexclude_bitmap[ino / 8];
+               if (idx & (1 << (ino % 8)))
+                       return 1;
        }
        return 0;
 }
 
 /*
        }
        return 0;
 }
 
 /*
- * This tests adds an inode to the exclusion list if it isn't already there
+ * This adds an inode to the exclusion bitmap if it isn't already there
  */
 void
 do_exclude_ino(dump_ino_t ino, const char *reason)
 {
  */
 void
 do_exclude_ino(dump_ino_t ino, const char *reason)
 {
-       if (!exclude_ino(ino)) {
-               if (iexclude_num == IEXCLUDE_MAXNUM) {
-                       msg("Too many exclude options\n");
-                       msg("The ENTIRE dump is aborted.\n");
-                       exit(X_STARTUP);
-               }
+       if (exclude_ino(ino))
+               return;
+
+       if (vflag) {
                if (reason)
                if (reason)
-                       msg("Excluding inode %u (%s) from dump\n", 
-                           ino, reason);
+                       msg("Excluding inode %u (%s) from dump\n", ino, reason);
                else
                        msg("Excluding inode %u from dump\n", ino);
                else
                        msg("Excluding inode %u from dump\n", ino);
-               iexclude_list[iexclude_num++] = ino;
        }
        }
+
+       /* check for enough mem; initialize */
+       if ((ino/8 + 1) > iexclude_bitmap_bytes) {
+               if (iexclude_bitmap_bytes == 0) {
+                       iexclude_bitmap_bytes = 2 * (ino/8 + 1);
+                       iexclude_bitmap = (char*) malloc(iexclude_bitmap_bytes);
+                       if (iexclude_bitmap == NULL) {
+                               msg("allocating memory failed\n");
+                               exit(X_STARTUP);
+                       }
+                       int j;
+                       for (j = 0; j < iexclude_bitmap_bytes; j++)
+                               iexclude_bitmap[j] = 0;
+               }
+               else {
+                       int oldsize = iexclude_bitmap_bytes;
+                       iexclude_bitmap_bytes *= 
+                               (ino / 8 + 1) / iexclude_bitmap_bytes + 1;
+                       iexclude_bitmap = (char*) realloc(iexclude_bitmap, 
+                               iexclude_bitmap_bytes);
+                       if (iexclude_bitmap == NULL) {
+                               msg("allocating memory failed\n");
+                               exit(X_STARTUP);
+                       }
+                       for( ; oldsize < iexclude_bitmap_bytes; oldsize++)
+                               iexclude_bitmap[oldsize] = 0;
+               }
+       }
+               
+       iexclude_bitmap[ino / 8] |= 1 << (ino % 8);
 }
 
 static void
 }
 
 static void