Whamcloud - gitweb
- revert the b=1934 fix from 1/16 to stop llmount from hanging
[fs/lustre-release.git] / lustre / lvfs / lvfs_linux.c
index b7fb933..61cd57c 100644 (file)
@@ -308,41 +308,47 @@ static int l_filldir(void *__buf, const char *name, int namlen, loff_t offset,
 {
         struct l_linux_dirent *dirent;
         struct l_readdir_callback *buf = (struct l_readdir_callback *)__buf;
+        int reclen = size_round(offsetof(struct l_linux_dirent, d_name) + namlen + 1);
         
-        dirent = buf->lrc_dirent;
+        buf->error = -EINVAL;
+        if (reclen > buf->count)
+                return -EINVAL;
+        dirent = buf->previous;
         if (dirent)
-               dirent->lld_off = offset; 
-
-        PORTAL_ALLOC(dirent, sizeof(*dirent));
-
-        list_add_tail(&dirent->lld_list, buf->lrc_list);
-
-        buf->lrc_dirent = dirent;
-        dirent->lld_ino = ino;
-        LASSERT(sizeof(dirent->lld_name) >= strlen(name) + 1);
-        memcpy(dirent->lld_name, name, strlen(name));
-
+               dirent->d_off = offset; 
+        dirent = buf->current_dir;
+        buf->previous = dirent;
+        dirent->d_ino = ino;
+        dirent->d_reclen = reclen;
+        memcpy(dirent->d_name, name, namlen);
+        ((char *)dirent) += reclen;
+        buf->current_dir = dirent;
+        buf->count -= reclen; 
         return 0;
 }
 
-long l_readdir(struct file *file, struct list_head *dentry_list)
+long l_readdir(struct file * file, void * dirent, unsigned int count)
 {
-        struct l_linux_dirent *lastdirent;
+        struct l_linux_dirent * lastdirent;
         struct l_readdir_callback buf;
         int error;
 
-        buf.lrc_dirent = NULL;
-        buf.lrc_list = dentry_list; 
+        buf.current_dir = (struct l_linux_dirent *)dirent;
+        buf.previous = NULL;
+        buf.count = count;
+        buf.error = 0;
 
         error = vfs_readdir(file, l_filldir, &buf);
         if (error < 0)
                 return error;
+        error = buf.error;
+        lastdirent = buf.previous;
 
-        lastdirent = buf.lrc_dirent;
-        if (lastdirent)
-                lastdirent->lld_off = file->f_pos;
-
-        return 0
+        if (lastdirent) {
+                lastdirent->d_off = file->f_pos;
+                error = count - buf.count;        
+        }
+        return error
 }
 EXPORT_SYMBOL(l_readdir);