]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - fs/aufs/dir.h
UBUNTU: SAUCE: Import aufs driver
[mirror_ubuntu-zesty-kernel.git] / fs / aufs / dir.h
1 /*
2 * Copyright (C) 2005-2016 Junjiro R. Okajima
3 *
4 * This program, aufs is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /*
19 * directory operations
20 */
21
22 #ifndef __AUFS_DIR_H__
23 #define __AUFS_DIR_H__
24
25 #ifdef __KERNEL__
26
27 #include <linux/fs.h>
28
29 /* ---------------------------------------------------------------------- */
30
31 /* need to be faster and smaller */
32
33 struct au_nhash {
34 unsigned int nh_num;
35 struct hlist_head *nh_head;
36 };
37
38 struct au_vdir_destr {
39 unsigned char len;
40 unsigned char name[0];
41 } __packed;
42
43 struct au_vdir_dehstr {
44 struct hlist_node hash;
45 union {
46 struct au_vdir_destr *str;
47 struct llist_node lnode; /* delayed free */
48 };
49 } ____cacheline_aligned_in_smp;
50
51 struct au_vdir_de {
52 ino_t de_ino;
53 unsigned char de_type;
54 /* caution: packed */
55 struct au_vdir_destr de_str;
56 } __packed;
57
58 struct au_vdir_wh {
59 struct hlist_node wh_hash;
60 #ifdef CONFIG_AUFS_SHWH
61 ino_t wh_ino;
62 aufs_bindex_t wh_bindex;
63 unsigned char wh_type;
64 #else
65 aufs_bindex_t wh_bindex;
66 #endif
67 /* caution: packed */
68 struct au_vdir_destr wh_str;
69 } __packed;
70
71 union au_vdir_deblk_p {
72 unsigned char *deblk;
73 struct au_vdir_de *de;
74 };
75
76 struct au_vdir {
77 unsigned char **vd_deblk;
78 unsigned long vd_nblk;
79 struct {
80 unsigned long ul;
81 union au_vdir_deblk_p p;
82 } vd_last;
83
84 unsigned long vd_version;
85 unsigned int vd_deblk_sz;
86 union {
87 unsigned long vd_jiffy;
88 struct llist_node vd_lnode; /* delayed free */
89 };
90 } ____cacheline_aligned_in_smp;
91
92 /* ---------------------------------------------------------------------- */
93
94 /* dir.c */
95 extern const struct file_operations aufs_dir_fop;
96 void au_add_nlink(struct inode *dir, struct inode *h_dir);
97 void au_sub_nlink(struct inode *dir, struct inode *h_dir);
98 loff_t au_dir_size(struct file *file, struct dentry *dentry);
99 void au_dir_ts(struct inode *dir, aufs_bindex_t bsrc);
100 int au_test_empty_lower(struct dentry *dentry);
101 int au_test_empty(struct dentry *dentry, struct au_nhash *whlist);
102
103 /* vdir.c */
104 unsigned int au_rdhash_est(loff_t sz);
105 int au_nhash_alloc(struct au_nhash *nhash, unsigned int num_hash, gfp_t gfp);
106 void au_nhash_wh_free(struct au_nhash *whlist);
107 int au_nhash_test_longer_wh(struct au_nhash *whlist, aufs_bindex_t btgt,
108 int limit);
109 int au_nhash_test_known_wh(struct au_nhash *whlist, char *name, int nlen);
110 int au_nhash_append_wh(struct au_nhash *whlist, char *name, int nlen, ino_t ino,
111 unsigned int d_type, aufs_bindex_t bindex,
112 unsigned char shwh);
113 void au_vdir_free(struct au_vdir *vdir, int atonce);
114 int au_vdir_init(struct file *file);
115 int au_vdir_fill_de(struct file *file, struct dir_context *ctx);
116
117 /* ioctl.c */
118 long aufs_ioctl_dir(struct file *file, unsigned int cmd, unsigned long arg);
119
120 #ifdef CONFIG_AUFS_RDU
121 /* rdu.c */
122 long au_rdu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
123 #ifdef CONFIG_COMPAT
124 long au_rdu_compat_ioctl(struct file *file, unsigned int cmd,
125 unsigned long arg);
126 #endif
127 #else
128 AuStub(long, au_rdu_ioctl, return -EINVAL, struct file *file,
129 unsigned int cmd, unsigned long arg)
130 #ifdef CONFIG_COMPAT
131 AuStub(long, au_rdu_compat_ioctl, return -EINVAL, struct file *file,
132 unsigned int cmd, unsigned long arg)
133 #endif
134 #endif
135
136 #endif /* __KERNEL__ */
137 #endif /* __AUFS_DIR_H__ */