aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJan Blunck <j.blunck@tu-harburg.de>2004-08-22 22:54:59 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-08-22 22:54:59 -0700
commit44d81093cd415933bdeda20d1424cef0e2bacead (patch)
tree541e0740fb6715a94a7b870011490841b7b159eb /fs
parent9573365038df362ee0f0de5d1c660be920746e7d (diff)
downloadhistory-44d81093cd415933bdeda20d1424cef0e2bacead.tar.gz
[PATCH] ext2_readdir() filp->f_pos fix
If the whole directory is read, ext2_readdir() sets the f_pos to a multiple of the page size (because of the conditions of the outer for loop). This sets the wrong f_pos for directory inodes on ext2 partitions with a block size differing from the page size. Signed-off-by: Jan Blunck <j.blunck@tu-harburg.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext2/dir.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 6af27658b60c76..bf30cbf571ead1 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -251,7 +251,7 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
loff_t pos = filp->f_pos;
struct inode *inode = filp->f_dentry->d_inode;
struct super_block *sb = inode->i_sb;
- unsigned offset = pos & ~PAGE_CACHE_MASK;
+ unsigned int offset = pos & ~PAGE_CACHE_MASK;
unsigned long n = pos >> PAGE_CACHE_SHIFT;
unsigned long npages = dir_pages(inode);
unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
@@ -270,8 +270,13 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
ext2_dirent *de;
struct page *page = ext2_get_page(inode, n);
- if (IS_ERR(page))
+ if (IS_ERR(page)) {
+ ext2_error(sb, __FUNCTION__,
+ "bad page in #%lu",
+ inode->i_ino);
+ filp->f_pos += PAGE_CACHE_SIZE - offset;
continue;
+ }
kaddr = page_address(page);
if (need_revalidate) {
offset = ext2_validate_entry(kaddr, offset, chunk_mask);
@@ -303,6 +308,7 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
goto success;
}
}
+ filp->f_pos += le16_to_cpu(de->rec_len);
}
ext2_put_page(page);
}
@@ -310,7 +316,6 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
success:
ret = 0;
done:
- filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
filp->f_version = inode->i_version;
return ret;
}