]> git.proxmox.com Git - mirror_zfs.git/blame - include/sys/zpl.h
cstyle: Resolve C style issues
[mirror_zfs.git] / include / sys / zpl.h
CommitLineData
1efb473f
BB
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/vfs.h>
7268e1be 29#include <linux/vfs_compat.h>
777d4af8 30#include <linux/xattr_compat.h>
7b3e34ba 31#include <linux/dcache_compat.h>
055656d4 32#include <linux/exportfs.h>
dde471ef 33#include <linux/writeback.h>
cb2d1901 34#include <linux/falloc.h>
e3dc14b8 35#include <linux/task_io_accounting_ops.h>
1efb473f
BB
36
37/* zpl_inode.c */
ebe7e575 38extern void zpl_vap_init(vattr_t *vap, struct inode *dir,
7b3e34ba 39 zpl_umode_t mode, cred_t *cr);
ebe7e575 40
1efb473f
BB
41extern const struct inode_operations zpl_inode_operations;
42extern const struct inode_operations zpl_dir_inode_operations;
43extern const struct inode_operations zpl_symlink_inode_operations;
44extern const struct inode_operations zpl_special_inode_operations;
7b3e34ba 45extern dentry_operations_t zpl_dentry_operations;
1efb473f
BB
46
47/* zpl_file.c */
48extern ssize_t zpl_read_common(struct inode *ip, const char *buf,
49 size_t len, loff_t pos, uio_seg_t segment, int flags, cred_t *cr);
50extern ssize_t zpl_write_common(struct inode *ip, const char *buf,
51 size_t len, loff_t pos, uio_seg_t segment, int flags, cred_t *cr);
cb2d1901
ED
52extern long zpl_fallocate_common(struct inode *ip, int mode,
53 loff_t offset, loff_t len);
1efb473f
BB
54
55extern const struct address_space_operations zpl_address_space_operations;
56extern const struct file_operations zpl_file_operations;
57extern const struct file_operations zpl_dir_file_operations;
58
59/* zpl_super.c */
ab26409d
BB
60extern void zpl_prune_sbs(int64_t bytes_to_scan, void *private);
61
1efb473f
BB
62typedef struct zpl_mount_data {
63 const char *z_osname; /* Dataset name */
64 void *z_data; /* Mount options string */
1efb473f
BB
65} zpl_mount_data_t;
66
67extern const struct super_operations zpl_super_operations;
055656d4 68extern const struct export_operations zpl_export_operations;
1efb473f
BB
69extern struct file_system_type zpl_fs_type;
70
71/* zpl_xattr.c */
72extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
5c03efc3
BB
73extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
74 const struct qstr *qstr);
b695c34e 75#if defined(CONFIG_FS_POSIX_ACL)
023699cd
MM
76extern int zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl);
77extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
78#if !defined(HAVE_GET_ACL)
79#if defined(HAVE_CHECK_ACL_WITH_FLAGS)
d1d7e268 80extern int zpl_check_acl(struct inode *inode, int mask, unsigned int flags);
023699cd
MM
81#elif defined(HAVE_CHECK_ACL)
82extern int zpl_check_acl(struct inode *inode, int mask);
83#elif defined(HAVE_PERMISSION_WITH_NAMEIDATA)
84extern int zpl_permission(struct inode *ip, int mask, struct nameidata *nd);
85#elif defined(HAVE_PERMISSION)
86extern int zpl_permission(struct inode *ip, int mask);
87#endif /* HAVE_CHECK_ACL | HAVE_PERMISSION */
88#endif /* HAVE_GET_ACL */
89
90extern int zpl_init_acl(struct inode *ip, struct inode *dir);
91extern int zpl_chmod_acl(struct inode *ip);
b695c34e
MM
92#else
93static inline int
94zpl_init_acl(struct inode *ip, struct inode *dir)
95{
96 return (0);
97}
98
99static inline int
100zpl_chmod_acl(struct inode *ip)
101{
102 return (0);
103}
104#endif /* CONFIG_FS_POSIX_ACL */
1efb473f 105
777d4af8 106extern xattr_handler_t *zpl_xattr_handlers[];
1efb473f 107
ebe7e575
BB
108/* zpl_ctldir.c */
109extern const struct file_operations zpl_fops_root;
110extern const struct inode_operations zpl_ops_root;
111
112extern const struct file_operations zpl_fops_snapdir;
113extern const struct inode_operations zpl_ops_snapdir;
114#ifdef HAVE_AUTOMOUNT
115extern const struct dentry_operations zpl_dops_snapdirs;
116#else
117extern const struct inode_operations zpl_ops_snapdirs;
118#endif /* HAVE_AUTOMOUNT */
119
120extern const struct file_operations zpl_fops_shares;
121extern const struct inode_operations zpl_ops_shares;
122
0f37d0c8
RY
123#ifdef HAVE_VFS_ITERATE
124
d1d7e268 125#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
0f37d0c8
RY
126 .actor = _actor, \
127 .pos = _pos, \
128}
129
130#else
131
132typedef struct dir_context {
133 void *dirent;
134 const filldir_t actor;
135 loff_t pos;
136} dir_context_t;
137
d1d7e268 138#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
0f37d0c8
RY
139 .dirent = _dirent, \
140 .actor = _actor, \
141 .pos = _pos, \
142}
143
144static inline bool
145dir_emit(struct dir_context *ctx, const char *name, int namelen,
146 uint64_t ino, unsigned type)
147{
d1d7e268
MK
148 return (ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type)
149 == 0);
0f37d0c8
RY
150}
151
152static inline bool
153dir_emit_dot(struct file *file, struct dir_context *ctx)
154{
d1d7e268
MK
155 return (ctx->actor(ctx->dirent, ".", 1, ctx->pos,
156 file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0);
0f37d0c8
RY
157}
158
159static inline bool
160dir_emit_dotdot(struct file *file, struct dir_context *ctx)
161{
d1d7e268
MK
162 return (ctx->actor(ctx->dirent, "..", 2, ctx->pos,
163 parent_ino(file->f_path.dentry), DT_DIR) == 0);
0f37d0c8
RY
164}
165
166static inline bool
167dir_emit_dots(struct file *file, struct dir_context *ctx)
168{
169 if (ctx->pos == 0) {
170 if (!dir_emit_dot(file, ctx))
d1d7e268 171 return (false);
0f37d0c8
RY
172 ctx->pos = 1;
173 }
174 if (ctx->pos == 1) {
175 if (!dir_emit_dotdot(file, ctx))
d1d7e268 176 return (false);
0f37d0c8
RY
177 ctx->pos = 2;
178 }
d1d7e268 179 return (true);
0f37d0c8
RY
180}
181#endif /* HAVE_VFS_ITERATE */
182
1efb473f 183#endif /* _SYS_ZPL_H */