in reply to How to Determine If A File Is On NFS? Local? Etc?

If it's only external commands you're worried about, you could read from /proc/mtab, as it contains the same information that mount provides (though in a different format).
--
$me = rand($hacker{perl});

All code, unless otherwise noted, is untested
  • Comment on Re: How to Determine If A File Is On NFS? Local? Etc?

Replies are listed 'Best First'.
Re^2: How to Determine If A File Is On NFS? Local? Etc?
by jaco (Pilgrim) on Sep 21, 2004 at 19:46 UTC
    while a good idea it's also very platform specific.
    Which it appears is something that he's trying to avoid.
    That is to say at least writing the code to deal with the
    multiple platforms <is to be avoided.

    I don't think there's anyway around this. You're either going to have to use an exec
    (in which case you'll still have very platform specific output) Or code out the values
    of the devices based on OS, or some other such nonsense. No matter how you look
    at it you're going to have to deal with the fact that OS' don't treat mount points or
    device numbers the same way.
      Since he mentioned NFS and Samba, I presumed that platform-specifity wasn't as much an issue as relying on external commands.

      I agree that there is pretty much no way of accomplishing the given task reliably in a cross-platform manner. However "an OS with /proc filesystem support" is a much better qualifier than "an OS which has a 'mount' command that produces output in a specific format". So, using the mtab file is still better than using the output from mount.

      The closest one could get to "cross-platform" would be checking the most likely OS targets to see which you are running under, and perform the logic that works for that OS. That's an unmaintainable curmudgeon, though.

      --
      $me = rand($hacker{perl});

      All code, unless otherwise noted, is untested