[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH 4/7] lib/9pfs: Add lookup and inactive vnops
Reviewed-by: Costin Lupu <costin.lupu@xxxxxxxxx> On 9/7/19 12:59 PM, Vlad-Andrei BĂDOIU (78692) wrote: > 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, > _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |