From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Copeland Subject: [RFC][PATCH 6/7] omfs: checksumming routines Date: Wed, 15 Mar 2006 22:01:45 -0500 Message-ID: <11424781052948-git-send-email-me@bobcopeland.com> References: <11424781043264-git-send-email-me@bobcopeland.com> Reply-To: Bob Copeland Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Cc: Bob Copeland Return-path: Received: from mail.deathmatch.net ([216.200.85.210]:35300 "EHLO mail.deathmatch.net") by vger.kernel.org with ESMTP id S1752168AbWCPDBr (ORCPT ); Wed, 15 Mar 2006 22:01:47 -0500 In-Reply-To: <11424781043264-git-send-email-me@bobcopeland.com> To: linux-fsdevel@vger.kernel.org Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org This patch adds routines to compute checksums that are stored in the headers of all filesystem entities in OMFS. --- fs/omfs/checksum.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) create mode 100644 fs/omfs/checksum.c e1a3b6f48ad0d0f0d69fcc35c890f92afaffb38f diff --git a/fs/omfs/checksum.c b/fs/omfs/checksum.c new file mode 100644 index 0000000..212e8b5 --- /dev/null +++ b/fs/omfs/checksum.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include "omfs.h" + +#define POLY 0x1021 + +/* + * crc-ccitt with MSB first (i.e., backwards), so we can't use the + * kernel table as-is. + */ +#ifdef OMFS_WRITE +static u16 omfs_crc(u16 crc, unsigned char *buf, int count) +{ + int i, j; + printk(KERN_DEBUG "omfs: in crc for count %x\n", count); + for (i=0; ii_head.h_body_size); + ofs = sizeof(struct omfs_header); + + printk(KERN_DEBUG "omfs: body size is %x\n", count); + + crc = omfs_crc(crc, ptr + ofs, count); + oi->i_head.h_crc = cpu_to_be16(crc); + + xor = ptr[0]; + for (i=1; ii_head.h_check_xor = xor; + + printk(KERN_DEBUG "Calculated checksum for %lx as %x\n", + ino, crc); +#endif + return ret; +} + + -- 1.2.1