Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!cbnewsc!dcon From: dcon@cbnewsc.att.com (david.r.connet) Newsgroups: comp.unix.shell Subject: Re: finding the filesystem of a file Keywords: filesystem search find file Message-ID: <1990Nov6.195105.21043@cbnewsc.att.com> Date: 6 Nov 90 19:51:05 GMT References: <6495@emory.mathcs.emory.edu> <6500@emory.mathcs.emory.edu> <10243@jpl-devvax.JPL.NASA.GOV> Distribution: usa Organization: AT&T Bell Laboratories Lines: 23 In article <10243@jpl-devvax.JPL.NASA.GOV>, lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: > In article <6500@emory.mathcs.emory.edu> dt@mathcs.emory.edu (Dave Taylor {guest}) writes: > : > Curious to know if anyone can tell me the fastest way to find out which > : > filesystem a given file is on if the entire pathname is given. > > If you happen to have perl handy, either of the following will work > (presuming you have no symbolic links): [some perl examples] > > In the absence of perl, your best bet will probably be to look for the longest > match from /etc/mtab, presuming you have a reasonable one. The following > works on my /etc/mtab, but is suboptimal: [shell example] On some systems, /etc/mtab is known as /etc/mnttab. Also, on SVR4 systems, [I know this doesn't help you Dave, just throwing out some additional things] you can use the statvfs() call. int statvfs(char *path, struct statvfs *buf); The field buf->f_fstr will give the filesystem name. Dave Connet dcon@iwtng.att.com