[PATCH] ext2_readdir() filp->f_pos fix

From: Jan Blunck
Date: Thu Jul 29 2004 - 14:25:14 EST


If the whole inode 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@xxxxxxxxxxxxx>

dir.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

Index: testing-2.5/fs/ext2/dir.c
===================================================================
--- testing-2.5.orig/fs/ext2/dir.c 2004-07-27 19:24:00.000000000 +0200
+++ testing-2.5/fs/ext2/dir.c 2004-07-29 20:32:10.141354816 +0200
@@ -251,7 +251,7 @@
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);
@@ -303,6 +303,7 @@
goto success;
}
}
+ filp->f_pos += le16_to_cpu(de->rec_len);
}
ext2_put_page(page);
}
@@ -310,7 +311,6 @@
success:
ret = 0;
done:
- filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
filp->f_version = inode->i_version;
return ret;
}