lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri,  4 May 2007 14:43:24 +0530
From:	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
To:	linux-ext4@...r.kernel.org
Cc:	aneesh.kumar@...ux.vnet.ibm.com
Subject: [PATCH 4/4] Add ext4replay tool.

From: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>

This tool can be used to replay the transactions stored in the database
during ext4migrate.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>
---
 ext4migrate/Makefile.in |    7 ++++++-
 ext4migrate/replay.c    |   45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletions(-)
 create mode 100644 ext4migrate/replay.c

diff --git a/ext4migrate/Makefile.in b/ext4migrate/Makefile.in
index b000ae7..8fe6291 100644
--- a/ext4migrate/Makefile.in
+++ b/ext4migrate/Makefile.in
@@ -21,7 +21,7 @@ DEPLIBS= $(LIBEXT2FS)  $(LIBCOM_ERR)
 	@#cc -g -I../lib/  -Wunreachable-code -Wunused -Wunused-function
 	@#-Wunused-label  -Wunused-parameter -Wunused-value  -Wunused-variable  -c migrate.c
 
-PROGS= ext4migrate
+PROGS= ext4migrate ext4replay
 
 all:: $(PROGS)
 
@@ -29,6 +29,10 @@ ext4migrate: migrate.o  extents.o $(DEPLIBS)
 	@echo "	LD $@"
 	@$(CC) $(ALL_LDFLAGS) -o ext4migrate migrate.o extents.o $(LIBS)
 
+ext4replay: replay.o
+	@echo "	LD $@"
+	@$(CC) $(ALL_LDFLAGS) -o ext4replay replay.o  -ltdb
+
 installdirs:
 	@echo "	MKINSTALLDIRS $(root_sbindir)"
 	@$(MKINSTALLDIRS) $(DESTDIR)$(root_sbindir)
@@ -64,3 +68,4 @@ distclean: clean
 #
 migrate.o: $(srcdir)/migrate.c
 extents.o: $(srcdir)/extents.c
+replay.o:  $(srcdir)/replay.c
diff --git a/ext4migrate/replay.c b/ext4migrate/replay.c
new file mode 100644
index 0000000..8476416
--- /dev/null
+++ b/ext4migrate/replay.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <tdb.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.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;
+	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);
+		location = *(long long int *)key.dptr;
+		printf("Replayed transaction of size %d at location %lld\n", data.dsize, location);
+		lseek(fd, location, SEEK_SET);
+		write(fd, data.dptr, data.dsize);
+	}
+	close(fd);
+	tdb_close(tdb);
+
+}
-- 
1.5.2.rc0.71.g4342-dirty

-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