方法supportsFileAttributeView(...)的java的Filestore类

时间:2015-10-26 16:17:25

标签: java mount

我尝试在我的环境中添加对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位。

1 个答案:

答案 0 :(得分:0)

我发现,由于方法supportsFileAttributeView(UserDefinedFileAttributeView.class)返回false,实际上支持UserDefinedFileAttributeView(可以使用,设置,检索......)。