Skip to content

Commit

Permalink
virtio-fs: use FUSE_OPENDIR and FUSE_RELEASEDIR
Browse files Browse the repository at this point in the history
When the file being open()ed or close()d is a directory, use
FUSE_OPENDIR and FUSE_RELEASEDIR instead of FUSE_OPEN and FUSE_RELEASE
respectively.

Signed-off-by: Fotis Xenakis <[email protected]>
Message-Id: <AM0PR03MB62929C121686C738E09F2D94A67A0@AM0PR03MB6292.eurprd03.prod.outlook.com>
  • Loading branch information
foxeng authored and wkozaczuk committed Jul 22, 2020
1 parent afe903f commit f9ae1e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/virtiofs/virtiofs_vnops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ static int virtiofs_open(struct file* fp)

auto* m_data = static_cast<virtiofs_mount_data*>(vnode->v_mount->m_data);
auto* drv = m_data->drv;
auto error = fuse_req_send_and_receive_reply(drv, FUSE_OPEN,
auto operation = S_ISDIR(inode->attr.mode) ? FUSE_OPENDIR : FUSE_OPEN;
auto error = fuse_req_send_and_receive_reply(drv, operation,
inode->nodeid, in_args.get(), sizeof(*in_args), out_args.get(),
sizeof(*out_args)).second;
if (error) {
Expand Down Expand Up @@ -148,7 +149,8 @@ static int virtiofs_close(struct vnode* vnode, struct file* fp)

auto* m_data = static_cast<virtiofs_mount_data*>(vnode->v_mount->m_data);
auto* drv = m_data->drv;
auto error = fuse_req_send_and_receive_reply(drv, FUSE_RELEASE,
auto operation = S_ISDIR(inode->attr.mode) ? FUSE_RELEASEDIR : FUSE_RELEASE;
auto error = fuse_req_send_and_receive_reply(drv, operation,
inode->nodeid, in_args.get(), sizeof(*in_args), nullptr, 0).second;
if (error) {
kprintf("[virtiofs] inode %lld, close failed\n", inode->nodeid);
Expand Down

0 comments on commit f9ae1e5

Please sign in to comment.