[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 4/7] lib/9pfs: Add lookup and inactive vnops


  • To: "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
  • Date: Sat, 7 Sep 2019 09:59:54 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=stud.acs.upb.ro; dmarc=pass action=none header.from=stud.acs.upb.ro; dkim=pass header.d=stud.acs.upb.ro; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4ekTANXKfuW//NsyhB3dggcU0UTze37/01O+tcANgvA=; b=AeY3zX5L+mK003CVUebCtgKfOZmfmSSGuvtTmh+rxP4M/d8DlO1rHqZsgVkQP6mID0aWem3Uziqq6GqibMrj9dyi6gATHBKGCylqKhBbafgeFVe116ktqE3UX4aW6CSdcBvKhkdmfBCoavp/hoeW7k0Ty0SdUkZwQW7yTk/BpHua1iotiDWoiQQaprlcAVAkDuN5ZNziyyP7FDOJlDFvDxHQ8SrvUboSDdSpmy4ijapOSEF07HnvlxCmQ3MSjfXzx8liR+kWtsWDVbNHhdbCxASR39Qj/I8iJqEylSeA2kxUI0oc7HdXHNBtYiWaOPIE6G4fkb8BBM5bmElLcZCU5w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CJSLavr8KpeziyhXNSKJPRQxa4w+OF7ml/nvxlIf6MAwhjynfXpmWGev+EASy/g1zMTkm7fVZfmH5HXjGUruz1/efGhsCYByShbLA/SbnB5pyrpR5RccoXUly+V0chN85QedoogYxLmfAMfvVKhCR68A5y5/RNsPsa3fVnzQCC7Dq5fQ140sC352ScqStdctUBzQKk63Gj+yjQGWbtFoV/n9mJEpiVHVTQhO4bSGRU5gGHPZdxXy72mpc3sfQ/lgiWRWZf9O+qnnFeUXDuiBWEkPIkzhGVdA4YabEZpFq4gL0hDSBCvTPo71gkFfC7+elyPmYeEIIJiVWMQqeAjWRg==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=vlad_andrei.badoiu@xxxxxxxxxxxxxxx;
  • Cc: "costin.lupu@xxxxxxxxx" <costin.lupu@xxxxxxxxx>, Cristian Banu <cristb@xxxxxxxxx>
  • Delivery-date: Sat, 07 Sep 2019 10:00:17 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Thread-index: AQHVZWL/W4REVppzT06jPWsZo3lQWw==
  • Thread-topic: [UNIKRAFT PATCH 4/7] lib/9pfs: Add lookup and inactive vnops

From: Cristian Banu <cristb@xxxxxxxxx>

This patch adds the lookup and inactive vnops.

Signed-off-by: Cristian Banu <cristb@xxxxxxxxx>
---
 lib/9pfs/9pfs_vnops.c | 112 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 110 insertions(+), 2 deletions(-)

diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index 809fac43..0fe3eb22 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -47,6 +47,47 @@
 
 #include "9pfs.h"
 
+static int uk_9pfs_posix_perm_from_mode(int mode)
+{
+       int res;
+
+       res = mode & 0777;
+       if (mode & UK_9P_DMSETUID)
+               res |= S_ISUID;
+       if (mode & UK_9P_DMSETGID)
+               res |= S_ISGID;
+       if (mode & UK_9P_DMSETVTX)
+               res |= S_ISVTX;
+
+       return res;
+}
+
+static int uk_9pfs_posix_mode_from_mode(int mode)
+{
+       int res;
+
+       res = uk_9pfs_posix_perm_from_mode(mode);
+
+       if (mode & UK_9P_DMDIR)
+               res |= S_IFDIR;
+       else
+               res |= S_IFREG;
+
+       return res;
+}
+
+static int uk_9pfs_vtype_from_mode(int mode)
+{
+       if (mode & UK_9P_DMDIR)
+               return VDIR;
+       return VREG;
+}
+
+static uint64_t uk_9pfs_ino(struct uk_9p_stat *stat)
+{
+       return stat->qid.path;
+}
+
 int uk_9pfs_allocate_vnode_data(struct vnode *vp, struct uk_9pfid *fid)
 {
        struct uk_9pfs_node_data *nd;
@@ -79,6 +120,75 @@ void uk_9pfs_free_vnode_data(struct vnode *vp)
        vp->v_data = NULL;
 }
 
