opts.h 5.94 KB
Newer Older
1
2
/* SPDX-License-Identifier: GPL-2.0 */
/*
3
 * Copyright (C) 2005-2020 Junjiro R. Okajima
4
5
6
7
8
9
10
11
12
13
14
15
16
 *
 * This program, aufs is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
19
20
21
22
23
24
25
26
27
28
29
 */

/*
 * mount options/flags
 */

#ifndef __AUFS_OPTS_H__
#define __AUFS_OPTS_H__

#ifdef __KERNEL__

#include <linux/path.h>

J. R. Okajima's avatar
J. R. Okajima committed
30
31
struct file;

J. R. Okajima's avatar
J. R. Okajima committed
32
33
34
35
36
/* ---------------------------------------------------------------------- */

/* mount flags */
#define AuOpt_XINO		1		/* external inode number bitmap
						   and translation table */
J. R. Okajima's avatar
J. R. Okajima committed
37
#define AuOpt_TRUNC_XINO	(1 << 1)	/* truncate xino files */
38
39
#define AuOpt_UDBA_NONE		(1 << 2)	/* users direct branch access */
#define AuOpt_UDBA_REVAL	(1 << 3)
J. R. Okajima's avatar
J. R. Okajima committed
40
#define AuOpt_UDBA_HNOTIFY	(1 << 4)
J. R. Okajima's avatar
J. R. Okajima committed
41
#define AuOpt_SHWH		(1 << 5)	/* show whiteout */
42
#define AuOpt_PLINK		(1 << 6)	/* pseudo-link */
J. R. Okajima's avatar
J. R. Okajima committed
43
44
#define AuOpt_DIRPERM1		(1 << 7)	/* ignore the lower dir's perm
						   bits */
J. R. Okajima's avatar
J. R. Okajima committed
45
#define AuOpt_ALWAYS_DIROPQ	(1 << 9)	/* policy to creating diropq */
J. R. Okajima's avatar
J. R. Okajima committed
46
47
#define AuOpt_SUM		(1 << 10)	/* summation for statfs(2) */
#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 */
J. R. Okajima's avatar
J. R. Okajima committed
52

J. R. Okajima's avatar
J. R. Okajima committed
53
54
55
56
#ifndef CONFIG_AUFS_HNOTIFY
#undef AuOpt_UDBA_HNOTIFY
#define AuOpt_UDBA_HNOTIFY	0
#endif
57
58
59
60
#ifndef CONFIG_AUFS_DIRREN
#undef AuOpt_DIRREN
#define AuOpt_DIRREN		0
#endif
J. R. Okajima's avatar
J. R. Okajima committed
61
62
63
64
#ifndef CONFIG_AUFS_SHWH
#undef AuOpt_SHWH
#define AuOpt_SHWH		0
#endif
J. R. Okajima's avatar
J. R. Okajima committed
65

66
#define AuOpt_Def	(AuOpt_XINO \
67
			 | AuOpt_UDBA_REVAL \
J. R. Okajima's avatar
J. R. Okajima committed
68
69
			 | AuOpt_PLINK \
			 /* | AuOpt_DIRPERM1 */ \
70
			 | AuOpt_WARN_PERM)
71
#define AuOptMask_UDBA	(AuOpt_UDBA_NONE \
J. R. Okajima's avatar
J. R. Okajima committed
72
73
			 | AuOpt_UDBA_REVAL \
			 | AuOpt_UDBA_HNOTIFY)
J. R. Okajima's avatar
J. R. Okajima committed
74
75
76

