]> git.wh0rd.org - dump.git/blobdiff - dump/traverse.c
'filetype' feature bug when dumping huge filesystems.
[dump.git] / dump / traverse.c
index 32ffd7ef4df4c8b9b54f9ab8f15247e092808b27..9c275c1a1d4934a658943151c9118c82f8c084ba 100644 (file)
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: traverse.c,v 1.9 1999/11/21 00:17:16 tiniou Exp $";
+       "$Id: traverse.c,v 1.12 2000/01/09 23:47:33 tiniou Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -100,6 +100,35 @@ static     int searchdir __P((ino_t ino, daddr_t blkno, long size, long filesize));
 #endif
 static void mapfileino __P((ino_t ino, long *tapesize, int *dirskipped));
 
+/* #define EXT3_FEATURE_INCOMPAT_RECOVER */
+
+int dump_fs_open(const char *disk, ext2_filsys *fs)
+{
+       int retval;
+       struct ext2fs_sb *s;
+
+#ifdef EXT3_FEATURE_INCOMPAT_RECOVER
+       retval = ext2fs_open(disk, EXT2_FLAG_FORCE, 0, 0, unix_io_manager, fs);
+#else
+       retval = ext2fs_open(disk, 0, 0, 0, unix_io_manager, fs);
+#endif
+       if (!retval) {
+               s = (struct ext2fs_sb *) (*fs)->super;
+               if ((s->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
+#ifdef EXT3_FEATURE_INCOMPAT_RECOVER
+                   (s->s_feature_incompat & ~(EXT3_FEATURE_INCOMPAT_RECOVER | EXT2_LIB_FEATURE_INCOMPAT_SUPP))) {
+#else
+                   (s->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP)) {
+#endif
+                       retval = EXT2_ET_UNSUPP_FEATURE;
+               }
+               else if (s->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
+                       retval = EXT2_ET_RO_UNSUPP_FEATURE;
+               }
+       }
+       return retval;
+}
+
 /*
  * This is an estimation of the number of TP_BSIZE blocks in the file.
  * It estimates the number of blocks in files with holes by assuming
@@ -254,9 +283,9 @@ mapfilesindir(struct ext2_dir_entry *dirent, int offset, int blocksize, char *bu
        dp = getino(dirent->inode);
        mode = dp->di_mode & IFMT;
        if (mode == IFDIR && dp->di_nlink != 0 && dp->di_dtime == 0) {
-               if ((dirent->name[0] != '.' || dirent->name_len != 1) &&
+               if ((dirent->name[0] != '.' || ( dirent->name_len & 0xFF ) != 1) &&
                    (dirent->name[0] != '.' || dirent->name[1] != '.' ||
-                    dirent->name_len != 2)) {
+                    ( dirent->name_len & 0xFF ) != 2)) {
                retval = ext2fs_dir_iterate(fs, ino, 0, NULL,
                                            mapfilesindir, private);
                if (retval)
@@ -487,9 +516,9 @@ searchdir(struct ext2_dir_entry *dp, int offset, int blocksize, char *buf, void
        if (dp->inode == 0)
                return 0;
        if (dp->name[0] == '.') {
-               if (dp->name_len == 1)
+               if (( dp->name_len & 0xFF ) == 1)
                        return 0;
-               if (dp->name[1] == '.' && dp->name_len == 2)
+               if (dp->name[1] == '.' && ( dp->name_len & 0xFF ) == 2)
                        return 0;
        }
        if (mdc->nodump) {
@@ -730,6 +759,7 @@ dumpino(struct dinode *dp, ino_t ino)
        if (bc.cnt > 0) {
                blksout (bc.buf, bc.cnt, bc.ino);
        }
+       free(bc.buf);
 #else
        for (ind_level = 0; ind_level < NIADDR; ind_level++) {
                dmpindir(ino, dp->di_ib[ind_level], ind_level, &size);