From 67793be06d93a6c433acaf6a3c7063d203acf583 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Mon, 12 May 2003 14:16:35 +0000 Subject: [PATCH] Unlimited fast inode exclusion. --- CHANGES | 6 ++++- THANKS | 3 ++- dump/dump.h | 5 +--- dump/main.c | 66 +++++++++++++++++++++++++++++++++++++---------------- 4 files changed, 54 insertions(+), 26 deletions(-) diff --git a/CHANGES b/CHANGES index 47eead2..e4ec918 100644 --- 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 ??????????????) ==================================================================== @@ -12,6 +12,10 @@ Changes between versions 0.4b34 and 0.4b35 (released ??????????????) LDFLAGS environment variables. Thanks to Arcady Genkin 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 for the patch. + Changes between versions 0.4b33 and 0.4b34 (released April 18, 2003) ==================================================================== diff --git a/THANKS b/THANKS index cd3a3ad..031d70a 100644 --- 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. @@ -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 +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 diff --git a/dump/dump.h b/dump/dump.h index 8fb157a..1c3c425 100644 --- a/dump/dump.h +++ b/dump/dump.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - AlcĂ´ve , 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 - /* 04-Feb-00 ILC */ -#define IEXCLUDE_MAXNUM 256 /* max size of inode exclude list */ - diff --git a/dump/main.c b/dump/main.c index 379e876..007a37d 100644 --- a/dump/main.c +++ b/dump/main.c @@ -37,7 +37,7 @@ #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 @@ -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 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[]) @@ -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) { - /* 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; } /* - * 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) { - 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) - 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); - 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 -- 2.39.2