]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/uapi/linux/aufs_type.h
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * Copyright (C) 2005-2021 Junjiro R. Okajima
5 * This program, aufs is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
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
36 #include <linux/limits.h>
39 #include <sys/types.h>
41 #endif /* __KERNEL__ */
43 #define AUFS_VERSION "5.15.5-20211129"
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 /* ---------------------------------------------------------------------- */
51 #ifdef CONFIG_AUFS_BRANCH_MAX_127
52 typedef int8_t aufs_bindex_t
;
53 #define AUFS_BRANCH_MAX 127
55 typedef int16_t aufs_bindex_t
;
56 #ifdef CONFIG_AUFS_BRANCH_MAX_511
57 #define AUFS_BRANCH_MAX 511
58 #elif defined(CONFIG_AUFS_BRANCH_MAX_1023)
59 #define AUFS_BRANCH_MAX 1023
60 #elif defined(CONFIG_AUFS_BRANCH_MAX_32767)
61 #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_FHSM_CACHE_DEF_SEC 30 /* seconds */
98 #define AUFS_PLINK_WARN 50 /* number of plinks in a single bucket */
100 /* pseudo-link maintenace under /proc */
101 #define AUFS_PLINK_MAINT_NAME "plink_maint"
102 #define AUFS_PLINK_MAINT_DIR "fs/" AUFS_NAME
103 #define AUFS_PLINK_MAINT_PATH AUFS_PLINK_MAINT_DIR "/" AUFS_PLINK_MAINT_NAME
105 /* dirren, renamed dir */
106 #define AUFS_DR_INFO_PFX AUFS_WH_PFX ".dr."
107 #define AUFS_DR_BRHINO_NAME AUFS_WH_PFX "hino"
108 /* whiteouted doubly */
109 #define AUFS_WH_DR_INFO_PFX AUFS_WH_PFX AUFS_DR_INFO_PFX
110 #define AUFS_WH_DR_BRHINO AUFS_WH_PFX AUFS_DR_BRHINO_NAME
112 #define AUFS_DIROPQ_NAME AUFS_WH_PFX ".opq" /* whiteouted doubly */
113 #define AUFS_WH_DIROPQ AUFS_WH_PFX AUFS_DIROPQ_NAME
115 #define AUFS_BASE_NAME AUFS_WH_PFX AUFS_NAME
116 #define AUFS_PLINKDIR_NAME AUFS_WH_PFX "plnk"
117 #define AUFS_ORPHDIR_NAME AUFS_WH_PFX "orph"
119 /* doubly whiteouted */
120 #define AUFS_WH_BASE AUFS_WH_PFX AUFS_BASE_NAME
121 #define AUFS_WH_PLINKDIR AUFS_WH_PFX AUFS_PLINKDIR_NAME
122 #define AUFS_WH_ORPHDIR AUFS_WH_PFX AUFS_ORPHDIR_NAME
124 /* branch permissions and attributes */
125 #define AUFS_BRPERM_RW "rw"
126 #define AUFS_BRPERM_RO "ro"
127 #define AUFS_BRPERM_RR "rr"
128 #define AUFS_BRATTR_COO_REG "coo_reg"
129 #define AUFS_BRATTR_COO_ALL "coo_all"
130 #define AUFS_BRATTR_FHSM "fhsm"
131 #define AUFS_BRATTR_UNPIN "unpin"
132 #define AUFS_BRATTR_ICEX "icex"
133 #define AUFS_BRATTR_ICEX_SEC "icexsec"
134 #define AUFS_BRATTR_ICEX_SYS "icexsys"
135 #define AUFS_BRATTR_ICEX_TR "icextr"
136 #define AUFS_BRATTR_ICEX_USR "icexusr"
137 #define AUFS_BRATTR_ICEX_OTH "icexoth"
138 #define AUFS_BRRATTR_WH "wh"
139 #define AUFS_BRWATTR_NLWH "nolwh"
140 #define AUFS_BRWATTR_MOO "moo"
142 #define AuBrPerm_RW 1 /* writable, hardlinkable wh */
143 #define AuBrPerm_RO (1 << 1) /* readonly */
144 #define AuBrPerm_RR (1 << 2) /* natively readonly */
145 #define AuBrPerm_Mask (AuBrPerm_RW | AuBrPerm_RO | AuBrPerm_RR)
147 #define AuBrAttr_COO_REG (1 << 3) /* copy-up on open */
148 #define AuBrAttr_COO_ALL (1 << 4)
149 #define AuBrAttr_COO_Mask (AuBrAttr_COO_REG | AuBrAttr_COO_ALL)
151 #define AuBrAttr_FHSM (1 << 5) /* file-based hsm */
152 #define AuBrAttr_UNPIN (1 << 6) /* rename-able top dir of
153 branch. meaningless since
156 /* ignore error in copying XATTR */
157 #define AuBrAttr_ICEX_SEC (1 << 7)
158 #define AuBrAttr_ICEX_SYS (1 << 8)
159 #define AuBrAttr_ICEX_TR (1 << 9)
160 #define AuBrAttr_ICEX_USR (1 << 10)
161 #define AuBrAttr_ICEX_OTH (1 << 11)
162 #define AuBrAttr_ICEX (AuBrAttr_ICEX_SEC \
163 | AuBrAttr_ICEX_SYS \
165 | AuBrAttr_ICEX_USR \
168 #define AuBrRAttr_WH (1 << 12) /* whiteout-able */
169 #define AuBrRAttr_Mask AuBrRAttr_WH
171 #define AuBrWAttr_NoLinkWH (1 << 13) /* un-hardlinkable whiteouts */
172 #define AuBrWAttr_MOO (1 << 14) /* move-up on open */
173 #define AuBrWAttr_Mask (AuBrWAttr_NoLinkWH | AuBrWAttr_MOO)
175 #define AuBrAttr_CMOO_Mask (AuBrAttr_COO_Mask | AuBrWAttr_MOO)
177 /* #warning test userspace */
179 #ifndef CONFIG_AUFS_FHSM
181 #define AuBrAttr_FHSM 0
183 #ifndef CONFIG_AUFS_XATTR
185 #define AuBrAttr_ICEX 0
186 #undef AuBrAttr_ICEX_SEC
187 #define AuBrAttr_ICEX_SEC 0
188 #undef AuBrAttr_ICEX_SYS
189 #define AuBrAttr_ICEX_SYS 0
190 #undef AuBrAttr_ICEX_TR
191 #define AuBrAttr_ICEX_TR 0
192 #undef AuBrAttr_ICEX_USR
193 #define AuBrAttr_ICEX_USR 0
194 #undef AuBrAttr_ICEX_OTH
195 #define AuBrAttr_ICEX_OTH 0
199 /* the longest combination */
200 /* AUFS_BRATTR_ICEX and AUFS_BRATTR_ICEX_TR don't affect here */
201 #define AuBrPermStrSz sizeof(AUFS_BRPERM_RW \
202 "+" AUFS_BRATTR_COO_REG \
203 "+" AUFS_BRATTR_FHSM \
204 "+" AUFS_BRATTR_UNPIN \
205 "+" AUFS_BRATTR_ICEX_SEC \
206 "+" AUFS_BRATTR_ICEX_SYS \
207 "+" AUFS_BRATTR_ICEX_USR \
208 "+" AUFS_BRATTR_ICEX_OTH \
209 "+" AUFS_BRWATTR_NLWH)
212 char a
[AuBrPermStrSz
];
215 static inline int au_br_writable(int brperm
)
217 return brperm
& AuBrPerm_RW
;
220 static inline int au_br_whable(int brperm
)
222 return brperm
& (AuBrPerm_RW
| AuBrRAttr_WH
);
225 static inline int au_br_wh_linkable(int brperm
)
227 return !(brperm
& AuBrWAttr_NoLinkWH
);
230 static inline int au_br_cmoo(int brperm
)
232 return brperm
& AuBrAttr_CMOO_Mask
;
235 static inline int au_br_fhsm(int brperm
)
237 return brperm
& AuBrAttr_FHSM
;
240 /* ---------------------------------------------------------------------- */
244 /* readdir in userspace */
248 AuCtl_WBR_FD
, /* pathconf wrapper */
249 AuCtl_IBUSY
, /* busy inode */
250 AuCtl_MVDOWN
, /* move-down */
251 AuCtl_BR
, /* info about branches */
252 AuCtl_FHSM_FD
/* connection for fhsm */
255 /* borrowed from linux/include/linux/kernel.h */
258 #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
260 #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
262 #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
265 /* borrowed from linux/include/linux/compiler-gcc3.h */
267 #define __aligned(x) __attribute__((aligned(x)))
272 #define __packed __attribute__((packed))
276 struct au_rdu_cookie
{
293 static inline int au_rdu_len(int nlen
)
295 /* include the terminating NULL */
296 return ALIGN(sizeof(struct au_rdu_ent
) + nlen
+ 1,
300 union au_rdu_ent_ul
{
301 struct au_rdu_ent __user
*e
;
313 uint64_t sz
; /* AuCtl_RDU */
314 uint64_t nent
; /* AuCtl_RDU_INO */
316 union au_rdu_ent_ul ent
;
317 uint16_t verify
[AufsCtlRduV_End
];
323 union au_rdu_ent_ul tail
;
324 /* number of entries which were added in a single call */
329 struct au_rdu_cookie cookie
;
332 /* ---------------------------------------------------------------------- */
334 /* dirren. the branch is identified by the filename who contains this */
344 struct au_drinfo_fdata
{
346 struct au_drinfo drinfo
;
349 #define AUFS_DRINFO_MAGIC_V1 ('a' << 24 | 'd' << 16 | 'r' << 8 | 0x01)
351 #define AUFS_DRINFO_MAGIC_V2 ('a' << 24 | 'd' << 16 | 'r' << 8 | 0x02)
353 /* ---------------------------------------------------------------------- */
360 /* ---------------------------------------------------------------------- */
367 /* ---------------------------------------------------------------------- */
369 /* error code for move-down */
370 /* the actual message strings are implemented in aufs-util.git */
372 EAU_MVDOWN_OPAQUE
= 1,
377 EAU_MVDOWN_NOLOWERBR
,
381 /* flags for move-down */
382 #define AUFS_MVDOWN_DMSG 1
383 #define AUFS_MVDOWN_OWLOWER (1 << 1) /* overwrite lower */
384 #define AUFS_MVDOWN_KUPPER (1 << 2) /* keep upper */
385 #define AUFS_MVDOWN_ROLOWER (1 << 3) /* do even if lower is RO */
386 #define AUFS_MVDOWN_ROLOWER_R (1 << 4) /* did on lower RO */
387 #define AUFS_MVDOWN_ROUPPER (1 << 5) /* do even if upper is RO */
388 #define AUFS_MVDOWN_ROUPPER_R (1 << 6) /* did on upper RO */
389 #define AUFS_MVDOWN_BRID_UPPER (1 << 7) /* upper brid */
390 #define AUFS_MVDOWN_BRID_LOWER (1 << 8) /* lower brid */
391 #define AUFS_MVDOWN_FHSM_LOWER (1 << 9) /* find fhsm attr for lower */
392 #define AUFS_MVDOWN_STFS (1 << 10) /* req. stfs */
393 #define AUFS_MVDOWN_STFS_FAILED (1 << 11) /* output: stfs is unusable */
394 #define AUFS_MVDOWN_BOTTOM (1 << 12) /* output: no more lowers */
396 /* index for move-down */
404 * additional info of move-down
405 * number of free blocks and inodes.
406 * subset of struct kstatfs, but smaller and always 64bit.
416 int16_t brid
; /* optional input */
417 int16_t bindex
; /* output */
418 struct aufs_stfs stfs
; /* output when AUFS_MVDOWN_STFS set */
422 uint32_t flags
; /* input/output */
423 struct aufs_stbr stbr
[AUFS_MVDOWN_NARRAY
]; /* input/output */
424 int8_t au_errno
; /* output */
427 /* ---------------------------------------------------------------------- */
430 /* PATH_MAX may differ between kernel-space and user-space */
439 /* ---------------------------------------------------------------------- */
441 #define AuCtlType 'A'
442 #define AUFS_CTL_RDU _IOWR(AuCtlType, AuCtl_RDU, struct aufs_rdu)
443 #define AUFS_CTL_RDU_INO _IOWR(AuCtlType, AuCtl_RDU_INO, struct aufs_rdu)
444 #define AUFS_CTL_WBR_FD _IOW(AuCtlType, AuCtl_WBR_FD, \
446 #define AUFS_CTL_IBUSY _IOWR(AuCtlType, AuCtl_IBUSY, struct aufs_ibusy)
447 #define AUFS_CTL_MVDOWN _IOWR(AuCtlType, AuCtl_MVDOWN, \
449 #define AUFS_CTL_BRINFO _IOW(AuCtlType, AuCtl_BR, union aufs_brinfo)
450 #define AUFS_CTL_FHSM_FD _IOW(AuCtlType, AuCtl_FHSM_FD, int)
452 #endif /* __AUFS_TYPE_H__ */