+
+/*
+ * This tests whether an inode is in the exclude list
+ */
+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;
+ }
+ return 0;
+}
+
+/*
+ * This tests adds an inode to the exclusion list 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 (reason)
+ msg("Added inode %u to exclude list (%s)\n",
+ ino, reason);
+ else
+ msg("Added inode %u to exclude list\n", ino);
+ iexclude_list[iexclude_num++] = ino;
+ }
+}
+
+static void
+do_exclude_ino_str(char * ino) {
+ char *r;
+ unsigned long inod;
+
+ inod = strtoul(ino, &r, 10);
+ if (*r != '\0' || inod <= ROOTINO) {
+ msg("Invalid inode argument %s\n", ino);
+ msg("The ENTIRE dump is aborted.\n");
+ exit(X_STARTUP);
+ }
+ do_exclude_ino(inod, NULL);
+}
+
+/*
+ * This reads a file containing one inode number per line and exclude them all
+ */
+static void
+do_exclude_from_file(char *file) {
+ FILE *f;
+ char *p, fname[MAXPATHLEN];
+
+
+ if (!( f = fopen(file, "r")) ) {
+ msg("Cannot open file for reading: %s\n", file);
+ msg("The ENTIRE dump is aborted.\n");
+ exit(X_STARTUP);
+ }
+ while (( p = fgets(fname, MAXPATHLEN, f))) {
+ if ( *p && *(p + strlen(p) - 1) == '\n' ) /* possible null string */
+ *(p + strlen(p) - 1) = '\0';
+ if ( !*p ) /* skip empty lines */
+ continue;
+ do_exclude_ino_str(p);
+ }
+ fclose(f);
+}