xref: /freebsd/sys/contrib/openzfs/include/os/linux/spl/sys/vnode.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
4  *  Copyright (C) 2007 The Regents of the University of California.
5  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
6  *  Written by Brian Behlendorf <behlendorf1@llnl.gov>.
7  *  UCRL-CODE-235197
8  *
9  *  This file is part of the SPL, Solaris Porting Layer.
10  *
11  *  The SPL is free software; you can redistribute it and/or modify it
12  *  under the terms of the GNU General Public License as published by the
13  *  Free Software Foundation; either version 2 of the License, or (at your
14  *  option) any later version.
15  *
16  *  The SPL is distributed in the hope that it will be useful, but WITHOUT
17  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19  *  for more details.
20  *
21  *  You should have received a copy of the GNU General Public License along
22  *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef _SPL_VNODE_H
26 #define	_SPL_VNODE_H
27 
28 #include <linux/module.h>
29 #include <linux/syscalls.h>
30 #include <linux/fcntl.h>
31 #include <linux/buffer_head.h>
32 #include <linux/dcache.h>
33 #include <linux/namei.h>
34 #include <linux/file.h>
35 #include <linux/fs.h>
36 #include <linux/fs_struct.h>
37 #include <linux/mount.h>
38 #include <sys/kmem.h>
39 #include <sys/mutex.h>
40 #include <sys/types.h>
41 #include <sys/time.h>
42 #include <sys/uio.h>
43 #include <sys/user.h>
44 
45 /*
46  * Prior to linux-2.6.33 only O_DSYNC semantics were implemented and
47  * they used the O_SYNC flag.  As of linux-2.6.33 the this behavior
48  * was properly split in to O_SYNC and O_DSYNC respectively.
49  */
50 #ifndef O_DSYNC
51 #define	O_DSYNC		O_SYNC
52 #endif
53 
54 #define	F_FREESP	11 	/* Free file space */
55 
56 
57 #if defined(SEEK_HOLE) && defined(SEEK_DATA)
58 #define	F_SEEK_DATA	SEEK_DATA
59 #define	F_SEEK_HOLE	SEEK_HOLE
60 #endif
61 
62 /*
63  * The vnode AT_ flags are mapped to the Linux ATTR_* flags.
64  * This allows them to be used safely with an iattr structure.
65  * The AT_XVATTR flag has been added and mapped to the upper
66  * bit range to avoid conflicting with the standard Linux set.
67  */
68 #undef AT_UID
69 #undef AT_GID
70 
71 #define	AT_MODE		ATTR_MODE
72 #define	AT_UID		ATTR_UID
73 #define	AT_GID		ATTR_GID
74 #define	AT_SIZE		ATTR_SIZE
75 #define	AT_ATIME	ATTR_ATIME
76 #define	AT_MTIME	ATTR_MTIME
77 #define	AT_CTIME	ATTR_CTIME
78 
79 #define	ATTR_XVATTR	(1U << 31)
80 #define	AT_XVATTR	ATTR_XVATTR
81 
82 #define	ATTR_IATTR_MASK	(ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_SIZE | \
83 			ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_FILE)
84 
85 #define	CRCREAT		0x01
86 #define	RMFILE		0x02
87 
88 #define	B_INVAL		0x01
89 #define	B_TRUNC		0x02
90 
91 #define	LOOKUP_DIR		0x01
92 #define	LOOKUP_XATTR		0x02
93 #define	CREATE_XATTR_DIR	0x04
94 #define	ATTR_NOACLCHECK		0x20
95 
96 typedef struct vattr {
97 	uint32_t	va_mask;	/* attribute bit-mask */
98 	ushort_t	va_mode;	/* acc mode */
99 	uid_t		va_uid;		/* owner uid */
100 	gid_t		va_gid;		/* owner gid */
101 	long		va_fsid;	/* fs id */
102 	long		va_nodeid;	/* node # */
103 	uint32_t	va_nlink;	/* # links */
104 	uint64_t	va_size;	/* file size */
105 	inode_timespec_t va_atime;	/* last acc */
106 	inode_timespec_t va_mtime;	/* last mod */
107 	inode_timespec_t va_ctime;	/* last chg */
108 	dev_t		va_rdev;	/* dev */
109 	uint64_t	va_nblocks;	/* space used */
110 	uint32_t	va_blksize;	/* block size */
111 	struct dentry	*va_dentry;	/* dentry to wire */
112 } vattr_t;
113 #endif /* SPL_VNODE_H */
114