]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - zfs/include/sys/zpl.h
UBUNTU: SAUCE: (noup) Update spl to 0.6.5.9-1, zfs to 0.6.5.9-2
[mirror_ubuntu-artful-kernel.git] / zfs / include / sys / zpl.h
CommitLineData
87d546d8
TG
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 */
42extern void zpl_vap_init(vattr_t *vap, struct inode *dir,
43 zpl_umode_t mode, cred_t *cr);
44
45extern const struct inode_operations zpl_inode_operations;
46extern const struct inode_operations zpl_dir_inode_operations;
47extern const struct inode_operations zpl_symlink_inode_operations;
48extern const struct inode_operations zpl_special_inode_operations;
49extern dentry_operations_t zpl_dentry_operations;
50
51/* zpl_file.c */
52extern 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);
55extern 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)
59extern 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
63extern const struct address_space_operations zpl_address_space_operations;
64extern const struct file_operations zpl_file_operations;
65extern const struct file_operations zpl_dir_file_operations;
66
67/* zpl_super.c */
68extern void zpl_prune_sb(int64_t nr_to_scan, void *arg);
69
70extern const struct super_operations zpl_super_operations;
71extern const struct export_operations zpl_export_operations;
72extern struct file_system_type zpl_fs_type;
73
74/* zpl_xattr.c */
75extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
76extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
77 const struct qstr *qstr);
78#if defined(CONFIG_FS_POSIX_ACL)
79extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type);
80extern 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)
83extern int zpl_check_acl(struct inode *inode, int mask, unsigned int flags);
84#elif defined(HAVE_CHECK_ACL)
85extern int zpl_check_acl(struct inode *inode, int mask);
86#elif defined(HAVE_PERMISSION_WITH_NAMEIDATA)
87extern int zpl_permission(struct inode *ip, int mask, struct nameidata *nd);
88#elif defined(HAVE_PERMISSION)
89extern int zpl_permission(struct inode *ip, int mask);
90#endif /* HAVE_CHECK_ACL | HAVE_PERMISSION */
91#endif /* HAVE_GET_ACL */
92
93extern int zpl_init_acl(struct inode *ip, struct inode *dir);
94extern int zpl_chmod_acl(struct inode *ip);
95#else
96static inline int
97zpl_init_acl(struct inode *ip, struct inode *dir)
98{
99 return (0);
100}
101
102static inline int
103zpl_chmod_acl(struct inode *ip)
104{
105 return (0);
106}
107#endif /* CONFIG_FS_POSIX_ACL */
108
109extern xattr_handler_t *zpl_xattr_handlers[];
110
111/* zpl_ctldir.c */
112extern const struct file_operations zpl_fops_root;
113extern const struct inode_operations zpl_ops_root;
114
115extern const struct file_operations zpl_fops_snapdir;
116extern const struct inode_operations zpl_ops_snapdir;
117#ifdef HAVE_AUTOMOUNT
118extern const struct dentry_operations zpl_dops_snapdirs;
119#else
120extern const struct inode_operations zpl_ops_snapdirs;
121#endif /* HAVE_AUTOMOUNT */
122
123extern const struct file_operations zpl_fops_shares;
124extern const struct inode_operations zpl_ops_shares;
125
126#if defined(HAVE_VFS_ITERATE) || defined(HAVE_VFS_ITERATE_SHARED)
127
128#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
129 .actor = _actor, \
130 .pos = _pos, \
131}
132
133#else
134
135typedef struct dir_context {
136 void *dirent;
137 const filldir_t actor;
138 loff_t pos;
139} dir_context_t;
140
141#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
142 .dirent = _dirent, \
143 .actor = _actor, \
144 .pos = _pos, \
145}
146
147static inline bool
148dir_emit(struct dir_context *ctx, const char *name, int namelen,
149 uint64_t ino, unsigned type)
150{
151 return (ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type)
152 == 0);
153}
154
155static inline bool
156dir_emit_dot(struct file *file, struct dir_context *ctx)
157{
158 return (ctx->actor(ctx->dirent, ".", 1, ctx->pos,
159 file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0);
160}
161
162static inline bool
163dir_emit_dotdot(struct file *file, struct dir_context *ctx)
164{
165 return (ctx->actor(ctx->dirent, "..", 2, ctx->pos,
166 parent_ino(file->f_path.dentry), DT_DIR) == 0);
167}
168
169static inline bool
170dir_emit_dots(struct file *file, struct dir_context *ctx)
171{
172 if (ctx->pos == 0) {
173 if (!dir_emit_dot(file, ctx))
174 return (false);
175 ctx->pos = 1;
176 }
177 if (ctx->pos == 1) {
178 if (!dir_emit_dotdot(file, ctx))
179 return (false);
180 ctx->pos = 2;
181 }
182 return (true);
183}
184#endif /* HAVE_VFS_ITERATE */
185
186#endif /* _SYS_ZPL_H */