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

[Minios-devel] [UNIKRAFT PATCH 5/7] lib/9pfs: Add create, mkdir, rmdir, remove 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:55 +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=oevdDIwIdzv4oeNLTsC0/LVYlbV82hR8Z2gGlbKWaFM=; b=ThQMHbaGwbJqV6NUus8xi1jQnQlN88Koo4b6IgsxPINMTSUCANAxyMMfgOKBkqaMNioncvOW+Nb3l/slU10OIfUdR2+pIk0qByCdmceowHNOxQ1Bg94iDof+IrI2ngY2y7vOG6D0KVqrGadSSJBBVfKpmqV81fC0wWltdAosmTfBb+liIGquIbKQ5WX97tbj7IZ2DoE3tS8JlRpgeMuf9cHPpHi+MYEgYlCcr+8PFSEO19yisPnLz3zOKjWGPGHHcM2r9RbYBUstVZp3495Q4ynkWKy5hcByOPvsencE2xpxs7P5yHKUbBCh+3yfEs9W4lxSPpG5XOd4qzrVGeT9eg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTxfxIjn5LqrQUH1jZOs+GHBFBXKTemM69d9d3JPwt+R2BFFxVmFQeH1Znqa+Yx3jkGe8mVaiTCMg/T4Uw0ayhE0fXVu70bf4XisBKFqAyjzkOBiucxeGOk+gJSKOa5x2/l4orsNDGYuoyo6UJHo7LSQkyWG4C43uEVXdtn35XSDDPe4sxient3bbMbNq2C1pX/X5LZccDIZVC/NfU1ZUyaWbsRn+fWBIKGVrMYPYhOOcHdGdPubhgsYROaX1TMWQQW0LeTa3zfbSXgEiUKuflCxYutzKC3aNmPuHc+HXZmG9uh6k1XcgNSmGHJgX2CiN5s3RdQHYg1NNqoWb0YI9A==
  • 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:22 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Thread-index: AQHVZWMAIR+TBLPb+0+4giZeEbfOzg==
  • Thread-topic: [UNIKRAFT PATCH 5/7] lib/9pfs: Add create, mkdir, rmdir, remove vnops

From: Cristian Banu <cristb@xxxxxxxxx>

This patch adds file and directory creation and deletion VFS node
operations.

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

diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index 0fe3eb22..50f83148 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -62,6 +62,17 @@ static int uk_9pfs_posix_perm_from_mode(int mode)
        return res;
 }
 
+static uint32_t uk_9pfs_perm_from_posix_mode(mode_t mode)
+{
+       int res;
+
+       res = mode & 0777;
+       if (S_ISDIR(mode))
+               res |= UK_9P_DMDIR;
+
+       return res;
+}
+
 static int uk_9pfs_posix_mode_from_mode(int mode)
 {
        int res;
@@ -189,6 +200,69 @@ static int uk_9pfs_inactive(struct vnode *vp)
        return 0;
 }
 
+static int uk_9pfs_create_generic(struct vnode *dvp, char *name, mode_t mode)
+{
+       struct uk_9pdev *dev = UK_9PFS_MD(dvp->v_mount)->dev;
+       struct uk_9pfid *fid;
+       int rc;
+
+       if (strlen(name) > NAME_MAX)
+               return ENAMETOOLONG;
+
+       /* Clone parent fid. */
+       fid = uk_9p_walk(dev, UK_9PFS_VFID(dvp), NULL);
+
+       rc = uk_9p_create(dev, fid, name, uk_9pfs_perm_from_posix_mode(mode),
+                       UK_9P_OTRUNC | UK_9P_OWRITE, NULL);
+
+       uk_9pfid_put(fid);
+       return -rc;
+}
+
+static int uk_9pfs_create(struct vnode *dvp, char *name, mode_t mode)
+{
+       if (!S_ISREG(mode))
+               return EINVAL;
+
+       return uk_9pfs_create_generic(dvp, name, mode);
+}
+
+static int uk_9pfs_remove_generic(struct vnode *dvp, struct vnode *vp)
+{
+       struct uk_9pdev *dev = UK_9PFS_MD(dvp->v_mount)->dev;
+       struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
+       int rc = 0;
+
+       if (!nd->removed && !nd->nb_open_files)
+               rc = uk_9p_remove(dev, nd->fid);
+       else
+               nd->removed = true;
+
+       uk_9pfs_free_vnode_data(vp);
+
+       return -rc;
+}
+
+static int uk_9pfs_remove(struct vnode *dvp, struct vnode *vp,
+               char *name __unused)
+{
+       return uk_9pfs_remove_generic(dvp, vp);
+}
+
+static int uk_9pfs_mkdir(struct vnode *dvp, char *name, mode_t mode)
+{
+       if (!S_ISDIR(mode))
+               return EINVAL;
+
+       return uk_9pfs_create_generic(dvp, name, mode);
+}
+
+static int uk_9pfs_rmdir(struct vnode *dvp, struct vnode *vp,
+               char *name __unused)
+{
+       return uk_9pfs_remove_generic(dvp, vp);
+}
+
 static int uk_9pfs_readdir(struct vnode *vp, struct vfscore_file *fp,
                struct dirent *dir)
 {
@@ -206,11 +280,7 @@ static int uk_9pfs_readdir(struct vnode *vp, struct 
vfscore_file *fp,
 #define uk_9pfs_readlink       ((vnop_readlink_t)vfscore_vop_einval)
 #define uk_9pfs_symlink                ((vnop_symlink_t)vfscore_vop_eperm)
 #define uk_9pfs_fallocate      ((vnop_fallocate_t)vfscore_vop_nullop)
-#define uk_9pfs_create         ((vnop_create_t)vfscore_vop_einval)
-#define uk_9pfs_remove         ((vnop_remove_t)vfscore_vop_einval)
 #define uk_9pfs_rename         ((vnop_rename_t)vfscore_vop_einval)
-#define uk_9pfs_mkdir          ((vnop_mkdir_t)vfscore_vop_einval)
-#define uk_9pfs_rmdir          ((vnop_rmdir_t)vfscore_vop_einval)
 #define uk_9pfs_open           ((vnop_open_t)vfscore_vop_einval)
 #define uk_9pfs_close          ((vnop_close_t)vfscore_vop_einval)
 #define uk_9pfs_read           ((vnop_read_t)vfscore_vop_einval)
-- 
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®.