java-native-access/jna · error · IOException

errno: " + eno

Error message

errno: " + eno

What it means

Generic errno sentinel thrown when the Linux setxattr(2) call returns a negative value while setting an extended attribute. The appended errno identifies the cause — ENOENT (path or attribute namespace wrong), EPERM/EACCES (file not owned or filesystem mounted without user_xattr), ENOTSUP/ENOSPC (filesystem does not support xattrs or quota exceeded).

Solutions

  1. Map the errno: 1 = EPERM (own the file or use CAP_FOWNER), 95 = ENOTSUP (remount with user_xattr or use a supporting fs like ext4/xfs), 2 = ENOENT (verify path)
  2. Prefix attribute names with 'user.' — most filesystems only allow the user namespace for unprivileged callers
  3. Free disk/inode space if errno indicates ENOSPC
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at contrib/platform/src/com/sun/jna/platform/linux/XAttrUtil.java:85 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12). Data as JSON: /api/errors/73a0a51e767f50ad. Report an issue: GitHub.

Appendix: source

Thrown at contrib/platform/src/com/sun/jna/platform/linux/XAttrUtil.java:85

     */
    public static void setXAttr(String path, String name, String value, String encoding)
        throws IOException {
        setXAttr(path, name, value.getBytes(encoding));
    }

    /**
     * Set or replace value of extended attribute.
     *
     * @param path  file path
     * @param name  extended attribute name
     * @param value value to set
     * @throws IOException on any error
     */
    public static void setXAttr(String path, String name, byte[] value) throws IOException {
        int retval = XAttr.INSTANCE.setxattr(path, name, value, new size_t(value.length), 0);
        if (retval != 0) {
            final int eno = Native.getLastError();
            throw new IOException("errno: " + eno);
        }
    }


    /**
     * Set or replace value of extended attribute but in case of symbolic link set the extended
     * attribute on the link itself instead linked file.
     *
     * @param path  file path
     * @param name  extended attribute name
     * @param value value to set
     * @throws IOException on any error
     */
    public static void lSetXAttr(String path, String name, String value) throws IOException {
        lSetXAttr(path, name, value, Native.getDefaultStringEncoding());
    }

    /**

View on GitHub (pinned to d036ad9781)