commit 0265f87c308a466e0b54a09da741dc505c175a8b
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Thu May 10 20:05:59 2007 -0400

    readdir: set file pos to max possible value on EOF, so
    
    that its bigger than both the union dir file and the odf
    cached dirent file

diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index 15cc7f7..54057a8 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -78,8 +78,7 @@ static int unionfs_readdir(struct file *file, void *dirent, 
filldir_t filldir)
        }
 
        /* check EOF */
-       size = odi->dentry->d_inode->i_size;
-       if (file->f_pos >= size)
+       if (file->f_pos == DIREOF)
                goto out;
 
        odf_file->f_pos = file->f_pos;
@@ -91,12 +90,23 @@ static int unionfs_readdir(struct file *file, void *dirent, 
filldir_t filldir)
 
        /* filldir */
        err = filldir(dirent, name, namelen, odf_file->f_pos, ino, d_type);
+       if (err)
+               goto out;
 
        /* Copy the atime. */
        fsstack_copy_attr_atime(inode, odi->dentry->d_inode);
 
        /* save the file position */
        file->f_pos = odf_file->f_pos;
+       size = odi->dentry->d_inode->i_size;
+
+       /* If EOF is reached, we set the file pos to the max posible value
+        * since the file pos must be greater than the size of the file as
+        * viewed through the union and also odf cached file as not to
+        * confuse unionfs_/nfs_readdir when EOF is reached
+        */
+       if (file->f_pos >= size)
+               file->f_pos = DIREOF;
 
 out:
        kfree(name);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 2d4a156..9d17304 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -228,6 +228,7 @@ extern int add_filldir_node(struct unionfs_dir_state 
*rdstate, const char *name,
 extern struct filldir_node *find_filldir_node(struct unionfs_dir_state 
*rdstate,
                                              const char *name, int namelen);
 #define MAXRDCOOKIE (0xfff)
+#define DIREOF (0xffffff)
 
 #define unionfs_read_lock(sb)   down_read(&UNIONFS_SB(sb)->rwsem)
 #define unionfs_read_unlock(sb)         up_read(&UNIONFS_SB(sb)->rwsem)
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to