从 Java 程序访问 NFS 共享
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1864299/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Access NFS share from Java program
提问by Ben
I'd like to read some data from an NFS share from my Java program. I'd need the program to authenticate to the NFS server first, then do the I/O. (Requiring the NFS share to be previously mounted is not acceptable.)
我想从我的 Java 程序的 NFS 共享中读取一些数据。我需要该程序首先向 NFS 服务器进行身份验证,然后进行 I/O。(要求先前安装 NFS 共享是不可接受的。)
So, I'd like the functionality that's provided by this library: http://jcifs.samba.org/, except for NFS instead of CIFS. Is such a thing built into Java already, or do I need a third-party library?
所以,我想要这个库提供的功能:http: //jcifs.samba.org/,除了 NFS 而不是 CIFS。Java 已经内置了这样的东西,还是我需要第三方库?
I'm also interested in whether this can be done in Perl, Python, or Ruby. But mostly Java.
我也对这是否可以在 Perl、Python 或 Ruby 中完成感兴趣。但主要是Java。
回答by AravindC
I am the author of the NFS client in Java mentioned above. Sorry for such a late reply. I still have a copy lying around even though I am not sure whether it is compatible with Java 1.4+. I can work on it if there is real interest.
我是上述 Java 中 NFS 客户端的作者。抱歉这么晚回复。即使我不确定它是否与 Java 1.4+ 兼容,我仍然有一份副本。如果有真正的兴趣,我可以工作。
回答by UnixShadow
There is a library called yaNFS that is a port of webnfs source. I haven't tried it myself, but it looks like it can be something for you http://java.net/projects/yanfs
有一个名为 yaNFS 的库,它是 webnfs 源的一个端口。我自己还没有尝试过,但看起来它可能适合你http://java.net/projects/yanfs
回答by Peter Cordes
NFS is almost always implemented in-kernel, but it looks like you may be in luck. I googled for "nfs client library", and found a few, one even in Java.
NFS 几乎总是在内核中实现,但看起来您可能很幸运。我在 google 上搜索了“nfs 客户端库”,找到了一些,甚至在 Java 中也有。
http://www.jars.com/utilities/libraries/resource.php/12291
http://www.jars.com/utilities/libraries/resource.php/12291
edit: that one's old and abandoned. sorry.
编辑:那个旧的和被遗弃的。对不起。
If you can make sysadmin style changes during install of your app, you can set up automount. e.g. on my linux systems at home, /net/llama/home/peter is my home directory on llama, but the trick is that it's only mounted when I access the path. This looks like a decent intro to automounting:
如果您可以在安装应用程序期间更改系统管理员样式,则可以设置自动挂载。例如,在我家里的 linux 系统上,/net/llama/home/peter 是我在 llama 上的主目录,但诀窍是它仅在我访问路径时才安装。这看起来是一个不错的自动挂载介绍:
http://wiki.archlinux.org/index.php/AutofsIt mostly applies to any Linux distro, except for the bits about installing specific packages.
http://wiki.archlinux.org/index.php/Autofs它主要适用于任何 Linux 发行版,除了关于安装特定软件包的部分。
If you want to enable this only for the user of your app, the automount directory could be inside a directory with limited permissions, unlike the usual /net.
如果您只想为您的应用程序用户启用此功能,则自动挂载目录可能位于权限有限的目录中,这与通常的 /net 不同。

