Xref: utzoo comp.unix.questions:13811 comp.unix.wizards:16338 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ulowell!arosen@hawk.ulowell.edu From: arosen@hawk.ulowell.edu (MFHorn) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: help in finding which machine a file is actually stored on Message-ID: <13397@swan.ulowell.edu> Date: 23 May 89 20:13:35 GMT References: <8204@thorin.cs.unc.edu> Sender: news@swan.ulowell.edu Lines: 23 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