问题
I would like to build a FUSE-based underland filesystem application, in Java. There are a few bindings library available on the web, Fuse-J, jnetfs, Fuseforjava, javafuse.
None of them seem really alive as of today, so I gave my first try to JavaFuse
.
The interface we must implement is there: http://code.google.com/p/javafuse/source/browse/fs/JavaFS.java
and I wanted to reproduce this fuse helloworld example.
Question: Is there any chance that this:
static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
(void) offset;
(void) fi;
if(strcmp(path, "/") != 0)
return -ENOENT;
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, hello_path + 1, NULL, 0);
return 0;
}
can be implemented by this java function:
public int readdir_pre(String path, long buf, long filler, int offset, Fuse_file_info info);
public int readdir_post(String path, long buf, long filler, int offset, Fuse_file_info info, int result);
- Fuse_file_info
Maybe I missed something, but I can't see how to use filler
to populate the directory content ...
There are other oddities just for this helloworld example, like:
public int read_post(String path, String buf, int size, int offset, Fuse_file_info info, int result);
which is supposed to fill buf
with size
bytes of data, whereas Java String
are supposed to be immutable.
回答1:
You can try jnr-fuse project.
The project uses JNR, so you achieve full JNI performance and ease of implementation.
An example of implementation hello-world filesystem filter.
回答2:
I'm not exactly sure, what you are trying to do with the double function read_pre
& read_post
.
Though I guess, they represent pre-work and post-work. Maybe you can declare the normal readdir()
and call you pre & post from inside? Passing the same arguments back & forth? Because you have to declare readdir()
to the fuse_main()
.
And about the second thing with buffers, it just expects a byte holding storage. You can pass it character arrays, or anything with bytes in it, denoted by size_t size
that represents the size of buffer. In helloworld.c
, the string characters are copied to buffer through memcpy()
. You can read bytes from file and pass them on as buffer along with appropriate length.
I'm new to FUSE and would like to know how it is to work using Java as compared to the standard C.
来源:https://stackoverflow.com/questions/11233838/any-chance-javafuse-can-work