#define au_opt_test(flags, name)	(flags & AuOpt_##name)
#define au_opt_set(flags, name) do { \
77
78
79
80
81
	BUILD_BUG_ON(AuOpt_##name & AuOptMask_UDBA); \
	((flags) |= AuOpt_##name); \
} while (0)
#define au_opt_set_udba(flags, name) do { \
	(flags) &= ~AuOptMask_UDBA; \
J. R. Okajima's avatar
J. R. Okajima committed
82
83
84
85
86
87
	((flags) |= AuOpt_##name); \
} while (0)
#define au_opt_clr(flags, name) do { \
	((flags) &= ~AuOpt_##name); \
} while (0)

88
89
90
91
92
93
94
95
96
static inline unsigned int au_opts_plink(unsigned int mntflags)
{
#ifdef CONFIG_PROC_FS
	return mntflags;
#else
	return mntflags & ~AuOpt_PLINK;
#endif
}

J. R. Okajima's avatar
J. R. Okajima committed
97
98
/* ---------------------------------------------------------------------- */

99
100
101
/* policies to select one among multiple writable branches */
enum {
	AuWbrCreate_TDP,	/* top down parent */
102
103
104
105
106
107
108
109
110
111
112
	AuWbrCreate_RR,		/* round robin */
	AuWbrCreate_MFS,	/* most free space */
	AuWbrCreate_MFSV,	/* mfs with seconds */
	AuWbrCreate_MFSRR,	/* mfs then rr */
	AuWbrCreate_MFSRRV,	/* mfs then rr with seconds */
	AuWbrCreate_TDMFS,	/* top down regardless parent and mfs */
	AuWbrCreate_TDMFSV,	/* top down regardless parent and mfs */
	AuWbrCreate_PMFS,	/* parent and mfs */
	AuWbrCreate_PMFSV,	/* parent and mfs with seconds */
	AuWbrCreate_PMFSRR,	/* parent, mfs and round-robin */
	AuWbrCreate_PMFSRRV,	/* plus seconds */
113
114
115
116
117
118

	AuWbrCreate_Def = AuWbrCreate_TDP
};

enum {
	AuWbrCopyup_TDP,	/* top down parent */
119
120
	AuWbrCopyup_BUP,	/* bottom up parent */
	AuWbrCopyup_BU,		/* bottom up */
121
122
123
124
125
126

	AuWbrCopyup_Def = AuWbrCopyup_TDP
};

/* ---------------------------------------------------------------------- */

127
128
129
130
131
132
133
struct au_opt_add {
	aufs_bindex_t	bindex;
	char		*pathname;
	int		perm;
	struct path	path;
};

134
135
136
137
138
struct au_opt_del {
	char		*pathname;
	struct path	h_path;
};

139
140
141
142
143
144
struct au_opt_mod {
	char		*path;
	int		perm;
	struct dentry	*h_root;
};

J. R. Okajima's avatar
J. R. Okajima committed
145
146
147
148
149
struct au_opt_xino {
	char		*path;
	struct file	*file;
};

J. R. Okajima's avatar
J. R. Okajima committed
150
151
152
153
struct au_opt_xino_itrunc {
	aufs_bindex_t	bindex;
};

154
155
struct au_opt_wbr_create {
	int			wbr_create;
156
157
	int			mfs_second;
	unsigned long long	mfsrr_watermark;
158
159
};

160
161
162
struct au_opt {
	int type;
	union {
J. R. Okajima's avatar
J. R. Okajima committed
163
		struct au_opt_xino	xino;
J. R. Okajima's avatar
J. R. Okajima committed
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;
J. R. Okajima's avatar
J. R. Okajima committed
168
		int			dirwh;
169
170
171
		int			rdcache;
		unsigned int		rdblk;
		unsigned int		rdhash;
J. R. Okajima's avatar
J. R. Okajima committed
172
		int			udba;
173
174
		struct au_opt_wbr_create wbr_create;
		int			wbr_copyup;
175
		unsigned int		fhsm_second;
176
177
178
	};
};

J. R. Okajima's avatar
J. R. Okajima committed
179
/* opts flags */
180
181
#define AuOpts_REMOUNT		1
#define AuOpts_REFRESH		(1 << 1)
J. R. Okajima's avatar
J. R. Okajima committed
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)
J. R. Okajima's avatar
J. R. Okajima committed
186
187
188
189
190
191
#define au_ftest_opts(flags, name)	((flags) & AuOpts_##name)
#define au_fset_opts(flags, name) \
	do { (flags) |= AuOpts_##name; } while (0)
#define au_fclr_opts(flags, name) \
	do { (flags) &= ~AuOpts_##name; } while (0)

192
193
194
195
196
#ifndef CONFIG_AUFS_DIRREN
#undef AuOpts_DR_FLUSHED
#define AuOpts_DR_FLUSHED	0
#endif

197
198
199
struct au_opts {
	struct au_opt	*opt;
	int		max_opt;
200

J. R. Okajima's avatar
J. R. Okajima committed
201
	unsigned int	given_udba;
J. R. Okajima's avatar
J. R. Okajima committed
202
	unsigned int	flags;
203
	unsigned long	sb_flags;
204
205
};

206
207
208
209
/* ---------------------------------------------------------------------- */

/* opts.c */
void au_optstr_br_perm(au_br_perm_str_t *str, int perm);
210
const char *au_optstr_udba(int udba);
211
212
const char *au_optstr_wbr_copyup(int wbr_copyup);
const char *au_optstr_wbr_create(int wbr_create);
213
214
215
216

void au_opts_free(struct au_opts *opts);
struct super_block;
int au_opts_parse(struct super_block *sb, char *str, struct au_opts *opts);
217
218
int au_opts_verify(struct super_block *sb, unsigned long sb_flags,
		   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
223
unsigned int au_opt_udba(struct super_block *sb);

224
225
#endif /* __KERNEL__ */
#endif /* __AUFS_OPTS_H__ */