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
--
| Linus Torvalds | Linux 2.6.27-rc8 |
| Trent Piepho | [PATCH] [POWERPC] Improve (in|out)_beXX() asm code |
| Satyam Sharma | Re: 2.6.23-rc4-mm1 "no CRC" MODPOST warnings |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
git: | |
| Bill Lear | Dangers of working on a tracking branch |
| Jeff King | Re: What's cooking in git/spearce.git (topics) |
| Jason Garber | git push [rejected] question |
| Maxim Gordienko | [GIT-P4] usage under Windows |
| Richard Stallman | Real men don't attack straw men |
| Leon Dippenaar | New tcp stack attack |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Brandon Lee | DELL PERC 5iR slow performance |
| Jeff Garzik | Re: [PATCH] drivers/net: remove network drivers' last few uses of IRQF_SAMPLE_RANDOM |
| Paul Moore | [PATCH v7 00/17] Labeled networking patches for 2.6.28 |
| Denys Vlasenko | Re: bnx2 dirver's firmware images |
| Herbert Xu | Re: csum offload and af_packet |