+static int uk_9pfs_lookup(struct vnode *dvp, char *name, struct vnode **vpp)
+{
+       struct uk_9pdev *dev = UK_9PFS_MD(dvp->v_mount)->dev;
+       struct uk_9pfid *dfid = UK_9PFS_VFID(dvp);
+       struct uk_9pfid *fid;
+       struct uk_9p_stat stat;
+       struct uk_9preq *stat_req;
+       struct vnode *vp;
+       int rc;
+
+       if (strlen(name) > NAME_MAX)
+               return ENAMETOOLONG;
+
+       fid = uk_9p_walk(dev, dfid, name);
+       if (PTRISERR(fid)) {
+               rc = PTR2ERR(fid);
+               goto out;
+       }
+
+       stat_req = uk_9p_stat(dev, fid, &stat);
+       if (PTRISERR(stat_req)) {
+               rc = PTR2ERR(stat_req);
+               goto out_fid;
+       }
+
+       /* No stat string fields are used below. */
+       uk_9pdev_req_remove(dev, stat_req);
+
+       if (vfscore_vget(dvp->v_mount, uk_9pfs_ino(&stat), &vp)) {
+               /* Already in cache. */
+               rc = 0;
+               *vpp = vp;
+               /* if the vnode already has node data, it may be reused. */
+               if (vp->v_data)
+                       goto out_fid;
+       }
+
+       if (!vp) {
+               rc = -ENOMEM;
+               goto out_fid;
+       }
+
+       vp->v_flags = 0;
+       vp->v_mode = uk_9pfs_posix_mode_from_mode(stat.mode);
+       vp->v_type = uk_9pfs_vtype_from_mode(stat.mode);
+       vp->v_size = stat.length;
+
+       rc = uk_9pfs_allocate_vnode_data(vp, fid);
+       if (rc != 0)
+               goto out_fid;
+
+       *vpp = vp;
+
+       return 0;
+
+out_fid:
+       uk_9pfid_put(fid);
+out:
+       return -rc;
+}
+
+static int uk_9pfs_inactive(struct vnode *vp)
+{
+       if (vp->v_data)
+               uk_9pfs_free_vnode_data(vp);
+
+       return 0;
+}
+
 static int uk_9pfs_readdir(struct vnode *vp, struct vfscore_file *fp,
                struct dirent *dir)
 {
@@ -91,7 +201,6 @@ static int uk_9pfs_readdir(struct vnode *vp, struct 
vfscore_file *fp,
 #define uk_9pfs_getattr                ((vnop_getattr_t)vfscore_vop_nullop)
 #define uk_9pfs_setattr                ((vnop_setattr_t)vfscore_vop_nullop)
 #define uk_9pfs_truncate       ((vnop_truncate_t)vfscore_vop_nullop)
-#define uk_9pfs_inactive       ((vnop_inactive_t)vfscore_vop_nullop)
 #define uk_9pfs_link           ((vnop_link_t)vfscore_vop_eperm)
 #define uk_9pfs_cache          ((vnop_cache_t)NULL)
 #define uk_9pfs_readlink       ((vnop_readlink_t)vfscore_vop_einval)
@@ -106,7 +215,6 @@ static int uk_9pfs_readdir(struct vnode *vp, struct 
vfscore_file *fp,
 #define uk_9pfs_close          ((vnop_close_t)vfscore_vop_einval)
 #define uk_9pfs_read           ((vnop_read_t)vfscore_vop_einval)
 #define uk_9pfs_write          ((vnop_write_t)vfscore_vop_einval)
-#define uk_9pfs_lookup         ((vnop_lookup_t)vfscore_vop_einval)
 
 struct vnops uk_9pfs_vnops = {
        .vop_open       = uk_9pfs_open,
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.