2
* Copyright (C) 2005-2009 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>
31
#include <linux/aufs_type.h>
33
static inline int au_test_aufs(struct super_block *sb)
35
return sb->s_magic == AUFS_SUPER_MAGIC;
38
static inline const char *au_sbtype(struct super_block *sb)
40
return sb->s_type->name;
43
static inline int au_test_iso9660(struct super_block *sb __maybe_unused)
45
#if defined(CONFIG_ROMFS_FS) || defined(CONFIG_ROMFS_FS_MODULE)
46
return sb->s_magic == ROMFS_MAGIC;
52
static inline int au_test_romfs(struct super_block *sb __maybe_unused)
54
#if defined(CONFIG_ISO9660_FS) || defined(CONFIG_ISO9660_FS_MODULE)
55
return sb->s_magic == ISOFS_SUPER_MAGIC;
61
static inline int au_test_cramfs(struct super_block *sb __maybe_unused)
63
#if defined(CONFIG_CRAMFS) || defined(CONFIG_CRAMFS_MODULE)
64
return sb->s_magic == CRAMFS_MAGIC;
69
static inline int au_test_nfs(struct super_block *sb __maybe_unused)
71
#if defined(CONFIG_NFS_FS) || defined(CONFIG_NFS_FS_MODULE)
72
return sb->s_magic == NFS_SUPER_MAGIC;
78
static inline int au_test_fuse(struct super_block *sb __maybe_unused)
80
#if defined(CONFIG_FUSE_FS) || defined(CONFIG_FUSE_FS_MODULE)
81
return sb->s_magic == FUSE_SUPER_MAGIC;
87
static inline int au_test_xfs(struct super_block *sb __maybe_unused)
89
#if defined(CONFIG_XFS_FS) || defined(CONFIG_XFS_FS_MODULE)
90
return sb->s_magic == XFS_SB_MAGIC;
96
static inline int au_test_tmpfs(struct super_block *sb __maybe_unused)
99
return sb->s_magic == TMPFS_MAGIC;
105
static inline int au_test_ecryptfs(struct super_block *sb __maybe_unused)
107
#if defined(CONFIG_ECRYPT_FS) || defined(CONFIG_ECRYPT_FS_MODULE)
108
return !strcmp(au_sbtype(sb), "ecryptfs");
114
static inline int au_test_smbfs(struct super_block *sb __maybe_unused)
116
#if defined(CONFIG_SMB_FS) || defined(CONFIG_SMB_FS_MODULE)
117
return sb->s_magic == SMB_SUPER_MAGIC;
123
static inline int au_test_ocfs2(struct super_block *sb __maybe_unused)
125
#if defined(CONFIG_OCFS2_FS) || defined(CONFIG_OCFS2_FS_MODULE)
126
return sb->s_magic == OCFS2_SUPER_MAGIC;
132
static inline int au_test_ocfs2_dlmfs(struct super_block *sb __maybe_unused)
134
#if defined(CONFIG_OCFS2_FS_O2CB) || defined(CONFIG_OCFS2_FS_O2CB_MODULE)
135
return sb->s_magic == DLMFS_MAGIC;
141
static inline int au_test_coda(struct super_block *sb __maybe_unused)
143
#if defined(CONFIG_CODA_FS) || defined(CONFIG_CODA_FS_MODULE)
144
return sb->s_magic == CODA_SUPER_MAGIC;
150
static inline int au_test_v9fs(struct super_block *sb __maybe_unused)
152
#if defined(CONFIG_9P_FS) || defined(CONFIG_9P_FS_MODULE)
153
return sb->s_magic == V9FS_MAGIC;
159
static inline int au_test_ext4(struct super_block *sb __maybe_unused)
161
#if defined(CONFIG_EXT4DEV_FS) || defined(CONFIG_EXT4DEV_FS_MODULE)
162
return sb->s_magic == EXT4_SUPER_MAGIC;
168
static inline int au_test_sysv(struct super_block *sb __maybe_unused)
170
#if defined(CONFIG_SYSV_FS) || defined(CONFIG_SYSV_FS_MODULE)
171
return !strcmp(au_sbtype(sb), "sysv");
177
static inline int au_test_ramfs(struct super_block *sb)
179
return sb->s_magic == RAMFS_MAGIC;
182
static inline int au_test_ubifs(struct super_block *sb __maybe_unused)
184
#if defined(CONFIG_UBIFS_FS) || defined(CONFIG_UBIFS_FS_MODULE)
185
return sb->s_magic == UBIFS_SUPER_MAGIC;
191
static inline int au_test_procfs(struct super_block *sb __maybe_unused)
193
#ifdef CONFIG_PROC_FS
194
return sb->s_magic == PROC_SUPER_MAGIC;
200
static inline int au_test_sysfs(struct super_block *sb __maybe_unused)
203
return sb->s_magic == SYSFS_MAGIC;
209
static inline int au_test_configfs(struct super_block *sb __maybe_unused)
211
#if defined(CONFIG_CONFIGFS_FS) || defined(CONFIG_CONFIGFS_FS_MODULE)
212
return sb->s_magic == CONFIGFS_MAGIC;
218
static inline int au_test_minix(struct super_block *sb __maybe_unused)
220
#if defined(CONFIG_MINIX_FS) || defined(CONFIG_MINIX_FS_MODULE)
221
return sb->s_magic == MINIX3_SUPER_MAGIC
222
|| sb->s_magic == MINIX2_SUPER_MAGIC
223
|| sb->s_magic == MINIX2_SUPER_MAGIC2
224
|| sb->s_magic == MINIX_SUPER_MAGIC
225
|| sb->s_magic == MINIX_SUPER_MAGIC2;
231
static inline int au_test_cifs(struct super_block *sb __maybe_unused)
233
#if defined(CONFIG_CIFS_FS) || defined(CONFIGCIFS_FS_MODULE)
234
return sb->s_magic == CIFS_MAGIC_NUMBER;
240
static inline int au_test_fat(struct super_block *sb __maybe_unused)
242
#if defined(CONFIG_FAT_FS) || defined(CONFIG_FAT_FS_MODULE)
243
return sb->s_magic == MSDOS_SUPER_MAGIC;
249
static inline int au_test_msdos(struct super_block *sb)
251
return au_test_fat(sb);
254
static inline int au_test_vfat(struct super_block *sb)
256
return au_test_fat(sb);
259
static inline int au_test_securityfs(struct super_block *sb __maybe_unused)
261
#ifdef CONFIG_SECURITYFS
262
return sb->s_magic == SECURITYFS_MAGIC;
268
static inline int au_test_squashfs(struct super_block *sb __maybe_unused)
270
#if defined(CONFIG_SQUASHFS) || defined(CONFIG_SQUASHFS_MODULE)
271
return sb->s_magic == SQUASHFS_MAGIC;
277
static inline int au_test_btrfs(struct super_block *sb __maybe_unused)
279
#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
280
return sb->s_magic == BTRFS_SUPER_MAGIC;
286
static inline int au_test_xenfs(struct super_block *sb __maybe_unused)
288
#if defined(CONFIG_XENFS) || defined(CONFIG_XENFS_MODULE)
289
return sb->s_magic == XENFS_SUPER_MAGIC;
295
static inline int au_test_debugfs(struct super_block *sb __maybe_unused)
297
#ifdef CONFIG_DEBUG_FS
298
return sb->s_magic == DEBUGFS_MAGIC;
304
static inline int au_test_nilfs(struct super_block *sb __maybe_unused)
306
#if defined(CONFIG_NILFS) || defined(CONFIG_NILFS_MODULE)
307
return sb->s_magic == NILFS_SUPER_MAGIC;
313
/* ---------------------------------------------------------------------- */
315
* they can't be an aufs branch.
317
static inline int au_test_fs_unsuppoted(struct super_block *sb)
320
#ifndef CONFIG_AUFS_BR_RAMFS
325
|| au_test_configfs(sb)
326
|| au_test_debugfs(sb)
327
|| au_test_securityfs(sb)
329
|| au_test_ecryptfs(sb)
330
/* || !strcmp(au_sbtype(sb), "unionfs") */
331
|| au_test_aufs(sb); /* will be supported in next version */
335
* If the filesystem supports NFS-export, then it has to support NULL as
336
* a nameidata parameter for ->create(), ->lookup() and ->d_revalidate().
337
* We can apply this principle when we handle a lower filesystem.
339
static inline int au_test_fs_null_nd(struct super_block *sb)
341
return !!sb->s_export_op;
344
static inline int au_test_fs_remote(struct super_block *sb)
346
return !au_test_tmpfs(sb)
347
#ifdef CONFIG_AUFS_BR_RAMFS
348
&& !au_test_ramfs(sb)
350
&& !(sb->s_type->fs_flags & FS_REQUIRES_DEV);
353
/* ---------------------------------------------------------------------- */
356
* Note: these functions (below) are created after reading ->getattr() in all
357
* filesystems under linux/fs. it means we have to do so in every update...
361
* some filesystems require getattr to refresh the inode attributes before
363
* in most cases, we can rely on the inode attribute in NFS (or every remote fs)
364
* and leave the work for d_revalidate()
366
static inline int au_test_fs_refresh_iattr(struct super_block *sb)
368
return au_test_nfs(sb)
370
/* || au_test_smbfs(sb) */ /* untested */
371
/* || au_test_ocfs2(sb) */ /* untested */
372
/* || au_test_btrfs(sb) */ /* untested */
373
/* || au_test_coda(sb) */ /* untested */
374
/* || au_test_v9fs(sb) */ /* untested */
379
* filesystems which don't maintain i_size or i_blocks.
381
static inline int au_test_fs_bad_iattr_size(struct super_block *sb)
383
return au_test_xfs(sb)
384
/* || au_test_ext4(sb) */ /* untested */
385
/* || au_test_ocfs2(sb) */ /* untested */
386
/* || au_test_ocfs2_dlmfs(sb) */ /* untested */
387
/* || au_test_sysv(sb) */ /* untested */
388
/* || au_test_ubifs(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
413
|| au_test_ubifs(sb);
417
* filesystems which sets S_NOATIME and S_NOCMTIME.
419
static inline int au_test_fs_notime(struct super_block *sb)
421
return au_test_nfs(sb)
424
/* || au_test_cifs(sb) */ /* untested */
429
* filesystems which requires replacing i_mapping.
431
static inline int au_test_fs_bad_mapping(struct super_block *sb)
433
return au_test_fuse(sb)
434
|| au_test_ubifs(sb);
437
/* temporary support for i#1 in cramfs */
438
static inline int au_test_fs_unique_ino(struct inode *inode)
440
if (au_test_cramfs(inode->i_sb))
441
return inode->i_ino != 1;
445
/* ---------------------------------------------------------------------- */
448
* the filesystem where the xino files placed must support i/o after unlink and
449
* maintain i_size and i_blocks.
451
static inline int au_test_fs_bad_xino(struct super_block *sb)
453
return au_test_fs_remote(sb)
454
|| au_test_fs_bad_iattr_size(sb)
455
#ifdef CONFIG_AUFS_BR_RAMFS
456
|| !(au_test_ramfs(sb) || au_test_fs_null_nd(sb))
458
|| !au_test_fs_null_nd(sb) /* to keep xino code simple */
460
/* don't want unnecessary work for xino */
462
|| au_test_ecryptfs(sb)
463
|| au_test_nilfs(sb);
466
static inline int au_test_fs_trunc_xino(struct super_block *sb)
468
return au_test_tmpfs(sb)
469
|| au_test_ramfs(sb);
473
* test if the @sb is real-readonly.
475
static inline int au_test_fs_rr(struct super_block *sb)
477
return au_test_squashfs(sb)
478
|| au_test_iso9660(sb)
479
|| au_test_cramfs(sb)
480
|| au_test_romfs(sb);
483
#endif /* __KERNEL__ */
484
#endif /* __AUFS_FSTYPE_H__ */