detecting nfs mounted files



Hi,

I want to be able to determine if a file is on a local disk or will be nfs
mounted by the automounter.

For example if I use the following code on a Solaris machine,
---------------------------------------------------------------------
#include <sys/statvfs.h>
int
main (int argc, char *argv[])
{
 struct statvfs buf;
 statvfs(argv[1],&buf);
 printf("Filesystem Type for %s is %s.\n",argv[1],buf.f_basetype);
}

/*Yes I know its ugly and has no error checking but its just for illustration
purposes.*/
----------------------------------------------------------------------

I can find out if a dir is going to be automounted, or if it is already mounted
via nfs.

typical results from this are.

# ./a.out /usr/lib
Filesystem Type for /usr/lib is ufs.

#./a.out /home/stephenb/
Filesystem Type for /home/stephenb is nfs.

#./a.out /home/guest
Filesystem Type for/home/guest is autofs.

The first case is a local file.
The second case is my homedir which is already automounted
The third case is another homedir which is not mounted but I know it will
automounted.

Does anyone know how to do a similar thing that would work on both Solaris and
linux?

I really just need to know if a file is local or remote.

Thanks,

Stephen.






_______________________________________________
gnome-hackers mailing list
gnome-hackers gnome org
http://mail.gnome.org/mailman/listinfo/gnome-hackers




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]