From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: john.jolly@gmail.com, Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 3/4] tests: create crcsum progam to support resizing tests
Date: Sun, 31 Mar 2013 20:44:02 -0400 [thread overview]
Message-ID: <1364777043-20610-4-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1364777043-20610-1-git-send-email-tytso@mit.edu>
The only checksum program which we can reliably count upon being
installed on all systems is "sum", which is not a particular robust
checksum. The problem with using md5sum or sha1sum is it hat it may
not be installed on all systems. So create a crcsum program which is
used so we can validate that a data file on a resized file system has
not been corrupted.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
tests/progs/Makefile.in | 6 ++++-
tests/progs/crcsum.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/test_config | 1 +
3 files changed, 76 insertions(+), 1 deletion(-)
create mode 100644 tests/progs/crcsum.c
diff --git a/tests/progs/Makefile.in b/tests/progs/Makefile.in
index 0e28192..e3c1ef4 100644
--- a/tests/progs/Makefile.in
+++ b/tests/progs/Makefile.in
@@ -13,7 +13,7 @@ INSTALL = @INSTALL@
MK_CMDS= _SS_DIR_OVERRIDE=../../lib/ss ../../lib/ss/mk_cmds
-PROGS= test_icount
+PROGS= test_icount crcsum
TEST_REL_OBJS= test_rel.o test_rel_cmds.o
@@ -34,6 +34,10 @@ test_rel: $(TEST_REL_OBJS) $(DEPLIBS)
$(E) " LD $@"
$(Q) $(LD) $(ALL_LDFLAGS) -o test_rel $(TEST_REL_OBJS) $(LIBS)
+crcsum: crcsum.o $(DEPLIBS)
+ $(E) " LD $@"
+ $(Q) $(LD) $(ALL_LDFLAGS) -o crcsum crcsum.o $(LIBS)
+
test_rel_cmds.c: test_rel_cmds.ct
$(E) " MK_CMDS $@"
$(Q) $(MK_CMDS) $(srcdir)/test_rel_cmds.ct
diff --git a/tests/progs/crcsum.c b/tests/progs/crcsum.c
new file mode 100644
index 0000000..bee979b
--- /dev/null
+++ b/tests/progs/crcsum.c
@@ -0,0 +1,70 @@
+/*
+ * crcsum.c
+ *
+ * Copyright (C) 2013 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+#include <fcntl.h>
+
+#include "et/com_err.h"
+#include "ss/ss.h"
+#include "ext2fs/ext2fs.h"
+
+
+int main(int argc, char **argv)
+{
+ int c;
+ uint32_t crc = ~0;
+ uint32_t (*csum_func)(uint32_t crc, unsigned char const *p,
+ size_t len);
+ FILE *f;
+
+ csum_func = ext2fs_crc32c_le;
+
+ while ((c = getopt (argc, argv, "B")) != EOF) {
+ switch (c) {
+ case 'B':
+ csum_func = ext2fs_crc32c_be;
+ break;
+ default:
+ com_err(argv[0], 0, "Usage: crcsum [-b] [file]\n");
+ return 1;
+ }
+ }
+
+ if (optind == argc)
+ f = stdin;
+ else {
+ f = fopen(argv[optind], "r");
+ if (!f) {
+ com_err(argv[0], errno, "while trying to open %s\n",
+ argv[optind]);
+ exit(1);
+ }
+ }
+
+ while (!feof(f)) {
+ unsigned char buf[4096];
+
+ int c = fread(buf, 1, sizeof(buf), f);
+
+ if (c)
+ crc = csum_func(crc, buf, c);
+ }
+ printf("%u\n", crc);
+ return 0;
+}
diff --git a/tests/test_config b/tests/test_config
index 0ba8b5e..36b53b7 100644
--- a/tests/test_config
+++ b/tests/test_config
@@ -19,6 +19,7 @@ RESIZE2FS="$USE_VALGRIND $RESIZE2FS_EXE"
E2UNDO_EXE="../misc/e2undo"
TEST_REL=../tests/progs/test_rel
TEST_ICOUNT=../tests/progs/test_icount
+CRCSUM=../tests/progs/crcsum
LD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss
DYLD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss
export LD_LIBRARY_PATH
--
1.7.12.rc0.22.gcdd159b
next prev parent reply other threads:[~2013-04-01 0:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-28 3:44 Failure of resize2fs past 4TB John Jolly
2013-03-28 3:57 ` Eric Sandeen
2013-03-28 11:55 ` Theodore Ts'o
2013-04-01 0:43 ` [PATCH 0/4] e2fsprogs: fix off-line resizing of small ext4 file systems Theodore Ts'o
2013-04-01 0:44 ` [PATCH 1/4] resize2fs: fix off-line resize of file systems with flex_bg && !resize_inode Theodore Ts'o
2013-04-01 0:44 ` [PATCH 2/4] mke2fs: don't display bigalloc/quota fs feature warnings in quiet mode Theodore Ts'o
2013-04-01 0:44 ` Theodore Ts'o [this message]
2013-04-01 0:44 ` [PATCH 4/4] tests: add more tests for off-line resizing Theodore Ts'o
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=1364777043-20610-4-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=john.jolly@gmail.com \
--cc=linux-ext4@vger.kernel.org \
/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).