===================================================================
@@ -74,7 +74,7 @@
struct p9_fid *fid;
int buflen;
char *statbuf;
- int n, i = 0;
+ int n, i, reclen;
P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", filp->COMPAT_f_dentry->d_name.name);
fid = filp->private_data;
@@ -85,12 +85,20 @@
return -ENOMEM;
while (1) {
- err = v9fs_file_readn(filp, statbuf, NULL, buflen,
- fid->rdir_fpos);
- if (err <= 0)
- break;
-
- n = err;
+ if (fid->rdir_fpos > filp->f_pos) {
+ n = fid->rdir_fpos - filp->f_pos;
+ memcpy(statbuf, fid->aux, n);
+ kfree(fid->aux);
+ fid->aux = NULL;
+ } else {
+ err = v9fs_file_readn(filp, statbuf, NULL, buflen,
+ fid->rdir_fpos);
+ if (err <= 0)
+ break;
+ n = err;
+ fid->rdir_fpos += n;
+ }
+ i = 0;
while (i < n) {
err = p9stat_read(statbuf + i, buflen-i, &st,
fid->clnt->dotu);
@@ -100,21 +108,25 @@
p9stat_free(&st);
goto free_and_exit;
}
+ reclen = st.size+2;
- i += st.size+2;
- fid->rdir_fpos += st.size+2;
-
over = filldir(dirent, st.name, strlen(st.name),
filp->f_pos, v9fs_qid2ino(&st.qid), dt_type(&st));
- filp->f_pos += st.size+2;
-
p9stat_free(&st);
if (over) {
+ fid->aux = kmalloc(n - i, GFP_KERNEL);
+ if (!fid->aux) {
+ err = -ENOMEM;
+ goto free_and_exit;
+ }
+ memcpy(fid->aux, statbuf + i, n - i);
err = 0;
goto free_and_exit;
}
+ filp->f_pos += reclen;
+ i += reclen;
}
}
===================================================================
@@ -615,6 +615,8 @@
spin_lock_irqsave(&clnt->lock, flags);
list_del(&fid->flist);
spin_unlock_irqrestore(&clnt->lock, flags);
+ if (fid->aux)
+ kfree(fid->aux);
kfree(fid);
}