Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure fstat(int fd) uses __fxstat64() on linux. Fixes jruby/jruby#390

  • Loading branch information...
commit c561e7a1e120a7a0e871c8f7fdcad2d8a1b035e4 1 parent dd3a1ef
Wayne Meissner authored
Showing with 14 additions and 9 deletions.
  1. +1 −1  pom.xml
  2. +13 −8 src/main/java/jnr/posix/LinuxPOSIX.java
View
2  pom.xml
@@ -70,7 +70,7 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
- <version>0.7.7</version>
+ <version>0.7.10</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
View
21 src/main/java/jnr/posix/LinuxPOSIX.java
@@ -1,5 +1,6 @@
package jnr.posix;
+import jnr.constants.platform.Errno;
import jnr.constants.platform.Sysconf;
import jnr.ffi.Pointer;
import jnr.ffi.mapper.FromNativeContext;
@@ -31,38 +32,42 @@ public FileStat allocateStat() {
}
}
- private final FileStat old_fstat(FileDescriptor fileDescriptor) {
+ private FileStat old_fstat(int fd) {
try {
- return super.fstat(fileDescriptor);
+ return super.fstat(fd);
} catch (UnsatisfiedLinkError ex2) {
handler.unimplementedError("fstat");
return null;
}
}
+
@Override
- public FileStat fstat(FileDescriptor fileDescriptor) {
+ public FileStat fstat(int fd) {
if (use_fxstat64) {
try {
FileStat stat = allocateStat();
- int fd = helper.getfd(fileDescriptor);
-
if (((LinuxLibC) libc()).__fxstat64(statVersion, fd, stat) < 0) {
- handler.error(ENOENT, "" + fd);
+ handler.error(Errno.valueOf(errno()), Integer.toString(fd));
}
return stat;
} catch (UnsatisfiedLinkError ex) {
use_fxstat64 = false;
- return old_fstat(fileDescriptor);
+ return old_fstat(fd);
}
} else {
- return old_fstat(fileDescriptor);
+ return old_fstat(fd);
}
}
+ @Override
+ public FileStat fstat(FileDescriptor fileDescriptor) {
+ return fstat(helper.getfd(fileDescriptor));
+ }
+
private final FileStat old_lstat(String path) {
try {
return super.lstat(path);
Please sign in to comment.
Something went wrong with that request. Please try again.