From: Bob Copeland <me@bobcopeland.com>
To: Sergey Vlasov <vsu@altlinux.ru>,
Harvey Harrison <harvey.harrison@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 6/7] omfs: add checksumming routines
Date: Sat, 29 Mar 2008 23:30:06 -0400 [thread overview]
Message-ID: <20080330033006.GD18825@hash.localnet> (raw)
In-Reply-To: <20080327164114.6c9fc82c.vsu@altlinux.ru>
Version 2 of this patch, with changes:
- use lib/crc-itu-t.c instead of open-coded version
>From 6ce3bb9ce2faaf937df0ec8e64c39e1adc403b2e Mon Sep 17 00:00:00 2001
From: Bob Copeland <me@bobcopeland.com>
Date: Thu, 27 Mar 2008 17:23:12 -0400
Subject: [PATCH] omfs: add checksumming routines
OMFS checksums the metadata of all filesystem objects. This change adds
the necessary functions to do so.
Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
fs/omfs/checksum.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
create mode 100644 fs/omfs/checksum.c
diff --git a/fs/omfs/checksum.c b/fs/omfs/checksum.c
new file mode 100644
index 0000000..cbd0471
--- /dev/null
+++ b/fs/omfs/checksum.c
@@ -0,0 +1,31 @@
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
+#include <linux/crc-itu-t.h>
+#include "omfs.h"
+
+/*
+ * Update the header checksums for a dirty inode based on its contents.
+ * Caller is expected to hold the buffer head underlying oi and mark it
+ * dirty.
+ */
+int omfs_update_checksums(struct omfs_inode *oi)
+{
+ int ret = 0;
+ int xor, i, ofs = 0, count;
+ u16 crc = 0;
+ unsigned char *ptr = (unsigned char *) oi;
+
+ count = be32_to_cpu(oi->i_head.h_body_size);
+ ofs = sizeof(struct omfs_header);
+
+ crc = crc_itu_t(crc, ptr + ofs, count);
+ oi->i_head.h_crc = cpu_to_be16(crc);
+
+ xor = ptr[0];
+ for (i = 1; i < OMFS_XOR_COUNT; i++)
+ xor ^= ptr[i];
+
+ oi->i_head.h_check_xor = xor;
+
+ return ret;
+}
--
1.5.4.2.182.gb3092
--
Bob Copeland %% www.bobcopeland.com
next prev parent reply other threads:[~2008-03-30 3:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-27 0:45 [PATCH 6/7] omfs: add checksumming routines Bob Copeland
2008-03-27 1:22 ` Harvey Harrison
2008-03-27 12:24 ` Bob Copeland
2008-03-27 13:41 ` Sergey Vlasov
2008-03-27 14:34 ` Bob Copeland
2008-03-30 3:30 ` Bob Copeland [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-04-12 22:58 Bob Copeland
2008-04-13 8:09 ` Christoph Hellwig
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=20080330033006.GD18825@hash.localnet \
--to=me@bobcopeland.com \
--cc=harvey.harrison@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vsu@altlinux.ru \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.