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
20 * judging filesystem type
23 #ifndef __AUFS_FSTYPE_H__
24 #define __AUFS_FSTYPE_H__
29 #include <linux/magic.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 defined(CONFIG_ROMFS_FS) || defined(CONFIG_ROMFS_FS_MODULE)
45 return sb->s_magic == ROMFS_MAGIC;
51 static inline int au_test_romfs(struct super_block *sb __maybe_unused)
53 #if defined(CONFIG_ISO9660_FS) || defined(CONFIG_ISO9660_FS_MODULE)
54 return sb->s_magic == ISOFS_SUPER_MAGIC;
60 static inline int au_test_cramfs(struct super_block *sb __maybe_unused)
62 #if defined(CONFIG_CRAMFS) || defined(CONFIG_CRAMFS_MODULE)
63 return sb->s_magic == CRAMFS_MAGIC;
68 static inline int au_test_nfs(struct super_block *sb __maybe_unused)
70 #if defined(CONFIG_NFS_FS) || defined(CONFIG_NFS_FS_MODULE)
71 return sb->s_magic == NFS_SUPER_MAGIC;
77 static inline int au_test_fuse(struct super_block *sb __maybe_unused)
79 #if defined(CONFIG_FUSE_FS) || defined(CONFIG_FUSE_FS_MODULE)
80 return sb->s_magic == FUSE_SUPER_MAGIC;
86 static inline int au_test_xfs(struct super_block *sb __maybe_unused)
88 #if defined(CONFIG_XFS_FS) || defined(CONFIG_XFS_FS_MODULE)
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 defined(CONFIG_ECRYPT_FS) || defined(CONFIG_ECRYPT_FS_MODULE)
107 return !strcmp(au_sbtype(sb), "ecryptfs");
113 static inline int au_test_ocfs2(struct super_block *sb __maybe_unused)
115 #if defined(CONFIG_OCFS2_FS) || defined(CONFIG_OCFS2_FS_MODULE)
116 return sb->s_magic == OCFS2_SUPER_MAGIC;
122 static inline int au_test_ocfs2_dlmfs(struct super_block *sb __maybe_unused)
124 #if defined(CONFIG_OCFS2_FS_O2CB) || defined(CONFIG_OCFS2_FS_O2CB_MODULE)
125 return sb->s_magic == DLMFS_MAGIC;
131 static inline int au_test_coda(struct super_block *sb __maybe_unused)
133 #if defined(CONFIG_CODA_FS) || defined(CONFIG_CODA_FS_MODULE)
134 return sb->s_magic == CODA_SUPER_MAGIC;
140 static inline int au_test_v9fs(struct super_block *sb __maybe_unused)
142 #if defined(CONFIG_9P_FS) || defined(CONFIG_9P_FS_MODULE)
143 return sb->s_magic == V9FS_MAGIC;
149 static inline int au_test_ext4(struct super_block *sb __maybe_unused)
151 #if defined(CONFIG_EXT4_FS) || defined(CONFIG_EXT4_FS_MODULE)
152 return sb->s_magic == EXT4_SUPER_MAGIC;
158 static inline int au_test_sysv(struct super_block *sb __maybe_unused)
160 #if defined(CONFIG_SYSV_FS) || defined(CONFIG_SYSV_FS_MODULE)
161 return !strcmp(au_sbtype(sb), "sysv");
167 static inline int au_test_ramfs(struct super_block *sb)
169 return sb->s_magic == RAMFS_MAGIC;
172 static inline int au_test_ubifs(struct super_block *sb __maybe_unused)
174 #if defined(CONFIG_UBIFS_FS) || defined(CONFIG_UBIFS_FS_MODULE)
175 return sb->s_magic == UBIFS_SUPER_MAGIC;
181 static inline int au_test_procfs(struct super_block *sb __maybe_unused)
183 #ifdef CONFIG_PROC_FS
184 return sb->s_magic == PROC_SUPER_MAGIC;
190 static inline int au_test_sysfs(struct super_block *sb __maybe_unused)
193 return sb->s_magic == SYSFS_MAGIC;
199 static inline int au_test_configfs(struct super_block *sb __maybe_unused)
201 #if defined(CONFIG_CONFIGFS_FS) || defined(CONFIG_CONFIGFS_FS_MODULE)
202 return sb->s_magic == CONFIGFS_MAGIC;
208 static inline int au_test_minix(struct super_block *sb __maybe_unused)
210 #if defined(CONFIG_MINIX_FS) || defined(CONFIG_MINIX_FS_MODULE)
211 return sb->s_magic == MINIX3_SUPER_MAGIC
212 || sb->s_magic == MINIX2_SUPER_MAGIC
213 || sb->s_magic == MINIX2_SUPER_MAGIC2
214 || sb->s_magic == MINIX_SUPER_MAGIC
215 || sb->s_magic == MINIX_SUPER_MAGIC2;
221 static inline int au_test_cifs(struct super_block *sb __maybe_unused)
223 #if defined(CONFIG_CIFS_FS) || defined(CONFIGCIFS_FS_MODULE)
224 return sb->s_magic == CIFS_MAGIC_NUMBER;
230 static inline int au_test_fat(struct super_block *sb __maybe_unused)
232 #if defined(CONFIG_FAT_FS) || defined(CONFIG_FAT_FS_MODULE)
233 return sb->s_magic == MSDOS_SUPER_MAGIC;
239 static inline int au_test_msdos(struct super_block *sb)
241 return au_test_fat(sb);
244 static inline int au_test_vfat(struct super_block *sb)
246 return au_test_fat(sb);
249 static inline int au_test_securityfs(struct super_block *sb __maybe_unused)
251 #ifdef CONFIG_SECURITYFS
252 return sb->s_magic == SECURITYFS_MAGIC;
258 static inline int au_test_squashfs(struct super_block *sb __maybe_unused)
260 #if defined(CONFIG_SQUASHFS) || defined(CONFIG_SQUASHFS_MODULE)
261 return sb->s_magic == SQUASHFS_MAGIC;
267 static inline int au_test_btrfs(struct super_block *sb __maybe_unused)
269 #if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
270 return sb->s_magic == BTRFS_SUPER_MAGIC;
276 static inline int au_test_xenfs(struct super_block *sb __maybe_unused)
278 #if defined(CONFIG_XENFS) || defined(CONFIG_XENFS_MODULE)
279 return sb->s_magic == XENFS_SUPER_MAGIC;
285 static inline int au_test_debugfs(struct super_block *sb __maybe_unused)
287 #ifdef CONFIG_DEBUG_FS
288 return sb->s_magic == DEBUGFS_MAGIC;
294 static inline int au_test_nilfs(struct super_block *sb __maybe_unused)
296 #if defined(CONFIG_NILFS) || defined(CONFIG_NILFS_MODULE)
297 return sb->s_magic == NILFS_SUPER_MAGIC;
303 static inline int au_test_hfsplus(struct super_block *sb __maybe_unused)
305 #if defined(CONFIG_HFSPLUS_FS) || defined(CONFIG_HFSPLUS_FS_MODULE)
306 return sb->s_magic == HFSPLUS_SUPER_MAGIC;
312 /* ---------------------------------------------------------------------- */
314 * they can't be an aufs branch.
316 static inline int au_test_fs_unsuppoted(struct super_block *sb)
319 #ifndef CONFIG_AUFS_BR_RAMFS
324 || au_test_configfs(sb)
325 || au_test_debugfs(sb)
326 || au_test_securityfs(sb)
328 || au_test_ecryptfs(sb)
329 /* || !strcmp(au_sbtype(sb), "unionfs") */
330 || au_test_aufs(sb); /* will be supported in next version */
334 * If the filesystem supports NFS-export, then it has to support NULL as
335 * a nameidata parameter for ->create(), ->lookup() and ->d_revalidate().
336 * We can apply this principle when we handle a lower filesystem.
338 static inline int au_test_fs_null_nd(struct super_block *sb)
340 return !!sb->s_export_op;
343 static inline int au_test_fs_remote(struct super_block *sb)
345 return !au_test_tmpfs(sb)
346 #ifdef CONFIG_AUFS_BR_RAMFS
347 && !au_test_ramfs(sb)
349 && !(sb->s_type->fs_flags & FS_REQUIRES_DEV);
352 /* ---------------------------------------------------------------------- */
355 * Note: these functions (below) are created after reading ->getattr() in all
356 * filesystems under linux/fs. it means we have to do so in every update...
360 * some filesystems require getattr to refresh the inode attributes before
362 * in most cases, we can rely on the inode attribute in NFS (or every remote fs)
363 * and leave the work for d_revalidate()
365 static inline int au_test_fs_refresh_iattr(struct super_block *sb)
367 return au_test_nfs(sb)
369 /* || au_test_ocfs2(sb) */ /* untested */
370 /* || au_test_btrfs(sb) */ /* untested */
371 /* || au_test_coda(sb) */ /* untested */
372 /* || au_test_v9fs(sb) */ /* untested */
377 * filesystems which don't maintain i_size or i_blocks.
379 static inline int au_test_fs_bad_iattr_size(struct super_block *sb)
381 return au_test_xfs(sb)
384 || au_test_hfsplus(sb) /* maintained, but incorrect */
385 /* || au_test_ext4(sb) */ /* untested */
386 /* || au_test_ocfs2(sb) */ /* untested */
387 /* || au_test_ocfs2_dlmfs(sb) */ /* untested */
388 /* || au_test_sysv(sb) */ /* untested */
389 /* || au_test_minix(sb) */ /* untested */
394 * filesystems which don't store the correct value in some of their inode
397 static inline int au_test_fs_bad_iattr(struct super_block *sb)
399 return au_test_fs_bad_iattr_size(sb)
400 /* || au_test_cifs(sb) */ /* untested */
406 /* they don't check i_nlink in link(2) */
407 static inline int au_test_fs_no_limit_nlink(struct super_block *sb)
409 return au_test_tmpfs(sb)
410 #ifdef CONFIG_AUFS_BR_RAMFS
415 || au_test_hfsplus(sb);
419 * filesystems which sets S_NOATIME and S_NOCMTIME.
421 static inline int au_test_fs_notime(struct super_block *sb)
423 return au_test_nfs(sb)
426 /* || au_test_cifs(sb) */ /* untested */
431 * filesystems which requires replacing i_mapping.
433 static inline int au_test_fs_bad_mapping(struct super_block *sb)
435 return au_test_fuse(sb)
436 || au_test_ubifs(sb);
439 /* temporary support for i#1 in cramfs */
440 static inline int au_test_fs_unique_ino(struct inode *inode)
442 if (au_test_cramfs(inode->i_sb))
443 return inode->i_ino != 1;
447 /* ---------------------------------------------------------------------- */
450 * the filesystem where the xino files placed must support i/o after unlink and
451 * maintain i_size and i_blocks.
453 static inline int au_test_fs_bad_xino(struct super_block *sb)
455 return au_test_fs_remote(sb)
456 || au_test_fs_bad_iattr_size(sb)
457 #ifdef CONFIG_AUFS_BR_RAMFS
458 || !(au_test_ramfs(sb) || au_test_fs_null_nd(sb))
460 || !au_test_fs_null_nd(sb) /* to keep xino code simple */
462 /* don't want unnecessary work for xino */
464 || au_test_ecryptfs(sb)
465 || au_test_nilfs(sb);
468 static inline int au_test_fs_trunc_xino(struct super_block *sb)
470 return au_test_tmpfs(sb)
471 || au_test_ramfs(sb);
475 * test if the @sb is real-readonly.
477 static inline int au_test_fs_rr(struct super_block *sb)
479 return au_test_squashfs(sb)
480 || au_test_iso9660(sb)
481 || au_test_cramfs(sb)
482 || au_test_romfs(sb);
485 #endif /* __KERNEL__ */
486 #endif /* __AUFS_FSTYPE_H__ */