]> git.proxmox.com Git - mirror_zfs-debian.git/blob - include/sys/zpl.h
Imported Upstream version 0.6.2
[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/vfs.h>
29 #include <linux/vfs_compat.h>
30 #include <linux/xattr_compat.h>
31 #include <linux/dcache_compat.h>
32 #include <linux/exportfs.h>
33 #include <linux/writeback.h>
34 #include <linux/falloc.h>
35
36 /* zpl_inode.c */
37 extern void zpl_vap_init(vattr_t *vap, struct inode *dir,
38 zpl_umode_t mode, cred_t *cr);
39
40 extern const struct inode_operations zpl_inode_operations;
41 extern const struct inode_operations zpl_dir_inode_operations;
42 extern const struct inode_operations zpl_symlink_inode_operations;
43 extern const struct inode_operations zpl_special_inode_operations;
44 extern dentry_operations_t zpl_dentry_operations;
45
46 /* zpl_file.c */
47 extern ssize_t zpl_read_common(struct inode *ip, const char *buf,
48 size_t len, loff_t pos, uio_seg_t segment, int flags, cred_t *cr);
49 extern ssize_t zpl_write_common(struct inode *ip, const char *buf,
50 size_t len, loff_t pos, uio_seg_t segment, int flags, cred_t *cr);
51 extern long zpl_fallocate_common(struct inode *ip, int mode,
52 loff_t offset, loff_t len);
53
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_sbs(int64_t bytes_to_scan, void *private);
60
61 typedef struct zpl_mount_data {
62 const char *z_osname; /* Dataset name */
63 void *z_data; /* Mount options string */
64 } zpl_mount_data_t;
65
66 extern const struct super_operations zpl_super_operations;
67 extern const struct export_operations zpl_export_operations;
68 extern struct file_system_type zpl_fs_type;
69
70 /* zpl_xattr.c */
71 extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
72 extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
73 const struct qstr *qstr);
74
75 extern xattr_handler_t *zpl_xattr_handlers[];
76
77 /* zpl_ctldir.c */
78 extern const struct file_operations zpl_fops_root;
79 extern const struct inode_operations zpl_ops_root;
80
81 extern const struct file_operations zpl_fops_snapdir;
82 extern const struct inode_operations zpl_ops_snapdir;
83 #ifdef HAVE_AUTOMOUNT
84 extern const struct dentry_operations zpl_dops_snapdirs;
85 #else
86 extern const struct inode_operations zpl_ops_snapdirs;
87 #endif /* HAVE_AUTOMOUNT */
88
89 extern const struct file_operations zpl_fops_shares;
90 extern const struct inode_operations zpl_ops_shares;
91
92 #ifdef HAVE_VFS_ITERATE
93
94 #define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
95 .actor = _actor, \
96 .pos = _pos, \
97 }
98
99 #else
100
101 typedef struct dir_context {
102 void *dirent;
103 const filldir_t actor;
104 loff_t pos;
105 } dir_context_t;
106
107 #define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
108 .dirent = _dirent, \
109 .actor = _actor, \
110 .pos = _pos, \
111 }
112
113 static inline bool
114 dir_emit(struct dir_context *ctx, const char *name, int namelen,
115 uint64_t ino, unsigned type)
116 {
117 return ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type) == 0;
118 }
119
120 static inline bool
121 dir_emit_dot(struct file *file, struct dir_context *ctx)
122 {
123 return ctx->actor(ctx->dirent, ".", 1, ctx->pos,
124 file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0;
125 }
126
127 static inline bool
128 dir_emit_dotdot(struct file *file, struct dir_context *ctx)
129 {
130 return ctx->actor(ctx->dirent, "..", 2, ctx->pos,
131 parent_ino(file->f_path.dentry), DT_DIR) == 0;
132 }
133
134 static inline bool
135 dir_emit_dots(struct file *file, struct dir_context *ctx)
136 {
137 if (ctx->pos == 0) {
138 if (!dir_emit_dot(file, ctx))
139 return false;
140 ctx->pos = 1;
141 }
142 if (ctx->pos == 1) {
143 if (!dir_emit_dotdot(file, ctx))
144 return false;
145 ctx->pos = 2;
146 }
147 return true;
148 }
149 #endif /* HAVE_VFS_ITERATE */
150
151 #endif /* _SYS_ZPL_H */