2 * Copyright (C) 2005-2012 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>
33 #define pr_fmt(fmt) AUFS_NAME " %s:%d:%s[%d]: " fmt, \
34 __func__, __LINE__, current->comm, current->pid
37 #include <sys/types.h>
38 #endif /* __KERNEL__ */
40 #include <linux/limits.h>
42 #define AUFS_VERSION "3.2-20120109"
44 /* todo? move this to linux-2.6.19/include/magic.h */
45 #define AUFS_SUPER_MAGIC ('a' << 24 | 'u' << 16 | 'f' << 8 | 's')
47 /* ---------------------------------------------------------------------- */
49 #ifdef CONFIG_AUFS_BRANCH_MAX_127
50 typedef int8_t aufs_bindex_t;
51 #define AUFS_BRANCH_MAX 127
53 typedef int16_t aufs_bindex_t;
54 #ifdef CONFIG_AUFS_BRANCH_MAX_511
55 #define AUFS_BRANCH_MAX 511
56 #elif defined(CONFIG_AUFS_BRANCH_MAX_1023)
57 #define AUFS_BRANCH_MAX 1023
58 #elif defined(CONFIG_AUFS_BRANCH_MAX_32767)
59 #define AUFS_BRANCH_MAX 32767
64 #ifndef AUFS_BRANCH_MAX
65 #error unknown CONFIG_AUFS_BRANCH_MAX value
67 #endif /* __KERNEL__ */
69 /* ---------------------------------------------------------------------- */
71 #define AUFS_FSTYPE AUFS_NAME
73 #define AUFS_ROOT_INO 2
74 #define AUFS_FIRST_INO 11
76 #define AUFS_WH_PFX ".wh."
77 #define AUFS_WH_PFX_LEN ((int)sizeof(AUFS_WH_PFX) - 1)
78 #define AUFS_WH_TMP_LEN 4
79 /* a limit for rmdir/rename a dir */
80 #define AUFS_MAX_NAMELEN (NAME_MAX \
81 - AUFS_WH_PFX_LEN * 2 /* doubly whiteouted */\
83 - AUFS_WH_TMP_LEN) /* hex */
84 #define AUFS_XINO_FNAME "." AUFS_NAME ".xino"
85 #define AUFS_XINO_DEFPATH "/tmp/" AUFS_XINO_FNAME
86 #define AUFS_XINO_TRUNC_INIT 64 /* blocks */
87 #define AUFS_XINO_TRUNC_STEP 4 /* blocks */
88 #define AUFS_DIRWH_DEF 3
89 #define AUFS_RDCACHE_DEF 10 /* seconds */
90 #define AUFS_RDCACHE_MAX 3600 /* seconds */
91 #define AUFS_RDBLK_DEF 512 /* bytes */
92 #define AUFS_RDHASH_DEF 32
93 #define AUFS_WKQ_NAME AUFS_NAME "d"
94 #define AUFS_MFS_DEF_SEC 30 /* seconds */
95 #define AUFS_MFS_MAX_SEC 3600 /* seconds */
96 #define AUFS_PLINK_WARN 100 /* number of plinks */
98 /* pseudo-link maintenace under /proc */
99 #define AUFS_PLINK_MAINT_NAME "plink_maint"
100 #define AUFS_PLINK_MAINT_DIR "fs/" AUFS_NAME
101 #define AUFS_PLINK_MAINT_PATH AUFS_PLINK_MAINT_DIR "/" AUFS_PLINK_MAINT_NAME
103 #define AUFS_DIROPQ_NAME AUFS_WH_PFX ".opq" /* whiteouted doubly */
104 #define AUFS_WH_DIROPQ AUFS_WH_PFX AUFS_DIROPQ_NAME
106 #define AUFS_BASE_NAME AUFS_WH_PFX AUFS_NAME
107 #define AUFS_PLINKDIR_NAME AUFS_WH_PFX "plnk"
108 #define AUFS_ORPHDIR_NAME AUFS_WH_PFX "orph"
110 /* doubly whiteouted */
111 #define AUFS_WH_BASE AUFS_WH_PFX AUFS_BASE_NAME
112 #define AUFS_WH_PLINKDIR AUFS_WH_PFX AUFS_PLINKDIR_NAME
113 #define AUFS_WH_ORPHDIR AUFS_WH_PFX AUFS_ORPHDIR_NAME
115 /* branch permissions and attributes */
116 #define AUFS_BRPERM_RW "rw"
117 #define AUFS_BRPERM_RO "ro"
118 #define AUFS_BRPERM_RR "rr"
119 #define AUFS_BRRATTR_WH "wh"
120 #define AUFS_BRWATTR_NLWH "nolwh"
122 /* ---------------------------------------------------------------------- */
126 /* readdir in userspace */
130 /* pathconf wrapper */
137 /* borrowed from linux/include/linux/kernel.h */
139 #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
140 #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
143 /* borrowed from linux/include/linux/compiler-gcc3.h */
145 #define __aligned(x) __attribute__((aligned(x)))
150 #define __packed __attribute__((packed))
154 struct au_rdu_cookie {
171 static inline int au_rdu_len(int nlen)
173 /* include the terminating NULL */
174 return ALIGN(sizeof(struct au_rdu_ent) + nlen + 1,
178 union au_rdu_ent_ul {
179 struct au_rdu_ent __user *e;
191 uint64_t sz; /* AuCtl_RDU */
192 uint64_t nent; /* AuCtl_RDU_INO */
194 union au_rdu_ent_ul ent;
195 uint16_t verify[AufsCtlRduV_End];
201 union au_rdu_ent_ul tail;
202 /* number of entries which were added in a single call */
207 struct au_rdu_cookie cookie;
210 /* ---------------------------------------------------------------------- */
217 /* ---------------------------------------------------------------------- */
224 /* ---------------------------------------------------------------------- */
226 #define AuCtlType 'A'
227 #define AUFS_CTL_RDU _IOWR(AuCtlType, AuCtl_RDU, struct aufs_rdu)
228 #define AUFS_CTL_RDU_INO _IOWR(AuCtlType, AuCtl_RDU_INO, struct aufs_rdu)
229 #define AUFS_CTL_WBR_FD _IOW(AuCtlType, AuCtl_WBR_FD, \
231 #define AUFS_CTL_IBUSY _IOWR(AuCtlType, AuCtl_IBUSY, struct aufs_ibusy)
233 #endif /* __AUFS_TYPE_H__ */