blob: 10216604c5b30741c33d3b0b77e7af6c9c379cb2 [file] [log] [blame]
subrata_modak431c9dd2009-08-04 11:30:16 +00001/*
2 * Michal Simek <monstr@monstr.eu>, 2009-08-03 - ramfs
3 * Kumar Gala <galak@kernel.crashing.org>, 2007-11-14 - nfs
4 * Ricky Ng-Adam <rngadam@yahoo.com>, 2005-01-01 - tmpfs
5 *
6 * DESCRIPTION
7 * Check if current directory is on a tmpfs/nfs/ramfs filesystem
8 * If current directory is tmpfs/nfs/ramfs, return 1
9 * If current directory is NOT tmpfs/nfs/ramfs, return 0
10 */
11
12#include <sys/vfs.h>
13
Wanlong Gao354ebb42012-12-07 10:10:04 +080014#define TMPFS_MAGIC 0x01021994 /* man 2 statfs */
subrata_modak431c9dd2009-08-04 11:30:16 +000015int tst_is_cwd_tmpfs(void)
16{
17 struct statfs sf;
18 statfs(".", &sf);
19
20 /* Verify that the file is not on a tmpfs (in-memory) filesystem */
Cyril Hrubisce101842011-02-24 20:07:33 +010021 return (sf.f_type == TMPFS_MAGIC);
subrata_modak431c9dd2009-08-04 11:30:16 +000022}
23
Wanlong Gao354ebb42012-12-07 10:10:04 +080024#define NFS_MAGIC 0x6969 /* man 2 statfs */
subrata_modak431c9dd2009-08-04 11:30:16 +000025int tst_is_cwd_nfs(void)
26{
27 struct statfs sf;
28 statfs(".", &sf);
29
30 /* Verify that the file is not on a nfs filesystem */
Cyril Hrubisce101842011-02-24 20:07:33 +010031 return (sf.f_type == NFS_MAGIC);
subrata_modak431c9dd2009-08-04 11:30:16 +000032}
33
Wanlong Gao354ebb42012-12-07 10:10:04 +080034#define V9FS_MAGIC 0x01021997 /* kernel-source/include/linux/magic.h */
Cyril Hrubisbc5da682011-02-24 20:04:44 +010035int tst_is_cwd_v9fs(void)
36{
Wanlong Gao354ebb42012-12-07 10:10:04 +080037 struct statfs sf;
38 statfs(".", &sf);
Cyril Hrubisbc5da682011-02-24 20:04:44 +010039
Wanlong Gao354ebb42012-12-07 10:10:04 +080040 /* Verify that the file is not on a nfs filesystem */
41 return (sf.f_type == V9FS_MAGIC);
Cyril Hrubisbc5da682011-02-24 20:04:44 +010042}
43
subrata_modak431c9dd2009-08-04 11:30:16 +000044#define RAMFS_MAGIC 0x858458f6
45int tst_is_cwd_ramfs(void)
46{
47 struct statfs sf;
48 statfs(".", &sf);
49
50 /* Verify that the file is not on a ramfs (in-memory) filesystem */
Cyril Hrubisce101842011-02-24 20:07:33 +010051 return (sf.f_type == RAMFS_MAGIC);
52}