finding the filesystem of a file

david.r.connet dcon at cbnewsc.att.com
Wed Nov 7 06:51:05 AEST 1990


In article <10243 at jpl-devvax.JPL.NASA.GOV>, lwall at jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:
> In article <6500 at emory.mathcs.emory.edu> dt at 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 at iwtng.att.com



More information about the Comp.unix.shell mailing list