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]>
---
 fs/virtiofs/virtiofs_vnops.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/virtiofs/virtiofs_vnops.cc b/fs/virtiofs/virtiofs_vnops.cc
index 1e3cf99e..4bea964e 100644
--- a/fs/virtiofs/virtiofs_vnops.cc
+++ b/fs/virtiofs/virtiofs_vnops.cc
@@ -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) {
@@ -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);
-- 
2.27.0

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/AM0PR03MB62929C121686C738E09F2D94A67A0%40AM0PR03MB6292.eurprd03.prod.outlook.com.

Reply via email to