]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - fs/aufs/fstype.h
2 * Copyright (C) 2005-2017 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, see <http://www.gnu.org/licenses/>.
19 * judging filesystem type
22 #ifndef __AUFS_FSTYPE_H__
23 #define __AUFS_FSTYPE_H__
28 #include <linux/magic.h>
29 #include <linux/nfs_fs.h>
30 #include <linux/romfs_fs.h>
32 static inline int au_test_aufs(struct super_block
*sb
)
34 return sb
->s_magic
== AUFS_SUPER_MAGIC
;
37 static inline const char *au_sbtype(struct super_block
*sb
)
39 return sb
->s_type
->name
;
42 static inline int au_test_iso9660(struct super_block
*sb __maybe_unused
)
44 #if IS_ENABLED(CONFIG_ISO9660_FS)
45 return sb
->s_magic
== ISOFS_SUPER_MAGIC
;
51 static inline int au_test_romfs(struct super_block
*sb __maybe_unused
)
53 #if IS_ENABLED(CONFIG_ROMFS_FS)
54 return sb
->s_magic
== ROMFS_MAGIC
;
60 static inline int au_test_cramfs(struct super_block
*sb __maybe_unused
)
62 #if IS_ENABLED(CONFIG_CRAMFS)
63 return sb
->s_magic
== CRAMFS_MAGIC
;
68 static inline int au_test_nfs(struct super_block
*sb __maybe_unused
)
70 #if IS_ENABLED(CONFIG_NFS_FS)
71 return sb
->s_magic
== NFS_SUPER_MAGIC
;
77 static inline int au_test_fuse(struct super_block
*sb __maybe_unused
)
79 #if IS_ENABLED(CONFIG_FUSE_FS)
80 return sb
->s_magic
== FUSE_SUPER_MAGIC
;
86 static inline int au_test_xfs(struct super_block
*sb __maybe_unused
)
88 #if IS_ENABLED(CONFIG_XFS_FS)
89 return sb
->s_magic
== XFS_SB_MAGIC
;
95 static inline int au_test_tmpfs(struct super_block
*sb __maybe_unused
)
98 return sb
->s_magic
== TMPFS_MAGIC
;
104 static inline int au_test_ecryptfs(struct super_block
*sb __maybe_unused
)
106 #if IS_ENABLED(CONFIG_ECRYPT_FS)
107 return !strcmp(au_sbtype(sb
), "ecryptfs");
113 static inline int au_test_ramfs(struct super_block
*sb
)
115 return sb
->s_magic
== RAMFS_MAGIC
;
118 static inline int au_test_ubifs(struct super_block
*sb __maybe_unused
)
120 #if IS_ENABLED(CONFIG_UBIFS_FS)
121 return sb
->s_magic
== UBIFS_SUPER_MAGIC
;
127 static inline int au_test_procfs(struct super_block
*sb __maybe_unused
)
129 #ifdef CONFIG_PROC_FS
130 return sb
->s_magic
== PROC_SUPER_MAGIC
;
136 static inline int au_test_sysfs(struct super_block
*sb __maybe_unused
)
139 return sb
->s_magic
== SYSFS_MAGIC
;
145 static inline int au_test_configfs(struct super_block
*sb __maybe_unused
)
147 #if IS_ENABLED(CONFIG_CONFIGFS_FS)
148 return sb
->s_magic
== CONFIGFS_MAGIC
;
154 static inline int au_test_minix(struct super_block
*sb __maybe_unused
)
156 #if IS_ENABLED(CONFIG_MINIX_FS)
157 return sb
->s_magic
== MINIX3_SUPER_MAGIC
158 || sb
->s_magic
== MINIX2_SUPER_MAGIC
159 || sb
->s_magic
== MINIX2_SUPER_MAGIC2
160 || sb
->s_magic
== MINIX_SUPER_MAGIC
161 || sb
->s_magic
== MINIX_SUPER_MAGIC2
;
167 static inline int au_test_fat(struct super_block
*sb __maybe_unused
)
169 #if IS_ENABLED(CONFIG_FAT_FS)
170 return sb
->s_magic
== MSDOS_SUPER_MAGIC
;
176 static inline int au_test_msdos(struct super_block
*sb
)
178 return au_test_fat(sb
);
181 static inline int au_test_vfat(struct super_block
*sb
)
183 return au_test_fat(sb
);
186 static inline int au_test_securityfs(struct super_block
*sb __maybe_unused
)
188 #ifdef CONFIG_SECURITYFS
189 return sb
->s_magic
== SECURITYFS_MAGIC
;
195 static inline int au_test_squashfs(struct super_block
*sb __maybe_unused
)
197 #if IS_ENABLED(CONFIG_SQUASHFS)
198 return sb
->s_magic
== SQUASHFS_MAGIC
;
204 static inline int au_test_btrfs(struct super_block
*sb __maybe_unused
)
206 #if IS_ENABLED(CONFIG_BTRFS_FS)
207 return sb
->s_magic
== BTRFS_SUPER_MAGIC
;
213 static inline int au_test_xenfs(struct super_block
*sb __maybe_unused
)
215 #if IS_ENABLED(CONFIG_XENFS)
216 return sb
->s_magic
== XENFS_SUPER_MAGIC
;
222 static inline int au_test_debugfs(struct super_block
*sb __maybe_unused
)
224 #ifdef CONFIG_DEBUG_FS
225 return sb
->s_magic
== DEBUGFS_MAGIC
;
231 static inline int au_test_nilfs(struct super_block
*sb __maybe_unused
)
233 #if IS_ENABLED(CONFIG_NILFS)
234 return sb
->s_magic
== NILFS_SUPER_MAGIC
;
240 static inline int au_test_hfsplus(struct super_block
*sb __maybe_unused
)
242 #if IS_ENABLED(CONFIG_HFSPLUS_FS)
243 return sb
->s_magic
== HFSPLUS_SUPER_MAGIC
;
249 /* ---------------------------------------------------------------------- */
251 * they can't be an aufs branch.
253 static inline int au_test_fs_unsuppoted(struct super_block
*sb
)
256 #ifndef CONFIG_AUFS_BR_RAMFS
261 || au_test_configfs(sb
)
262 || au_test_debugfs(sb
)
263 || au_test_securityfs(sb
)
265 || au_test_ecryptfs(sb
)
266 /* || !strcmp(au_sbtype(sb), "unionfs") */
267 || au_test_aufs(sb
); /* will be supported in next version */
270 static inline int au_test_fs_remote(struct super_block
*sb
)
272 return !au_test_tmpfs(sb
)
273 #ifdef CONFIG_AUFS_BR_RAMFS
274 && !au_test_ramfs(sb
)
276 && !(sb
->s_type
->fs_flags
& FS_REQUIRES_DEV
);
279 /* ---------------------------------------------------------------------- */
282 * Note: these functions (below) are created after reading ->getattr() in all
283 * filesystems under linux/fs. it means we have to do so in every update...
287 * some filesystems require getattr to refresh the inode attributes before
289 * in most cases, we can rely on the inode attribute in NFS (or every remote fs)
290 * and leave the work for d_revalidate()
292 static inline int au_test_fs_refresh_iattr(struct super_block
*sb
)
294 return au_test_nfs(sb
)
296 /* || au_test_btrfs(sb) */ /* untested */
301 * filesystems which don't maintain i_size or i_blocks.
303 static inline int au_test_fs_bad_iattr_size(struct super_block
*sb
)
305 return au_test_xfs(sb
)
308 || au_test_hfsplus(sb
) /* maintained, but incorrect */
309 /* || au_test_minix(sb) */ /* untested */
314 * filesystems which don't store the correct value in some of their inode
317 static inline int au_test_fs_bad_iattr(struct super_block
*sb
)
319 return au_test_fs_bad_iattr_size(sb
)
325 /* they don't check i_nlink in link(2) */
326 static inline int au_test_fs_no_limit_nlink(struct super_block
*sb
)
328 return au_test_tmpfs(sb
)
329 #ifdef CONFIG_AUFS_BR_RAMFS
333 || au_test_hfsplus(sb
);
337 * filesystems which sets S_NOATIME and S_NOCMTIME.
339 static inline int au_test_fs_notime(struct super_block
*sb
)
341 return au_test_nfs(sb
)
347 /* temporary support for i#1 in cramfs */
348 static inline int au_test_fs_unique_ino(struct inode
*inode
)
350 if (au_test_cramfs(inode
->i_sb
))
351 return inode
->i_ino
!= 1;
355 /* ---------------------------------------------------------------------- */
358 * the filesystem where the xino files placed must support i/o after unlink and
359 * maintain i_size and i_blocks.
361 static inline int au_test_fs_bad_xino(struct super_block
*sb
)
363 return au_test_fs_remote(sb
)
364 || au_test_fs_bad_iattr_size(sb
)
365 /* don't want unnecessary work for xino */
367 || au_test_ecryptfs(sb
)
368 || au_test_nilfs(sb
);
371 static inline int au_test_fs_trunc_xino(struct super_block
*sb
)
373 return au_test_tmpfs(sb
)
374 || au_test_ramfs(sb
);
378 * test if the @sb is real-readonly.
380 static inline int au_test_fs_rr(struct super_block
*sb
)
382 return au_test_squashfs(sb
)
383 || au_test_iso9660(sb
)
384 || au_test_cramfs(sb
)
385 || au_test_romfs(sb
);
389 * test if the @inode is nfs with 'noacl' option
390 * NFS always sets SB_POSIXACL regardless its mount option 'noacl.'
392 static inline int au_test_nfs_noacl(struct inode
*inode
)
394 return au_test_nfs(inode
->i_sb
)
395 /* && IS_POSIXACL(inode) */
396 && !nfs_server_capable(inode
, NFS_CAP_ACLS
);
399 #endif /* __KERNEL__ */
400 #endif /* __AUFS_FSTYPE_H__ */