How to tell if a directory is remotely mounted using Java

java, mount

Solution

for Linux, and possibly Macintosh, you can use system library through JNI. The relevant system call is `getmntent`, described here.

There is a field in `mntent` you can use to check to see if mount point is from device or a server, `mnt_fsname`, in a similar field you can get filesystem type, `mnt_type"

Problem

Is there a way to determine programatically if a particular directory is actually remotely mounted? Can this be done with Java, and if not can it be done with native C code over JNI? Since this is Java it could be running under Linux or Windows or Mac, so a proper solution needs to address all these platforms. (Again if its multiple separate solutions with C over JNI thats ok). And there may be different cases like with NFS or samba or anything else. Thanks.

Original source