+#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
+#ifndef EXT2_FT_UNKNOWN
+#define EXT2_FT_UNKNOWN 0
+#define EXT2_FT_REG_FILE 1
+#define EXT2_FT_DIR 2
+#define EXT2_FT_CHRDEV 3
+#define EXT2_FT_BLKDEV 4
+#define EXT2_FT_FIFO 5
+#define EXT2_FT_SOCK 6
+#define EXT2_FT_SYMLINK 7
+#define EXT2_FT_MAX 8
+#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){
+ msg("This is a 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))) {
+ msg("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)
+ do_exclude_ino(journal_ino, "journal inode");
+ do_exclude_ino(EXT2_RESIZE_INO, "resize inode");
+ }
+ }
+ return retval;
+}