aufs: fix up for the new stable kernel
[pandora-kernel.git] / fs / aufs / opts.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  * mount options/flags
21  */
22
23 #ifndef __AUFS_OPTS_H__
24 #define __AUFS_OPTS_H__
25
26 #ifdef __KERNEL__
27
28 #include <linux/path.h>
29
30 struct file;
31 struct super_block;
32
33 /* ---------------------------------------------------------------------- */
34
35 /* mount flags */
36 #define AuOpt_XINO              1               /* external inode number bitmap
37                                                    and translation table */
38 #define AuOpt_TRUNC_XINO        (1 << 1)        /* truncate xino files */
39 #define AuOpt_UDBA_NONE         (1 << 2)        /* users direct branch access */
40 #define AuOpt_UDBA_REVAL        (1 << 3)
41 #define AuOpt_UDBA_HNOTIFY      (1 << 4)
42 #define AuOpt_SHWH              (1 << 5)        /* show whiteout */
43 #define AuOpt_PLINK             (1 << 6)        /* pseudo-link */
44 #define AuOpt_DIRPERM1          (1 << 7)        /* unimplemented */
45 #define AuOpt_REFROF            (1 << 8)        /* unimplemented */
46 #define AuOpt_ALWAYS_DIROPQ     (1 << 9)        /* policy to creating diropq */
47 #define AuOpt_SUM               (1 << 10)       /* summation for statfs(2) */
48 #define AuOpt_SUM_W             (1 << 11)       /* unimplemented */
49 #define AuOpt_WARN_PERM         (1 << 12)       /* warn when add-branch */
50 #define AuOpt_VERBOSE           (1 << 13)       /* busy inode when del-branch */
51 #define AuOpt_DIO               (1 << 14)       /* direct io */
52
53 #ifndef CONFIG_AUFS_HNOTIFY
54 #undef AuOpt_UDBA_HNOTIFY
55 #define AuOpt_UDBA_HNOTIFY      0
56 #endif
57 #ifndef CONFIG_AUFS_SHWH
58 #undef AuOpt_SHWH
59 #define AuOpt_SHWH              0
60 #endif
61
62 #define AuOpt_Def       (AuOpt_XINO \
63                          | AuOpt_UDBA_REVAL \
64                          | AuOpt_PLINK \
65                          /* | AuOpt_DIRPERM1 */ \
66                          | AuOpt_WARN_PERM)
67 #define AuOptMask_UDBA  (AuOpt_UDBA_NONE \
68                          | AuOpt_UDBA_REVAL \
69                          | AuOpt_UDBA_HNOTIFY)
70
71 #define au_opt_test(flags, name)        (flags & AuOpt_##name)
72 #define au_opt_set(flags, name) do { \
73         BUILD_BUG_ON(AuOpt_##name & AuOptMask_UDBA); \
74         ((flags) |= AuOpt_##name); \
75 } while (0)
76 #define au_opt_set_udba(flags, name) do { \
77         (flags) &= ~AuOptMask_UDBA; \
78         ((flags) |= AuOpt_##name); \
79 } while (0)
80 #define au_opt_clr(flags, name) do { \
81         ((flags) &= ~AuOpt_##name); \
82 } while (0)
83
84 static inline unsigned int au_opts_plink(unsigned int mntflags)
85 {
86 #ifdef CONFIG_PROC_FS
87         return mntflags;
88 #else
89         return mntflags & ~AuOpt_PLINK;
90 #endif
91 }
92
93 /* ---------------------------------------------------------------------- */
94
95 /* policies to select one among multiple writable branches */
96 enum {
97         AuWbrCreate_TDP,        /* top down parent */
98         AuWbrCreate_RR,         /* round robin */
99         AuWbrCreate_MFS,        /* most free space */
100         AuWbrCreate_MFSV,       /* mfs with seconds */
101         AuWbrCreate_MFSRR,      /* mfs then rr */
102         AuWbrCreate_MFSRRV,     /* mfs then rr with seconds */
103         AuWbrCreate_PMFS,       /* parent and mfs */
104         AuWbrCreate_PMFSV,      /* parent and mfs with seconds */
105         AuWbrCreate_PMFSRR,     /* parent, mfs and round-robin */
106         AuWbrCreate_PMFSRRV,    /* plus seconds */
107
108         AuWbrCreate_Def = AuWbrCreate_TDP
109 };
110
111 enum {
112         AuWbrCopyup_TDP,        /* top down parent */
113         AuWbrCopyup_BUP,        /* bottom up parent */
114         AuWbrCopyup_BU,         /* bottom up */
115
116         AuWbrCopyup_Def = AuWbrCopyup_TDP
117 };
118
119 /* ---------------------------------------------------------------------- */
120
121 struct au_opt_add {
122         aufs_bindex_t   bindex;
123         char            *pathname;
124         int             perm;
125         struct path     path;
126 };
127
128 struct au_opt_del {
129         char            *pathname;
130         struct path     h_path;
131 };
132
133 struct au_opt_mod {
134         char            *path;
135         int             perm;
136         struct dentry   *h_root;
137 };
138
139 struct au_opt_xino {
140         char            *path;
141         struct file     *file;
142 };
143
144 struct au_opt_xino_itrunc {
145         aufs_bindex_t   bindex;
146 };
147
148 struct au_opt_wbr_create {
149         int                     wbr_create;
150         int                     mfs_second;
151         unsigned long long      mfsrr_watermark;
152 };
153
154 struct au_opt {
155         int type;
156         union {
157                 struct au_opt_xino      xino;
158                 struct au_opt_xino_itrunc xino_itrunc;
159                 struct au_opt_add       add;
160                 struct au_opt_del       del;
161                 struct au_opt_mod       mod;
162                 int                     dirwh;
163                 int                     rdcache;
164                 unsigned int            rdblk;
165                 unsigned int            rdhash;
166                 int                     udba;
167                 struct au_opt_wbr_create wbr_create;
168                 int                     wbr_copyup;
169         };
170 };
171
172 /* opts flags */
173 #define AuOpts_REMOUNT          1
174 #define AuOpts_REFRESH          (1 << 1)
175 #define AuOpts_TRUNC_XIB        (1 << 2)
176 #define AuOpts_REFRESH_DYAOP    (1 << 3)
177 #define au_ftest_opts(flags, name)      ((flags) & AuOpts_##name)
178 #define au_fset_opts(flags, name) \
179         do { (flags) |= AuOpts_##name; } while (0)
180 #define au_fclr_opts(flags, name) \
181         do { (flags) &= ~AuOpts_##name; } while (0)
182
183 struct au_opts {
184         struct au_opt   *opt;
185         int             max_opt;
186
187         unsigned int    given_udba;
188         unsigned int    flags;
189         unsigned long   sb_flags;
190 };
191
192 /* ---------------------------------------------------------------------- */
193
194 char *au_optstr_br_perm(int brperm);
195 const char *au_optstr_udba(int udba);
196 const char *au_optstr_wbr_copyup(int wbr_copyup);
197 const char *au_optstr_wbr_create(int wbr_create);
198
199 void au_opts_free(struct au_opts *opts);
200 int au_opts_parse(struct super_block *sb, char *str, struct au_opts *opts);
201 int au_opts_verify(struct super_block *sb, unsigned long sb_flags,
202                    unsigned int pending);
203 int au_opts_mount(struct super_block *sb, struct au_opts *opts);
204 int au_opts_remount(struct super_block *sb, struct au_opts *opts);
205
206 unsigned int au_opt_udba(struct super_block *sb);
207
208 /* ---------------------------------------------------------------------- */
209
210 #endif /* __KERNEL__ */
211 #endif /* __AUFS_OPTS_H__ */