[prev in list] [next in list] [prev in thread] [next in thread] 

List:       grid-engine-dev
Subject:    Detecting NFS filesystems
From:       Andy Schwierskott <andy.schwierskott () sun ! com>
Date:       2004-01-29 11:36:47
Message-ID: Pine.GSO.4.56.0401291226070.28000 () sr-ergb01-01
[Download RAW message or body]

Hi,

on some systems locally mounted file systems can easily found out with
"df -l". A generic programmatic appraoch is the statfs/statvfs system call
interface. I tested the code below in our lab systems, however I couldn't test it on
SUPER-UX, Freebsd, (Cray) and Linux on OS'es other than x86.

Could you please send me your feedback. Does it return "nfs" when you run

    statfs <path_to_nfs_filesystem>

Below is the code. On Linux compile it

   gcc -DLINUX statfs.c -o statfs

on Mac:

    gcc -DDARWIN statfs.c -o statfs

and on other OS'es

    cc statfs.c -o statfs

---------------------------------------------------------
#if defined(DARWIN)
#  include <sys/param.h>
#  include <sys/mount.h>
#elif defined(LINUX)
#  include <sys/vfs.h>
#else
#  include <sys/types.h>
#  include <sys/statvfs.h>
#endif

#include <stdio.h>

int main(int argc, char *argv[])
{
#if defined(LINUX) || defined(DARWIN)
   struct statfs buf;
   statfs(argv[1], &buf);
#else
   struct statvfs buf;
   statvfs(argv[1], &buf);
#endif

#if defined (DARWIN)
   printf("%s\n", buf.f_fstypename);
#elif defined(LINUX)
   if (buf.f_type == 0x6969)
      printf("nfs\n");
   else
      printf("%lx\n", buf.f_type);
#else
   printf("%s\n", buf.f_basetype);
#endif
}
---------------------------------------------------------

Thanks,
Andy

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic