我尝试在我的环境中添加对UserDefinedFileAttributeView的支持。到目前为止,这是我所做的。我已经将'user_xattr'选项添加到/ etc / fstab文件中:
# / was on /dev/sda3 during installation
UUID=9b1809de-d409-47ce-aee0-dd1e878b0bab / ext4 errors=remount-ro,user_xattr 0 1
# /boot was on /dev/sda2 during installation
UUID=fd898890-17a0-423a-987e-9dc0a5008320 /boot ext2 defaults 0 2
# /home was on /dev/sda5 during installation
UUID=439ea035-cac4-4801-9023-b1b1abb4ab9e /home ext4 defaults,user_xattr 0 2
# swap was on /dev/sda1 during installation
UUID=a534b1c7-1a00-488f-92a8-a530b5d902ac none swap sw 0 0
像这样的简单代码:
for (FileStore store : fileSystem.getFileStores()) {
boolean supported = store.supportsFileAttributeView(UserDefinedFileAttributeView.class);
System.out.println(store.name() + " --- " + supported);
}
显示“ / home”(/ dev / sdar5)的显示:
/dev/sda5 --- true
但是,如果我这样做:
FileStore store1 = Files.getFileStore((new File("/home")).toPath());
boolean supported1 = store1.supportsFileAttributeView(UserDefinedFileAttributeView.class);
System.out.println(store1.name() + " --- " + supported1);
我得到:
/dev/sda5 --- false
这是为什么?我认为在两种情况下都是“真实的”。
我的操作系统是Linux Mint 17.2 Rafaela 64位。
最佳答案
我发现,由于方法supportsFileAttributeView(UserDefinedFileAttributeView.class)返回false,因此实际上支持UserDefinedFileAttributeView(可以使用,设置,检索...)。