]>
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 | |
6801b715 BB |
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 | |
36e6f861 | 53 | |
4b171585 | 54 | #define FREAD 1 |
55 | #define FWRITE 2 | |
56 | #define FCREAT O_CREAT | |
57 | #define FTRUNC O_TRUNC | |
58 | #define FOFFMAX O_LARGEFILE | |
59 | #define FSYNC O_SYNC | |
60 | #define FDSYNC O_DSYNC | |
1b439713 | 61 | #define FRSYNC O_SYNC |
4b171585 | 62 | #define FEXCL O_EXCL |
63 | #define FDIRECT O_DIRECT | |
5d86345d | 64 | #define FAPPEND O_APPEND |
4b171585 | 65 | |
66 | #define FNODSYNC 0x10000 /* fsync pseudo flag */ | |
67 | #define FNOFOLLOW 0x20000 /* don't follow symlinks */ | |
68 | ||
47995fa6 BB |
69 | /* |
70 | * The vnode AT_ flags are mapped to the Linux ATTR_* flags. | |
71 | * This allows them to be used safely with an iattr structure. | |
72 | * The AT_XVATTR flag has been added and mapped to the upper | |
73 | * bit range to avoid conflicting with the standard Linux set. | |
74 | */ | |
75 | #undef AT_UID | |
76 | #undef AT_GID | |
77 | ||
78 | #define AT_MODE ATTR_MODE | |
79 | #define AT_UID ATTR_UID | |
80 | #define AT_GID ATTR_GID | |
81 | #define AT_SIZE ATTR_SIZE | |
82 | #define AT_ATIME ATTR_ATIME | |
83 | #define AT_MTIME ATTR_MTIME | |
84 | #define AT_CTIME ATTR_CTIME | |
85 | ||
86 | #define ATTR_XVATTR (1 << 31) | |
87 | #define AT_XVATTR ATTR_XVATTR | |
88 | ||
89 | #define ATTR_IATTR_MASK (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_SIZE | \ | |
90 | ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_FILE) | |
4b171585 | 91 | |
2f5d55aa | 92 | #define CRCREAT 0x01 |
93 | #define RMFILE 0x02 | |
4b171585 | 94 | |
36e6f861 | 95 | #define B_INVAL 0x01 |
96 | #define B_TRUNC 0x02 | |
97 | ||
bd6ac72b BB |
98 | #define LOOKUP_DIR 0x01 |
99 | #define LOOKUP_XATTR 0x02 | |
100 | #define CREATE_XATTR_DIR 0x04 | |
101 | #define ATTR_NOACLCHECK 0x20 | |
102 | ||
57d86234 | 103 | #ifdef HAVE_PATH_IN_NAMEIDATA |
104 | # define nd_dentry path.dentry | |
105 | # define nd_mnt path.mnt | |
106 | #else | |
107 | # define nd_dentry dentry | |
108 | # define nd_mnt mnt | |
109 | #endif | |
110 | ||
6adf99e7 | 111 | typedef enum vtype { |
4b171585 | 112 | VNON = 0, |
113 | VREG = 1, | |
114 | VDIR = 2, | |
115 | VBLK = 3, | |
116 | VCHR = 4, | |
117 | VLNK = 5, | |
118 | VFIFO = 6, | |
119 | VDOOR = 7, | |
120 | VPROC = 8, | |
121 | VSOCK = 9, | |
122 | VPORT = 10, | |
123 | VBAD = 11 | |
6adf99e7 | 124 | } vtype_t; |
125 | ||
4b171585 | 126 | typedef struct vattr { |
23f5c4c2 BB |
127 | enum vtype va_type; /* vnode type */ |
128 | u_int va_mask; /* attribute bit-mask */ | |
129 | u_short va_mode; /* acc mode */ | |
dcd9cb5a BB |
130 | uid_t va_uid; /* owner uid */ |
131 | gid_t va_gid; /* owner gid */ | |
23f5c4c2 BB |
132 | long va_fsid; /* fs id */ |
133 | long va_nodeid; /* node # */ | |
dcd9cb5a BB |
134 | uint32_t va_nlink; /* # links */ |
135 | uint64_t va_size; /* file size */ | |
dcd9cb5a BB |
136 | struct timespec va_atime; /* last acc */ |
137 | struct timespec va_mtime; /* last mod */ | |
138 | struct timespec va_ctime; /* last chg */ | |
23f5c4c2 | 139 | dev_t va_rdev; /* dev */ |
47995fa6 BB |
140 | uint64_t va_nblocks; /* space used */ |
141 | uint32_t va_blksize; /* block size */ | |
142 | uint32_t va_seq; /* sequence */ | |
91cb1d91 | 143 | struct dentry *va_dentry; /* dentry to wire */ |
4b171585 | 144 | } vattr_t; |
0b3cf046 | 145 | |
af828292 | 146 | typedef struct vnode { |
e4f1d29f | 147 | struct file *v_file; |
af828292 | 148 | kmutex_t v_lock; /* protects vnode fields */ |
149 | uint_t v_flag; /* vnode flags (see below) */ | |
150 | uint_t v_count; /* reference count */ | |
151 | void *v_data; /* private data for fs */ | |
152 | struct vfs *v_vfsp; /* ptr to containing VFS */ | |
153 | struct stdata *v_stream; /* associated stream */ | |
154 | enum vtype v_type; /* vnode type */ | |
155 | dev_t v_rdev; /* device (VCHR, VBLK) */ | |
4be55565 | 156 | gfp_t v_gfp_mask; /* original mapping gfp mask */ |
af828292 | 157 | } vnode_t; |
158 | ||
e4f1d29f | 159 | typedef struct vn_file { |
23f5c4c2 | 160 | int f_fd; /* linux fd for lookup */ |
763b2f3b | 161 | struct task_struct *f_task; /* linux task this fd belongs to */ |
23f5c4c2 BB |
162 | struct file *f_file; /* linux file struct */ |
163 | atomic_t f_ref; /* ref count */ | |
164 | kmutex_t f_lock; /* struct lock */ | |
165 | loff_t f_offset; /* offset */ | |
166 | vnode_t *f_vnode; /* vnode */ | |
71c8ab9c | 167 | struct list_head f_list; /* list referenced file_t's */ |
e4f1d29f | 168 | } file_t; |
169 | ||
af828292 | 170 | extern vnode_t *vn_alloc(int flag); |
171 | void vn_free(vnode_t *vp); | |
4295b530 BB |
172 | extern vtype_t vn_mode_to_vtype(mode_t); |
173 | extern mode_t vn_vtype_to_mode(vtype_t); | |
73e540a0 | 174 | extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode, |
4b171585 | 175 | vnode_t **vpp, int x1, void *x2); |
73e540a0 | 176 | extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode, |
4b171585 | 177 | vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd); |
178 | extern int vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, | |
73e540a0 | 179 | offset_t off, uio_seg_t seg, int x1, rlim64_t x2, |
4b171585 | 180 | void *x3, ssize_t *residp); |
2f5d55aa | 181 | extern int vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4); |
47995fa6 | 182 | extern int vn_seek(vnode_t *vp, offset_t o, offset_t *op, void *ct); |
97735c39 | 183 | |
73e540a0 | 184 | extern int vn_remove(const char *path, uio_seg_t seg, int flags); |
4b171585 | 185 | extern int vn_rename(const char *path1, const char *path2, int x1); |
36e6f861 | 186 | extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4); |
2f5d55aa | 187 | extern int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4); |
e4f1d29f | 188 | extern file_t *vn_getf(int fd); |
189 | extern void vn_releasef(int fd); | |
51a727e9 | 190 | extern int vn_set_pwd(const char *filename); |
4b171585 | 191 | |
12ff95ff BB |
192 | int spl_vn_init_kallsyms_lookup(void); |
193 | int spl_vn_init(void); | |
194 | void spl_vn_fini(void); | |
af828292 | 195 | |
4b171585 | 196 | #define VOP_CLOSE vn_close |
97735c39 | 197 | #define VOP_SEEK vn_seek |
4b171585 | 198 | #define VOP_GETATTR vn_getattr |
199 | #define VOP_FSYNC vn_fsync | |
647fa73c | 200 | #define VOP_PUTPAGE(vp, o, s, f, x1, x2) ((void)0) |
4b171585 | 201 | #define vn_is_readonly(vp) 0 |
e4f1d29f | 202 | #define getf vn_getf |
203 | #define releasef vn_releasef | |
4b171585 | 204 | |
51a727e9 | 205 | extern vnode_t *rootdir; |
0b3cf046 | 206 | |
207 | #endif /* SPL_VNODE_H */ |