Skip to content

Commit

Permalink
Merge branch 'upstream-pr-1021'
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasblaesing committed Nov 10, 2018
2 parents b7964f1 + bd184d5 commit 4e88709
Show file tree
Hide file tree
Showing 4 changed files with 827 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Features
--------
* [#1029](https://github.com/java-native-access/jna/issues/1029): Add `statvfs` to `c.s.j.platform.linux.LibC` - [@dbwiddis](https://github.com/dbwiddis).
* [#1032](https://github.com/java-native-access/jna/pull/1032): Deprecate `c.s.j.platform.win32.COM.util.annotation.ComEventCallback` in favour of `c.s.j.platform.win32.COM.util.annotation.ComMethod` - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#1021](https://github.com/java-native-access/jna/pull/1021): Added `com.sun.jna.platform.linux.XAttr` and `com.sun.jna.platform.linux.XAttrUtil` JNA wrapper for `<sys/xattr.h>` for Linux - [@wilx](https://github.com/wilx).

Bug Fixes
---------
Expand Down
95 changes: 95 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/linux/XAttr.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (c) 2018 Václav Haisman, All Rights Reserved
*
* The contents of this file is dual-licensed under 2
* alternative Open Source/Free licenses: LGPL 2.1 or later and
* Apache License 2.0.
*
* You can freely decide which license you want to apply to
* the project.
*
* You may obtain a copy of the LGPL License at:
*
* http://www.gnu.org/licenses/licenses.html
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "LGPL2.1".
*
* You may obtain a copy of the Apache License at:
*
* http://www.apache.org/licenses/
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "AL2.0".
*/
package com.sun.jna.platform.linux;

import com.sun.jna.IntegerType;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;

public interface XAttr extends Library {
XAttr INSTANCE = Native.load(XAttr.class);

class size_t extends IntegerType {
public static final size_t ZERO = new size_t();

private static final long serialVersionUID = 1L;

public size_t() { this(0); }
public size_t(long value) { super(Native.SIZE_T_SIZE, value, true); }
}

class ssize_t extends IntegerType {
public static final ssize_t ZERO = new ssize_t();

private static final long serialVersionUID = 1L;

public ssize_t() {
this(0);
}

public ssize_t(long value) {
super(Native.SIZE_T_SIZE, value, false);
}
}

int XATTR_CREATE = 1;
int XATTR_REPLACE = 2;

int EPERM = 1;
int E2BIG = 7;
int EEXIST = 17;
int ENOSPC = 28;
int ERANGE = 34;
int ENODATA = 61;
int ENOATTR = ENODATA;
int ENOTSUP = 95;
int EDQUOT = 122;

int setxattr(String path, String name, Pointer value, size_t size, int flags);
int setxattr(String path, String name, byte[] value, size_t size, int flags);
int lsetxattr(String path, String name, Pointer value, size_t size, int flags);
int lsetxattr(String path, String name, byte[] value, size_t size, int flags);
int fsetxattr(int fd, String name, Pointer value, size_t size, int flags);
int fsetxattr(int fd, String name, byte[] value, size_t size, int flags);

ssize_t getxattr(String path, String name, Pointer value, size_t size);
ssize_t getxattr(String path, String name, byte[] value, size_t size);
ssize_t lgetxattr(String path, String name, Pointer value, size_t size);
ssize_t lgetxattr(String path, String name, byte[] value, size_t size);
ssize_t fgetxattr(int fd, String name, Pointer value, size_t size);
ssize_t fgetxattr(int fd, String name, byte[] value, size_t size);

ssize_t listxattr(String path, Pointer list, size_t size);
ssize_t listxattr(String path, byte[] list, size_t size);
ssize_t llistxattr(String path, Pointer list, size_t size);
ssize_t llistxattr(String path, byte[] list, size_t size);
ssize_t flistxattr(int fd, Pointer list, size_t size);
ssize_t flistxattr(int fd, byte[] list, size_t size);

int removexattr(String path, String name);
int lremovexattr(String path, String name);
int fremovexattr(int fd, String name);
}
Loading

0 comments on commit 4e88709

Please sign in to comment.