This is rather more complex than you might think - it checks any kind of fs that is available - look here:
[link|http://www.reznor.com/tools/lsof/?C=S&O=A|http://www.reznor.co...ols/lsof/?C=S&O=A]
You'll also see that there are a lot of flavors depending on the platform.
I think I would just adapt this code into a function instead of a main().