blob: ad6b747f025659d27b70b22963f57d596ae0d80b [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
14#define TMPFS_MAGIC 0x01021994 /* man 2 statfs */
15int 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 */
21 return sf.f_type == TMPFS_MAGIC ? 1 : 0;
22}
23
24#define NFS_MAGIC 0x6969 /* man 2 statfs */
25int 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 */
31 return sf.f_type == NFS_MAGIC ? 1 : 0;
32}
33
34#define RAMFS_MAGIC 0x858458f6
35int tst_is_cwd_ramfs(void)
36{
37 struct statfs sf;
38 statfs(".", &sf);
39
40 /* Verify that the file is not on a ramfs (in-memory) filesystem */
41 return sf.f_type == RAMFS_MAGIC ? 1 : 0;
42}