General Information
FUSE-J Java bindings for FUSE (Filesystem in USErspace) is a Java API that uses JNI bindings to FUSE library and enables writing Linux filesystems in Java language.
FUSE (Filesystem in USErspace) is a simple interface for userspace programs to export a virtual filesystem to the linux kernel.
FUSE is writen by Miklos Szeredi (mszeredi@inf.bme.hu) and can be downloaded from
News
2005-05-18: new relase: FUSE-J 2.2.3
JNI part of FUSE-J (libjavafs.so
) now compiles on
amd64 Linux machines (if it runs remains to be seen). The changes
that were done are:
added option -fPIC
to gcc invocations in
jni/Makefile
.
LDPATH
variable in jni/Makefile
was
hardcoded. Now it is set by including jvm_ldpath.def
file that is generated by running a Java program which produces
correct library paths by looking into
System.getProperty(“java.library.path”)
. This way
we can potentially build with any JDK version on any FUSE supported
platform (not just SUN's JDK on i386 Linux).
libjavafs.so
is now linked with a shared
libfuse.so
(it was linked with static libfuse.a
before, but that didn't work on amd64 machines). When mounting a
filesystem you have to set LD_LIBRARY_PATH
to include
both libfuse.so
directory and libjavafs.so
directory (see the example zipfs_mount.sh
script).
Note that FUSE-J 2.2.3 compiles on amd64 machines (compilation tested on Fedora Core 3 for amd64) but was not run-tested on this architecture. That's because I don't have root access to the SourceForge's compile-farm amd64-linux machine which is needed to be able to load FUSE kernel module. Can someone try this version (example zipfs_mount.sh is enough) on amd64 (and maybe other) architecture?
Download this version from:
http://www.select-tech.si/fuse/fuse-j-2.2.3.tar.gz
2005-04-20: new relase: FUSE-J 2.2.2
Changes:
The main change in this release is that the native to Java API is now byte oriented (not character oriented as before) and that encoding of file names and paths is done in Java (not forced to UTF-8 anymore). This is acomplished with the following:
The interface that JNI bindings invoke is now fuse.FuseFS
(and not fuse.Filesystem
any more). This
interface is byte oriented. This means that any file or path name is
passed as either a direct java.nio.ByteBuffer
(the
fastest way for Java to read from and/or write to native memeory
locations) or a byte[]
array. It is not meant that Java
filesystem implementations would implement this interface directly
but instead use fuse.FilesystemToFuseFSAdapter
class to
convert between a byte oriented and String oriented API. You can
specify an encoding as a parameter to fuse.FilesystemToFuseFSAdapter
constructor.
Multithreaded operation is fixed now. If FUSE library calls Java in multiple threads, those threads are now bound to Java threads as daemon threads so that after unmounting the filesystem (when main_loop returns) JVM can exit normally.
Download this version from:
http://www.select-tech.si/fuse/fuse-j-2.2.2.tar.gz
2005-04-18 afternoon: new release: FUSE-J 2.2.1
Changes:
Incorporated a patch from Daniel Wunsch <the.gray@gmx.net>
(thanks) for a bug that prevented the propagation of errno
from Java to C.
Started to refactor for using new FUSE API (FUSE_USE_VERSION
22
). This caused the Java API to change. fuse.Filesystem
interface has 2 new methods (flush, fsync
) and
some methods have changed signature (namely: open
now
returns a filehandle, read
, write
and
release
have an additional filehandle parameter and
write
has an aditional flag indicating a writepage
operation).
fuse.FuseDirEnt
has an aditional inode
field, so that a filesystem can return inode numbers.
Old fuse.Filesystem
interface has been renamed
to fuse.Filesystem1
and an adapter class
fuse.Filesystem1ToFilesystemAdapter
has been writen so
that old filesystem implementations can be used unchanged (just
replace implements fuse.Filesystem
with implements
fuse.Filesystem1
).
Download this version from:
http://www.select-tech.si/fuse/fuse-j-2.2.1.tar.gz
Plans for future include:
Change fuse.Filesystem
API to use byte[]
instead of String
so that file names encoding will not
be forced to UTF-8 as is now done in JNI bindings but could be done
in Java instead. Update fuse.Filesystem1ToFilesystemAdapter
to work with this new API. (DONE in FUSE-J 2.2.2)
Extend fuse.Filesystem
API to include methods
for working with extended attributes.
Figure out how to pass the client info (struct
fuse_context
) to the Java API.
2005-04-18: After a year and a half of silence and a few Emails I got from various people asking about the FUSE-J binding I decided to update the software to current FUSE version (2.2.1).
I used the patch from Tim Moreton <tim.moreton@cl.cam.ac.uk> (thanks) and made some other minor modifications to compile and work with Java 5. You can download this version from:
http://www.select-tech.si/fuse/fuse-j-2.2.tar.gz
Installation
First you must get and install the FUSE kernel module and library
(se above). By default FUSE library is installed into /usr/local/lib
and header files in /usr/local/include
directories. If
you install FUSE to some other directory, you should edit build.conf
and set FUSE_HOME
variable to the base directory of your
FUSE library/headers instalation.
You will need JDK 1.4 or above (I'm using JDK 1.5.0_02 from
http://java.sun.com).
FUSE-J will not work or compile with JDK 1.3 or earlier since it uses
JNI_VERSION_1_4
features (such as direct
java.nio.ByteBuffer
). Edit build.conf
and
set JDK_HOME
variable to point to the JDK installation.
run 'make'
This will first compile Java sources from src
directory into class files in build
directory. It will
then run the JNI bindings generation process which will produce two
files: jni/javafs_bindings.h
&
jni/javafs_bindings.c
. After that the jni/libjavafs.so
shared library for inclusion in the JVM will be built.
How To Use
FUSE-J is made up of two main parts:
A JNI shared library (jni/libjavafs.so
)
A Java API for implementing and mounting filesystems writen
in Java (Java classes in build
directory)
You can try and test the example ZIP filesystem with the following command:
cd fuse-j-build-dir
./zipfs_mount.sh some.zip
/mnt/point
And then use fusermount to unmount it:
fusremount -u /mnt/point
Here's how to create your very own virtual filesystem in three easy steps:
Implement the fuse.Filesystem
interface (see
example fuse.zipfs.ZipFilesystem
)
call fuse.FuseMount.mount(String[] args,
fuse.Filesystem filesystem)
...where args
is an array
of arguments passed to FUSE library's fuse_main
function
and must contain:
mountpoint as 1st argument
optional options as 2nd and subsequent arguments (see FUSE docs for more info)
...and filesystem
is an
instance of a class implementing fuse.Filesystem
interface
ls -al /mount/point
Author
FUSE-J is writen by Peter Levart (peter@select-tech.si)
FUSE is writen by Miklos Szeredi (mszeredi@inf.bme.hu)