UBUNTU: ubuntu: AUFS -- update to 4cf5db36bcd9748e8e7270022f295f84d1fc2245
[linux-flexiantxendom0.git] / ubuntu / include / linux / aufs_type.h
1 /*
2  * Copyright (C) 2005-2011 Junjiro R. Okajima
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #ifndef __AUFS_TYPE_H__
20 #define __AUFS_TYPE_H__
21
22 #include <linux/ioctl.h>
23 #include <linux/kernel.h>
24 #include <linux/limits.h>
25 #ifdef __KERNEL__
26 #include <linux/types.h>
27 #else
28 #include <stdint.h>
29 #include <sys/types.h>
30 #endif
31
32 #define AUFS_VERSION    "3.x-rcN-20111205"
33
34 /* todo? move this to linux-2.6.19/include/magic.h */
35 #define AUFS_SUPER_MAGIC        ('a' << 24 | 'u' << 16 | 'f' << 8 | 's')
36
37 /* ---------------------------------------------------------------------- */
38
39 #ifdef CONFIG_AUFS_BRANCH_MAX_127
40 typedef int8_t aufs_bindex_t;
41 #define AUFS_BRANCH_MAX 127
42 #else
43 typedef int16_t aufs_bindex_t;
44 #ifdef CONFIG_AUFS_BRANCH_MAX_511
45 #define AUFS_BRANCH_MAX 511
46 #elif defined(CONFIG_AUFS_BRANCH_MAX_1023)
47 #define AUFS_BRANCH_MAX 1023
48 #elif defined(CONFIG_AUFS_BRANCH_MAX_32767)
49 #define AUFS_BRANCH_MAX 32767
50 #endif
51 #endif
52
53 #ifdef __KERNEL__
54 #ifndef AUFS_BRANCH_MAX
55 #error unknown CONFIG_AUFS_BRANCH_MAX value
56 #endif
57 #endif /* __KERNEL__ */
58
59 /* ---------------------------------------------------------------------- */
60
61 #define AUFS_NAME               "aufs"
62 #define AUFS_FSTYPE             AUFS_NAME
63
64 #define AUFS_ROOT_INO           2
65 #define AUFS_FIRST_INO          11
66
67 #define AUFS_WH_PFX             ".wh."
68 #define AUFS_WH_PFX_LEN         ((int)sizeof(AUFS_WH_PFX) - 1)
69 #define AUFS_WH_TMP_LEN         4
70 /* a limit for rmdir/rename a dir */
71 #define AUFS_MAX_NAMELEN        (NAME_MAX \
72                                 - AUFS_WH_PFX_LEN * 2   /* doubly whiteouted */\
73                                 - 1                     /* dot */\
74                                 - AUFS_WH_TMP_LEN)      /* hex */
75 #define AUFS_XINO_FNAME         "." AUFS_NAME ".xino"
76 #define AUFS_XINO_DEFPATH       "/tmp/" AUFS_XINO_FNAME
77 #define AUFS_XINO_TRUNC_INIT    64 /* blocks */
78 #define AUFS_XINO_TRUNC_STEP    4  /* blocks */
79 #define AUFS_DIRWH_DEF          3
80 #define AUFS_RDCACHE_DEF        10 /* seconds */
81 #define AUFS_RDCACHE_MAX        3600 /* seconds */
82 #define AUFS_RDBLK_DEF          512 /* bytes */
83 #define AUFS_RDHASH_DEF         32
84 #define AUFS_WKQ_NAME           AUFS_NAME "d"
85 #define AUFS_MFS_DEF_SEC        30 /* seconds */
86 #define AUFS_MFS_MAX_SEC        3600 /* seconds */
87 #define AUFS_PLINK_WARN         100 /* number of plinks */
88
89 /* pseudo-link maintenace under /proc */
90 #define AUFS_PLINK_MAINT_NAME   "plink_maint"
91 #define AUFS_PLINK_MAINT_DIR    "fs/" AUFS_NAME
92 #define AUFS_PLINK_MAINT_PATH   AUFS_PLINK_MAINT_DIR "/" AUFS_PLINK_MAINT_NAME
93
94 #define AUFS_DIROPQ_NAME        AUFS_WH_PFX ".opq" /* whiteouted doubly */
95 #define AUFS_WH_DIROPQ          AUFS_WH_PFX AUFS_DIROPQ_NAME
96
97 #define AUFS_BASE_NAME          AUFS_WH_PFX AUFS_NAME
98 #define AUFS_PLINKDIR_NAME      AUFS_WH_PFX "plnk"
99 #define AUFS_ORPHDIR_NAME       AUFS_WH_PFX "orph"
100
101 /* doubly whiteouted */
102 #define AUFS_WH_BASE            AUFS_WH_PFX AUFS_BASE_NAME
103 #define AUFS_WH_PLINKDIR        AUFS_WH_PFX AUFS_PLINKDIR_NAME
104 #define AUFS_WH_ORPHDIR         AUFS_WH_PFX AUFS_ORPHDIR_NAME
105
106 /* branch permissions and attributes */
107 #define AUFS_BRPERM_RW          "rw"
108 #define AUFS_BRPERM_RO          "ro"
109 #define AUFS_BRPERM_RR          "rr"
110 #define AUFS_BRRATTR_WH         "wh"
111 #define AUFS_BRWATTR_NLWH       "nolwh"
112
113 /* ---------------------------------------------------------------------- */
114
115 /* ioctl */
116 enum {
117         /* readdir in userspace */
118         AuCtl_RDU,
119         AuCtl_RDU_INO,
120
121         /* pathconf wrapper */
122         AuCtl_WBR_FD,
123
124         /* busy inode */
125         AuCtl_IBUSY
126 };
127
128 /* borrowed from linux/include/linux/kernel.h */
129 #ifndef ALIGN
130 #define ALIGN(x, a)             __ALIGN_MASK(x, (typeof(x))(a)-1)
131 #define __ALIGN_MASK(x, mask)   (((x)+(mask))&~(mask))
132 #endif
133
134 /* borrowed from linux/include/linux/compiler-gcc3.h */
135 #ifndef __aligned
136 #define __aligned(x)                    __attribute__((aligned(x)))
137 #endif
138
139 #ifdef __KERNEL__
140 #ifndef __packed
141 #define __packed                        __attribute__((packed))
142 #endif
143 #endif
144
145 struct au_rdu_cookie {
146         uint64_t        h_pos;
147         int16_t         bindex;
148         uint8_t         flags;
149         uint8_t         pad;
150         uint32_t        generation;
151 } __aligned(8);
152
153 struct au_rdu_ent {
154         uint64_t        ino;
155         int16_t         bindex;
156         uint8_t         type;
157         uint8_t         nlen;
158         uint8_t         wh;
159         char            name[0];
160 } __aligned(8);
161
162 static inline int au_rdu_len(int nlen)
163 {
164         /* include the terminating NULL */
165         return ALIGN(sizeof(struct au_rdu_ent) + nlen + 1,
166                      sizeof(uint64_t));
167 }
168
169 union au_rdu_ent_ul {
170         struct au_rdu_ent __user        *e;
171         uint64_t                        ul;
172 };
173
174 enum {
175         AufsCtlRduV_SZ,
176         AufsCtlRduV_End
177 };
178
179 struct aufs_rdu {
180         /* input */
181         union {
182                 uint64_t        sz;     /* AuCtl_RDU */
183                 uint64_t        nent;   /* AuCtl_RDU_INO */
184         };
185         union au_rdu_ent_ul     ent;
186         uint16_t                verify[AufsCtlRduV_End];
187
188         /* input/output */
189         uint32_t                blk;
190
191         /* output */
192         union au_rdu_ent_ul     tail;
193         /* number of entries which were added in a single call */
194         uint64_t                rent;
195         uint8_t                 full;
196         uint8_t                 shwh;
197
198         struct au_rdu_cookie    cookie;
199 } __aligned(8);
200
201 /* ---------------------------------------------------------------------- */
202
203 struct aufs_wbr_fd {
204         uint32_t        oflags;
205         int16_t         brid;
206 } __aligned(8);
207
208 /* ---------------------------------------------------------------------- */
209
210 struct aufs_ibusy {
211         uint64_t        ino, h_ino;
212         int16_t         bindex;
213 } __aligned(8);
214
215 /* ---------------------------------------------------------------------- */
216
217 #define AuCtlType               'A'
218 #define AUFS_CTL_RDU            _IOWR(AuCtlType, AuCtl_RDU, struct aufs_rdu)
219 #define AUFS_CTL_RDU_INO        _IOWR(AuCtlType, AuCtl_RDU_INO, struct aufs_rdu)
220 #define AUFS_CTL_WBR_FD         _IOW(AuCtlType, AuCtl_WBR_FD, \
221                                      struct aufs_wbr_fd)
222 #define AUFS_CTL_IBUSY          _IOWR(AuCtlType, AuCtl_IBUSY, struct aufs_ibusy)
223
224 #endif /* __AUFS_TYPE_H__ */