From 68a1624d18bfd7dc0919fd7d5b44966716aad170 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@cloudius-systems.com>
Date: Wed, 14 Aug 2013 09:30:40 -0400
Subject: [PATCH] vfs: pass a file structure to vnop_open

---
 .../contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c    | 9 +++++----
 fs/devfs/devfs_vnops.c                                   | 5 +++--
 fs/vfs/vfs_syscalls.c                                    | 4 ++--
 include/osv/vnode.h                                      | 4 ++--
 4 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
index 02959bbdd..2dd31b205 100644
--- a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -159,22 +159,23 @@
  */
 
 static int
-zfs_open(vnode_t *vp, int flags)
+zfs_open(struct file *fp)
 {
+	struct vnode *vp = fp->f_vnode;
 	znode_t	*zp = VTOZ(vp);
 	zfsvfs_t *zfsvfs = zp->z_zfsvfs;
 
 	ZFS_ENTER(zfsvfs);
 	ZFS_VERIFY_ZP(zp);
 
-	if ((flags & FWRITE) && (zp->z_pflags & ZFS_APPENDONLY) &&
-	    ((flags & O_APPEND) == 0)) {
+	if ((fp->f_flags & FWRITE) && (zp->z_pflags & ZFS_APPENDONLY) &&
+	    ((fp->f_flags & O_APPEND) == 0)) {
 		ZFS_EXIT(zfsvfs);
 		return (EPERM);
 	}
 
 	/* Keep a count of the synchronous opens in the znode */
-	if (flags & O_DSYNC)
+	if (fp->f_flags & O_DSYNC)
 		atomic_inc_32(&zp->z_sync_cnt);
 
 	ZFS_EXIT(zfsvfs);
diff --git a/fs/devfs/devfs_vnops.c b/fs/devfs/devfs_vnops.c
index e772abde2..09761bb3e 100755
--- a/fs/devfs/devfs_vnops.c
+++ b/fs/devfs/devfs_vnops.c
@@ -50,8 +50,9 @@
 #include "devfs.h"
 
 static int
-devfs_open(struct vnode *vp, int flags)
+devfs_open(struct file *fp)
 {
+	struct vnode *vp = fp->f_vnode;
 	char *path;
 	struct device *dev;
 	int error;
@@ -68,7 +69,7 @@ devfs_open(struct vnode *vp, int flags)
 	}
 	if (*path == '/')
 		path++;
-	error = device_open(path, flags & DO_RWMASK, &dev);
+	error = device_open(path, fp->f_flags & DO_RWMASK, &dev);
 	if (error) {
 		DPRINTF(("devfs_open: can not open device = %s error=%d\n",
 			 path, error));
diff --git a/fs/vfs/vfs_syscalls.c b/fs/vfs/vfs_syscalls.c
index 8b70a45f5..495e22dd1 100755
--- a/fs/vfs/vfs_syscalls.c
+++ b/fs/vfs/vfs_syscalls.c
@@ -122,8 +122,8 @@ sys_open(char *path, int flags, mode_t mode, struct file *fp)
 	finit(fp, flags, DTYPE_VNODE, NULL, &vfs_ops);
 	fp->f_vnode = vp;
 
-	/* Request to file system */
-	if ((error = VOP_OPEN(vp, flags)) != 0) {
+	error = VOP_OPEN(vp, fp);
+	if (error) {
 		vput(vp);
 		return error;
 	}
diff --git a/include/osv/vnode.h b/include/osv/vnode.h
index fb71f871a..f8fba431a 100755
--- a/include/osv/vnode.h
+++ b/include/osv/vnode.h
@@ -115,7 +115,7 @@ struct vattr {
 #define IO_SYNC		0x0002
 
 
-typedef	int (*vnop_open_t)	(struct vnode *, int);
+typedef	int (*vnop_open_t)	(struct file *);
 typedef	int (*vnop_close_t)	(struct vnode *, struct file *);
 typedef	int (*vnop_read_t)	(struct vnode *, struct uio *, int);
 typedef	int (*vnop_write_t)	(struct vnode *, struct uio *, int);
@@ -162,7 +162,7 @@ struct vnops {
 /*
  * vnode interface
  */
-#define VOP_OPEN(VP, F)		   ((VP)->v_op->vop_open)(VP, F)
+#define VOP_OPEN(VP, FP)	   ((VP)->v_op->vop_open)(FP)
 #define VOP_CLOSE(VP, FP)	   ((VP)->v_op->vop_close)(VP, FP)
 #define VOP_READ(VP, U, F)	   ((VP)->v_op->vop_read)(VP, U, F)
 #define VOP_WRITE(VP, U, F)	   ((VP)->v_op->vop_write)(VP, U, F)
-- 
GitLab