]> git.proxmox.com Git - mirror_zfs.git/blob - include/os/linux/zfs/sys/zpl.h
linux 6.2 compat: get_acl() got moved to get_inode_acl() in 6.2
[mirror_zfs.git] / include / os / linux / zfs / 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 https://opensource.org/licenses/CDDL-1.0.
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/parser.h>
35 #include <linux/task_io_accounting_ops.h>
36 #include <linux/vfs_compat.h>
37 #include <linux/writeback.h>
38 #include <linux/xattr_compat.h>
39
40 /* zpl_inode.c */
41 extern void zpl_vap_init(vattr_t *vap, struct inode *dir,
42 umode_t mode, cred_t *cr, zuserns_t *mnt_ns);
43
44 extern const struct inode_operations zpl_inode_operations;
45 #ifdef HAVE_RENAME2_OPERATIONS_WRAPPER
46 extern const struct inode_operations_wrapper zpl_dir_inode_operations;
47 #else
48 extern const struct inode_operations zpl_dir_inode_operations;
49 #endif
50 extern const struct inode_operations zpl_symlink_inode_operations;
51 extern const struct inode_operations zpl_special_inode_operations;
52
53 /* zpl_file.c */
54 extern const struct address_space_operations zpl_address_space_operations;
55 extern const struct file_operations zpl_file_operations;
56 extern const struct file_operations zpl_dir_file_operations;
57
58 /* zpl_super.c */
59 extern void zpl_prune_sb(int64_t nr_to_scan, void *arg);
60
61 extern const struct super_operations zpl_super_operations;
62 extern const struct export_operations zpl_export_operations;
63 extern struct file_system_type zpl_fs_type;
64
65 /* zpl_xattr.c */
66 extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
67 extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
68 const struct qstr *qstr);
69 #if defined(CONFIG_FS_POSIX_ACL)
70 #if defined(HAVE_SET_ACL)
71 #if defined(HAVE_SET_ACL_USERNS)
72 extern int zpl_set_acl(struct user_namespace *userns, struct inode *ip,
73 struct posix_acl *acl, int type);
74 #else
75 extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type);
76 #endif /* HAVE_SET_ACL_USERNS */
77 #endif /* HAVE_SET_ACL */
78 #if defined(HAVE_GET_ACL_RCU) || defined(HAVE_GET_INODE_ACL)
79 extern struct posix_acl *zpl_get_acl(struct inode *ip, int type, bool rcu);
80 #elif defined(HAVE_GET_ACL)
81 extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
82 #endif
83 extern int zpl_init_acl(struct inode *ip, struct inode *dir);
84 extern int zpl_chmod_acl(struct inode *ip);
85 #else
86 static inline int
87 zpl_init_acl(struct inode *ip, struct inode *dir)
88 {
89 return (0);
90 }
91
92 static inline int
93 zpl_chmod_acl(struct inode *ip)
94 {
95 return (0);
96 }
97 #endif /* CONFIG_FS_POSIX_ACL */
98
99 extern xattr_handler_t *zpl_xattr_handlers[];
100
101 /* zpl_ctldir.c */
102 extern const struct file_operations zpl_fops_root;
103 extern const struct inode_operations zpl_ops_root;
104
105 extern const struct file_operations zpl_fops_snapdir;
106 extern const struct inode_operations zpl_ops_snapdir;
107
108 extern const struct file_operations zpl_fops_shares;
109 extern const struct inode_operations zpl_ops_shares;
110
111 #if defined(HAVE_VFS_ITERATE) || defined(HAVE_VFS_ITERATE_SHARED)
112
113 #define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
114 .actor = _actor, \
115 .pos = _pos, \
116 }
117
118 typedef struct dir_context zpl_dir_context_t;
119
120 #define zpl_dir_emit dir_emit
121 #define zpl_dir_emit_dot dir_emit_dot
122 #define zpl_dir_emit_dotdot dir_emit_dotdot
123 #define zpl_dir_emit_dots dir_emit_dots
124
125 #else
126
127 typedef struct zpl_dir_context {
128 void *dirent;
129 const filldir_t actor;
130 loff_t pos;
131 } zpl_dir_context_t;
132
133 #define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
134 .dirent = _dirent, \
135 .actor = _actor, \
136 .pos = _pos, \
137 }
138
139 static inline bool
140 zpl_dir_emit(zpl_dir_context_t *ctx, const char *name, int namelen,
141 uint64_t ino, unsigned type)
142 {
143 return (!ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type));
144 }
145
146 static inline bool
147 zpl_dir_emit_dot(struct file *file, zpl_dir_context_t *ctx)
148 {
149 return (ctx->actor(ctx->dirent, ".", 1, ctx->pos,
150 file_inode(file)->i_ino, DT_DIR) == 0);
151 }
152
153 static inline bool
154 zpl_dir_emit_dotdot(struct file *file, zpl_dir_context_t *ctx)
155 {
156 return (ctx->actor(ctx->dirent, "..", 2, ctx->pos,
157 parent_ino(file_dentry(file)), DT_DIR) == 0);
158 }
159
160 static inline bool
161 zpl_dir_emit_dots(struct file *file, zpl_dir_context_t *ctx)
162 {
163 if (ctx->pos == 0) {
164 if (!zpl_dir_emit_dot(file, ctx))
165 return (false);
166 ctx->pos = 1;
167 }
168 if (ctx->pos == 1) {
169 if (!zpl_dir_emit_dotdot(file, ctx))
170 return (false);
171 ctx->pos = 2;
172 }
173 return (true);
174 }
175 #endif /* HAVE_VFS_ITERATE */
176
177 #if defined(HAVE_INODE_TIMESTAMP_TRUNCATE)
178 #define zpl_inode_timestamp_truncate(ts, ip) timestamp_truncate(ts, ip)
179 #elif defined(HAVE_INODE_TIMESPEC64_TIMES)
180 #define zpl_inode_timestamp_truncate(ts, ip) \
181 timespec64_trunc(ts, (ip)->i_sb->s_time_gran)
182 #else
183 #define zpl_inode_timestamp_truncate(ts, ip) \
184 timespec_trunc(ts, (ip)->i_sb->s_time_gran)
185 #endif
186
187 #if defined(HAVE_INODE_OWNER_OR_CAPABLE)
188 #define zpl_inode_owner_or_capable(ns, ip) inode_owner_or_capable(ip)
189 #elif defined(HAVE_INODE_OWNER_OR_CAPABLE_IDMAPPED)
190 #define zpl_inode_owner_or_capable(ns, ip) inode_owner_or_capable(ns, ip)
191 #else
192 #error "Unsupported kernel"
193 #endif
194
195 #ifdef HAVE_SETATTR_PREPARE_USERNS
196 #define zpl_setattr_prepare(ns, dentry, ia) setattr_prepare(ns, dentry, ia)
197 #else
198 /*
199 * Use kernel-provided version, or our own from
200 * linux/vfs_compat.h
201 */
202 #define zpl_setattr_prepare(ns, dentry, ia) setattr_prepare(dentry, ia)
203 #endif
204
205 #endif /* _SYS_ZPL_H */