]> git.proxmox.com Git - mirror_zfs-debian.git/blob - include/sys/zpl.h
New upstream version 0.7.9
[mirror_zfs-debian.git] / include / sys / zpl.h
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2011, Lawrence Livermore National Security, LLC.
23 */
24
25 #ifndef _SYS_ZPL_H
26 #define _SYS_ZPL_H
27
28 #include <sys/mntent.h>
29 #include <sys/vfs.h>
30 #include <linux/aio.h>
31 #include <linux/dcache_compat.h>
32 #include <linux/exportfs.h>
33 #include <linux/falloc.h>
34 #include <linux/file_compat.h>
35 #include <linux/parser.h>
36 #include <linux/task_io_accounting_ops.h>
37 #include <linux/vfs_compat.h>
38 #include <linux/writeback.h>
39 #include <linux/xattr_compat.h>
40
41 /* zpl_inode.c */
42 extern void zpl_vap_init(vattr_t *vap, struct inode *dir,
43 zpl_umode_t mode, cred_t *cr);
44
45 extern const struct inode_operations zpl_inode_operations;
46 extern const struct inode_operations zpl_dir_inode_operations;
47 extern const struct inode_operations zpl_symlink_inode_operations;
48 extern const struct inode_operations zpl_special_inode_operations;
49 extern dentry_operations_t zpl_dentry_operations;
50
51 /* zpl_file.c */
52 extern ssize_t zpl_read_common(struct inode *ip, const char *buf,
53 size_t len, loff_t *ppos, uio_seg_t segment, int flags,
54 cred_t *cr);
55 extern ssize_t zpl_write_common(struct inode *ip, const char *buf,
56 size_t len, loff_t *ppos, uio_seg_t segment, int flags,
57 cred_t *cr);
58 #if defined(HAVE_FILE_FALLOCATE) || defined(HAVE_INODE_FALLOCATE)
59 extern long zpl_fallocate_common(struct inode *ip, int mode,
60 loff_t offset, loff_t len);
61 #endif /* defined(HAVE_FILE_FALLOCATE) || defined(HAVE_INODE_FALLOCATE) */
62
63 extern const struct address_space_operations zpl_address_space_operations;
64 extern const struct file_operations zpl_file_operations;
65 extern const struct file_operations zpl_dir_file_operations;
66
67 /* zpl_super.c */
68 extern void zpl_prune_sb(int64_t nr_to_scan, void *arg);
69
70 extern const struct super_operations zpl_super_operations;
71 extern const struct export_operations zpl_export_operations;
72 extern struct file_system_type zpl_fs_type;
73
74 /* zpl_xattr.c */
75 extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
76 extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
77 const struct qstr *qstr);
78 #if defined(CONFIG_FS_POSIX_ACL)
79 extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type);
80 extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
81 #if !defined(HAVE_GET_ACL)
82 #if defined(HAVE_CHECK_ACL_WITH_FLAGS)
83 extern int zpl_check_acl(struct inode *inode, int mask, unsigned int flags);
84 #elif defined(HAVE_CHECK_ACL)
85 extern int zpl_check_acl(struct inode *inode, int mask);
86 #elif defined(HAVE_PERMISSION_WITH_NAMEIDATA)
87 extern int zpl_permission(struct inode *ip, int mask, struct nameidata *nd);
88 #elif defined(HAVE_PERMISSION)
89 extern int zpl_permission(struct inode *ip, int mask);
90 #endif /* HAVE_CHECK_ACL | HAVE_PERMISSION */
91 #endif /* HAVE_GET_ACL */
92
93 extern int zpl_init_acl(struct inode *ip, struct inode *dir);
94 extern int zpl_chmod_acl(struct inode *ip);
95 #else
96 static inline int
97 zpl_init_acl(struct inode *ip, struct inode *dir)
98 {
99 return (0);
100 }
101
102 static inline int
103 zpl_chmod_acl(struct inode *ip)
104 {
105 return (0);
106 }
107 #endif /* CONFIG_FS_POSIX_ACL */
108
109 extern xattr_handler_t *zpl_xattr_handlers[];
110
111 /* zpl_ctldir.c */
112 extern const struct file_operations zpl_fops_root;
113 extern const struct inode_operations zpl_ops_root;
114
115 extern const struct file_operations zpl_fops_snapdir;
116 extern const struct inode_operations zpl_ops_snapdir;
117 #ifdef HAVE_AUTOMOUNT
118 extern const struct dentry_operations zpl_dops_snapdirs;
119 #else
120 extern const struct inode_operations zpl_ops_snapdirs;
121 #endif /* HAVE_AUTOMOUNT */
122
123 extern const struct file_operations zpl_fops_shares;
124 extern const struct inode_operations zpl_ops_shares;
125
126 #if defined(HAVE_VFS_ITERATE) || defined(HAVE_VFS_ITERATE_SHARED)
127
128 #define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
129 .actor = _actor, \
130 .pos = _pos, \
131 }
132
133 typedef struct dir_context zpl_dir_context_t;
134
135 #define zpl_dir_emit dir_emit
136 #define zpl_dir_emit_dot dir_emit_dot
137 #define zpl_dir_emit_dotdot dir_emit_dotdot
138 #define zpl_dir_emit_dots dir_emit_dots
139
140 #else
141
142 typedef struct zpl_dir_context {
143 void *dirent;
144 const filldir_t actor;
145 loff_t pos;
146 } zpl_dir_context_t;
147
148 #define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
149 .dirent = _dirent, \
150 .actor = _actor, \
151 .pos = _pos, \
152 }
153
154 static inline bool
155 zpl_dir_emit(zpl_dir_context_t *ctx, const char *name, int namelen,
156 uint64_t ino, unsigned type)
157 {
158 return (!ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type));
159 }
160
161 static inline bool
162 zpl_dir_emit_dot(struct file *file, zpl_dir_context_t *ctx)
163 {
164 return (ctx->actor(ctx->dirent, ".", 1, ctx->pos,
165 file_inode(file)->i_ino, DT_DIR) == 0);
166 }
167
168 static inline bool
169 zpl_dir_emit_dotdot(struct file *file, zpl_dir_context_t *ctx)
170 {
171 return (ctx->actor(ctx->dirent, "..", 2, ctx->pos,
172 parent_ino(file_dentry(file)), DT_DIR) == 0);
173 }
174
175 static inline bool
176 zpl_dir_emit_dots(struct file *file, zpl_dir_context_t *ctx)
177 {
178 if (ctx->pos == 0) {
179 if (!zpl_dir_emit_dot(file, ctx))
180 return (false);
181 ctx->pos = 1;
182 }
183 if (ctx->pos == 1) {
184 if (!zpl_dir_emit_dotdot(file, ctx))
185 return (false);
186 ctx->pos = 2;
187 }
188 return (true);
189 }
190 #endif /* HAVE_VFS_ITERATE */
191
192 #endif /* _SYS_ZPL_H */