Open lynaghk opened 11 years ago
I can't reproduce this (read
always shows up on each cat
for me), I'm guessing the caching behaviour is OS-dependent.
As for how to fix it, I'm not sure but my gut tells me that these bits are not what they should be. JNA unfortunately makes it pretty painful (i.e. completely manual) to use structs with bitfields in them.
So if I understand correctly, we should have something like this:
32-bit words: ... /------- Word boundary --------\ / - - - - --- Word boundary --------\
Offset: ... 0123456789ABCDEF0123456789ABCDEF 0 1 2 3 4 56789ABCDEF0123456789ABCDEF
C struct: ... <--- 32-bits int writepage ----> <A> <B> <C> <D> <E> <---- 27-bits padding ---->
Java struct: ... \---- public int writepage ----/ \-------- public int flags_bitfield ---------/
Where A
is direct_io
, B
is keep_cache
, etc. Thus, BIT_KEEP_CACHE
should be the second leftmost bit of a 32-bit integer, which on big-endian would be 1 << 30
or 1 << 6
on little-endian. AFAIK the JVM is big-endian, so try setting BIT_KEEP_CACHE
to 1 << 30
in StructFuseFileInfo
and see what happens.
My second gut feeling is simply your operating system ignoring what FUSE says, which isn't out of the question either.
Sorry for the late reply---I wanted to test out your theory that it might be OS dependent. On a 64 bit Debian Linux machine the behavior is what you report; reads from FUSE on every invocation.
I'll see if there are some global options with OS X FUSE that I can use to disable buffering and what, if anything, would need to change with the JNA code to support it.
(I tried private static final int BIT_KEEP_CACHE = 1 << 30;
and 1 << 6
as per your suggestion, but no change in behavior.)
First off---thanks for releasing this project and taking the time to put together a few simple examples. It's exactly what I need and has been great to use thus far.
I need my code to be executed every time something tries to read a file; what's the proper way to tell FUSE not to cache reads?
According the the FUSE docs (http://fuse.sourceforge.net/doxygen/structfuse__file__info.html) I should be able to set the file info stuct to have
keep_cache = 0
in the filesystem'sopen
call. I tried adding this to the included HelloFS example:but the file content is still cached.
cat
ing the file gives:but then
cat
ing it a second time again gives:(Notice the lack of a call to HelloFS's
read
method.)This is on OS X 10.7 with