summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-02-26 20:45:36 -0500
committerTheodore Ts'o <tytso@mit.edu>2008-02-26 20:45:36 -0500
commitab52e12a904b4a31fc3416f0ef7d959f0c38e773 (patch)
treeceb5f9f9859d675dffb7c205e3af0c82f2915d4f
parentdb197a81cc7841af1afeb499645fd2a5767fa146 (diff)
downloade2fsprogs-ab52e12a904b4a31fc3416f0ef7d959f0c38e773.tar.gz
libext2fs: Add EXT2_FLAG_NONFREE_ON_ERROR to ext2fs_open2()
Add a flag which returns the partially completed filesystem object so e2fsck can print more intelligent error messages. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--lib/ext2fs/ext2fs.h1
-rw-r--r--lib/ext2fs/openfs.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index e1ae89d3..0b2c321e 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -188,6 +188,7 @@ typedef struct ext2_file *ext2_file_t;
#define EXT2_FLAG_IMAGE_FILE 0x2000
#define EXT2_FLAG_EXCLUSIVE 0x4000
#define EXT2_FLAG_SOFTSUPP_FEATURES 0x8000
+#define EXT2_FLAG_NOFREE_ON_ERROR 0x10000
/*
* Special flag in the ext2 inode i_flag field that means that this is
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 947675e5..d705b1c3 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -305,10 +305,14 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
fs->stride = fs->super->s_raid_stride;
+ fs->flags &= ~EXT2_FLAG_NOFREE_ON_ERROR;
*ret_fs = fs;
return 0;
cleanup:
- ext2fs_free(fs);
+ if (flags & EXT2_FLAG_NOFREE_ON_ERROR)
+ *ret_fs = fs;
+ else
+ ext2fs_free(fs);
return retval;
}