opts.h 4.04 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2005-2019 Junjiro R. Okajima
 */

/*
 * 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
17
18
struct file;

J. R. Okajima's avatar
J. R. Okajima committed
19
20
21
22
23
/* ---------------------------------------------------------------------- */

/* mount flags */
#define AuOpt_XINO		1		/* external inode number bitmap
						   and translation table */
J. R. Okajima's avatar
J. R. Okajima committed
24
#define AuOpt_TRUNC_XINO	(1 << 1)	/* truncate xino files */
25
26
#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
27
#define AuOpt_UDBA_HNOTIFY	(1 << 4)
28
#define AuOpt_PLINK		(1 << 6)	/* pseudo-link */
29
#define AuOpt_DIO		(1 << 14)	/* direct io */
J. R. Okajima's avatar
J. R. Okajima committed
30

J. R. Okajima's avatar
J. R. Okajima committed
31
32
33
34
35
#ifndef CONFIG_AUFS_HNOTIFY
#undef AuOpt_UDBA_HNOTIFY
#define AuOpt_UDBA_HNOTIFY	0
#endif

36
#define AuOpt_Def	(AuOpt_XINO \
37
			 | AuOpt_UDBA_REVAL \
38
			 | AuOpt_PLINK)
39
#define AuOptMask_UDBA	(AuOpt_UDBA_NONE \
J. R. Okajima's avatar
J. R. Okajima committed
40
41
			 | AuOpt_UDBA_REVAL \
			 | AuOpt_UDBA_HNOTIFY)
J. R. Okajima's avatar
J. R. Okajima committed
42
43
44

#define au_opt_test(flags, name)	(flags & AuOpt_##name)
#define au_opt_set(flags, name) do { \
45
46
47
48
49
	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
50
51
52
53
54
55
	((flags) |= AuOpt_##name); \
} while (0)
#define au_opt_clr(flags, name) do { \
	((flags) &= ~AuOpt_##name); \
} while (0)

56
57
58
59
60
61
62
63
64
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
65
66
/* ---------------------------------------------------------------------- */

67
68
69
/* policies to select one among multiple writable branches */
enum {
	AuWbrCreate_TDP,	/* top down parent */
70
71
72
73
74
75
76
77
78
79
80
	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 */
81
82
83
84
85
86

	AuWbrCreate_Def = AuWbrCreate_TDP
};

enum {
	AuWbrCopyup_TDP,	/* top down parent */
87
88
	AuWbrCopyup_BUP,	/* bottom up parent */
	AuWbrCopyup_BU,		/* bottom up */
89
90
91
92
93
94

	AuWbrCopyup_Def = AuWbrCopyup_TDP
};

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

95
96
97
98
99
100
101
struct au_opt_add {
	aufs_bindex_t	bindex;
	char		*pathname;
	int		perm;
	struct path	path;
};

J. R. Okajima's avatar
J. R. Okajima committed
102
103
104
105
106
struct au_opt_xino {
	char		*path;
	struct file	*file;
};

J. R. Okajima's avatar
J. R. Okajima committed
107
108
109
110
struct au_opt_xino_itrunc {
	aufs_bindex_t	bindex;
};

111
112
struct au_opt_wbr_create {
	int			wbr_create;
113
114
	int			mfs_second;
	unsigned long long	mfsrr_watermark;
115
116
};

117
118
119
struct au_opt {
	int type;
	union {
J. R. Okajima's avatar
J. R. Okajima committed
120
		struct au_opt_xino	xino;
J. R. Okajima's avatar
J. R. Okajima committed
121
		struct au_opt_xino_itrunc xino_itrunc;
122
		struct au_opt_add	add;
123
124
		struct au_opt_wbr_create wbr_create;
		int			wbr_copyup;
125
126
127
128
		/* add more later */
	};
};

J. R. Okajima's avatar
J. R. Okajima committed
129
130
/* opts flags */
#define AuOpts_TRUNC_XIB	(1 << 2)
131
#define AuOpts_REFRESH_DYAOP	(1 << 3)
J. R. Okajima's avatar
J. R. Okajima committed
132
133
134
135
136
137
#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)

138
139
140
struct au_opts {
	struct au_opt	*opt;
	int		max_opt;
141

J. R. Okajima's avatar
J. R. Okajima committed
142
	unsigned int	flags;
143
	unsigned long	sb_flags;
144
145
};

146
147
148
149
/* ---------------------------------------------------------------------- */

/* opts.c */
void au_optstr_br_perm(au_br_perm_str_t *str, int perm);
150
const char *au_optstr_udba(int udba);
151
152
const char *au_optstr_wbr_copyup(int wbr_copyup);
const char *au_optstr_wbr_create(int wbr_create);
153
154
155
156

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);
157
158
int au_opts_verify(struct super_block *sb, unsigned long sb_flags,
		   unsigned int pending);
159
160
int au_opts_mount(struct super_block *sb, struct au_opts *opts);

161
162
unsigned int au_opt_udba(struct super_block *sb);

163
164
#endif /* __KERNEL__ */
#endif /* __AUFS_OPTS_H__ */