commit 61511c50148c3a5f4753fec7c0684a4a20e18da1
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Sat May 19 13:10:00 2007 -0400

    correct readdir implementation: keep calling filldir until it overflows

diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index 3ecdd1b..43b76b9 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -25,6 +25,7 @@ static int unionfs_readdir(struct file *file, void *dirent, 
filldir_t filldir)
        struct inode *inode = NULL;
        struct odf_dentry_info *odi = NULL;
        loff_t size;
+       int overflow = 0;
        /* dirent */
        u64 ino;
        char *name = NULL;
@@ -83,29 +84,22 @@ static int unionfs_readdir(struct file *file, void *dirent, 
filldir_t filldir)
 
        odf_file->f_pos = file->f_pos;
 
-       /* read the next dirent */
-       err = odf_read_dirent(odf_file, &name, &namelen, &ino, &d_type);
-       if (err)
-               goto out;
+       size = odi->dentry->d_inode->i_size;
+       while (odf_file->f_pos < size && !overflow) {
+               /* read the next dirent */
+               err = odf_read_dirent(odf_file, &name, &namelen, &ino, &d_type);
+               if (err)
+                       goto out;
 
-       /* filldir */
-       err = filldir(dirent, name, namelen, odf_file->f_pos, ino, d_type);
-       /* nfs_filldir buffer might be full and returned EINVAL, we must return
-        * no error so nfs_readdir continues readding the dir
-        */
-       if (err == -EINVAL) {
-               err = 0;
-               goto out;
+               /* filldir */
+               overflow = 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
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to