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