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