]>
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 | ||
36e6f861 | 48 | #define O_DSYNC 040000000 |
49 | ||
4b171585 | 50 | #define FREAD 1 |
51 | #define FWRITE 2 | |
52 | #define FCREAT O_CREAT | |
53 | #define FTRUNC O_TRUNC | |
54 | #define FOFFMAX O_LARGEFILE | |
55 | #define FSYNC O_SYNC | |
56 | #define FDSYNC O_DSYNC | |
57 | #define FRSYNC O_RSYNC | |
58 | #define FEXCL O_EXCL | |
59 | #define FDIRECT O_DIRECT | |
5d86345d | 60 | #define FAPPEND O_APPEND |
4b171585 | 61 | |
62 | #define FNODSYNC 0x10000 /* fsync pseudo flag */ | |
63 | #define FNOFOLLOW 0x20000 /* don't follow symlinks */ | |
64 | ||
65 | #define AT_TYPE 0x00001 | |
66 | #define AT_MODE 0x00002 | |
67 | #undef AT_UID /* Conflicts with linux/auxvec.h */ | |
68 | #define AT_UID 0x00004 | |
69 | #undef AT_GID /* Conflicts with linux/auxvec.h */ | |
70 | #define AT_GID 0x00008 | |
71 | #define AT_FSID 0x00010 | |
72 | #define AT_NODEID 0x00020 | |
73 | #define AT_NLINK 0x00040 | |
74 | #define AT_SIZE 0x00080 | |
75 | #define AT_ATIME 0x00100 | |
76 | #define AT_MTIME 0x00200 | |
77 | #define AT_CTIME 0x00400 | |
78 | #define AT_RDEV 0x00800 | |
79 | #define AT_BLKSIZE 0x01000 | |
80 | #define AT_NBLOCKS 0x02000 | |
81 | #define AT_SEQ 0x08000 | |
82 | #define AT_XVATTR 0x10000 | |
83 | ||
2f5d55aa | 84 | #define CRCREAT 0x01 |
85 | #define RMFILE 0x02 | |
4b171585 | 86 | |
36e6f861 | 87 | #define B_INVAL 0x01 |
88 | #define B_TRUNC 0x02 | |
89 | ||
57d86234 | 90 | #ifdef HAVE_PATH_IN_NAMEIDATA |
91 | # define nd_dentry path.dentry | |
92 | # define nd_mnt path.mnt | |
93 | #else | |
94 | # define nd_dentry dentry | |
95 | # define nd_mnt mnt | |
96 | #endif | |
97 | ||
6adf99e7 | 98 | typedef enum vtype { |
4b171585 | 99 | VNON = 0, |
100 | VREG = 1, | |
101 | VDIR = 2, | |
102 | VBLK = 3, | |
103 | VCHR = 4, | |
104 | VLNK = 5, | |
105 | VFIFO = 6, | |
106 | VDOOR = 7, | |
107 | VPROC = 8, | |
108 | VSOCK = 9, | |
109 | VPORT = 10, | |
110 | VBAD = 11 | |
6adf99e7 | 111 | } vtype_t; |
112 | ||
4b171585 | 113 | typedef struct vattr { |
23f5c4c2 BB |
114 | enum vtype va_type; /* vnode type */ |
115 | u_int va_mask; /* attribute bit-mask */ | |
116 | u_short va_mode; /* acc mode */ | |
117 | short va_uid; /* owner uid */ | |
118 | short va_gid; /* owner gid */ | |
119 | long va_fsid; /* fs id */ | |
120 | long va_nodeid; /* node # */ | |
121 | short va_nlink; /* # links */ | |
122 | u_long va_size; /* file size */ | |
123 | long va_blocksize; /* block size */ | |
124 | struct timeval va_atime; /* last acc */ | |
125 | struct timeval va_mtime; /* last mod */ | |
126 | struct timeval va_ctime; /* last chg */ | |
127 | dev_t va_rdev; /* dev */ | |
128 | long va_blocks; /* space used */ | |
4b171585 | 129 | } vattr_t; |
0b3cf046 | 130 | |
131 | typedef struct xoptattr { | |
23f5c4c2 BB |
132 | timestruc_t xoa_createtime; /* Create time of file */ |
133 | uint8_t xoa_archive; | |
134 | uint8_t xoa_system; | |
135 | uint8_t xoa_readonly; | |
136 | uint8_t xoa_hidden; | |
137 | uint8_t xoa_nounlink; | |
138 | uint8_t xoa_immutable; | |
139 | uint8_t xoa_appendonly; | |
140 | uint8_t xoa_nodump; | |
141 | uint8_t xoa_settable; | |
142 | uint8_t xoa_opaque; | |
143 | uint8_t xoa_av_quarantined; | |
144 | uint8_t xoa_av_modified; | |
0b3cf046 | 145 | } xoptattr_t; |
146 | ||
0b3cf046 | 147 | typedef struct xvattr { |
23f5c4c2 BB |
148 | vattr_t xva_vattr; /* Embedded vattr structure */ |
149 | uint32_t xva_magic; /* Magic Number */ | |
150 | uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */ | |
151 | uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */ | |
152 | uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */ | |
153 | uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */ | |
154 | xoptattr_t xva_xoptattrs; /* Optional attributes */ | |
0b3cf046 | 155 | } xvattr_t; |
156 | ||
157 | typedef struct vsecattr { | |
23f5c4c2 BB |
158 | uint_t vsa_mask; /* See below */ |
159 | int vsa_aclcnt; /* ACL entry count */ | |
160 | void *vsa_aclentp; /* pointer to ACL entries */ | |
161 | int vsa_dfaclcnt; /* default ACL entry count */ | |
162 | void *vsa_dfaclentp; /* pointer to default ACL entries */ | |
163 | size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */ | |
0b3cf046 | 164 | } vsecattr_t; |
4b171585 | 165 | |
af828292 | 166 | typedef struct vnode { |
e4f1d29f | 167 | struct file *v_file; |
af828292 | 168 | kmutex_t v_lock; /* protects vnode fields */ |
169 | uint_t v_flag; /* vnode flags (see below) */ | |
170 | uint_t v_count; /* reference count */ | |
171 | void *v_data; /* private data for fs */ | |
172 | struct vfs *v_vfsp; /* ptr to containing VFS */ | |
173 | struct stdata *v_stream; /* associated stream */ | |
174 | enum vtype v_type; /* vnode type */ | |
175 | dev_t v_rdev; /* device (VCHR, VBLK) */ | |
176 | } vnode_t; | |
177 | ||
e4f1d29f | 178 | typedef struct vn_file { |
23f5c4c2 BB |
179 | int f_fd; /* linux fd for lookup */ |
180 | struct file *f_file; /* linux file struct */ | |
181 | atomic_t f_ref; /* ref count */ | |
182 | kmutex_t f_lock; /* struct lock */ | |
183 | loff_t f_offset; /* offset */ | |
184 | vnode_t *f_vnode; /* vnode */ | |
71c8ab9c | 185 | struct list_head f_list; /* list referenced file_t's */ |
e4f1d29f | 186 | } file_t; |
187 | ||
23f5c4c2 BB |
188 | typedef struct caller_context { |
189 | pid_t cc_pid; /* Process ID of the caller */ | |
190 | int cc_sysid; /* System ID, used for remote calls */ | |
191 | u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ | |
192 | ulong_t cc_flags; | |
193 | } caller_context_t; | |
194 | ||
af828292 | 195 | extern vnode_t *vn_alloc(int flag); |
196 | void vn_free(vnode_t *vp); | |
73e540a0 | 197 | extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode, |
4b171585 | 198 | vnode_t **vpp, int x1, void *x2); |
73e540a0 | 199 | extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode, |
4b171585 | 200 | vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd); |
201 | extern int vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, | |
73e540a0 | 202 | offset_t off, uio_seg_t seg, int x1, rlim64_t x2, |
4b171585 | 203 | void *x3, ssize_t *residp); |
2f5d55aa | 204 | extern int vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4); |
97735c39 BB |
205 | extern int vn_seek(vnode_t *vp, offset_t o, offset_t *op, caller_context_t *ct); |
206 | ||
73e540a0 | 207 | extern int vn_remove(const char *path, uio_seg_t seg, int flags); |
4b171585 | 208 | extern int vn_rename(const char *path1, const char *path2, int x1); |
36e6f861 | 209 | extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4); |
2f5d55aa | 210 | extern int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4); |
e4f1d29f | 211 | extern file_t *vn_getf(int fd); |
212 | extern void vn_releasef(int fd); | |
51a727e9 | 213 | extern int vn_set_pwd(const char *filename); |
4b171585 | 214 | |
af828292 | 215 | int vn_init(void); |
216 | void vn_fini(void); | |
217 | ||
36e6f861 | 218 | static __inline__ int |
219 | vn_rele(vnode_t *vp) | |
220 | { | |
221 | return 0; | |
222 | } /* vn_rele() */ | |
223 | ||
224 | static __inline__ int | |
225 | vn_putpage(vnode_t *vp, offset_t off, ssize_t size, | |
23f5c4c2 | 226 | int flags, void *x1, void *x2) { |
36e6f861 | 227 | return 0; |
228 | } /* vn_putpage() */ | |
229 | ||
4b171585 | 230 | #define VOP_CLOSE vn_close |
97735c39 | 231 | #define VOP_SEEK vn_seek |
36e6f861 | 232 | #define VN_RELE vn_rele |
4b171585 | 233 | #define VOP_GETATTR vn_getattr |
234 | #define VOP_FSYNC vn_fsync | |
36e6f861 | 235 | #define VOP_PUTPAGE vn_putpage |
4b171585 | 236 | #define vn_is_readonly(vp) 0 |
e4f1d29f | 237 | #define getf vn_getf |
238 | #define releasef vn_releasef | |
4b171585 | 239 | |
51a727e9 | 240 | extern vnode_t *rootdir; |
0b3cf046 | 241 | |
242 | #endif /* SPL_VNODE_H */ |