FUSEFS: during FUSE_READDIR, set the read size correctly.
The old formula was unnecessarily restrictive. Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
3ba6a4d473
commit
4a4282cb06
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=345565
@ -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;
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user