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

[Minios-devel] [UNIKRAFT PATCH] lib/9pfs: Add getattr filesystem operation



Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 lib/9pfs/9pfs_vnops.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index 53d00b8e..87fde712 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -549,10 +549,39 @@ out:
        return -rc;
 }
 
+static int uk_9pfs_getattr(struct vnode *vp, struct vattr *attr)
+{
+       struct uk_9pdev *dev = UK_9PFS_MD(vp->v_mount)->dev;
+       struct uk_9pfid *fid = UK_9PFS_VFID(vp);
+       struct uk_9p_stat stat;
+       struct uk_9preq *stat_req;
+       int rc;
+
+       stat_req = uk_9p_stat(dev, fid, &stat);
+       if (PTRISERR(stat_req)) {
+               rc = PTR2ERR(stat_req);
+               goto out;
+       }
+
+       /* No stat string fields are used below. */
+       uk_9pdev_req_remove(dev, stat_req);
+
+       attr->va_type = uk_9pfs_vtype_from_mode(stat.mode);
+       attr->va_mode = uk_9pfs_posix_mode_from_mode(stat.mode);
+       attr->va_nodeid = vp->v_ino;
+       attr->va_size = stat.length;
+
+       memcpy(&(attr->va_atime), &(stat.atime), sizeof(struct timespec));
+       memcpy(&(attr->va_mtime), &(stat.mtime), sizeof(struct timespec));
+       memset(&(attr->va_ctime), 0, sizeof(struct timespec));
+
+out:
+       return -rc;
+}
+
 #define uk_9pfs_seek           ((vnop_seek_t)vfscore_vop_nullop)
 #define uk_9pfs_ioctl          ((vnop_ioctl_t)vfscore_vop_einval)
 #define uk_9pfs_fsync          ((vnop_fsync_t)vfscore_vop_nullop)
-#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_link           ((vnop_link_t)vfscore_vop_eperm)
-- 
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®.