Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8260966: (fs) Consolidate Linux and macOS implementations of UserDefi…
Browse files Browse the repository at this point in the history
…nedFileAttributeView

8260691: (fs) LinuxNativeDispatcher should link to xattr functions

Reviewed-by: alanb
  • Loading branch information
overheadhunter authored and Alan Bateman committed Mar 2, 2021
1 parent 5f4bc0a commit 0de6abd
Show file tree
Hide file tree
Showing 16 changed files with 555 additions and 977 deletions.
21 changes: 0 additions & 21 deletions src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java
Expand Up @@ -105,27 +105,6 @@ UnixMountEntry findMountEntry() throws IOException {
throw new IOException("Mount point not found");
}

// returns true if extended attributes enabled on file system where given
// file resides, returns false if disabled or unable to determine.
private boolean isExtendedAttributesEnabled(UnixPath path) {
int fd = -1;
try {
fd = path.openForAttributeAccess(false);

// fgetxattr returns size if called with size==0
byte[] name = Util.toBytes("user.java");
LinuxNativeDispatcher.fgetxattr(fd, name, 0L, 0);
return true;
} catch (UnixException e) {
// attribute does not exist
if (e.errno() == UnixConstants.ENODATA)
return true;
} finally {
UnixNativeDispatcher.close(fd);
}
return false;
}

// get kernel version as a three element array {major, minor, micro}
private static int[] getKernelVersion() {
Pattern pattern = Pattern.compile("\\D+");
Expand Down
Expand Up @@ -69,7 +69,7 @@ public Set<String> supportedFileAttributeViews() {

@Override
void copyNonPosixAttributes(int ofd, int nfd) {
LinuxUserDefinedFileAttributeView.copyExtendedAttributes(ofd, nfd);
UnixUserDefinedFileAttributeView.copyExtendedAttributes(ofd, nfd);
}

/**
Expand Down
55 changes: 0 additions & 55 deletions src/java.base/linux/classes/sun/nio/fs/LinuxNativeDispatcher.java
Expand Up @@ -69,61 +69,6 @@ static native int getmntent0(long fp, UnixMountEntry entry, long buffer, int buf
*/
static native void endmntent(long stream) throws UnixException;

/**
* ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size);
*/
static int fgetxattr(int filedes, byte[] name, long valueAddress,
int valueLen) throws UnixException
{
NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
try {
return fgetxattr0(filedes, buffer.address(), valueAddress, valueLen);
} finally {
buffer.release();
}
}

private static native int fgetxattr0(int filedes, long nameAddress,
long valueAddress, int valueLen) throws UnixException;

/**
* fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags);
*/
static void fsetxattr(int filedes, byte[] name, long valueAddress,
int valueLen) throws UnixException
{
NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
try {
fsetxattr0(filedes, buffer.address(), valueAddress, valueLen);
} finally {
buffer.release();
}
}

private static native void fsetxattr0(int filedes, long nameAddress,
long valueAddress, int valueLen) throws UnixException;

/**
* fremovexattr(int filedes, const char *name);
*/
static void fremovexattr(int filedes, byte[] name) throws UnixException {
NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
try {
fremovexattr0(filedes, buffer.address());
} finally {
buffer.release();
}
}

private static native void fremovexattr0(int filedes, long nameAddress)
throws UnixException;

/**
* size_t flistxattr(int filedes, const char *list, size_t size)
*/
static native int flistxattr(int filedes, long listAddress, int size)
throws UnixException;

// initialize
private static native void init();

Expand Down

0 comments on commit 0de6abd

Please sign in to comment.