Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 11921
b: refs/heads/master
c: 451cbaa
h: refs/heads/master
i:
  11919: ad7bdc4
v: v3
  • Loading branch information
OGAWA Hirofumi authored and Linus Torvalds committed Oct 31, 2005
1 parent ad7c3bf commit 6451cbd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4e57b6817880946a3a78d5d8cad1ace363f7e449
refs/heads/master: 451cbaa1c328082832a8fbcc427cd4416c602c5a
10 changes: 2 additions & 8 deletions trunk/fs/fat/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ int fat_search_long(struct inode *inode, const unsigned char *name,
unsigned char id;
unsigned char slot;
unsigned char slots;
unsigned char sum;
unsigned char alias_checksum;

if (!unicode) {
Expand Down Expand Up @@ -317,9 +316,7 @@ int fat_search_long(struct inode *inode, const unsigned char *name,
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;
}

Expand Down Expand Up @@ -479,7 +476,6 @@ static int fat_readdirx(struct inode *inode, struct file *filp, void *dirent,
unsigned char id;
unsigned char slot;
unsigned char slots;
unsigned char sum;
unsigned char alias_checksum;

if (!unicode) {
Expand Down Expand Up @@ -534,9 +530,7 @@ static int fat_readdirx(struct inode *inode, struct file *filp, void *dirent,
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;
}

Expand Down
3 changes: 1 addition & 2 deletions trunk/fs/vfat/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
11 changes: 11 additions & 0 deletions trunk/include/linux/msdos_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6451cbd

Please sign in to comment.