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