diff --git a/sys/fs/fuse/fuse_internal.c b/sys/fs/fuse/fuse_internal.c index 5f39f8ced798..e87456ce1fc4 100644 --- a/sys/fs/fuse/fuse_internal.c +++ b/sys/fs/fuse/fuse_internal.c @@ -353,12 +353,8 @@ fuse_internal_readdir(struct vnode *vp, fri = fdi.indata; fri->fh = fufh->fh_id; fri->offset = uio_offset(uio); - /* - * XXX AWS Try removing the min(...,4096). I'm pretty sure - * there's no reason for it to be there. - */ - fri->size = min(uio_resid(uio), 4096); - /* mp->max_read */ + fri->size = MIN(uio->uio_resid, + fuse_get_mpdata(vp->v_mount)->max_read); if ((err = fdisp_wait_answ(&fdi))) { break; diff --git a/tests/sys/fs/fusefs/readdir.cc b/tests/sys/fs/fusefs/readdir.cc index 13387bf8d567..09d7034f23f3 100644 --- a/tests/sys/fs/fusefs/readdir.cc +++ b/tests/sys/fs/fusefs/readdir.cc @@ -187,6 +187,40 @@ TEST_F(Readdir, eio) /* Deliberately leak dir. RELEASEDIR will be tested separately */ } +/* getdirentries(2) can use a larger buffer size than readdir(3) */ +TEST_F(Readdir, getdirentries) +{ + const char FULLPATH[] = "mountpoint/some_dir"; + const char RELPATH[] = "some_dir"; + uint64_t ino = 42; + int fd; + char buf[8192]; + ssize_t r; + + expect_lookup(RELPATH, ino); + expect_opendir(ino); + + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_READDIR && + in->header.nodeid == ino && + in->body.readdir.size == 8192); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) { + out->header.error = 0; + out->header.len = sizeof(out->header); + }))); + + errno = 0; + fd = open(FULLPATH, O_DIRECTORY); + ASSERT_LE(0, fd) << strerror(errno); + r = getdirentries(fd, buf, sizeof(buf), 0); + ASSERT_EQ(0, r); + + /* Deliberately leak dir. RELEASEDIR will be tested separately */ +} + /* * FUSE_READDIR returns nothing, not even "." and "..". This is legal, though * the filesystem obviously won't be fully functional.