]>
Commit | Line | Data |
---|---|---|
716154c5 BB |
1 | /*****************************************************************************\ |
2 | * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. | |
3 | * Copyright (C) 2007 The Regents of the University of California. | |
4 | * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). | |
5 | * Written by Brian Behlendorf <behlendorf1@llnl.gov>. | |
715f6251 | 6 | * UCRL-CODE-235197 |
7 | * | |
716154c5 BB |
8 | * This file is part of the SPL, Solaris Porting Layer. |
9 | * For details, see <http://github.com/behlendorf/spl/>. | |
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. | |
715f6251 | 15 | * |
716154c5 | 16 | * The SPL is distributed in the hope that it will be useful, but WITHOUT |
715f6251 | 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 | |
716154c5 BB |
22 | * with the SPL. If not, see <http://www.gnu.org/licenses/>. |
23 | \*****************************************************************************/ | |
715f6251 | 24 | |
0b3cf046 | 25 | #ifndef _SPL_VNODE_H |
26 | #define _SPL_VNODE_H | |
27 | ||
4b171585 | 28 | #include <linux/module.h> |
6adf99e7 | 29 | #include <linux/syscalls.h> |
4b171585 | 30 | #include <linux/fcntl.h> |
4b171585 | 31 | #include <linux/buffer_head.h> |
32 | #include <linux/dcache.h> | |
33 | #include <linux/namei.h> | |
e4f1d29f | 34 | #include <linux/file.h> |
4b171585 | 35 | #include <linux/fs.h> |
baf2979e | 36 | #include <linux/fs_struct.h> |
57d86234 | 37 | #include <linux/mount.h> |
af828292 | 38 | #include <sys/kmem.h> |
39 | #include <sys/mutex.h> | |
4b171585 | 40 | #include <sys/types.h> |
41 | #include <sys/time.h> | |
42 | #include <sys/uio.h> | |
4e62fd41 | 43 | #include <sys/sunldi.h> |
6adf99e7 | 44 | |
0b3cf046 | 45 | #define XVA_MAPSIZE 3 |
46 | #define XVA_MAGIC 0x78766174 | |
47 | ||
6801b715 BB |
48 | /* |
49 | * Prior to linux-2.6.33 only O_DSYNC semantics were implemented and | |
50 | * they used the O_SYNC flag. As of linux-2.6.33 the this behavior | |
51 | * was properly split in to O_SYNC and O_DSYNC respectively. | |
52 | */ | |
53 | #ifndef O_DSYNC | |
54 | #define O_DSYNC O_SYNC | |
55 | #endif | |
36e6f861 | 56 | |
4b171585 | 57 | #define FREAD 1 |
58 | #define FWRITE 2 | |
59 | #define FCREAT O_CREAT | |
60 | #define FTRUNC O_TRUNC | |
61 | #define FOFFMAX O_LARGEFILE | |
62 | #define FSYNC O_SYNC | |
63 | #define FDSYNC O_DSYNC | |
1b439713 | 64 | #define FRSYNC O_SYNC |
4b171585 | 65 | #define FEXCL O_EXCL |
66 | #define FDIRECT O_DIRECT | |
5d86345d | 67 | #define FAPPEND O_APPEND |
4b171585 | 68 | |
69 | #define FNODSYNC 0x10000 /* fsync pseudo flag */ | |
70 | #define FNOFOLLOW 0x20000 /* don't follow symlinks */ | |
71 | ||
72 | #define AT_TYPE 0x00001 | |
73 | #define AT_MODE 0x00002 | |
74 | #undef AT_UID /* Conflicts with linux/auxvec.h */ | |
75 | #define AT_UID 0x00004 | |
76 | #undef AT_GID /* Conflicts with linux/auxvec.h */ | |
77 | #define AT_GID 0x00008 | |
78 | #define AT_FSID 0x00010 | |
79 | #define AT_NODEID 0x00020 | |
80 | #define AT_NLINK 0x00040 | |
81 | #define AT_SIZE 0x00080 | |
82 | #define AT_ATIME 0x00100 | |
83 | #define AT_MTIME 0x00200 | |
84 | #define AT_CTIME 0x00400 | |
85 | #define AT_RDEV 0x00800 | |
86 | #define AT_BLKSIZE 0x01000 | |
87 | #define AT_NBLOCKS 0x02000 | |
88 | #define AT_SEQ 0x08000 | |
89 | #define AT_XVATTR 0x10000 | |
90 | ||
2f5d55aa | 91 | #define CRCREAT 0x01 |
92 | #define RMFILE 0x02 | |
4b171585 | 93 | |
36e6f861 | 94 | #define B_INVAL 0x01 |
95 | #define B_TRUNC 0x02 | |
96 | ||
bd6ac72b BB |
97 | #define V_ACE_MASK 0x0001 |
98 | #define V_APPEND 0x0002 | |
99 | ||
100 | #define LOOKUP_DIR 0x01 | |
101 | #define LOOKUP_XATTR 0x02 | |
102 | #define CREATE_XATTR_DIR 0x04 | |
103 | #define ATTR_NOACLCHECK 0x20 | |
104 | ||
57d86234 | 105 | #ifdef HAVE_PATH_IN_NAMEIDATA |
106 | # define nd_dentry path.dentry | |
107 | # define nd_mnt path.mnt | |
108 | #else | |
109 | # define nd_dentry dentry | |
110 | # define nd_mnt mnt | |
111 | #endif | |
112 | ||
6adf99e7 | 113 | typedef enum vtype { |
4b171585 | 114 | VNON = 0, |
115 | VREG = 1, | |
116 | VDIR = 2, | |
117 | VBLK = 3, | |
118 | VCHR = 4, | |
119 | VLNK = 5, | |
120 | VFIFO = 6, | |
121 | VDOOR = 7, | |
122 | VPROC = 8, | |
123 | VSOCK = 9, | |
124 | VPORT = 10, | |
125 | VBAD = 11 | |
6adf99e7 | 126 | } vtype_t; |
127 | ||
4b171585 | 128 | typedef struct vattr { |
23f5c4c2 BB |
129 | enum vtype va_type; /* vnode type */ |
130 | u_int va_mask; /* attribute bit-mask */ | |
131 | u_short va_mode; /* acc mode */ | |
dcd9cb5a BB |
132 | uid_t va_uid; /* owner uid */ |
133 | gid_t va_gid; /* owner gid */ | |
23f5c4c2 BB |
134 | long va_fsid; /* fs id */ |
135 | long va_nodeid; /* node # */ | |
dcd9cb5a BB |
136 | uint32_t va_nlink; /* # links */ |
137 | uint64_t va_size; /* file size */ | |
138 | uint32_t va_blocksize; /* block size */ | |
139 | uint64_t va_nblocks; /* space used */ | |
140 | struct timespec va_atime; /* last acc */ | |
141 | struct timespec va_mtime; /* last mod */ | |
142 | struct timespec va_ctime; /* last chg */ | |
23f5c4c2 | 143 | dev_t va_rdev; /* dev */ |
4b171585 | 144 | } vattr_t; |
0b3cf046 | 145 | |
146 | typedef struct xoptattr { | |
23f5c4c2 BB |
147 | timestruc_t xoa_createtime; /* Create time of file */ |
148 | uint8_t xoa_archive; | |
149 | uint8_t xoa_system; | |
150 | uint8_t xoa_readonly; | |
151 | uint8_t xoa_hidden; | |
152 | uint8_t xoa_nounlink; | |
153 | uint8_t xoa_immutable; | |
154 | uint8_t xoa_appendonly; | |
155 | uint8_t xoa_nodump; | |
156 | uint8_t xoa_settable; | |
157 | uint8_t xoa_opaque; | |
158 | uint8_t xoa_av_quarantined; | |
159 | uint8_t xoa_av_modified; | |
0b3cf046 | 160 | } xoptattr_t; |
161 | ||
0b3cf046 | 162 | typedef struct xvattr { |
23f5c4c2 BB |
163 | vattr_t xva_vattr; /* Embedded vattr structure */ |
164 | uint32_t xva_magic; /* Magic Number */ | |
165 | uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */ | |
166 | uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */ | |
167 | uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */ | |
168 | uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */ | |
169 | xoptattr_t xva_xoptattrs; /* Optional attributes */ | |
0b3cf046 | 170 | } xvattr_t; |
171 | ||
172 | typedef struct vsecattr { | |
23f5c4c2 BB |
173 | uint_t vsa_mask; /* See below */ |
174 | int vsa_aclcnt; /* ACL entry count */ | |
175 | void *vsa_aclentp; /* pointer to ACL entries */ | |
176 | int vsa_dfaclcnt; /* default ACL entry count */ | |
177 | void *vsa_dfaclentp; /* pointer to default ACL entries */ | |
178 | size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */ | |
dcd9cb5a | 179 | uint_t vsa_aclflags; /* ACE ACL flags */ |
0b3cf046 | 180 | } vsecattr_t; |
4b171585 | 181 | |
af828292 | 182 | typedef struct vnode { |
e4f1d29f | 183 | struct file *v_file; |
af828292 | 184 | kmutex_t v_lock; /* protects vnode fields */ |
185 | uint_t v_flag; /* vnode flags (see below) */ | |
186 | uint_t v_count; /* reference count */ | |
187 | void *v_data; /* private data for fs */ | |
188 | struct vfs *v_vfsp; /* ptr to containing VFS */ | |
189 | struct stdata *v_stream; /* associated stream */ | |
190 | enum vtype v_type; /* vnode type */ | |
191 | dev_t v_rdev; /* device (VCHR, VBLK) */ | |
4be55565 | 192 | gfp_t v_gfp_mask; /* original mapping gfp mask */ |
af828292 | 193 | } vnode_t; |
194 | ||
e4f1d29f | 195 | typedef struct vn_file { |
23f5c4c2 BB |
196 | int f_fd; /* linux fd for lookup */ |
197 | struct file *f_file; /* linux file struct */ | |
198 | atomic_t f_ref; /* ref count */ | |
199 | kmutex_t f_lock; /* struct lock */ | |
200 | loff_t f_offset; /* offset */ | |
201 | vnode_t *f_vnode; /* vnode */ | |
71c8ab9c | 202 | struct list_head f_list; /* list referenced file_t's */ |
e4f1d29f | 203 | } file_t; |
204 | ||
23f5c4c2 BB |
205 | typedef struct caller_context { |
206 | pid_t cc_pid; /* Process ID of the caller */ | |
207 | int cc_sysid; /* System ID, used for remote calls */ | |
208 | u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ | |
209 | ulong_t cc_flags; | |
210 | } caller_context_t; | |
211 | ||
af828292 | 212 | extern vnode_t *vn_alloc(int flag); |
213 | void vn_free(vnode_t *vp); | |
4295b530 BB |
214 | extern vtype_t vn_mode_to_vtype(mode_t); |
215 | extern mode_t vn_vtype_to_mode(vtype_t); | |
73e540a0 | 216 | extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode, |
4b171585 | 217 | vnode_t **vpp, int x1, void *x2); |
73e540a0 | 218 | extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode, |
4b171585 | 219 | vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd); |
220 | extern int vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, | |
73e540a0 | 221 | offset_t off, uio_seg_t seg, int x1, rlim64_t x2, |
4b171585 | 222 | void *x3, ssize_t *residp); |
2f5d55aa | 223 | extern int vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4); |
97735c39 BB |
224 | extern int vn_seek(vnode_t *vp, offset_t o, offset_t *op, caller_context_t *ct); |
225 | ||
73e540a0 | 226 | extern int vn_remove(const char *path, uio_seg_t seg, int flags); |
4b171585 | 227 | extern int vn_rename(const char *path1, const char *path2, int x1); |
36e6f861 | 228 | extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4); |
2f5d55aa | 229 | extern int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4); |
e4f1d29f | 230 | extern file_t *vn_getf(int fd); |
231 | extern void vn_releasef(int fd); | |
51a727e9 | 232 | extern int vn_set_pwd(const char *filename); |
4b171585 | 233 | |
af828292 | 234 | int vn_init(void); |
235 | void vn_fini(void); | |
236 | ||
4b171585 | 237 | #define VOP_CLOSE vn_close |
97735c39 | 238 | #define VOP_SEEK vn_seek |
4b171585 | 239 | #define VOP_GETATTR vn_getattr |
240 | #define VOP_FSYNC vn_fsync | |
647fa73c | 241 | #define VOP_PUTPAGE(vp, o, s, f, x1, x2) ((void)0) |
4b171585 | 242 | #define vn_is_readonly(vp) 0 |
e4f1d29f | 243 | #define getf vn_getf |
244 | #define releasef vn_releasef | |
4b171585 | 245 | |
51a727e9 | 246 | extern vnode_t *rootdir; |
0b3cf046 | 247 | |
248 | #endif /* SPL_VNODE_H */ |