Messages in this thread Patch in this message | | | Subject | Re: [OFFTOPIC] f_pos ? [PATCH 2.6.7-mm6] ext2_readdir commenting | From | FabF <> | Date | Tue, 06 Jul 2004 22:38:51 +0200 |
| |
On Tue, 2004-07-06 at 21:58, Maneesh Soni wrote: > On Sun, Jul 04, 2004 at 07:31:29PM +0000, FabF wrote: > > Hi, > > > > I try to understand how readdir process works and I can't understand > > f_pos management : > > > > Having in mind things work that way : > > > > user : ls > > glibc : > > open (->sys_open) > > getdentries64 (->sys_getdentries64) > > > > kernel: > > sys_getdentries64 > > ->vfs_readdir > > ->ext2_readdir > > > > At that point, I don't understand why ext2_readdir is playing with > > filp->f_pos .... It should be 0 ...Why does it care about offset ? > > > > I think it may not be 0 all the time. A seekdir() could change could change > the offset to non-zero. Thanks Maneesh :) Anton brightly explained me readdir : it can be called more than once (buffering ...) so the reason for that offset.Action taking place in filldir return.'over' in ext2 readdir could bring confusion though....It's 'over' for kernel duty but the whole path is not necessarily explored yet.
I think the trivial comment patch attached (against 2.6.7-mm6) could be interesting for that issue.
Regards, FabF
> > Thanks > Maneesh ext2_readdir commenting
Signed off by FabF ---
diff -puN fs/ext2/dir.c~ext2readdir_comment fs/ext2/dir.c --- linux-2.6.7/fs/ext2/dir.c~ext2readdir_comment 2004-07-06 22:20:14.514980596 +0200 +++ linux-2.6.7-heatwave/fs/ext2/dir.c 2004-07-06 22:31:52.822458517 +0200 @@ -245,6 +245,12 @@ static inline void ext2_set_de_type(ext2 de->file_type = 0; } +/* + * ext2_readdir() + * + * copy directory entries to userland from its current offset (filp->f_pos) + * up to the end or when buffer is full (over=-EFAULT | -EINVAL) + */ static int ext2_readdir (struct file * filp, void * dirent, filldir_t filldir) { _ | |