-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement binding for extended file attributes handling on Linux. #1018
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
contrib/platform/src/com/sun/jna/platform/linux/XAttr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* 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.loadLibrary(null, 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 lsetxattr(String path, String name, Pointer value, size_t size, int flags); | ||
int fsetxattr(int fd, String name, Pointer value, size_t size, int flags); | ||
|
||
ssize_t getxattr(String path, String name, Pointer value, size_t size); | ||
ssize_t lgetxattr(String path, String name, Pointer value, size_t size); | ||
ssize_t fgetxattr(int fd, String name, Pointer value, size_t size); | ||
|
||
ssize_t listxattr(String path, Pointer list, size_t size); | ||
ssize_t llistxattr(String path, Pointer list, size_t size); | ||
ssize_t flistxattr(int fd, Pointer list, size_t size); | ||
|
||
int removexattr(String path, String name); | ||
int lremovexattr(String path, String name); | ||
int fremovexattr(int fd, String name); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
XAttrUtil
you convertMemory
<->byte[]
. You could add overloads here, that takebyte[]
in addition to pointer - I can see use-cases for both calls:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see why it would be convenient to have such overload. But I do not understand if JNA will then apply the right conversion to handle the
byte[]
automatically. Does it?