Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139479
b: refs/heads/master
c: 3d0518f
h: refs/heads/master
i:
  139477: ea0a19e
  139475: d07abae
  139471: 7fa730f
v: v3
  • Loading branch information
Wei Yongjun authored and Theodore Ts'o committed Feb 15, 2009
1 parent 84c356a commit c29dbd5
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 70 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: 8bad4597c2d71365adfa846ea1ca6cf99161a455
refs/heads/master: 3d0518f4758eca4339e75e5b9dbb7e06a5ce08b4
16 changes: 10 additions & 6 deletions trunk/fs/ext4/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ int ext4_check_dir_entry(const char *function, struct inode *dir,
unsigned int offset)
{
const char *error_msg = NULL;
const int rlen = ext4_rec_len_from_disk(de->rec_len);
const int rlen = ext4_rec_len_from_disk(de->rec_len,
dir->i_sb->s_blocksize);

if (rlen < EXT4_DIR_REC_LEN(1))
error_msg = "rec_len is smaller than minimal";
Expand Down Expand Up @@ -178,10 +179,11 @@ static int ext4_readdir(struct file *filp,
* least that it is non-zero. A
* failure will be detected in the
* dirent test below. */
if (ext4_rec_len_from_disk(de->rec_len)
< EXT4_DIR_REC_LEN(1))
if (ext4_rec_len_from_disk(de->rec_len,
sb->s_blocksize) < EXT4_DIR_REC_LEN(1))
break;
i += ext4_rec_len_from_disk(de->rec_len);
i += ext4_rec_len_from_disk(de->rec_len,
sb->s_blocksize);
}
offset = i;
filp->f_pos = (filp->f_pos & ~(sb->s_blocksize - 1))
Expand All @@ -203,7 +205,8 @@ static int ext4_readdir(struct file *filp,
ret = stored;
goto out;
}
offset += ext4_rec_len_from_disk(de->rec_len);
offset += ext4_rec_len_from_disk(de->rec_len,
sb->s_blocksize);
if (le32_to_cpu(de->inode)) {
/* We might block in the next section
* if the data destination is
Expand All @@ -225,7 +228,8 @@ static int ext4_readdir(struct file *filp,
goto revalidate;
stored++;
}
filp->f_pos += ext4_rec_len_from_disk(de->rec_len);
filp->f_pos += ext4_rec_len_from_disk(de->rec_len,
sb->s_blocksize);
}
offset = 0;
brelse(bh);
Expand Down
21 changes: 3 additions & 18 deletions trunk/fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,24 +855,6 @@ struct ext4_dir_entry_2 {
~EXT4_DIR_ROUND)
#define EXT4_MAX_REC_LEN ((1<<16)-1)

static inline unsigned ext4_rec_len_from_disk(__le16 dlen)
{
unsigned len = le16_to_cpu(dlen);

if (len == EXT4_MAX_REC_LEN || len == 0)
return 1 << 16;
return len;
}

static inline __le16 ext4_rec_len_to_disk(unsigned len)
{
if (len == (1 << 16))
return cpu_to_le16(EXT4_MAX_REC_LEN);
else if (len > (1 << 16))
BUG();
return cpu_to_le16(len);
}

/*
* Hash Tree Directory indexing
* (c) Daniel Phillips, 2001
Expand Down Expand Up @@ -1097,7 +1079,10 @@ extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);

/* migrate.c */
extern int ext4_ext_migrate(struct inode *);

/* namei.c */
extern unsigned int ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize);
extern __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize);
extern int ext4_orphan_add(handle_t *, struct inode *);
extern int ext4_orphan_del(handle_t *, struct inode *);
extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
Expand Down
Loading

0 comments on commit c29dbd5

Please sign in to comment.