1

When running this code, "aclAttr" is alway null on Linux (OpenSuSE 13.3) while "view" is fine. On Windows 7 "aclAttr" is fine. Any idea to get the code to work on Linux?

    FileSystem fs = FileSystems.getDefault();
    Path path=fs.getPath(filename);
    AclFileAttributeView aclAttr = Files.getFileAttributeView(path, AclFileAttributeView.class);
    LOGGER.info("Attr={}", aclAttr);
    FileOwnerAttributeView view = Files.getFileAttributeView(path,FileOwnerAttributeView.class);
    LOGGER.info("View={}", view);
Ulrich
  • 715
  • 2
  • 7
  • 25

1 Answers1

1

I believe the implementation of AclFileAttributeView is supported on Windows & Solaris and doesn't work on Linux (all I have that is evidence of this is that it works on Windows, I would expect it to work on Solaris).

You need to actually test for support using the boolean test:

Files.getFileStore(path).supportsFileAttributeView(AclFileAttributeView.class)

Which I've never seen returning true on Linux.

Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122
  • You're right - returned false. How can I instantiate a class to make use of the setACL()/getACL-methods. I thought to maintain permission by a Java GUI - do I need to use JNI for that? – Ulrich Jul 24 '14 at 18:26
  • You'll probably have to resort to JNI to maintain permissions in a java app. It's quite irritating that it's not supported on Linux. This would round out the functionality quite well. – Anya Shenanigans Jul 25 '14 at 06:52