Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8274562

(fs) UserDefinedFileAttributeView doesn't correctly determine if supported when using OverlayFS

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b18
    • Introduced In Version:
      17
    • Resolved In Build:
      b18
    • CPU:
      x86_64
    • OS:
      linux
    • Verification:
      Verified

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        Ubuntu 20.04, Java 17+35-Ubuntu-120.04

        A DESCRIPTION OF THE PROBLEM :
        JDK-8262957 (https://github.com/openjdk/jdk/pull/2816) introduced a fast-fail mechanism determining if a filesystem
        supports `UserDefinedFileAttributeView` based on if `_SYS_XATTR_H_` is defined; which is defined by `xattr.h`.

        The problem with this approach is that this variable is not the same in both MacOS `_SYS_XATTR_H_` and Linux `_SYS_XATTR_H` which can cause the JDK to incorrectly determine that a Linux filesystem doesn't support user defined file attributes when it does using:

        Files.getFileStore(Paths.get( "/tmp/testfile"))
                .supportsFileAttributeView(UserDefinedFileAttributeView.class);

        Proposed Fix
        One solution is to cover both cases

        #if defined _SYS_XATTR_H || defined _SYS_XATTR_H_
            capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_XATTR;
        #endif

        The proposed solution here is to use XATTR_CREATE which is defined in both MacOS (https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/xattr.h#L38) and Linux glibc (https://github.com/bminor/glibc/blob/88361b408b9dbd313f15413cc2e6be0f1cafb01a/misc/sys/xattr.h#L33)

        Proposed Fix: https://github.com/openjdk/jdk/pull/5767

        REGRESSION : Last worked in version 16.0.2

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run test case using a Linux based system with OverlayFS. May be reproducible on any non-ext4 file system due to special handling of EXT4

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Expected that JDK would correctly determine if a filesystem supports user defined file attributes. Returning "true" if it supports it, or "false" if it does not. But it should not return false that it is not supported if it actually does.
        ACTUAL -
        JDK 17 reports that filesystem does not support extended attributes when it does

        ---------- BEGIN SOURCE ----------
        import java.io.IOException;
        import java.nio.file.Files;
        import java.nio.file.Paths;
        import java.nio.file.attribute.UserDefinedFileAttributeView;

        public class ExtFileAttributeChecker {
            public static void main(String[] args) throws IOException {
                System.out.println(Files.getFileStore(Paths.get("/tmp/testfile")).supportsFileAttributeView(UserDefinedFileAttributeView.class));
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        No known work-around

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                bpb Brian Burkhalter
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: