summaryrefslogtreecommitdiff
path: root/lib/ext2fs/openfs.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2004-07-28 21:11:48 -0400
committerTheodore Ts'o <tytso@mit.edu>2004-07-28 21:11:48 -0400
commit1ad54a940c499a66241f624882f1ffa03ce56d90 (patch)
tree97dc071ddf88a406944adb2af4be53d9e9a7d8c8 /lib/ext2fs/openfs.c
parent8c6b6483887c81b2f04db3e0683bd1d00dba3714 (diff)
downloade2fsprogs-1ad54a940c499a66241f624882f1ffa03ce56d90.tar.gz
Add ability for debugfs to use a separate source of data blocks when
reading from an e2image file. (New -d option) Add new functions ext2fs_get_data_io, ext2fs_set_data_io, ext2fs_rewrite_to_io to libext2fs library.
Diffstat (limited to 'lib/ext2fs/openfs.c')
-rw-r--r--lib/ext2fs/openfs.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index bc7c5bb3..dac8a38c 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -96,6 +96,7 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock,
&fs->io);
if (retval)
goto cleanup;
+ fs->image_io = fs->io;
fs->io->app_data = fs;
retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
if (retval)
@@ -271,3 +272,36 @@ cleanup:
return retval;
}
+/*
+ * Set/get the filesystem data I/O channel.
+ *
+ * These functions are only valid if EXT2_FLAG_IMAGE_FILE is true.
+ */
+errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io)
+{
+ if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
+ return EXT2_ET_NOT_IMAGE_FILE;
+ if (old_io) {
+ *old_io = (fs->image_io == fs->io) ? 0 : fs->io;
+ }
+ return 0;
+}
+
+errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io)
+{
+ if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
+ return EXT2_ET_NOT_IMAGE_FILE;
+ fs->io = new_io ? new_io : fs->image_io;
+ return 0;
+}
+
+errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io)
+{
+ if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
+ return EXT2_ET_NOT_IMAGE_FILE;
+ fs->io = fs->image_io = new_io;
+ fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW |
+ EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY;
+ fs->flags &= ~EXT2_FLAG_IMAGE_FILE;
+ return 0;
+}