help in finding which machine a file is actually stored on
MFHorn
arosen at hawk.ulowell.edu
Wed May 24 06:13:35 AEST 1989
>From article <8204 at thorin.cs.unc.edu>, by sunj at unc.cs.unc.edu (John Sun):
> I need help some help in determining the actual machine a file is stored
> on. What I am looking for is a routine that given an absolute file name
> returns the machine it is stored on in a NFS environment. Is there a
> "system" call that does this? If not, any pointers in helping me write
> such a routine would be appreciated. Thanks!
Here's one way (probably not the only way). I'm assuming a BSD-like
system with a sane stat(2) struct, /etc/fstab and getfsent(3).
-Stat(2) the file and save the st_dev field.
-Look through /etc/fstab (see getfsent(3)), and stat(2) each mount
point (the fs_file field).
-If the st_dev fields match, you've got the right filesystem.
You can then check fs_type to see what type of filesystem it's on,
and fs_spec to find the system the file is on.
--
Andy Rosen | arosen at hawk.ulowell.edu | "I got this guitar and I
ULowell, Box #3031 | ulowell!arosen | learned how to make it
Lowell, Ma 01854 | | talk" -Thunder Road
RD in '88 - The way it should've been
More information about the Comp.unix.questions
mailing list