Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / fs / aufs / dir.h
1 /*
2  * Copyright (C) 2005-2013 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, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 /*
20  * directory operations
21  */
22
23 #ifndef __AUFS_DIR_H__
24 #define __AUFS_DIR_H__
25
26 #ifdef __KERNEL__
27
28 #include <linux/fs.h>
29
30 /* ---------------------------------------------------------------------- */
31
32 /* need to be faster and smaller */
33
34 struct au_nhash {
35         unsigned int            nh_num;
36         struct hlist_head       *nh_head;
37 };
38
39 struct au_vdir_destr {
40         unsigned char   len;
41         unsigned char   name[0];
42 } __packed;
43
44 struct au_vdir_dehstr {
45         struct hlist_node       hash;
46         struct au_vdir_destr    *str;
47 } ____cacheline_aligned_in_smp;
48
49 struct au_vdir_de {
50         ino_t                   de_ino;
51         unsigned char           de_type;
52         /* caution: packed */
53         struct au_vdir_destr    de_str;
54 } __packed;
55
56 struct au_vdir_wh {
57         struct hlist_node       wh_hash;
58 #ifdef CONFIG_AUFS_SHWH
59         ino_t                   wh_ino;
60         aufs_bindex_t           wh_bindex;
61         unsigned char           wh_type;
62 #else
63         aufs_bindex_t           wh_bindex;
64 #endif
65         /* caution: packed */
66         struct au_vdir_destr    wh_str;
67 } __packed;
68
69 union au_vdir_deblk_p {
70         unsigned char           *deblk;
71         struct au_vdir_de       *de;
72 };
73
74 struct au_vdir {
75         unsigned char   **vd_deblk;
76         unsigned long   vd_nblk;
77         struct {
78                 unsigned long           ul;
79                 union au_vdir_deblk_p   p;
80         } vd_last;
81
82         unsigned long   vd_version;
83         unsigned int    vd_deblk_sz;
84         unsigned long   vd_jiffy;
85 } ____cacheline_aligned_in_smp;
86
87 /* ---------------------------------------------------------------------- */
88
89 /* dir.c */
90 extern const struct file_operations aufs_dir_fop;
91 void au_add_nlink(struct inode *dir, struct inode *h_dir);
92 void au_sub_nlink(struct inode *dir, struct inode *h_dir);
93 loff_t au_dir_size(struct file *file, struct dentry *dentry);
94 int au_test_empty_lower(struct dentry *dentry);
95 int au_test_empty(struct dentry *dentry, struct au_nhash *whlist);
96
97 /* vdir.c */
98 unsigned int au_rdhash_est(loff_t sz);
99 int au_nhash_alloc(struct au_nhash *nhash, unsigned int num_hash, gfp_t gfp);
100 void au_nhash_wh_free(struct au_nhash *whlist);
101 int au_nhash_test_longer_wh(struct au_nhash *whlist, aufs_bindex_t btgt,
102                             int limit);
103 int au_nhash_test_known_wh(struct au_nhash *whlist, char *name, int nlen);
104 int au_nhash_append_wh(struct au_nhash *whlist, char *name, int nlen, ino_t ino,
105                        unsigned int d_type, aufs_bindex_t bindex,
106                        unsigned char shwh);
107 void au_vdir_free(struct au_vdir *vdir);
108 int au_vdir_init(struct file *file);
109 int au_vdir_fill_de(struct file *file, void *dirent, filldir_t filldir);
110
111 /* ioctl.c */
112 long aufs_ioctl_dir(struct file *file, unsigned int cmd, unsigned long arg);
113
114 #ifdef CONFIG_AUFS_RDU
115 /* rdu.c */
116 long au_rdu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
117 #ifdef CONFIG_COMPAT
118 long au_rdu_compat_ioctl(struct file *file, unsigned int cmd,
119                          unsigned long arg);
120 #endif
121 #else
122 static inline long au_rdu_ioctl(struct file *file, unsigned int cmd,
123                                 unsigned long arg)
124 {
125         return -EINVAL;
126 }
127 #ifdef CONFIG_COMPAT
128 static inline long au_rdu_compat_ioctl(struct file *file, unsigned int cmd,
129                                        unsigned long arg)
130 {
131         return -EINVAL;
132 }
133 #endif
134 #endif
135
136 #endif /* __KERNEL__ */
137 #endif /* __AUFS_DIR_H__ */