简体   繁体   中英

ANDROID: Accessing CIFS Shares in Java

I'm writing my first Android app, which is more or less going to be a mount point manager. Local mounts and NFS mounts have been easy, but I'm not sure of how to go about CIFS shares.

Ideally, after selecting a host, a list of CIFS shares would be displayed. At the bare minimum, I should be able to enter a CIFS URI/share string and mount it (eg: //192.168.1.100/mount_point). I'm thinking of EStrongs, where you can select a host, and it will display shares, which you can then further explore.

I've seen jCIFS (I think this is what Astro uses), and I've seen mention of the cifs.ko module on xda-developers. Are there any other standard approaches? Any tips/recommendations on how to go about using jCIFS or cifs.ko and doing this in general? I would prefer not to have to gain root access.

Fellow Androider here, I've looked into various protocols in the past and this is what I found:

If it has to be CIFS then I would recommend jCIFS. Astro does use it, as you mentioned and EStrongs does as well. And...so does AndSMB by lysesoft. So, I'm pretty sure that's the 'go to' standard approach.

If you are looking into only supporting SMB, you may be interested in this as an alternative: http://java-source.net/open-source/network-clients/jftp

Also, for other protocols, this is a great list to peruse: http://java-source.net/open-source/network-clients

Hope that helps.

因为Android是Linux,所以您可以使用内核驱动程序,但是加载这些驱动程序需要root权限,或者可以使用FUSE ,据说该功能自Gingerbread以来就受支持(我自己还没有尝试过),或者确实可以使用Java库(如JCIFS)

A quick Wireshark capture shows that EStrongs also uses jCIFS, so that would be my recommendation as well. jCIFS was written to be a CIFS client toolkit, so it should be adaptable to your project goals. It does not "mount" the remote file system, per se., but gives you access to files, directories, share listings, etc. How you present that information is up to you.

Another resource would be Implementing CIFS , an online book about the internals of the SMB/CIFS protocol suite. In particular, take a look at Appendix D , which covers the SMB URL format. The SMB URL is preferred over the mock UNC format used in the original post (above).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM