Running built-in fuse HelloFS example file system, shows a hello.txt file on root. Opening this file show an error as "...The file changed on disk do you want to reload the file. Reload/cancel"
How can I remove this error.
I am facing the same error in my custom File System because I had taken HelloFS as starting point. To make question simple I quoted HelloFS code because the same error is in helloFS also.
example code, log and screenshot of error are as below:
HelloFS java Code:
package net.fusejna.examples;
import java.io.File;
import java.nio.ByteBuffer;
import net.fusejna.DirectoryFiller;
import net.fusejna.ErrorCodes;
import net.fusejna.FuseException;
import net.fusejna.StructFuseFileInfo.FileInfoWrapper;
import net.fusejna.StructStat.StatWrapper;
import net.fusejna.types.TypeMode.NodeType;
import net.fusejna.util.FuseFilesystemAdapterFull;
public class HelloFS extends FuseFilesystemAdapterFull
{
public static void main(final String... args) throws FuseException
{
if (args.length != 1) {
System.err.println("Usage: HelloFS <mountpoint>");
System.exit(1);
}
new HelloFS().log(true).mount(args[0]);
}
private final String filename = "/hello.txt";
private final String contents = "Hello World!\n";
@Override
public int getattr(final String path, final StatWrapper stat)
{
if (path.equals(File.separator)) { // Root directory
stat.setMode(NodeType.DIRECTORY);
return 0;
}
if (path.equals(filename)) { // hello.txt
stat.setMode(NodeType.FILE).size(contents.length());
return 0;
}
return -ErrorCodes.ENOENT();
}
@Override
public int read(final String path, final ByteBuffer buffer, final long size, final long offset, final FileInfoWrapper info)
{
// Compute substring that we are being asked to read
final String s = contents.substring((int) offset,
(int) Math.max(offset, Math.min(contents.length() - offset, offset + size)));
buffer.put(s.getBytes());
return s.getBytes().length;
}
@Override
public int readdir(final String path, final DirectoryFiller filler)
{
filler.add(filename);
return 0;
}
}
error: ...The file changed on disk do you want to reload the file. Reload/cancel
log:
Mar 24, 2014 12:16:15 AM HelloFS statfs
INFO: [/] Method succeeded. Result: 0
Mar 24, 2014 12:16:33 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:36 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS getattr
INFO: [/] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS open
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS read
INFO: [/hello.txt] Method succeeded. Result: 13
Mar 24, 2014 12:16:45 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS flush
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS lock
INFO: [/hello.txt] Method succeeded. Result: -38
Mar 24, 2014 12:16:45 AM HelloFS release
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:46 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:46 AM HelloFS getattr
INFO: [/] Method succeeded. Result: 0
Mar 24, 2014 12:16:48 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Please Guide me how to fix this