2 * Copyright (C) 2005-2013 Junjiro R. Okajima
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.
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.
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
19 #ifndef __AUFS_TYPE_H__
20 #define __AUFS_TYPE_H__
22 #define AUFS_NAME "aufs"
26 * define it before including all other headers.
27 * sched.h may use pr_* macros before defining "current", so define the
28 * no-current version first, and re-define later.
30 #define pr_fmt(fmt) AUFS_NAME " %s:%d: " fmt, __func__, __LINE__
31 #include <linux/sched.h>
34 AUFS_NAME " %s:%d:%.*s[%d]: " fmt, __func__, __LINE__, \
35 (int)sizeof(current->comm), current->comm, current->pid
38 #include <sys/types.h>
39 #endif /* __KERNEL__ */
41 #include <linux/limits.h>
43 #define AUFS_VERSION "3.2.x-20131104"
45 /* todo? move this to linux-2.6.19/include/magic.h */
46 #define AUFS_SUPER_MAGIC ('a' << 24 | 'u' << 16 | 'f' << 8 | 's')
48 /* ---------------------------------------------------------------------- */
50 #ifdef CONFIG_AUFS_BRANCH_MAX_127
51 typedef int8_t aufs_bindex_t;
52 #define AUFS_BRANCH_MAX 127
54 typedef int16_t aufs_bindex_t;
55 #ifdef CONFIG_AUFS_BRANCH_MAX_511
56 #define AUFS_BRANCH_MAX 511
57 #elif defined(CONFIG_AUFS_BRANCH_MAX_1023)
58 #define AUFS_BRANCH_MAX 1023
59 #elif defined(CONFIG_AUFS_BRANCH_MAX_32767)
60 #define AUFS_BRANCH_MAX 32767
65 #ifndef AUFS_BRANCH_MAX
66 #error unknown CONFIG_AUFS_BRANCH_MAX value
68 #endif /* __KERNEL__ */
70 /* ---------------------------------------------------------------------- */
72 #define AUFS_FSTYPE AUFS_NAME
74 #define AUFS_ROOT_INO 2
75 #define AUFS_FIRST_INO 11
77 #define AUFS_WH_PFX ".wh."
78 #define AUFS_WH_PFX_LEN ((int)sizeof(AUFS_WH_PFX) - 1)
79 #define AUFS_WH_TMP_LEN 4
80 /* a limit for rmdir/rename a dir and copyup */
81 #define AUFS_MAX_NAMELEN (NAME_MAX \
82 - AUFS_WH_PFX_LEN * 2 /* doubly whiteouted */\
84 - AUFS_WH_TMP_LEN) /* hex */
85 #define AUFS_XINO_FNAME "." AUFS_NAME ".xino"
86 #define AUFS_XINO_DEFPATH "/tmp/" AUFS_XINO_FNAME
87 #define AUFS_XINO_DEF_SEC 30 /* seconds */
88 #define AUFS_XINO_DEF_TRUNC 45 /* percentage */
89 #define AUFS_DIRWH_DEF 3
90 #define AUFS_RDCACHE_DEF 10 /* seconds */
91 #define AUFS_RDCACHE_MAX 3600 /* seconds */
92 #define AUFS_RDBLK_DEF 512 /* bytes */
93 #define AUFS_RDHASH_DEF 32
94 #define AUFS_WKQ_NAME AUFS_NAME "d"
95 #define AUFS_MFS_DEF_SEC 30 /* seconds */
96 #define AUFS_MFS_MAX_SEC 3600 /* seconds */
97 #define AUFS_PLINK_WARN 50 /* number of plinks in a single bucket */
99 /* pseudo-link maintenace under /proc */
100 #define AUFS_PLINK_MAINT_NAME "plink_maint"
101 #define AUFS_PLINK_MAINT_DIR "fs/" AUFS_NAME
102 #define AUFS_PLINK_MAINT_PATH AUFS_PLINK_MAINT_DIR "/" AUFS_PLINK_MAINT_NAME
104 #define AUFS_DIROPQ_NAME AUFS_WH_PFX ".opq" /* whiteouted doubly */
105 #define AUFS_WH_DIROPQ AUFS_WH_PFX AUFS_DIROPQ_NAME
107 #define AUFS_BASE_NAME AUFS_WH_PFX AUFS_NAME
108 #define AUFS_PLINKDIR_NAME AUFS_WH_PFX "plnk"
109 #define AUFS_ORPHDIR_NAME AUFS_WH_PFX "orph"
111 /* doubly whiteouted */
112 #define AUFS_WH_BASE AUFS_WH_PFX AUFS_BASE_NAME
113 #define AUFS_WH_PLINKDIR AUFS_WH_PFX AUFS_PLINKDIR_NAME
114 #define AUFS_WH_ORPHDIR AUFS_WH_PFX AUFS_ORPHDIR_NAME
116 /* branch permissions and attributes */
117 #define AUFS_BRPERM_RW "rw"
118 #define AUFS_BRPERM_RO "ro"
119 #define AUFS_BRPERM_RR "rr"
120 #define AUFS_BRRATTR_WH "wh"
121 #define AUFS_BRWATTR_NLWH "nolwh"
122 #define AUFS_BRATTR_UNPIN "unpin"
124 /* ---------------------------------------------------------------------- */
128 /* readdir in userspace */
132 /* pathconf wrapper */
139 /* borrowed from linux/include/linux/kernel.h */
141 #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
142 #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
145 /* borrowed from linux/include/linux/compiler-gcc3.h */
147 #define __aligned(x) __attribute__((aligned(x)))
152 #define __packed __attribute__((packed))
156 struct au_rdu_cookie {
173 static inline int au_rdu_len(int nlen)
175 /* include the terminating NULL */
176 return ALIGN(sizeof(struct au_rdu_ent) + nlen + 1,
180 union au_rdu_ent_ul {
181 struct au_rdu_ent __user *e;
193 uint64_t sz; /* AuCtl_RDU */
194 uint64_t nent; /* AuCtl_RDU_INO */
196 union au_rdu_ent_ul ent;
197 uint16_t verify[AufsCtlRduV_End];
203 union au_rdu_ent_ul tail;
204 /* number of entries which were added in a single call */
209 struct au_rdu_cookie cookie;
212 /* ---------------------------------------------------------------------- */
219 /* ---------------------------------------------------------------------- */
226 /* ---------------------------------------------------------------------- */
228 #define AuCtlType 'A'
229 #define AUFS_CTL_RDU _IOWR(AuCtlType, AuCtl_RDU, struct aufs_rdu)
230 #define AUFS_CTL_RDU_INO _IOWR(AuCtlType, AuCtl_RDU_INO, struct aufs_rdu)
231 #define AUFS_CTL_WBR_FD _IOW(AuCtlType, AuCtl_WBR_FD, \
233 #define AUFS_CTL_IBUSY _IOWR(AuCtlType, AuCtl_IBUSY, struct aufs_ibusy)
235 #endif /* __AUFS_TYPE_H__ */