summaryrefslogtreecommitdiffstats
path: root/include/linux/msdos_fs.h
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2005-10-30 15:03:49 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 17:37:32 -0800
commit451cbaa1c328082832a8fbcc427cd4416c602c5a (patch)
tree139c3d33d0cf3f9eba214c504e4173f54c6cf66d /include/linux/msdos_fs.h
parent4e57b6817880946a3a78d5d8cad1ace363f7e449 (diff)
[PATCH] fat: cleanup and optimization of checksum
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/msdos_fs.h')
-rw-r--r--include/linux/msdos_fs.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index 9a3d2725798..941da5c016a 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -282,6 +282,17 @@ static inline u8 fat_attr(struct inode *inode)
MSDOS_I(inode)->i_attrs;
}
+static inline unsigned char fat_checksum(const __u8 *name)
+{
+ unsigned char s = name[0];
+ s = (s<<7) + (s>>1) + name[1]; s = (s<<7) + (s>>1) + name[2];
+ s = (s<<7) + (s>>1) + name[3]; s = (s<<7) + (s>>1) + name[4];
+ s = (s<<7) + (s>>1) + name[5]; s = (s<<7) + (s>>1) + name[6];
+ s = (s<<7) + (s>>1) + name[7]; s = (s<<7) + (s>>1) + name[8];
+ s = (s<<7) + (s>>1) + name[9]; s = (s<<7) + (s>>1) + name[10];
+ return s;
+}
+
static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus)
{
return ((sector_t)clus - FAT_START_ENT) * sbi->sec_per_clus