Cleaning up uio headers
[zfs.git] / include / os / linux / zfs / sys / zpl.h
blobb0bb9c29c0b4a7e080680005b949bd39b423c96b
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2011, Lawrence Livermore National Security, LLC.
25 #ifndef _SYS_ZPL_H
26 #define _SYS_ZPL_H
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>
40 /* zpl_inode.c */
41 extern void zpl_vap_init(vattr_t *vap, struct inode *dir,
42 umode_t mode, cred_t *cr);
44 extern const struct inode_operations zpl_inode_operations;
45 extern const struct inode_operations zpl_dir_inode_operations;
46 extern const struct inode_operations zpl_symlink_inode_operations;
47 extern const struct inode_operations zpl_special_inode_operations;
48 extern dentry_operations_t zpl_dentry_operations;
49 extern const struct address_space_operations zpl_address_space_operations;
50 extern const struct file_operations zpl_file_operations;
51 extern const struct file_operations zpl_dir_file_operations;
53 /* zpl_super.c */
54 extern void zpl_prune_sb(int64_t nr_to_scan, void *arg);
56 extern const struct super_operations zpl_super_operations;
57 extern const struct export_operations zpl_export_operations;
58 extern struct file_system_type zpl_fs_type;
60 /* zpl_xattr.c */
61 extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
62 extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
63 const struct qstr *qstr);
64 #if defined(CONFIG_FS_POSIX_ACL)
65 #if defined(HAVE_SET_ACL)
66 extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type);
67 #endif /* HAVE_SET_ACL */
68 extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
69 extern int zpl_init_acl(struct inode *ip, struct inode *dir);
70 extern int zpl_chmod_acl(struct inode *ip);
71 #else
72 static inline int
73 zpl_init_acl(struct inode *ip, struct inode *dir)
75 return (0);
78 static inline int
79 zpl_chmod_acl(struct inode *ip)
81 return (0);
83 #endif /* CONFIG_FS_POSIX_ACL */
85 extern xattr_handler_t *zpl_xattr_handlers[];
87 /* zpl_ctldir.c */
88 extern const struct file_operations zpl_fops_root;
89 extern const struct inode_operations zpl_ops_root;
91 extern const struct file_operations zpl_fops_snapdir;
92 extern const struct inode_operations zpl_ops_snapdir;
93 extern const struct dentry_operations zpl_dops_snapdirs;
95 extern const struct file_operations zpl_fops_shares;
96 extern const struct inode_operations zpl_ops_shares;
98 #if defined(HAVE_VFS_ITERATE) || defined(HAVE_VFS_ITERATE_SHARED)
100 #define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
101 .actor = _actor, \
102 .pos = _pos, \
105 typedef struct dir_context zpl_dir_context_t;
107 #define zpl_dir_emit dir_emit
108 #define zpl_dir_emit_dot dir_emit_dot
109 #define zpl_dir_emit_dotdot dir_emit_dotdot
110 #define zpl_dir_emit_dots dir_emit_dots
112 #else
114 typedef struct zpl_dir_context {
115 void *dirent;
116 const filldir_t actor;
117 loff_t pos;
118 } zpl_dir_context_t;
120 #define ZPL_DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
121 .dirent = _dirent, \
122 .actor = _actor, \
123 .pos = _pos, \
126 static inline bool
127 zpl_dir_emit(zpl_dir_context_t *ctx, const char *name, int namelen,
128 uint64_t ino, unsigned type)
130 return (!ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type));
133 static inline bool
134 zpl_dir_emit_dot(struct file *file, zpl_dir_context_t *ctx)
136 return (ctx->actor(ctx->dirent, ".", 1, ctx->pos,
137 file_inode(file)->i_ino, DT_DIR) == 0);
140 static inline bool
141 zpl_dir_emit_dotdot(struct file *file, zpl_dir_context_t *ctx)
143 return (ctx->actor(ctx->dirent, "..", 2, ctx->pos,
144 parent_ino(file_dentry(file)), DT_DIR) == 0);
147 static inline bool
148 zpl_dir_emit_dots(struct file *file, zpl_dir_context_t *ctx)
150 if (ctx->pos == 0) {
151 if (!zpl_dir_emit_dot(file, ctx))
152 return (false);
153 ctx->pos = 1;
155 if (ctx->pos == 1) {
156 if (!zpl_dir_emit_dotdot(file, ctx))
157 return (false);
158 ctx->pos = 2;
160 return (true);
162 #endif /* HAVE_VFS_ITERATE */
164 #if defined(HAVE_INODE_TIMESTAMP_TRUNCATE)
165 #define zpl_inode_timestamp_truncate(ts, ip) timestamp_truncate(ts, ip)
166 #elif defined(HAVE_INODE_TIMESPEC64_TIMES)
167 #define zpl_inode_timestamp_truncate(ts, ip) \
168 timespec64_trunc(ts, (ip)->i_sb->s_time_gran)
169 #else
170 #define zpl_inode_timestamp_truncate(ts, ip) \
171 timespec_trunc(ts, (ip)->i_sb->s_time_gran)
172 #endif
174 #endif /* _SYS_ZPL_H */