From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH 2/2] e2fsprogs: Add undoe2fs
Date: Wed, 11 Jul 2007 16:30:59 +0530 [thread overview]
Message-ID: <11841516682413-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
Message-ID: <7bda5b7be5247e02efe87ba887f28e141d96d1fd.1184151488.git.aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <11841516661516-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
In-Reply-To: <3552edc8ff6130d0687083e7462144c308fd2a14.1184151488.git.aneesh.kumar@linux.vnet.ibm.com>
From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
undoe2fs can be used to replay the transaction saved
in the transaction file using undo I/O Manager
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
misc/Makefile.in | 10 ++++++++--
misc/undoe2fs.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 2 deletions(-)
create mode 100644 misc/undoe2fs.c
diff --git a/misc/Makefile.in b/misc/Makefile.in
index ccad78c..51bb17a 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -15,7 +15,7 @@ INSTALL = @INSTALL@
@IMAGER_CMT@E2IMAGE_MAN= e2image.8
SPROGS= mke2fs badblocks tune2fs dumpe2fs blkid logsave \
- $(E2IMAGE_PROG) @FSCK_PROG@
+ $(E2IMAGE_PROG) @FSCK_PROG@ undoe2fs
USPROGS= mklost+found filefrag
SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \
e2label.8 findfs.8 blkid.8 $(E2IMAGE_MAN) \
@@ -39,6 +39,7 @@ E2IMAGE_OBJS= e2image.o
FSCK_OBJS= fsck.o base_device.o
BLKID_OBJS= blkid.o
FILEFRAG_OBJS= filefrag.o
+UNDOE2FS_OBJS= undoe2fs.o
XTRA_CFLAGS= -I$(srcdir)/../e2fsck -I.
@@ -47,7 +48,7 @@ SRCS= $(srcdir)/tune2fs.c $(srcdir)/mklost+found.c $(srcdir)/mke2fs.c \
$(srcdir)/badblocks.c $(srcdir)/fsck.c $(srcdir)/util.c \
$(srcdir)/uuidgen.c $(srcdir)/blkid.c $(srcdir)/logsave.c \
$(srcdir)/filefrag.c $(srcdir)/base_device.c \
- $(srcdir)/../e2fsck/profile.c
+ $(srcdir)/../e2fsck/profile.c $(srcdir)/undoe2fs.c
LIBS= $(LIBEXT2FS) $(LIBCOM_ERR)
DEPLIBS= $(LIBEXT2FS) $(LIBCOM_ERR)
@@ -108,6 +109,10 @@ e2image: $(E2IMAGE_OBJS) $(DEPLIBS)
@echo " LD $@"
@$(CC) $(ALL_LDFLAGS) -o e2image $(E2IMAGE_OBJS) $(LIBS) $(LIBINTL)
+undoe2fs: $(UNDOE2FS_OBJS) $(DEPLIBS)
+ @echo " LD $@"
+ @$(CC) $(ALL_LDFLAGS) -o undoe2fs $(UNDOE2FS_OBJS) $(LIBS)
+
base_device: base_device.c
@echo " LD $@"
@$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(srcdir)/base_device.c \
@@ -434,3 +439,4 @@ filefrag.o: $(srcdir)/filefrag.c
base_device.o: $(srcdir)/base_device.c $(srcdir)/fsck.h
profile.o: $(srcdir)/../e2fsck/profile.c $(top_srcdir)/lib/et/com_err.h \
$(srcdir)/../e2fsck/profile.h prof_err.h
+undoe2fs.o: $(srcdir)/undoe2fs.c $(top_srcdir)/lib/ext2fs/tdb.h
diff --git a/misc/undoe2fs.c b/misc/undoe2fs.c
new file mode 100644
index 0000000..c209878
--- /dev/null
+++ b/misc/undoe2fs.c
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include "ext2fs/tdb.h"
+
+void usage(char *prg_name)
+{
+ fprintf(stderr, "Usage: %s <transaction file> <filesystem>\n", prg_name);
+ exit(1);
+
+}
+
+
+main(int argc, char *argv[])
+{
+ TDB_CONTEXT *tdb;
+ TDB_DATA key, data;
+ unsigned long blk_num;
+ unsigned long long int location;
+ int fd;
+
+ if (argc != 3)
+ usage(argv[0]);
+
+ tdb = tdb_open(argv[1], 0, 0, O_RDONLY, 0600);
+
+ if (!tdb) {
+ printf("Failed tdb_open %s\n", strerror(errno));
+ exit(1);
+ }
+
+ fd = open(argv[2], O_WRONLY);
+
+ for (key = tdb_firstkey(tdb); key.dptr; key = tdb_nextkey(tdb, key)) {
+ data = tdb_fetch(tdb, key);
+ blk_num = *(unsigned long *)key.dptr;
+ location = blk_num * data.dsize;
+ printf("Replayed transaction of size %d at location %ld\n", data.dsize, blk_num);
+ lseek(fd, location, SEEK_SET);
+ write(fd, data.dptr, data.dsize);
+ }
+ close(fd);
+ tdb_close(tdb);
+
+}
--
1.5.3.rc0.63.gc956-dirty
next prev parent reply other threads:[~2007-07-11 11:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-11 11:00 e2fsprogs: Undo I/O manager Aneesh Kumar K.V
[not found] ` <3552edc8ff6130d0687083e7462144c308fd2a14.1184151488.git.aneesh.kumar@linux.vnet.ibm.com>
2007-07-11 11:00 ` [PATCH 1/2] e2fsprogs: Add undo " Aneesh Kumar K.V
[not found] ` <7bda5b7be5247e02efe87ba887f28e141d96d1fd.1184151488.git.aneesh.kumar@linux.vnet.ibm.com>
2007-07-11 11:00 ` Aneesh Kumar K.V [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-07-19 17:58 [Take 2]e2fsprogs: Undo " Aneesh Kumar K.V
2007-07-19 17:58 ` [PATCH 1/2] e2fsprogs: Add undo " Aneesh Kumar K.V
[not found] ` <42dd5d5526f5d0009749a1d612da840a03d58722.1184867582.git.aneesh.kumar@linux.vnet.ibm.com>
[not found] ` <461b5300ebb5cace30c279c531ed3bb4d84741d4.1184867582.git.aneesh.kumar@linux.vnet.ibm.com>
2007-07-19 17:58 ` [PATCH 2/2] e2fsprogs: Add undoe2fs Aneesh Kumar K.V
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11841516682413-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).