Theodore Ts'o wrote:
The hg repository located at:
http://thunk.org/hg/e2fsprogs
... contains what I hope to be the e2fsprogs 1.40 release. If folks
could test it and let me know if they find any embarassing bugs, I would
greatly appreciate it. It can also be found at:
ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/e2fsprogs-1.40-rc1.tar.gz
Over the next few days, I'll be working on converting e2fsprogs SCM from
hg to git. Assuming no one finds any problems, I'll be releasing
e2fsprogs 1.40 by the end of the week.
What about undo I/O manager ?
This I/O manager saves the contents of the location being overwritten
to a tdb database. This helps in undoing the changes done to the
file system.
The call sequence involve
set_undo_io_backing_manager(unix_io_manager);
set_undo_io_backup_file(/tmp/test.tdb);
retval = ext2fs_open2(dev_name, 0, flags,
superblock, block_size, undo_io_manager,
current_fs);
The patch is on top of e2fsprogs-upstream mercurial repo
Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]
diff -r fe55db3e508c lib/ext2fs/Makefile.in
--- a/lib/ext2fs/Makefile.inSun Jun 24 17:32:47 2007 -0400
+++ b/lib/ext2fs/Makefile.inMon Jun 25 20:59:36 2007 +0530
@@ -66,7 +66,8 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_O
unix_io.o \
unlink.o \
valid_blk.o \
- version.o
+ version.o \
+ undo_io.o
SRCS= ext2_err.c \
$(srcdir)/alloc.c \
@@ -134,7 +135,8 @@ SRCS= ext2_err.c \
$(srcdir)/tst_bitops.c \
$(srcdir)/tst_byteswap.c \
$(srcdir)/tst_getsize.c \
- $(srcdir)/tst_iscan.c
+ $(srcdir)/tst_iscan.c \
+ $(srcdir)/undo_io.c
HFILES= bitops.h ext2fs.h ext2_io.h ext2_fs.h ext2_ext_attr.h ext3_extents.h \
tdb.h
@@ -583,3 +585,4 @@ tst_iscan.o: $(srcdir)/tst_iscan.c $(src
$(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
$(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
+undo_io.o: $(srcdir)/undo_io.c $(srcdir)/ext2_fs.h $(srcdir)/ext2fs.h
diff -r fe55db3e508c lib/ext2fs/ext2_io.h
--- a/lib/ext2fs/ext2_io.h Sun Jun 24 17:32:47 2007 -0400
+++ b/lib/ext2fs/ext2_io.h Mon Jun 25 20:59:36 2007 +0530
@@ -96,6 +96,11 @@ extern errcode_t io_channel_write_byte(i
/* unix_io.c */
extern io_manager unix_io_manager;
+/* undo_io.c */
+extern io_manager undo_io_manager;
+extern errcode_t set_undo_io_backing_manager(io_manager manager);
+extern errcode_t set_undo_io_backup_file(char *file_name);
+
/* test_io.c */
extern io_manager test_io_manager, test_io_backing_manager;
extern void (*test_io_cb_read_blk)
diff -r fe55db3e508c lib/ext2fs/undo_io.c
--- /dev/null Thu Jan 01 00:00:00 1970 +
+++ b/lib/ext2fs/undo_io.c Mon Jun 25 21:02:24 2007 +0530
@@ -0,0 +1,478 @@
+/*
+ * undo_io.c --- This is the undo io manager that copies the old data that
+ * copies the old data being overwritten into a tdb database
+ *
+ * Copyright IBM Corporation, 2007
+ * Author Aneesh Kumar K.V [EMAIL PROTECTED]
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include stdio.h
+#include string.h
+#if HAVE_UNISTD_H
+#include unistd.h
+#endif
+#if HAVE_ERRNO_H
+#include errno.h
+#endif
+#include fcntl.h
+#include time.h
+#ifdef __linux__
+#include sys/utsname.h
+#endif
+#if HAVE_SYS_STAT_H
+#include sys/stat.h
+#endif
+#if HAVE_SYS_TYPES_H
+#include sys/types.h
+#endif
+#if HAVE_SYS_RESOURCE_H
+#include sys/resource.h
+#endif
+
+#include tdb.h
+
+#include ext2_fs.h
+#include ext2fs.h
+
+/*
+ * For checking structure magic numbers...
+ */
+
+#define EXT2_CHECK_MAGIC(struct, code) \
+ if ((struct)-magic != (code)) return (code)
+
+
+
+struct undo_private_data {
+ int magic;
+ TDB_CONTEXT *tdb;
+ char *tdb_file;
+
+ /* The backing io channel */
+ io_channel real;
+
+ /* to support offset in unix I/O manager */
+ ext2_loff_t offset;
+};
+
+static errcode_t undo_open(const char *name, int flags, io_channel *channel);
+static errcode_t undo_close(io_channel channel);
+static errcode_t undo_set_blksize(io_channel channel, int blksize);
+static errcode_t undo_read_blk(io_channel channel, unsigned long block,
+ int count, void *data);
+static errcode_t undo_write_blk(io_channel channel, unsigned long block,
+ int count, const void *data);
+static errcode_t undo_flush(io_channel channel);
+static errcode_t undo_write_byte(io_channel channel, unsigned long offset,
+ int size, const void *data);
+static errcode_t undo_set_option(io_channel channel, const char *option,
+const char *arg);
+
+static struct struct_io_manager struct_undo_manager =