+static void mapfileino __P((dump_ino_t ino, struct dinode const *dp, long *tapesize, int *dirskipped));
+static int exclude_ino __P((dump_ino_t ino));
+extern dump_ino_t iexclude_list[IEXCLUDE_MAXNUM]; /* the inode exclude list */
+extern int iexclude_num; /* number of elements in list */
+
+#ifdef HAVE_EXT2_JOURNAL_INUM
+#define ext2_journal_ino(sb) (sb->s_journal_inum)
+#else
+#define ext2_journal_ino(sb) (*((__u32 *)sb + 0x38))
+#endif
+#ifndef HAVE_EXT2_INO_T
+typedef ino_t ext2_ino_t;
+#endif
+
+#ifndef EXT3_FEATURE_COMPAT_HAS_JOURNAL
+#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+#endif
+#ifndef EXT2_FEATURE_INCOMPAT_FILETYPE
+#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
+#endif
+#ifndef EXT3_FEATURE_INCOMPAT_RECOVER
+#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
+#endif
+#ifndef EXT3_FEATURE_INCOMPAT_JOURNAL_DEV
+#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
+#endif
+
+#ifndef EXT2_LIB_FEATURE_INCOMPAT_SUPP
+#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_RECOVER | \
+ EXT2_FEATURE_INCOMPAT_FILETYPE)
+#endif
+#ifndef EXT2_RESIZE_INO
+#define EXT2_RESIZE_INO 7
+#endif
+
+int dump_fs_open(const char *disk, ext2_filsys *fs)
+{
+ int retval;
+
+ retval = ext2fs_open(disk, EXT2_FLAG_FORCE, 0, 0, unix_io_manager, fs);
+ if (!retval) {
+ struct ext2_super_block *es = (*fs)->super;
+ dump_ino_t journal_ino = ext2_journal_ino(es);
+
+ if (es->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV){
+ fprintf(stderr, "This an journal, not a filesystem!\n");
+ retval = EXT2_ET_UNSUPP_FEATURE;
+ ext2fs_close(*fs);
+ }
+ else if ((retval = es->s_feature_incompat &
+ ~(EXT2_LIB_FEATURE_INCOMPAT_SUPP |
+ EXT3_FEATURE_INCOMPAT_RECOVER))) {
+ fprintf(stderr,
+ "Unsupported feature(s) 0x%x in filesystem\n",
+ retval);
+ retval = EXT2_ET_UNSUPP_FEATURE;
+ ext2fs_close(*fs);
+ }
+ else {
+ if (es->s_feature_compat &
+ EXT3_FEATURE_COMPAT_HAS_JOURNAL &&
+ journal_ino && !exclude_ino(journal_ino)) {
+ iexclude_list[iexclude_num++] = journal_ino;
+ msg("Exclude ext3 journal inode %u\n",
+ journal_ino);
+ }
+ if (!exclude_ino(EXT2_RESIZE_INO))
+ iexclude_list[iexclude_num++] = EXT2_RESIZE_INO;
+ }
+ }
+ return retval;
+}