In *nix, how to determine which filesystem a particular file is on?

Posted by smokris on Server Fault See other posts from Server Fault or by smokris
Published on 2009-09-17T22:36:25Z Indexed on 2011/11/16 10:00 UTC
Read the original article Hit count: 341

Filed under:
|
|
|
|

In a generic, modern unix environment (say, GNU/Linux, GNU/Solaris, or Mac OS X), is there a good way to determine which mountpoint and filesystem-type a particular absolute file path is on?

I suppose I could execute the mount command and manually parse the output of that and string-compare it with my file path, but before I do that I'm wondering if there's a more elegant way.

I'm developing a BASH script that makes use of extended attributes, and want to make it Do The Right Thing (to the small extent that it is possible) for a variety of filesystems and host environments.

© Server Fault or respective owner

Related posts about unix

Related posts about bash