sunj@unc.cs.unc.edu (John Sun) (05/23/89)
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! John Sun sunj@dopey.cs.unc.edu
sethr@cunixc.cc.columbia.edu (Seth Robertson) (05/24/89)
In article <8204@thorin.cs.unc.edu> sunj@unc.cs.unc.edu (John Sun) writes: >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! Well, one way is to do a `df filename` If df returns "machinename:directory" it's on machinename. If df returns "directory" it's on the local machine. It will follow symbolic links correctly and everything. -Seth seth@ctr.columbia.edu
arosen@hawk.ulowell.edu (MFHorn) (05/24/89)
From article <8204@thorin.cs.unc.edu>, by sunj@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@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
gil@banyan.UUCP (Gil Pilz@Eng@Banyan) (05/26/89)
In article <8204@thorin.cs.unc.edu> sunj@unc.cs.unc.edu (John Sun) writes: >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. Stop. Go back and try to figure out why you think you need to do this. Chances are you're looking at the problem from an awkward angle. The whole point of distributed file systems is to free you from worrying about _where_ the files "actually" are. Whenever you find yourself running counter to the basic design goals of the tools you are using it's time to look at why you are using _those_ tools. Just a bit of unasked for advice. -=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=- Gilbert W. Pilz Jr. gil@banyan.com Banyan Systems Inc. (617) 898-1196 115 Flanders Road Westboro, MA 01581 -=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
mike@relgyro.stanford.edu (Mike Macgirvin) (05/27/89)
In article <8204@thorin.cs.unc.edu> sunj@unc.cs.unc.edu (John Sun) writes: >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. Try the sun-source archives at rice.edu. I think the program is called 'nfstat'. In article <435@banyan.UUCP> gil@banyan.com writes: >Stop. Go back and try to figure out why you think you need to do this. >Chances are you're looking at the problem from an awkward angle. The >whole point of distributed file systems is to free you from worrying >about _where_ the files "actually" are. Whenever you find yourself This is a great idea, but we live in an imperfect world, where file systems have finite sizes. ------------------------------------------------------- "There must be some kind of way out of here." Mike Macgirvin - mike@relgyro.stanford.edu (36.64.0.50) ------------------------------------------------------- ------------------------------------------------------- "There must be some kind of way out of here." Mike Macgirvin - mike@relgyro.stanford.edu (36.64.0.50) -------------------------------------------------------
abrams@max.bnl.gov (The Ancient Programmer) (06/03/89)
>In article <8204@thorin.cs.unc.edu> sunj@unc.cs.unc.edu (John Sun) writes: >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. Wouldn't "df /absolute/path/name" return the following? Filesystem kbytes used avail capacity Mounted on node_name:filesystem .....disk statistics.... /where_mounted ^^^^^^^^^ This should tell you what machine the file is actually on. Or have I misunderstood your question? INTERNET: abrams@bnlux0.bnl.gov BITNET: abrams@bnlux0.BITNET UUCP: ...philabs!sbcs!bnlux0!abrams