Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if a directory is remotely mounted using Java

Tags:

java

mount

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.

like image 883
Mike Kucera Avatar asked Jan 27 '10 22:01

Mike Kucera


1 Answers

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"

like image 169
Anycorn Avatar answered Nov 15 '22 08:11

Anycorn