From 451cbaa1c328082832a8fbcc427cd4416c602c5a Mon Sep 17 00:00:00 2001 From: OGAWA Hirofumi Date: Sun, 30 Oct 2005 15:03:49 -0800 Subject: [PATCH] fat: cleanup and optimization of checksum Signed-off-by: OGAWA Hirofumi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fat/dir.c | 10 ++-------- fs/vfat/namei.c | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'fs') diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 895049b2ac9..204d8614406 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -263,7 +263,6 @@ parse_record: unsigned char id; unsigned char slot; unsigned char slots; - unsigned char sum; unsigned char alias_checksum; if (!unicode) { @@ -317,9 +316,7 @@ parse_long: goto parse_long; if (IS_FREE(de->name) || (de->attr & ATTR_VOLUME)) continue; - for (sum = 0, i = 0; i < 11; i++) - sum = (((sum&1)<<7)|((sum&0xfe)>>1)) + de->name[i]; - if (sum != alias_checksum) + if (fat_checksum(de->name) != alias_checksum) nr_slots = 0; } @@ -479,7 +476,6 @@ GetNew: unsigned char id; unsigned char slot; unsigned char slots; - unsigned char sum; unsigned char alias_checksum; if (!unicode) { @@ -534,9 +530,7 @@ ParseLong: goto ParseLong; if (IS_FREE(de->name) || (de->attr & ATTR_VOLUME)) goto RecEnd; - for (sum = 0, i = 0; i < 11; i++) - sum = (((sum&1)<<7)|((sum&0xfe)>>1)) + de->name[i]; - if (sum != alias_checksum) + if (fat_checksum(de->name) != alias_checksum) long_slots = 0; } diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index 1c6f6b57ef1..467346b123d 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c @@ -621,8 +621,7 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name, } /* build the entry of long file name */ - for (cksum = i = 0; i < 11; i++) - cksum = (((cksum&1)<<7)|((cksum&0xfe)>>1)) + msdos_name[i]; + cksum = fat_checksum(msdos_name); *nr_slots = usize / 13; for (ps = slots, i = *nr_slots; i > 0; i--, ps++) { -- cgit v1.2.3