gint bluesky_dirent_compare(gconstpointer a, gconstpointer b,
gpointer unused);
-#define MAX_READDIR_DIRENTS 4
+#define MAX_READDIR_DIRENTS 64
readdir3res *
nfsproc3_readdir_3_svc(readdir3args *argp, struct svc_req *rqstp)
{
readdirplus3res *
nfsproc3_readdirplus_3_svc(readdirplus3args *argp, struct svc_req *rqstp)
{
+ /* XDR-encoded sizes:
+ * post_op_attr: 88 bytes
+ * base readdirplus3resok: 88 + 16 bytes
+ * base directory entry: 24 bytes + filename
+ * attributes/fh3: 88 + 8 + filehandle size
+ */
+ size_t dircount = 88 + 16, attrcount = 0;
static readdirplus3res result;
BlueSkyInode *dir = lookup_fh(&argp->dir);
BlueSkyDirent *d = g_sequence_get(i);
BlueSkyInode *inode = bluesky_get_inode(fs, d->inum);
if (inode != NULL) {
+ dircount += 24 + ((strlen(d->name) + 3) & ~3);
+ attrcount += 88 + 8 + 8;
+ if (dircount > argp->dircount
+ || dircount + attrcount > argp->maxcount)
+ break;
dirents[count].fileid = d->inum;
dirents[count].name = d->name;
dirents[count].cookie = d->cookie;