运行内置保险丝HelloFS示例文件系统,在root上显示hello.txt文件。 打开此文件显示错误为“...在磁盘上更改了文件是否要重新加载文件。重新加载/取消”
如何删除此错误。
我在自定义文件系统中面临同样的错误,因为我已将HelloFS作为起点。为了简化问题,我引用了HelloFS代码,因为同样的错误也在helloFS中。
示例代码,日志和错误屏幕截图如下:
HelloFS java代码:
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;
}
}
错误:...磁盘上更改的文件是否要重新加载文件。重载/取消
日志:
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
请指导我如何解决此问题
答案 0 :(得分:2)
我不熟悉FUSE的Java版本(我主要做的是C ++ / Python),但根据你的跟踪,我会说你的编辑器应用程序就是释放文件句柄的应用程序。也许它正在执行类似打开/读取/关闭的操作,然后将其保存在缓存中。尝试以更简单的方式打开文件,例如vi,或者使用cat。
关于“内容在磁盘上已更改”的内容可能是您的编辑器响应您的统计结构中不断变化的时间戳。尝试将您的StatWrapper.mtime(在您的getattr函数中)设置为某个固定时间,例如unix epoch,并查看是否有帮助。
示例文件系统是一个很好的起点,但为了易于理解,通常会有很多它们没有实现。