From 01c165cd1b2ac601d5ae73d3cb5e82ccdd94ac94 Mon Sep 17 00:00:00 2001 From: Le Chi Thu Date: Tue, 3 Apr 2012 01:23:00 +0200 Subject: Initial commit --- ltp_framework/lib/tst_is_cwd.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 ltp_framework/lib/tst_is_cwd.c (limited to 'ltp_framework/lib/tst_is_cwd.c') diff --git a/ltp_framework/lib/tst_is_cwd.c b/ltp_framework/lib/tst_is_cwd.c new file mode 100644 index 0000000..636aaca --- /dev/null +++ b/ltp_framework/lib/tst_is_cwd.c @@ -0,0 +1,52 @@ +/* + * Michal Simek , 2009-08-03 - ramfs + * Kumar Gala , 2007-11-14 - nfs + * Ricky Ng-Adam , 2005-01-01 - tmpfs + * + * DESCRIPTION + * Check if current directory is on a tmpfs/nfs/ramfs filesystem + * If current directory is tmpfs/nfs/ramfs, return 1 + * If current directory is NOT tmpfs/nfs/ramfs, return 0 + */ + +#include + +#define TMPFS_MAGIC 0x01021994 /* man 2 statfs */ +int tst_is_cwd_tmpfs(void) +{ + struct statfs sf; + statfs(".", &sf); + + /* Verify that the file is not on a tmpfs (in-memory) filesystem */ + return (sf.f_type == TMPFS_MAGIC); +} + +#define NFS_MAGIC 0x6969 /* man 2 statfs */ +int tst_is_cwd_nfs(void) +{ + struct statfs sf; + statfs(".", &sf); + + /* Verify that the file is not on a nfs filesystem */ + return (sf.f_type == NFS_MAGIC); +} + +#define V9FS_MAGIC 0x01021997 /* kernel-source/include/linux/magic.h */ +int tst_is_cwd_v9fs(void) +{ + struct statfs sf; + statfs(".", &sf); + + /* Verify that the file is not on a nfs filesystem */ + return (sf.f_type == V9FS_MAGIC); +} + +#define RAMFS_MAGIC 0x858458f6 +int tst_is_cwd_ramfs(void) +{ + struct statfs sf; + statfs(".", &sf); + + /* Verify that the file is not on a ramfs (in-memory) filesystem */ + return (sf.f_type == RAMFS_MAGIC); +} -- cgit v1.2.3