Skip to contentSkip to conversation

f_pos ?

OFFTOPIC FabF 2 participants 4 messages Jul 4, 2004 – Jul 6, 2004 ext2 file system

lore
Share & tools
lore

FabF

author
#0 lore raw

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 ?

Thanks in advance for your precious help,
FabF

#1 lore raw
Quoted 17 lines · FabF

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
Quoted 3 lines

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

Signature · 6 lines
Maneesh Soni
Linux Technology Center, 
IBM Austin
email: [email protected]
Phone: 1-512-838-1896 Fax: 
T/L : 6781896
author
#2 lore raw

Re: [OFFTOPIC] f_pos ? [PATCH 2.6.7-mm6] ext2_readdir commenting

Quoted 18 lines · Maneesh Soni
Quoted 17 lines · FabF

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
Quoted 6 lines
Quoted 3 lines

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

Quoted 3 lines

Thanks
Maneesh

ext2_readdir commenting

Signed off by FabF
---

fs/ext2/dir.c renamed from fs/ext2/dir.c~ext2readdir_comment +6 -0
diff -puN fs/ext2/dir.c~ext2readdir_comment fs/ext2/dir.c
@@ -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)
 {

_

author
#3 lore raw
In reply to Maneesh Soni
Quoted 18 lines · Maneesh Soni
Quoted 17 lines · FabF

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
Quoted 7 lines
Quoted 3 lines

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.

btw, someone could tell why old ext2 readdir had "do the readahead" feature ; current ext3 as well but new ext2 implementation doesn't ???

Regards,
FabF

Quoted 2 lines

Thanks
Maneesh