in reply to Filesystem checking

I think your (stat $dir)[0] idea is fine. Another possibility is to use the -l file test. That still calls stat, so it's probably not any improvement.

You could evade all those stat calls by parsing mount points out of /etc/mtab or the system mount call, then matching paths. That seems messy and has possible inaccuracies, though.

After Compline,
Zaxo