Projects
Mega:23.09
jnr-posix
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 3
View file
_service:tar_scm:jnr-posix.spec
Changed
@@ -1,5 +1,5 @@ Name: jnr-posix -Version: 3.0.47 +Version: 3.1.14 Release: 1 Summary: Java Posix layer License: CPL or GPLv2+ or LGPLv2+ @@ -39,5 +39,8 @@ %license LICENSE.txt %changelog +* Thu Sep 28 2023 Ge Wang <wang__ge@126.com> - 3.1.14-1 +- Update to version 3.1.14 + * Fri Jul 31 2020 Jeffery.Gao <gaojianxing@huawei.com> - 3.0.47-1 - Package init
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="url">git@gitee.com:src-openeuler/jnr-posix.git</param> <param name="scm">git</param> - <param name="revision">openEuler-23.09</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/.travis.yml
Deleted
@@ -1,32 +0,0 @@ -language: java -sudo: true - -before_install: - - if "$TRAVIS_OS_NAME" == "osx" ; then export JAVA_HOME=$(/usr/libexec/java_home); fi - - echo $JAVA_HOME - -matrix: - include: - - os: linux - jdk: openjdk7 - - os: linux - jdk: openjdk8 - - os: linux - jdk: openjdk9 - - os: linux - jdk: openjdk10 - - os: linux - jdk: openjdk11 - -os: - - linux - -notifications: - irc: - channels: - - "irc.freenode.org#jnr" - on_success: change - on_failure: always - template: - - "%{repository} (%{branch}:%{commit} by %{author}): %{message} (%{build_url})" -
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/appveyor.yml
Deleted
@@ -1,32 +0,0 @@ -version: '{build}' - -build: off - -environment: - matrix: -# - JAVA_HOME: C:\Program Files\Java\jdk1.7.0 -# - JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0 - - JAVA_HOME: C:\Program Files\Java\jdk1.8.0 - - JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0 - -install: - - ps: >- - Add-Type -AssemblyName System.IO.Compression.FileSystem - if (!(Test-Path -Path "C:\maven" )) { - (new-object System.Net.WebClient).DownloadFile( - 'http://www.us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip', - 'C:\maven-bin.zip' - ) - - System.IO.Compression.ZipFile::ExtractToDirectory("C:\maven-bin.zip", "C:\maven") - } - - cmd: SET PATH=C:\maven\apache-maven-3.3.3\bin;%JAVA_HOME%\bin;%PATH% - - cmd: echo %PATH% - - cmd: java -version - -cache: - - C:\maven - - C:\Users\appveyor\.m2 - -test_script: - - mvn test
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/.github
Added
+(directory)
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/.github/workflows
Added
+(directory)
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/.github/workflows/ci.yml
Added
@@ -0,0 +1,38 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Java CI with Maven + +on: + push: + branches: master + pull_request: + branches: master + +jobs: + jdk8: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v1.4.3 + with: + java-version: 8 + - name: Build with Maven + run: mvn -B package --file pom.xml + + jdk11: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1.4.3 + with: + java-version: 11 + - name: Build with Maven + run: mvn -B package --file pom.xml +
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/pom.xml -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/pom.xml
Changed
@@ -10,7 +10,7 @@ <groupId>com.github.jnr</groupId> <artifactId>jnr-posix</artifactId> <packaging>jar</packaging> - <version>3.0.47</version> + <version>3.1.14</version> <name>jnr-posix</name> <description> Common cross-project/cross-platform POSIX APIs @@ -65,26 +65,26 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <maven.compiler.source>1.5</maven.compiler.source> - <maven.compiler.target>1.5</maven.compiler.target> + <maven.compiler.source>8</maven.compiler.source> + <maven.compiler.target>8</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.11</version> + <version>4.13.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.github.jnr</groupId> <artifactId>jnr-ffi</artifactId> - <version>2.1.8</version> + <version>2.2.10</version> </dependency> <dependency> <groupId>com.github.jnr</groupId> <artifactId>jnr-constants</artifactId> - <version>0.9.9</version> + <version>0.10.3</version> </dependency> </dependencies> @@ -98,13 +98,6 @@ </extensions> <plugins> <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.6</source> - <target>1.6</target> - </configuration> - </plugin> - <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.3.7</version> @@ -133,6 +126,9 @@ <configuration> <archive> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> + <manifestEntries> + <Automatic-Module-Name>org.jnrproject.posix</Automatic-Module-Name> + </manifestEntries> </archive> </configuration> </plugin> @@ -152,6 +148,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> + <version>3.2.0</version> <executions> <execution> <id>attach-javadocs</id> @@ -161,6 +158,11 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + </plugin> </plugins> </build> <profiles> @@ -176,7 +178,6 @@ <configuration> <forkCount>2</forkCount> <reuseForks>false</reuseForks> - <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> <includes> <include>**/*Test.java</include> </includes> @@ -200,11 +201,48 @@ <configuration> <forkCount>2</forkCount> <reuseForks>false</reuseForks> - <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> </configuration> </plugin> </plugins> </build> </profile> + <profile> + <id>java9</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <executions> + <execution> + <id>default-compile</id> + <phase>compile</phase> + <goals><goal>compile</goal></goals> + <configuration> + <includes> + <include>jnr/posix/util/SunMiscSignal.java</include> + </includes> + </configuration> + </execution> + <execution> + <id>java9-compile</id> + <phase>compile</phase> + <goals><goal>compile</goal></goals> + <configuration> + <!-- Use -release compiler option rather than source/target if 9+ --> + <release>${maven.compiler.target}</release> + <excludes> + <exclude>jnr/posix/util/SunMiscSignal.java</exclude> + </excludes> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <activation> + <jdk>9,)</jdk> + </activation> + </profile> </profiles> </project>
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/AbstractJavaFileStat.java
Added
@@ -0,0 +1,133 @@ +package jnr.posix; + +public abstract class AbstractJavaFileStat implements FileStat { + protected final POSIXHandler handler; + protected final POSIX posix; + + public AbstractJavaFileStat(POSIX posix, POSIXHandler handler) { + this.handler = handler; + this.posix = posix; + } + + public boolean isBlockDev() { + handler.unimplementedError("block device detection"); + + return false; + } + + /** + * Limitation: see JRUBY-1516 We just pick more likely value. This is a little scary. + */ + public boolean isCharDev() { + return false; + } + + public boolean isFifo() { + handler.unimplementedError("fifo file detection"); + + return false; + } + + public boolean isNamedPipe() { + handler.unimplementedError("piped file detection"); + + return false; + } + + public boolean isSetgid() { + handler.unimplementedError("setgid detection"); + + return false; + } + + public boolean isSetuid() { + handler.unimplementedError("setuid detection"); + + return false; + } + + public boolean isSocket() { + handler.unimplementedError("socket file type detection"); + + return false; + } + + public boolean isSticky() { + handler.unimplementedError("sticky bit detection"); + + return false; + } + + public int major(long dev) { + handler.unimplementedError("major device"); + + return -1; + } + + public int minor(long dev) { + handler.unimplementedError("minor device"); + + return -1; + } + + public int nlink() { + handler.unimplementedError("stat.nlink"); + + return -1; + } + + public long rdev() { + handler.unimplementedError("stat.rdev"); + + return -1; + } + + // Limitation: We have no pure-java way of getting uid. RubyZip needs this defined to work. + public int uid() { + return -1; + } + + public long blocks() { + handler.unimplementedError("stat.st_blocks"); + + return -1; + } + + public long blockSize() { + // Limitation: We cannot determine, so always return 4096 (better than blowing up) + return 4096; + } + + public long dev() { + handler.unimplementedError("stat.st_dev"); + + return -1; + } + + public String ftype() { + if (isFile()) { + return "file"; + } else if (isDirectory()) { + return "directory"; + } + + return "unknown"; + } + + public int gid() { + handler.unimplementedError("stat.st_gid"); + + return -1; + } + + public boolean groupMember(int gid) { + return posix.getgid() == gid || posix.getegid() == gid; + } + + /** + * Limitation: We have no pure-java way of getting inode. webrick needs this defined to work. + */ + public long ino() { + return 0; + } +}
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/AixFlock.java
Added
@@ -0,0 +1,55 @@ +package jnr.posix; + +public final class AixFlock extends Flock { + public final Signed16 l_type = new Signed16(); + public final Signed16 l_whence = new Signed16(); + public final Unsigned32 l_sysid = new Unsigned32(); + public final Signed32 l_pid = new Signed32(); + public final Signed32 l_vfs = new Signed32(); + public final SignedLong l_start = new SignedLong(); + public final SignedLong l_len = new SignedLong(); + + public AixFlock(jnr.ffi.Runtime runtime) { + super(runtime); + } + + public void type(short type) { + this.l_type.set(type); + } + + public void whence(short whence) { + this.l_whence.set(whence); + } + + public void start(long start) { + this.l_start.set(start); + } + + public void len(long len) { + this.l_len.set(len); + } + + public void pid(int pid) { + this.l_pid.set(pid); + } + + public short type() { + return this.l_type.get(); + } + + public short whence() { + return this.l_whence.get(); + } + + public long start() { + return this.l_start.get(); + } + + public long len() { + return this.l_len.get(); + } + + public int pid() { + return this.l_pid.get(); + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/AixPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/AixPOSIX.java
Changed
@@ -32,14 +32,34 @@ package jnr.posix; import jnr.constants.platform.Sysconf; +import jnr.constants.platform.Fcntl; import jnr.ffi.Memory; import jnr.ffi.Pointer; import jnr.ffi.mapper.FromNativeContext; import jnr.posix.util.MethodName; import java.io.FileDescriptor; +import java.nio.ByteBuffer; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; final class AixPOSIX extends BaseNativePOSIX { + // These should probably be put into jnr-constants instead eventually, but + // they're here for now as a one-off to work around AIX flock issues + private enum FlockFlags { + LOCK_SH(1), + LOCK_EX(2), + LOCK_NB(4), + LOCK_UN(8); + private final int value; + FlockFlags(int value) { + this.value = value; + } + public final int intValue() { + return value; + } + } + AixPOSIX(LibCProvider libc, POSIXHandler handler) { super(libc, handler); } @@ -62,6 +82,14 @@ return libc().sysconf(name); } + public int confstr(Confstr name, ByteBuffer buf, int len) { + return libc().confstr(name, buf, len); + } + + public int fpathconf(int fd, Pathconf name) { + return libc().fpathconf(fd, name); + } + public Times times() { return NativeTimes.times(this); } @@ -80,4 +108,42 @@ public Pointer allocatePosixSpawnattr() { return Memory.allocateDirect(getRuntime(), 60); } + + // AIX flock lives in libbsd instead of libc. AIX flock locks fully + // interact with fcntl locks, so we can implement flock in terms of fcntl, + // which is what we do here to avoid having to pull in that lib. + @Override + public int flock(int fd, int operation) { + int cmd = Fcntl.F_SETLKW.intValue(); + short type = 0; + + // Map the flock call flags to a fcntl flock type flag + if ((operation & FlockFlags.LOCK_SH.intValue()) != 0) { + type = (short)Fcntl.F_RDLCK.intValue(); + } else if ((operation & FlockFlags.LOCK_EX.intValue()) != 0) { + type = (short)Fcntl.F_WRLCK.intValue(); + } else if ((operation & FlockFlags.LOCK_UN.intValue()) != 0) { + type = (short)Fcntl.F_UNLCK.intValue(); + } + + // Switch to the fcntl non-blocking command + if ((operation & FlockFlags.LOCK_NB.intValue()) != 0) { + cmd = Fcntl.F_SETLK.intValue(); + } + + Flock flock = allocateFlock(); + flock.type(type); + flock.whence((short)0); + flock.start(0); + flock.len(0); + return libc().fcntl(fd, cmd, flock); + } + + @Override + public Timeval allocateTimeval() { return new AixTimeval(getRuntime()); } + + // This isn't an override yet, because Flock would have to be implemented + // for all platforms, or at least with a DefaultNative implementation. This + // is fine for now, because only AIX uses the flock structure + public Flock allocateFlock() { return new AixFlock(getRuntime()); } }
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/AixTimeval.java
Added
@@ -0,0 +1,32 @@ +package jnr.posix; + +public final class AixTimeval extends Timeval { + public final SignedLong tv_sec = new SignedLong(); + public final Signed32 tv_usec = new Signed32(); + + public AixTimeval(jnr.ffi.Runtime runtime) { + super(runtime); + } + + public void setTime(long timeval) { + assert timeval.length == 2; + tv_sec.set(timeval0); + tv_usec.set((int)timeval1); + } + + public void sec(long sec) { + this.tv_sec.set(sec); + } + + public void usec(long usec) { + this.tv_usec.set((int)usec); + } + + public long sec() { + return tv_sec.get(); + } + + public long usec() { + return tv_usec.get(); + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/BaseMsgHdr.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/BaseMsgHdr.java
Changed
@@ -60,10 +60,11 @@ int offset = 0; for (int i = 0; i < dataLengths.length; ++i) { - int eachLen = posix.socketMacros().CMSG_SPACE(dataLengthsi); - CmsgHdr each = allocateCmsgHdrInternal(posix, ptr.slice(offset, eachLen), eachLen); + int eachSpace = posix.socketMacros().CMSG_SPACE(dataLengthsi); + int len = posix.socketMacros().CMSG_LEN(dataLengthsi); + CmsgHdr each = allocateCmsgHdrInternal(posix, ptr.slice(offset, eachSpace), len); cmsgsi = each; - offset += eachLen; + offset += eachSpace; } setControlPointer(ptr); @@ -86,7 +87,7 @@ while (offset < len) { CmsgHdr each = allocateCmsgHdrInternal(posix, controlPtr.slice(offset), -1); - offset += each.getLen(); + offset += posix.socketMacros().CMSG_SPACE(each.getLen()); control.add(each); }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/BaseNativePOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/BaseNativePOSIX.java
Changed
@@ -3,6 +3,7 @@ import jnr.constants.Constant; import jnr.constants.platform.Errno; import jnr.constants.platform.Fcntl; +import jnr.constants.platform.Signal; import jnr.constants.platform.Sysconf; import jnr.ffi.*; import jnr.ffi.byref.NumberByReference; @@ -22,7 +23,9 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import jnr.constants.platform.Signal; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; +import jnr.ffi.annotations.Out; public abstract class BaseNativePOSIX extends NativePOSIX implements POSIX { private final LibC libc; @@ -605,15 +608,25 @@ } public int fcntlInt(int fd, Fcntl fcntl, int arg) { - return libc().fcntl(fd, fcntl.intValue(), arg); + return fcntl(fd, fcntl, arg); } public int fcntl(int fd, Fcntl fcntl) { return libc().fcntl(fd, fcntl.intValue()); } - public int fcntl(int fd, Fcntl fcntl, int... arg) { - return libc().fcntl(fd, fcntl.intValue()); + public int fcntl(int fd, Fcntl fcntl, int arg) { + return libc().fcntl(fd, fcntl.intValue(), arg); + } + + @Deprecated + public int fcntl(int fd, Fcntl fcntl, int... args) { + if (args != null) { + if (args.length == 1) { + return fcntl(fd, fcntl, args0); + } + } + throw new IllegalArgumentException("fcntl with variadic int args is unsupported"); } public int access(CharSequence path, int amode) { @@ -657,6 +670,16 @@ } } + public int confstr(Confstr name, ByteBuffer buf, int len) { + errno(Errno.EOPNOTSUPP.intValue()); + return -1; + } + + public int fpathconf(int fd, Pathconf name) { + errno(Errno.EOPNOTSUPP.intValue()); + return -1; + } + public Times times() { return new JavaTimes(); } @@ -755,6 +778,22 @@ return libc().rename(oldName, newName); } + public String gethostname() { + ByteBuffer buffer = ByteBuffer.allocate(256); + int result; + try { + result = libc().gethostname(buffer, buffer.capacity() - 1); + } catch (java.lang.UnsatisfiedLinkError e) { + result = -1; + } + if (result == -1) return helper.gethostname(); + buffer.position(0); + while (buffer.hasRemaining() && buffer.get() != 0); + buffer.limit(buffer.position() - 1); + buffer.position(0); + return Charset.forName("US-ASCII").decode(buffer).toString(); + } + public String getcwd() { byte cwd = new byte1024; long result = libc().getcwd(cwd, 1024);
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/CheckedPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/CheckedPOSIX.java
Changed
@@ -11,6 +11,8 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.Collection; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; final class CheckedPOSIX implements POSIX { private final POSIX posix; @@ -442,6 +444,14 @@ try { return posix.sysconf(name); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } } + public int confstr(Confstr name, ByteBuffer buf, int len) { + try { return posix.confstr(name, buf, len); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } + } + + public int fpathconf(int fd, Pathconf name) { + try { return posix.fpathconf(fd, name); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } + } + public Times times() { try { return posix.times(); } catch (UnsatisfiedLinkError ule) { return unimplementedNull(); } } @@ -466,6 +476,11 @@ try { return posix.fcntl(fd, fcntlConst); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } } + public int fcntl(int fd, Fcntl fcntlConst, int arg) { + try { return posix.fcntl(fd, fcntlConst, arg); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } + } + + @Deprecated public int fcntl(int fd, Fcntl fcntlConst, int... arg) { try { return posix.fcntl(fd, fcntlConst); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } } @@ -622,4 +637,8 @@ public int gettimeofday(Timeval tv) { try {return posix.gettimeofday(tv); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } } + + public String gethostname() { + try {return posix.gethostname(); } catch (UnsatisfiedLinkError ule) { return unimplementedNull(); } + } }
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/DragonFlyFileStat.java
Added
@@ -0,0 +1,141 @@ +/***** BEGIN LICENSE BLOCK ***** + * Version: EPL 2.0/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Eclipse Public + * License Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.eclipse.org/legal/cpl-v10.html + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the CPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the CPL, the GPL or the LGPL. + ***** END LICENSE BLOCK *****/ +/** + * $Id: $ + */ + +package jnr.posix; + +import jnr.ffi.StructLayout; + +public final class DragonFlyFileStat extends BaseFileStat implements NanosecondFileStat { + private static final class Layout extends StructLayout { + + private Layout(jnr.ffi.Runtime runtime) { + super(runtime); + } + + public final class time_t extends SignedLong {} + public final class dev_t extends Unsigned32 {} + + public final Signed64 st_ino = new Signed64(); + public final Signed32 st_nlink = new Signed32(); + public final dev_t st_dev = new dev_t(); + public final Unsigned16 st_mode = new Unsigned16(); + public final Unsigned16 st_padding1 = new Unsigned16(); + public final Signed32 st_uid = new Signed32(); + public final Signed32 st_gid = new Signed32(); + public final dev_t st_rdev = new dev_t(); + public final time_t st_atim = new time_t(); + public final time_t st_atimnsec = new time_t(); + public final time_t st_mtim = new time_t(); + public final time_t st_mtimnsec = new time_t(); + public final time_t st_ctim = new time_t(); + public final time_t st_ctimnsec = new time_t(); + public final Signed32 st_size = new Signed32(); + public final Signed32 st_blocks = new Signed32(); + public final Signed32 st_blksize = new Signed32(); + public final Signed32 st_flags = new Signed32(); + public final Signed32 st_gen = new Signed32(); + public final Signed32 st_lspare = new Signed32(); + public final Signed64 st_qspare1 = new Signed64(); + public final Signed64 st_qspare2 = new Signed64(); + } + private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime()); + + public DragonFlyFileStat(NativePOSIX posix) { + super(posix, layout); + } + + public long atime() { + return layout.st_atim.get(memory); + } + + public long blocks() { + return layout.st_blocks.get(memory); + } + + public long blockSize() { + return layout.st_blksize.get(memory); + } + + public long ctime() { + return layout.st_ctim.get(memory); + } + + public long dev() { + return layout.st_dev.get(memory); + } + + public int gid() { + return layout.st_gid.get(memory); + } + + public long ino() { + return layout.st_ino.get(memory); + } + + public int mode() { + return layout.st_mode.get(memory) & 0xffff; + } + + public long mtime() { + return layout.st_mtim.get(memory); + } + + public int nlink() { + return layout.st_nlink.get(memory); + } + + public long rdev() { + return layout.st_rdev.get(memory); + } + + public long st_size() { + return layout.st_size.get(memory); + } + + public int uid() { + return layout.st_uid.get(memory); + } + + @Override + public long aTimeNanoSecs() { + return layout.st_atimnsec.get(memory); + } + + @Override + public long cTimeNanoSecs() { + return layout.st_ctimnsec.get(memory); + } + + @Override + public long mTimeNanoSecs() { + return layout.st_mtimnsec.get(memory); + } +}
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/DragonFlyPOSIX.java
Added
@@ -0,0 +1,92 @@ +/***** BEGIN LICENSE BLOCK ***** + * Version: EPL 2.0/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Eclipse Public + * License Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.eclipse.org/legal/cpl-v10.html + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the CPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the CPL, the GPL or the LGPL. + ***** END LICENSE BLOCK *****/ +/** + * $Id: $ + */ + +package jnr.posix; + +import java.nio.ByteBuffer; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; +import jnr.constants.platform.Sysconf; +import jnr.ffi.Memory; +import jnr.ffi.mapper.FromNativeContext; +import jnr.ffi.Pointer; +import jnr.posix.util.MethodName; + +final class DragonFlyPOSIX extends BaseNativePOSIX { + DragonFlyPOSIX(LibCProvider libc, POSIXHandler handler) { + super(libc, handler); + } + + public FileStat allocateStat() { + return new DragonFlyFileStat(this); + } + + public MsgHdr allocateMsgHdr() { + handler.unimplementedError(MethodName.getCallerMethodName()); + return null; + } + + public SocketMacros socketMacros() { + handler.unimplementedError(MethodName.getCallerMethodName()); + return null; + } + + public long sysconf(Sysconf name) { + return libc().sysconf(name); + } + + public int confstr(Confstr name, ByteBuffer buf, int len) { + return libc().confstr(name, buf, len); + } + + public int fpathconf(int fd, Pathconf name) { + return libc().fpathconf(fd, name); + } + + public Times times() { + return NativeTimes.times(this); + } + + + public static final PointerConverter PASSWD = new PointerConverter() { + public Object fromNative(Object arg, FromNativeContext ctx) { + return arg != null ? new DragonFlyPasswd((Pointer) arg) : null; + } + }; + + public Pointer allocatePosixSpawnFileActions() { + return Memory.allocateDirect(getRuntime(), 8); + } + + public Pointer allocatePosixSpawnattr() { + return Memory.allocateDirect(getRuntime(), 8); + } +}
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/DragonFlyPasswd.java
Added
@@ -0,0 +1,101 @@ +/***** BEGIN LICENSE BLOCK ***** + * Version: EPL 2.0/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Eclipse Public + * License Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.eclipse.org/legal/cpl-v10.html + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the CPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the CPL, the GPL or the LGPL. + ***** END LICENSE BLOCK *****/ +/** + * $Id: $ + */ + +package jnr.posix; + + +import jnr.ffi.StructLayout; + +public class DragonFlyPasswd extends NativePasswd implements Passwd { + private static final class Layout extends StructLayout { + + private Layout(jnr.ffi.Runtime runtime) { + super(runtime); + } + + public final UTF8StringRef pw_name = new UTF8StringRef(); // user name + public final UTF8StringRef pw_passwd = new UTF8StringRef(); // password (encrypted) + public final Signed32 pw_uid = new Signed32(); // user id + public final Signed32 pw_gid = new Signed32(); // user id + public final SignedLong pw_change = new SignedLong();// password change time + public final UTF8StringRef pw_class = new UTF8StringRef(); // user access class + public final UTF8StringRef pw_gecos = new UTF8StringRef(); // login info + public final UTF8StringRef pw_dir = new UTF8StringRef(); // home directory + public final UTF8StringRef pw_shell = new UTF8StringRef(); // default shell + public final SignedLong pw_expire = new SignedLong(); // account expiration + public final Signed32 pw_fields = new Signed32(); // internal: fields filled in + } + private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime()); + + DragonFlyPasswd(jnr.ffi.Pointer memory) { + super(memory); + } + + public java.lang.String getAccessClass() { + return layout.pw_class.get(memory); + } + + public java.lang.String getGECOS() { + return layout.pw_gecos.get(memory); + } + + public long getGID() { + return layout.pw_gid.get(memory); + } + + public java.lang.String getHome() { + return layout.pw_dir.get(memory); + } + + public java.lang.String getLoginName() { + return layout.pw_name.get(memory); + } + + public int getPasswdChangeTime() { + return layout.pw_change.intValue(memory); + } + + public java.lang.String getPassword() { + return layout.pw_passwd.get(memory); + } + + public java.lang.String getShell() { + return layout.pw_shell.get(memory); + } + + public long getUID() { + return layout.pw_uid.get(memory); + } + + public int getExpire() { + return layout.pw_expire.intValue(memory); + } +}
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/Flock.java
Added
@@ -0,0 +1,20 @@ +package jnr.posix; + +import jnr.ffi.Struct; + +abstract public class Flock extends Struct { + public Flock(jnr.ffi.Runtime runtime) { + super(runtime); + } + public abstract void type(short type); + public abstract void whence(short whence); + public abstract void start(long start); + public abstract void len(long len); + public abstract void pid(int pid); + + public abstract short type(); + public abstract short whence(); + public abstract long start(); + public abstract long len(); + public abstract int pid(); +}
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/FreeBSDCmsgHdr.java
Added
@@ -0,0 +1,72 @@ +package jnr.posix; + +import jnr.ffi.Pointer; +import jnr.ffi.Runtime; +import jnr.ffi.StructLayout; + +/** + * @author Bob McWhirter + */ +class FreeBSDCmsgHdr extends BaseCmsgHdr { + + public static class Layout extends StructLayout { + + protected Layout(Runtime runtime) { + super(runtime); + } + + public final socklen_t cmsg_len = new socklen_t(); + public final Signed32 cmsg_level = new Signed32(); + public final Signed32 cmsg_type = new Signed32(); + } + + public static final Layout layout = new Layout(Runtime.getSystemRuntime()); + + public FreeBSDCmsgHdr(NativePOSIX posix, Pointer memory) { + super(posix, memory); + } + + public FreeBSDCmsgHdr(NativePOSIX posix, Pointer memory, int totalLen) { + super(posix, memory, totalLen); + } + + public void setLevel(int level) { + layout.cmsg_level.set(this.memory, level); + } + + public int getLevel() { + return layout.cmsg_level.get(this.memory); + } + + public void setType(int type) { + layout.cmsg_type.set(this.memory, type); + } + + public int getType() { + return layout.cmsg_type.get(this.memory); + } + + public int getLen() { + return (int) layout.cmsg_len.get(this.memory); + } + + void setLen(int len) { + layout.cmsg_len.set(this.memory, len); + } + + public String toString(String indent) { + StringBuffer buf = new StringBuffer(); + + buf.append(indent).append("cmsg {\n"); + buf.append(indent).append(" cmsg_len=").append(layout.cmsg_len.get(this.memory)).append("\n"); + buf.append(indent).append(" cmsg_level=").append(layout.cmsg_level.get(this.memory)).append("\n"); + buf.append(indent).append(" cmsg_type=").append(layout.cmsg_type.get(this.memory)).append("\n"); + buf.append(indent).append(" cmsg_data=").append(getData()).append("\n"); + buf.append(indent).append("}"); + return buf.toString(); + } + + public String toString(){ + return toString( "" ); + } +}
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/FreeBSDFileStat12.java
Added
@@ -0,0 +1,145 @@ +/***** BEGIN LICENSE BLOCK ***** + * Version: EPL 2.0/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Eclipse Public + * License Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.eclipse.org/legal/cpl-v10.html + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the CPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the CPL, the GPL or the LGPL. + ***** END LICENSE BLOCK *****/ +/** + * $Id: $ + */ + +package jnr.posix; + +import jnr.ffi.StructLayout; + +public final class FreeBSDFileStat12 extends BaseFileStat implements NanosecondFileStat { + private static final class Layout extends StructLayout { + + private Layout(jnr.ffi.Runtime runtime) { + super(runtime); + } + + public final class time_t extends SignedLong {} + public final class dev_t extends Signed32 {} + + public final dev_t st_dev = new dev_t(); + public final Signed64 st_ino = new Signed64(); + // FIXME: this should be a 64-bit field + public final Signed32 st_nlink_upper = new Signed32(); + public final Signed32 st_nlink = new Signed32(); + public final Signed16 st_mode = new Signed16(); + public final Signed16 st_padding0 = new Signed16(); + public final Signed32 st_uid = new Signed32(); + public final Signed32 st_gid = new Signed32(); + public final Signed32 st_padding1 = new Signed32(); + public final dev_t st_rdev = new dev_t(); + public final time_t st_atime = new time_t(); + public final SignedLong st_atimensec = new SignedLong(); + public final time_t st_mtime = new time_t(); + public final SignedLong st_mtimensec = new SignedLong(); + public final time_t st_ctime = new time_t(); + public final SignedLong st_ctimensec = new SignedLong(); + public final time_t st_birthtime = new time_t(); + public final SignedLong st_birthtimensec = new SignedLong(); + public final Signed64 st_size = new Signed64(); + public final Signed64 st_blocks = new Signed64(); + public final Signed32 st_blksize = new Signed32(); + public final Signed32 st_flags = new Signed32(); + public final Signed64 st_gen = new Signed64(); + /* FIXME: This padding isn't quite correct */ + public final Signed64 st_qspare0 = new Signed64(); + } + private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime()); + + public FreeBSDFileStat12(NativePOSIX posix) { + super(posix, layout); + } + + public long atime() { + return layout.st_atime.get(memory); + } + + public long blocks() { + return layout.st_blocks.get(memory); + } + + public long blockSize() { + return layout.st_blksize.get(memory); + } + + public long ctime() { + return layout.st_ctime.get(memory); + } + + public long dev() { + return layout.st_dev.get(memory); + } + + public int gid() { + return layout.st_gid.get(memory); + } + + public long ino() { + return layout.st_ino.get(memory); + } + + public int mode() { + return layout.st_mode.get(memory) & 0xffff; + } + + public long mtime() { + return layout.st_mtime.get(memory); + } + + public int nlink() { + return layout.st_nlink.get(memory); + } + + public long rdev() { + return layout.st_rdev.get(memory); + } + + public long st_size() { + return layout.st_size.get(memory); + } + + public int uid() { + return layout.st_uid.get(memory); + } + + @Override + public long aTimeNanoSecs() { + return layout.st_atimensec.get(memory); + } + + @Override + public long cTimeNanoSecs() { + return layout.st_ctimensec.get(memory); + } + + @Override + public long mTimeNanoSecs() { + return layout.st_mtimensec.get(memory); + } +}
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/FreeBSDMsgHdr.java
Added
@@ -0,0 +1,151 @@ +package jnr.posix; + +import java.util.ArrayList; +import java.util.List; +import jnr.ffi.Pointer; +import jnr.ffi.Runtime; +import jnr.ffi.StructLayout; + +/** + * @author Bob McWhirter + */ +class FreeBSDMsgHdr extends BaseMsgHdr { + + public static class Layout extends StructLayout { + protected Layout(Runtime runtime) { + super(runtime); + } + + public final Pointer msg_name = new Pointer(); + public final socklen_t msg_namelen = new socklen_t(); + public final Pointer msg_iov = new Pointer(); + public final Signed32 msg_iovlen = new Signed32(); + public final Pointer msg_control = new Pointer(); + public final socklen_t msg_controllen = new socklen_t(); + public final Signed32 msg_flags = new Signed32(); + } + + private static final Layout layout = new Layout(Runtime.getSystemRuntime()); + + protected FreeBSDMsgHdr(NativePOSIX posix) { + super(posix, layout); + setName(null); + } + + CmsgHdr allocateCmsgHdrInternal(NativePOSIX posix, Pointer pointer, int len) { + if (len > 0) { + return new FreeBSDCmsgHdr(posix, pointer, len); + } else { + return new FreeBSDCmsgHdr(posix, pointer); + } + } + + @Override + void setControlPointer(Pointer control) { + layout.msg_control.set(this.memory, control); + } + + @Override + void setControlLen(int len) { + layout.msg_controllen.set(this.memory, len); + } + + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append("msghdr {\n"); + buf.append(" msg_name=").append(getName()).append(",\n"); + buf.append(" msg_namelen=").append(getNameLen()).append(",\n"); + + buf.append(" msg_iov=\n"); + Pointer iovp = layout.msg_iov.get(this.memory); + + int numIov = getIovLen(); + for (int i = 0; i < numIov; ++i) { + Pointer eachp = iovp.slice(i * BaseIovec.layout.size()); + buf.append(new BaseIovec(posix, eachp).toString(" ")); + if (i < (numIov - 1)) { + buf.append(",\n"); + } else { + buf.append("\n"); + } + } + buf.append(" ,\n"); + + buf.append(" msg_control=\n"); + + CmsgHdr controls = getControls(); + for (int i = 0; i < controls.length; ++i) { + buf.append(((FreeBSDCmsgHdr) controlsi).toString(" ")); + if (i < controls.length - 1) { + buf.append(",\n"); + } else { + buf.append("\n"); + } + } + buf.append(" ,\n"); + buf.append(" msg_controllen=").append(layout.msg_controllen.get(this.memory)).append("\n"); + + buf.append(" msg_iovlen=").append(getIovLen()).append(",\n"); + buf.append(" msg_flags=").append(getFlags()).append(",\n"); + buf.append("}"); + return buf.toString(); + } + + @Override + void setNamePointer(Pointer name) { + layout.msg_name.set( this.memory, name ); + } + + @Override + Pointer getNamePointer() { + return layout.msg_name.get( this.memory ); + } + + + @Override + void setNameLen(int len) { + layout.msg_namelen.set(this.memory, len); + } + + @Override + int getNameLen() { + return (int) layout.msg_namelen.get(this.memory); + } + + @Override + void setIovPointer(Pointer iov) { + layout.msg_iov.set(this.memory, iov); + } + + @Override + Pointer getIovPointer() { + return layout.msg_iov.get( this.memory ); + } + + @Override + void setIovLen(int len) { + layout.msg_iovlen.set(this.memory, len); + } + + @Override + int getIovLen() { + return (int) layout.msg_iovlen.get(this.memory); + } + + @Override + Pointer getControlPointer() { + return layout.msg_control.get(this.memory); + } + + public int getControlLen() { + return (int) layout.msg_controllen.get(this.memory); + } + + public void setFlags(int flags) { + layout.msg_flags.set(this.memory, flags); + } + + public int getFlags() { + return layout.msg_flags.get(this.memory); + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/FreeBSDPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/FreeBSDPOSIX.java
Changed
@@ -37,29 +37,69 @@ import jnr.ffi.Pointer; import jnr.posix.util.MethodName; +import java.lang.Runtime; +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.nio.ByteBuffer; +import java.text.NumberFormat; +import java.text.ParsePosition; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; + final class FreeBSDPOSIX extends BaseNativePOSIX { + private final int freebsdVersion; + FreeBSDPOSIX(LibCProvider libc, POSIXHandler handler) { super(libc, handler); + + int parsed_version = 0; + + // FreeBSD 12 introduces a new stat structure. Until jffi gets dlvsym() support + // to allow us to link explicitly to supported versions of functions, detect + // the current userspace version and cross our fingers. + try { + Process p = Runtime.getRuntime().exec("/bin/freebsd-version -u"); + String version = new BufferedReader(new InputStreamReader(p.getInputStream())).readLine(); + + if (p.waitFor() == 0 && version != null) { + NumberFormat fmt = NumberFormat.getIntegerInstance(); + fmt.setGroupingUsed(false); + + parsed_version = fmt.parse(version, new ParsePosition(0)).intValue(); + } + } catch (Exception e) { } + + freebsdVersion = parsed_version; } - + public FileStat allocateStat() { - return new FreeBSDFileStat(this); + if (freebsdVersion >= 12) { + return new FreeBSDFileStat12(this); + } else { + return new FreeBSDFileStat(this); + } } public MsgHdr allocateMsgHdr() { - handler.unimplementedError(MethodName.getCallerMethodName()); - return null; + return new FreeBSDMsgHdr(this); } public SocketMacros socketMacros() { - handler.unimplementedError(MethodName.getCallerMethodName()); - return null; + return FreeBSDSocketMacros.INSTANCE; } public long sysconf(Sysconf name) { return libc().sysconf(name); } + public int confstr(Confstr name, ByteBuffer buf, int len) { + return libc().confstr(name, buf, len); + } + + public int fpathconf(int fd, Pathconf name) { + return libc().fpathconf(fd, name); + } + public Times times() { return NativeTimes.times(this); }
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/FreeBSDSocketMacros.java
Added
@@ -0,0 +1,29 @@ +package jnr.posix; + +import jnr.ffi.*; +import jnr.ffi.Runtime; + +/** + * @author Bob McWhirter + */ +public class FreeBSDSocketMacros implements SocketMacros { + + public static final FreeBSDSocketMacros INSTANCE = new FreeBSDSocketMacros(); + + public int CMSG_ALIGN(int len) { + int sizeof_size_t = Runtime.getSystemRuntime().findType(TypeAlias.size_t).size(); + return (len + sizeof_size_t - 1) & ~(sizeof_size_t - 1); + } + + public int CMSG_SPACE(int l) { + return CMSG_ALIGN(FreeBSDCmsgHdr.layout.size()) + CMSG_ALIGN(l); + } + + public int CMSG_LEN(int l) { + return CMSG_ALIGN( FreeBSDCmsgHdr.layout.size() ) + (l); + } + + public Pointer CMSG_DATA(Pointer cmsg) { + return cmsg.slice(CMSG_ALIGN(FreeBSDCmsgHdr.layout.size())); + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/JavaFileStat.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/JavaFileStat.java
Changed
@@ -2,42 +2,122 @@ import java.io.File; import java.io.IOException; - -import jnr.posix.POSIXHandler.WARNING_ID; - -public class JavaFileStat implements FileStat { - private final POSIXHandler handler; - private final POSIX posix; - +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.DosFileAttributes; +import java.nio.file.attribute.FileTime; +import java.nio.file.attribute.PosixFileAttributes; +import java.nio.file.attribute.PosixFilePermission; +import java.util.Set; + +public class JavaFileStat extends AbstractJavaFileStat { short st_mode; - int st_blksize; - long st_size; - int st_ctime; - int st_mtime; - + + BasicFileAttributes attrs; + PosixFileAttributes posixAttrs; + DosFileAttributes dosAttrs; public JavaFileStat(POSIX posix, POSIXHandler handler) { - this.handler = handler; - this.posix = posix; + super(posix, handler); } - public void setup(String path) { - // ENEBO: This was originally JRubyFile, but I believe we use JRuby file for normalization - // of paths. So we should be safe. - File file = new JavaSecuredFile(path); - // Limitation: We cannot determine, so always return 4096 (better than blowing up) - st_blksize = 4096; - st_mode = calculateMode(file, st_mode); - st_size = file.length(); - - // Parent file last modified will only represent when something was added or removed. - // This is not correct, but it is better than nothing and does work in one common use - // case. - st_mtime = (int) (file.lastModified() / 1000); - if (file.getParentFile() != null) { - st_ctime = (int) (file.getParentFile().lastModified() / 1000); - } else { - st_ctime = st_mtime; + public void setup(String filePath) { + File file = new JavaSecuredFile(filePath); + Path path = file.toPath(); + + try { + try { + // try POSIX + posixAttrs = Files.readAttributes(path, PosixFileAttributes.class, LinkOption.NOFOLLOW_LINKS); + attrs = posixAttrs; + } catch (UnsupportedOperationException uoe) { + try { + // try DOS + dosAttrs = Files.readAttributes(path, DosFileAttributes.class, LinkOption.NOFOLLOW_LINKS); + attrs = dosAttrs; + } catch (UnsupportedOperationException uoe2) { + attrs = Files.readAttributes(path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS); + } + } + } catch (IOException ioe) { + // fall back on pre-NIO2 logic + attrs = new PreNIO2FileAttributes(file); + } + + // Simulated mode value + st_mode = calculateMode(file, (short) 0); + } + + private class PreNIO2FileAttributes implements BasicFileAttributes { + final long st_size; + final int st_ctime; + final int st_mtime; + final boolean regularFile; + final boolean directory; + + PreNIO2FileAttributes(File file) { + st_size = file.length(); + + st_mtime = (int) (file.lastModified() / 1000); + + // Parent file last modified will only represent when something was added or removed. + // This is not correct, but it is better than nothing and does work in one common use + // case. + if (file.getParentFile() != null) { + st_ctime = (int) (file.getParentFile().lastModified() / 1000); + } else { + st_ctime = st_mtime; + } + + regularFile = file.isFile(); + directory = file.isDirectory(); + } + + @Override + public FileTime lastModifiedTime() { + return FileTime.fromMillis(st_mtime); + } + + @Override + public FileTime lastAccessTime() { + return lastModifiedTime(); + } + + @Override + public FileTime creationTime() { + return FileTime.fromMillis(st_mtime); + } + + @Override + public boolean isRegularFile() { + return (st_mode & S_IFREG) != 0; + } + + @Override + public boolean isDirectory() { + return (st_mode & S_IFDIR) != 0; + } + + @Override + public boolean isSymbolicLink() { + return (st_mode & S_IFLNK) != 0; + } + + @Override + public boolean isOther() { + return !(isRegularFile() || isDirectory() || isSymbolicLink()); + } + + @Override + public long size() { + return st_size; + } + + @Override + public Object fileKey() { + return null; } } @@ -59,24 +139,28 @@ } else if (file.isFile()) { st_mode |= S_IFREG; } - - try { - st_mode = calculateSymlink(file, st_mode); - } catch (IOException e) { - // Not sure we can do much in this case... + + if (posixAttrs != null && posixAttrs.isSymbolicLink()) { + st_mode |= S_IFLNK; + } else { + try { + st_mode = calculateSymlink(file, st_mode); + } catch (IOException e) { + // Not sure we can do much in this case... + } } - + return st_mode; } - - private short calculateSymlink(File file, short st_mode) throws IOException { + + private static short calculateSymlink(File file, short st_mode) throws IOException { if (file.getAbsoluteFile().getParentFile() == null) { return st_mode; } File absoluteParent = file.getAbsoluteFile().getParentFile(); File canonicalParent = absoluteParent.getCanonicalFile(); - + if (canonicalParent.getAbsolutePath().equals(absoluteParent.getAbsolutePath())) { // parent doesn't change when canonicalized, compare absolute and canonical file directly if (!file.getAbsolutePath().equalsIgnoreCase(file.getCanonicalPath())) { @@ -84,13 +168,13 @@ return st_mode; } } - + // directory itself has symlinks (canonical != absolute), so build new path with canonical parent and compare file = new JavaSecuredFile(canonicalParent.getAbsolutePath() + "/" + file.getName());
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/JavaLibCHelper.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/JavaLibCHelper.java
Changed
@@ -31,6 +31,7 @@ import static jnr.constants.platform.Errno.*; import java.io.*; +import java.lang.management.ManagementFactory; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.nio.ByteBuffer; @@ -43,7 +44,6 @@ import jnr.constants.platform.Errno; import jnr.posix.util.Chmod; import jnr.posix.util.ExecIt; -import jnr.posix.util.FieldAccess; import jnr.posix.util.JavaCrypt; import jnr.posix.util.Platform; @@ -244,8 +244,43 @@ return System.getProperty("user.name"); } + public String gethostname() { + String hn = System.getenv("HOSTNAME"); + if (hn == null) hn = System.getenv("COMPUTERNAME"); + return hn; + } + public int getpid() { - return handler.getPID(); + try { + return handler.getPID(); + } catch (UnsupportedOperationException uoe) { + // if handler raises UOE, as our default handler does, try other ways + + // Java 9+ provide ProcessHandle.current + try { + Class processHandle = Class.forName("java.lang.ProcessHandle"); + Object current = processHandle.getMethod("current").invoke(null); // static + return (int) (long) (Long) processHandle.getMethod("pid").invoke(current); + } catch (Exception e) { + // ignore, try Java 8 logic below + } + + // Java 8- can use management beans to infer the pid + try { + String runtimeName = ManagementFactory.getRuntimeMXBean().getName(); + int index = runtimeName.indexOf('@'); + + if (index > 0) { + return (int) Long.parseLong(runtimeName.substring(0, index)); + } + } catch (Exception e) { + // ignore, rethrow UOE below + } + + // couldn't do it, rethrow + throw uoe; + } + } ThreadLocal<Integer> pwIndex = new ThreadLocal<Integer>() { @Override @@ -330,14 +365,17 @@ try { File file = new JavaSecuredFile(path); - if (!file.exists()) return -1; - + if (!file.exists()) { + errno(ENOENT); + return -1; + } + jstat.setup(file.getCanonicalPath()); } catch (IOException e) { // TODO: Throw error when we have problems stat'ing canonicalizing } - // TODO: Add error reporting for cases we can calculate: ENOTDIR, ENAMETOOLONG, ENOENT + // TODO: Add error reporting for cases we can calculate: ENOTDIR, ENAMETOOLONG, // EACCES, ELOOP, EFAULT, EIO return 0;
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/JavaPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/JavaPOSIX.java
Changed
@@ -2,22 +2,25 @@ import jnr.constants.platform.Errno; import jnr.constants.platform.Fcntl; +import jnr.constants.platform.Signal; import jnr.constants.platform.Sysconf; import jnr.ffi.Pointer; import jnr.posix.util.Java5ProcessMaker; import jnr.posix.util.MethodName; import jnr.posix.util.Platform; import jnr.posix.util.ProcessMaker; -import sun.misc.Signal; +import jnr.posix.util.SunMiscSignal; import java.io.*; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.Collection; import java.util.Map; +import jnr.constants.platform.Confstr; import static jnr.constants.platform.Errno.EINVAL; import static jnr.constants.platform.Errno.ENOENT; +import jnr.constants.platform.Pathconf; final class JavaPOSIX implements POSIX { private final POSIXHandler handler; @@ -267,27 +270,8 @@ return unimplementedInt("kill"); // FIXME: Can be implemented } - private static class SunMiscSignalHandler implements sun.misc.SignalHandler { - final SignalHandler handler; - public SunMiscSignalHandler(SignalHandler handler) { - this.handler = handler; - } - - public void handle(Signal signal) { - handler.handle(signal.getNumber()); - } - } - - public SignalHandler signal(jnr.constants.platform.Signal sig, final SignalHandler handler) { - Signal s = new Signal(sig.name().substring("SIG".length())); - - sun.misc.SignalHandler oldHandler = Signal.handle(s, new SunMiscSignalHandler(handler)); - - if (oldHandler instanceof SunMiscSignalHandler) { - return ((SunMiscSignalHandler)oldHandler).handler; - } else { - return null; - } + public SignalHandler signal(Signal sig, SignalHandler handler) { + return SunMiscSignal.signal(sig, handler); } public int raise(int sig) { @@ -558,6 +542,16 @@ } } + public int confstr(Confstr name, ByteBuffer buf, int len) { + errno(Errno.EOPNOTSUPP.intValue()); + return -1; + } + + public int fpathconf(int fd, Pathconf name) { + errno(Errno.EOPNOTSUPP.intValue()); + return -1; + } + public Times times() { return new JavaTimes(); } @@ -582,6 +576,11 @@ return unimplementedInt("fcntl"); } + public int fcntl(int fd, Fcntl fcntlConst, int arg) { + return unimplementedInt("fcntl"); + } + + @Deprecated public int fcntl(int fd, Fcntl fcntlConst, int... arg) { return unimplementedInt("fcntl"); } @@ -813,6 +812,10 @@ return -1; } + public String gethostname() { + return helper.gethostname(); + } + static final class LoginInfo { public static final int UID = IDHelper.getInt("-u"); public static final int GID = IDHelper.getInt("-g");
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/LazyPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LazyPOSIX.java
Changed
@@ -10,6 +10,8 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.Collection; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; import jnr.constants.platform.Signal; final class LazyPOSIX implements POSIX { @@ -436,6 +438,14 @@ return posix().sysconf(name); } + public int confstr(Confstr name, ByteBuffer buf, int len) { + return posix().confstr(name, buf, len); + } + + public int fpathconf(int fd, Pathconf name) { + return posix().fpathconf(fd, name); + } + public Times times() { return posix().times(); } @@ -460,6 +470,11 @@ return posix().fcntl(fd, fcntlConst); } + public int fcntl(int fd, Fcntl fcntlConst, int arg) { + return posix().fcntl(fd, fcntlConst, arg); + } + + @Deprecated public int fcntl(int fd, Fcntl fcntlConst, int... arg) { return posix().fcntl(fd, fcntlConst); } @@ -583,6 +598,10 @@ return posix().mkfifo(path, mode); } + public String gethostname() { + return posix().gethostname(); + } + public int daemon(int nochdir, int noclose) { return posix().daemon(nochdir, noclose); }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/LibC.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LibC.java
Changed
@@ -36,6 +36,9 @@ import jnr.ffi.types.*; import java.nio.ByteBuffer; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; +import jnr.ffi.byref.IntByReference; public interface LibC { int chmod(CharSequence filename, int mode); @@ -82,6 +85,7 @@ int dup(int fd); int dup2(int oldFd, int newFd); + int fcntl(int fd, int fnctl, Flock arg); int fcntl(int fd, int fnctl, Pointer arg); int fcntl(int fd, int fnctl); int fcntl(int fd, int fnctl, int arg); @@ -151,6 +155,11 @@ int chdir(CharSequence path); public long sysconf(Sysconf name); + + public int confstr(Confstr name, @Out ByteBuffer buf, int len); + + public int fpathconf(int fd, Pathconf name); + public @clock_t long times(@Out @Transient NativeTimes tms); int flock(int fd, int mode); @@ -161,6 +170,7 @@ int ftruncate(int fd, long offset); int rename(CharSequence oldName, CharSequence newName); long getcwd(byte cwd, int len); + int gethostname(@Out ByteBuffer buffer, int len); int fsync(int fd); int fdatasync(int fd); @@ -168,6 +178,9 @@ int sendmsg(int socket, @In MsgHdr message, int flags); int recvmsg(int socket, @Direct MsgHdr message, int flags); + int setsockopt(int s, int level, int optname, @In ByteBuffer optval, int optlen); + int getsockopt(int s, int level, int optname, @Out ByteBuffer optval, @In @Out IntByReference optlen); + Variable<Long> environ(); int syscall(int number);
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/Linux.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/Linux.java
Changed
@@ -1,9 +1,12 @@ package jnr.posix; +import jnr.constants.platform.PosixFadvise; + /** * Linux-specific POSIX-like functions. */ public interface Linux extends POSIX { int ioprio_get(int which, int who); int ioprio_set(int which, int who, int ioprio); + int posix_fadvise(int fd, long offset, long len, PosixFadvise advise); }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/LinuxCmsgHdr.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LinuxCmsgHdr.java
Changed
@@ -67,4 +67,7 @@ return buf.toString(); } + public String toString(){ + return toString( "" ); + } }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/LinuxFileStatAARCH64.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LinuxFileStatAARCH64.java
Changed
@@ -17,8 +17,10 @@ public final uid_t st_uid = new uid_t(); public final gid_t st_gid = new gid_t(); public final dev_t st_rdev = new dev_t(); + public final dev_t __pad1 = new dev_t(); public final off_t st_size = new off_t(); public final blksize_t st_blksize = new blksize_t(); + public final Signed32 __pad2 = new Signed32(); public final blkcnt_t st_blocks = new blkcnt_t(); public final time_t st_atime = new time_t(); // Time of last access public final SignedLong st_atimensec = new SignedLong(); // Time of last access (nanoseconds) @@ -26,7 +28,8 @@ public final SignedLong st_mtimensec = new SignedLong(); // Last data modification time (nanoseconds) public final time_t st_ctime = new time_t(); // Time of last status change public final SignedLong st_ctimensec = new SignedLong(); // Time of last status change (nanoseconds) - public final Signed64 __unused4 = new Signed64(); + public final Signed32 __unused4 = new Signed32(); + public final Signed32 __unused5 = new Signed32(); } private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime());
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LinuxFileStatMIPS64.java
Added
@@ -0,0 +1,110 @@ +package jnr.posix; + +import jnr.ffi.StructLayout; + +public final class LinuxFileStatMIPS64 extends BaseFileStat implements NanosecondFileStat { + public static final class Layout extends StructLayout { + + public Layout(jnr.ffi.Runtime runtime) { + super(runtime); + } + + public final Unsigned64 st_dev = new Unsigned64(); + public final Unsigned32 __pad01 = new Unsigned32(); + public final Unsigned32 __pad02 = new Unsigned32(); + public final Unsigned32 __pad03 = new Unsigned32(); + + public final Unsigned64 st_ino = new Unsigned64(); + public final Unsigned64 st_mode = new Unsigned64(); + public final Unsigned32 st_nlink = new Unsigned32(); + public final Unsigned32 st_uid = new Unsigned32(); + public final Unsigned32 st_gid = new Unsigned32(); + public final Unsigned64 st_rdev = new Unsigned64(); + public final Unsigned32 __pad11 = new Unsigned32(); + public final Unsigned32 __pad12 = new Unsigned32(); + public final Unsigned32 __pad13 = new Unsigned32(); + + public final Signed64 st_size = new Signed64(); + + public final Unsigned64 st_atime = new Unsigned64(); // Time of last access (time_t) + public final Unsigned64 st_atimensec = new Unsigned64(); // Time of last access (nanoseconds) + public final Unsigned64 st_mtime = new Unsigned64(); // Last data modification time (time_t) + public final Unsigned64 st_mtimensec = new Unsigned64(); // Last data modification time (nanoseconds) + public final Unsigned64 st_ctime = new Unsigned64(); // Time of last status change (time_t) + public final Unsigned64 st_ctimensec = new Unsigned64(); // Time of last status change (nanoseconds) + + public final Unsigned64 st_blksize = new Unsigned64(); + public final Unsigned32 __pad20 = new Unsigned32(); + public final Unsigned64 st_blocks = new Unsigned64(); + } + + private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime()); + + public LinuxFileStatMIPS64(LinuxPOSIX posix) { + super(posix, layout); + } + + public long atime() { + return layout.st_atime.get(memory); + } + + public long aTimeNanoSecs() { + return layout.st_atimensec.get(memory); + } + + public long blockSize() { + return layout.st_blksize.get(memory); + } + + public long blocks() { + return layout.st_blocks.get(memory); + } + + public long ctime() { + return layout.st_ctime.get(memory); + } + + public long cTimeNanoSecs() { + return layout.st_ctimensec.get(memory); + } + + public long dev() { + return layout.st_dev.get(memory); + } + + public int gid() { + return (int) layout.st_gid.get(memory); + } + + public long ino() { + return layout.st_ino.get(memory); + } + + public int mode() { + return (int) layout.st_mode.get(memory); + } + + public long mtime() { + return layout.st_mtime.get(memory); + } + + public long mTimeNanoSecs() { + return layout.st_mtimensec.get(memory); + } + + public int nlink() { + return (int) layout.st_nlink.get(memory); + } + + public long rdev() { + return layout.st_rdev.get(memory); + } + + public long st_size() { + return layout. st_size.get(memory); + } + + public int uid() { + return (int) layout.st_uid.get(memory); + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/LinuxLibC.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LinuxLibC.java
Changed
@@ -4,6 +4,7 @@ import jnr.ffi.annotations.NulTerminate; import jnr.ffi.annotations.Out; import jnr.ffi.annotations.Transient; +import jnr.ffi.types.off_t; import java.nio.ByteBuffer; public interface LinuxLibC extends UnixLibC { @@ -17,4 +18,5 @@ public int __lxstat64(int version, @NulTerminate @In ByteBuffer path, @Out @Transient FileStat stat); public int __xstat64(int version, CharSequence path, @Out @Transient FileStat stat); public int __xstat64(int version, @NulTerminate @In ByteBuffer path, @Out @Transient FileStat stat); + public int posix_fadvise(int fd, @off_t long offset, @off_t long len, int advice); }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/LinuxMsgHdr.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LinuxMsgHdr.java
Changed
@@ -1,5 +1,7 @@ package jnr.posix; +import java.util.ArrayList; +import java.util.List; import jnr.ffi.Pointer; import jnr.ffi.Runtime; import jnr.ffi.StructLayout; @@ -73,7 +75,7 @@ CmsgHdr controls = getControls(); for (int i = 0; i < controls.length; ++i) { - buf.append(((MacOSCmsgHdr) controlsi).toString(" ")); + buf.append(((LinuxCmsgHdr) controlsi).toString(" ")); if (i < controls.length - 1) { buf.append(",\n"); } else { @@ -146,4 +148,26 @@ public int getFlags() { return layout.msg_flags.get(this.memory); } + + @Override + public CmsgHdr getControls() { + int len = getControlLen(); + if (len == 0) { + return new CmsgHdr0; + } + + List<CmsgHdr> control = new ArrayList<CmsgHdr>(); + + int offset = 0; + + Pointer controlPtr = getControlPointer(); + + while (offset < len) { + CmsgHdr each = allocateCmsgHdrInternal(posix, controlPtr.slice(offset), -1); + offset += LinuxSocketMacros.INSTANCE.CMSG_ALIGN( each.getLen() ); + control.add(each); + } + + return control.toArray(new CmsgHdrcontrol.size()); + } }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/LinuxPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LinuxPOSIX.java
Changed
@@ -1,6 +1,7 @@ package jnr.posix; import jnr.constants.platform.Errno; +import jnr.constants.platform.PosixFadvise; import jnr.constants.platform.Sysconf; import jnr.ffi.Memory; import jnr.ffi.Pointer; @@ -8,6 +9,9 @@ import jnr.posix.util.Platform; import java.io.FileDescriptor; +import java.nio.ByteBuffer; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; final class LinuxPOSIX extends BaseNativePOSIX implements Linux { private volatile boolean use_fxstat64 = true; @@ -19,7 +23,7 @@ super(libcProvider, handler); - if (Platform.IS_32_BIT || "sparcv9".equals(Platform.ARCH)) { + if (Platform.IS_32_BIT || "sparcv9".equals(Platform.ARCH) || Platform.ARCH.contains("mips64")) { statVersion = 3; } else { FileStat stat = allocateStat(); @@ -43,6 +47,9 @@ if ("sparcv9".equals(Platform.ARCH)) { return new LinuxFileStatSPARCV9(this); } else{ + if (Platform.ARCH.contains("mips64")) { + return new LinuxFileStatMIPS64(this); + } return new LinuxFileStat64(this); } } @@ -187,6 +194,14 @@ return libc().sysconf(name); } + public int confstr(Confstr name, ByteBuffer buf, int len) { + return libc().confstr(name, buf, len); + } + + public int fpathconf(int fd, Pathconf name) { + return libc().fpathconf(fd, name); + } + public Times times() { return NativeTimes.times(this); } @@ -202,6 +217,8 @@ static final ABI _ABI_X86_64 = new ABI_X86_64(); static final ABI _ABI_AARCH64 = new ABI_AARCH64(); static final ABI _ABI_SPARCV9 = new ABI_SPARCV9(); + static final ABI _ABI_PPC64 = new ABI_PPC64(); + static final ABI _ABI_MIPS64 = new ABI_MIPS64(); public static ABI abi() { if ("x86_64".equals(Platform.ARCH)) { @@ -214,7 +231,11 @@ return _ABI_AARCH64; } else if ("sparcv9".equals(Platform.ARCH)) { return _ABI_SPARCV9; - } + } else if (Platform.ARCH.contains("ppc64")) { + return _ABI_PPC64; + } else if (Platform.ARCH.contains("mips64")) { + return _ABI_MIPS64; + } return null; } @@ -270,6 +291,30 @@ return 218; } } + + /** @see /usr/include/asm-generic/unistd.h */ + final static class ABI_PPC64 implements ABI { + @Override + public int __NR_ioprio_set() { + return 273; + } + @Override + public int __NR_ioprio_get() { + return 274 ; + } + } + + /** @see /usr/include/asm/unistd.h */ + final static class ABI_MIPS64 implements ABI { + @Override + public int __NR_ioprio_set() { + return 5273; + } + @Override + public int __NR_ioprio_get() { + return 5274; + } + } } public int ioprio_get(int which, int who) { @@ -291,4 +336,8 @@ return libc().syscall(abi.__NR_ioprio_set(), which, who, ioprio); } + + public int posix_fadvise(int fd, long offset, long len, PosixFadvise advise) { + return ((LinuxLibC) libc()).posix_fadvise(fd, offset, len, advise.intValue()); + } }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/LinuxSocketMacros.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/LinuxSocketMacros.java
Changed
@@ -20,7 +20,7 @@ } public int CMSG_LEN(int l) { - return CMSG_ALIGN( LinuxCmsgHdr.layout.size() + l ); + return CMSG_ALIGN( LinuxCmsgHdr.layout.size() ) + l; } public Pointer CMSG_DATA(Pointer cmsg) {
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/MacOSFileStat64Inode.java
Added
@@ -0,0 +1,144 @@ +/***** BEGIN LICENSE BLOCK ***** + * Version: EPL 2.0/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Eclipse Public + * License Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.eclipse.org/legal/cpl-v10.html + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the CPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the CPL, the GPL or the LGPL. + ***** END LICENSE BLOCK *****/ +/** + * $Id: $ + */ + +package jnr.posix; + +import jnr.ffi.StructLayout; + +/** + * An alternate stat layout when running with _DARWIN_FEATURE_64_BIT_INODE, which appears to be the default on M1. + */ +public final class MacOSFileStat64Inode extends BaseFileStat implements NanosecondFileStat { + public static class Layout64Inode extends StructLayout { + + public Layout64Inode(jnr.ffi.Runtime runtime) { + super(runtime); + } + + public final class time_t extends SignedLong { + } + public final Signed32 st_dev = new Signed32(); + public final Signed16 st_mode = new Signed16(); + public final Signed16 st_nlink = new Signed16(); + public final Signed64 st_ino = new Signed64(); + public final Signed32 st_uid = new Signed32(); + public final Signed32 st_gid = new Signed32(); + public final Signed32 st_rdev = new Signed32(); + public final time_t st_atime = new time_t(); + public final SignedLong st_atimensec = new SignedLong(); + public final time_t st_mtime = new time_t(); + public final SignedLong st_mtimensec = new SignedLong(); + public final time_t st_ctime = new time_t(); + public final SignedLong st_ctimensec = new SignedLong(); + public final time_t st_birthtime = new time_t(); + public final SignedLong st_birthtimensec = new SignedLong(); + public final Signed64 st_size = new Signed64(); + public final Signed64 st_blocks = new Signed64(); + public final Signed32 st_blksize = new Signed32(); + public final Signed32 st_flags = new Signed32(); + public final Signed32 st_gen = new Signed32(); + public final Signed32 st_lspare = new Signed32(); + public final Signed64 st_qspare0 = new Signed64(); + public final Signed64 st_qspare1 = new Signed64(); + } + private static final Layout64Inode layout = new Layout64Inode(jnr.ffi.Runtime.getSystemRuntime()); + + public MacOSFileStat64Inode(MacOSPOSIX posix) { + super(posix, layout); + } + + public long atime() { + return layout.st_atime.get(memory); + } + + public long blocks() { + return layout.st_blocks.get(memory); + } + + public long blockSize() { + return layout.st_blksize.get(memory); + } + + public long ctime() { + return layout.st_ctime.get(memory); + } + + public long dev() { + return layout.st_dev.get(memory); + } + + public int gid() { + return layout.st_gid.get(memory); + } + + public long ino() { + return layout.st_ino.get(memory); + } + + public int mode() { + return layout.st_mode.get(memory) & 0xffff; + } + + public long mtime() { + return layout.st_mtime.get(memory); + } + + public int nlink() { + return layout.st_nlink.get(memory); + } + + public long rdev() { + return layout.st_rdev.get(memory); + } + + public long st_size() { + return layout.st_size.get(memory); + } + + public int uid() { + return layout.st_uid.get(memory); + } + + @Override + public long aTimeNanoSecs() { + return layout.st_atimensec.get(memory); + } + + @Override + public long cTimeNanoSecs() { + return layout.st_ctimensec.get(memory); + } + + @Override + public long mTimeNanoSecs() { + return layout.st_mtimensec.get(memory); + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/MacOSPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/MacOSPOSIX.java
Changed
@@ -1,5 +1,8 @@ package jnr.posix; +import java.nio.ByteBuffer; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; import jnr.constants.platform.Sysconf; import jnr.ffi.*; import jnr.ffi.mapper.FromNativeContext; @@ -18,6 +21,10 @@ } public FileStat allocateStat() { + if (Platform.getNativePlatform().getCPU() == Platform.CPU.AARCH64) { + return new MacOSFileStat64Inode(this); + } + return new MacOSFileStat(this); } @@ -43,6 +50,14 @@ return libc().sysconf(name); } + public int confstr(Confstr name, ByteBuffer buf, int len) { + return libc().confstr(name, buf, len); + } + + public int fpathconf(int fd, Pathconf name) { + return libc().fpathconf(fd, name); + } + public Times times() { return NativeTimes.times(this); }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/OpenBSDPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/OpenBSDPOSIX.java
Changed
@@ -31,6 +31,9 @@ package jnr.posix; +import java.nio.ByteBuffer; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; import jnr.constants.platform.Sysconf; import jnr.ffi.Memory; import jnr.ffi.Struct; @@ -61,6 +64,14 @@ return libc().sysconf(name); } + public int confstr(Confstr name, ByteBuffer buf, int len) { + return libc().confstr(name, buf, len); + } + + public int fpathconf(int fd, Pathconf name) { + return libc().fpathconf(fd, name); + } + public Times times() { return NativeTimes.times(this); }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/POSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/POSIX.java
Changed
@@ -10,6 +10,9 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.Collection; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Pathconf; +import jnr.ffi.annotations.Out; public interface POSIX { CharSequence crypt(CharSequence key, CharSequence salt); @@ -143,6 +146,11 @@ ProcessMaker newProcessMaker(); public long sysconf(Sysconf name); + + public int confstr(Confstr name, @Out ByteBuffer buf, int len); + + public int fpathconf(int fd, Pathconf name); + public Times times(); public long posix_spawnp(String path, Collection<? extends SpawnFileAction> fileActions, @@ -159,6 +167,7 @@ int dup2(int oldFd, int newFd); int fcntlInt(int fd, Fcntl fcntlConst, int arg); + int fcntl(int fd, Fcntl fcntlConst, int arg); int fcntl(int fd, Fcntl fcntlConst); int access(CharSequence path, int amode); int close(int fd); @@ -190,6 +199,7 @@ int ftruncate(int fd, long offset); int rename(CharSequence oldName, CharSequence newName); String getcwd(); + String gethostname(); int socketpair(int domain, int type, int protocol, int fds); int sendmsg(int socket, MsgHdr message, int flags); @@ -208,6 +218,7 @@ * @param arg arguments for the flag or null if none * @return 0 if success, -1 if error */ + @Deprecated int fcntl(int fd, Fcntl fcntlConst, int... arg); int fsync(int fd); int fdatasync(int fd);
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/POSIXFactory.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/POSIXFactory.java
Changed
@@ -125,6 +125,9 @@ case FREEBSD: return loadFreeBSDPOSIX(handler); + + case DRAGONFLY: + return loadDragonFlyPOSIX(handler); case OPENBSD: return loadOpenBSDPOSIX(handler); @@ -158,6 +161,10 @@ return new FreeBSDPOSIX(DefaultLibCProvider.INSTANCE, handler); } + public static POSIX loadDragonFlyPOSIX(POSIXHandler handler) { + return new DragonFlyPOSIX(DefaultLibCProvider.INSTANCE, handler); + } + public static POSIX loadOpenBSDPOSIX(POSIXHandler handler) { return new OpenBSDPOSIX(DefaultLibCProvider.INSTANCE, handler); } @@ -178,6 +185,7 @@ case SOLARIS: return new String { "socket", "nsl", STANDARD_C_LIBRARY_NAME}; + case DRAGONFLY: case FREEBSD: case NETBSD: return new String {STANDARD_C_LIBRARY_NAME}; @@ -278,9 +286,26 @@ public static final LibCProvider INSTANCE = new DefaultLibCProvider(); private static final class SingletonHolder { - public static LibC libc = Library.loadLibrary(libraryInterface(), options(), libraries()); + public static LibC libc; public static Crypt crypt; static { + LibraryLoader<? extends LibC> libcLoader = LibraryLoader.create(libraryInterface()); + + // always do a default search + libcLoader.searchDefault(); + + for (String library : libraries()) { + libcLoader.library(library); + } + + for (Map.Entry<LibraryOption, Object> entry : options().entrySet()) { + libcLoader.option(entry.getKey(), entry.getValue()); + } + + libcLoader.failImmediately(); + + libc = libcLoader.load(); + Crypt c = null; // FIXME: This is kinda gross but there's no way to tell jnr-ffi that some libraries are ok to fail
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/POSIXHandler.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/POSIXHandler.java
Changed
@@ -66,7 +66,7 @@ * found a number of packages which would rather have some identity for the runtime than * nothing. * - * Note: If you do not want this to work you impl can just call unimplementedError(String). + * Note: If you do not want this to work you impl can just call {@link #unimplementedError(String)}. * * @return your runtime's process ID */
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/POSIXTypeMapper.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/POSIXTypeMapper.java
Changed
@@ -20,6 +20,8 @@ return SolarisPOSIX.PASSWD; } else if (Platform.IS_FREEBSD) { return FreeBSDPOSIX.PASSWD; + } else if (Platform.IS_DRAGONFLY) { + return DragonFlyPOSIX.PASSWD; } else if (Platform.IS_OPENBSD) { return OpenBSDPOSIX.PASSWD; } else if (Platform.IS_WINDOWS) {
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/SolarisPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/SolarisPOSIX.java
Changed
@@ -1,5 +1,7 @@ package jnr.posix; +import java.nio.ByteBuffer; +import jnr.constants.platform.Confstr; import jnr.constants.platform.Fcntl; import jnr.constants.platform.Sysconf; import jnr.ffi.*; @@ -8,6 +10,7 @@ import jnr.posix.util.Platform; import static jnr.constants.platform.Errno.EINVAL; +import jnr.constants.platform.Pathconf; final class SolarisPOSIX extends BaseNativePOSIX { SolarisPOSIX(LibCProvider libc, POSIXHandler handler) { @@ -32,6 +35,14 @@ return libc().sysconf(name); } + public int confstr(Confstr name, ByteBuffer buf, int len) { + return libc().confstr(name, buf, len); + } + + public int fpathconf(int fd, Pathconf name) { + return libc().fpathconf(fd, name); + } + public Times times() { return NativeTimes.times(this); }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/SpawnFileAction.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/SpawnFileAction.java
Changed
@@ -2,6 +2,11 @@ import jnr.ffi.Pointer; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; + public abstract class SpawnFileAction { abstract boolean act(POSIX posix, Pointer nativeFileActions); @@ -38,16 +43,44 @@ final String path; final int fd; final int flags, mode; + final ByteBuffer nativePath; public Open(String path, int fd, int flags, int mode) { this.path = path; this.fd = fd; this.flags = flags; this.mode = mode; + this.nativePath = defensiveCopy(path); + } + + private ByteBuffer defensiveCopy(String path) { + /* + This logic allocates a direct ByteBuffer to use for the path in order to work around systems that have not + patched CVE-2014-4043, in which older glibc versions do not make a defensive copy of the file path passed to + posix_spawn_file_actions_addopen. The buffer may be freed by the caller before it can be used in an + eventual posix_spawn call. + + See https://bugzilla.redhat.com/show_bug.cgi?id=1983750 for a RHEL version of this issue. + */ + + // determine encoded byte array length + CharsetEncoder encoder = Charset.defaultCharset().newEncoder(); + int bpc = (int) encoder.maxBytesPerChar(); + int size = (path.length() + 1) * bpc; + + // transcode to native buffer + ByteBuffer nativePath = ByteBuffer.allocateDirect(size); + encoder.encode(CharBuffer.wrap(path), nativePath, true); + nativePath.flip(); + + // null terminate + nativePath.limit(nativePath.limit() + bpc); + + return nativePath; } final boolean act(POSIX posix, Pointer nativeFileActions) { - return ((UnixLibC) posix.libc()).posix_spawn_file_actions_addopen(nativeFileActions, fd, path, flags, mode) == 0; + return ((UnixLibC) posix.libc()).posix_spawn_file_actions_addopen(nativeFileActions, fd, nativePath, flags, mode) == 0; } public String toString() {
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/UnixLibC.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/UnixLibC.java
Changed
@@ -1,6 +1,7 @@ package jnr.posix; import jnr.ffi.Pointer; +import jnr.ffi.annotations.Direct; import jnr.ffi.annotations.In; import jnr.ffi.annotations.Out; import jnr.ffi.byref.ByReference; @@ -9,6 +10,8 @@ import jnr.ffi.byref.ShortByReference; import jnr.ffi.types.pid_t; +import java.nio.ByteBuffer; + public interface UnixLibC extends LibC { public int posix_spawn(@Out ByReference pid, @In CharSequence path, @In Pointer fileActions, @In Pointer attr, @In CharSequence argv, @In CharSequence envp); @@ -19,8 +22,15 @@ public int posix_spawn_file_actions_init(Pointer fileActions); public int posix_spawn_file_actions_destroy(Pointer fileActions); public int posix_spawn_file_actions_addclose(Pointer fileActions, int filedes); + + /** + * @deprecated due to CVE-2014-4043 (https://bugzilla.redhat.com/show_bug.cgi?id=1983750) + */ + @Deprecated public int posix_spawn_file_actions_addopen(Pointer fileActions, int filedes, CharSequence path, int oflag, int mode); + public int posix_spawn_file_actions_addopen(Pointer fileActions, int filedes, @Direct ByteBuffer path, + int oflag, int mode); public int posix_spawn_file_actions_adddup2(Pointer fileActions, int filedes, int newfiledes); public int posix_spawnattr_init(Pointer attr); public int posix_spawnattr_destroy(Pointer attr);
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/WindowsLibC.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/WindowsLibC.java
Changed
@@ -108,6 +108,11 @@ @In WString envValue); @StdCall + boolean GetComputerNameW( + @Out ByteBuffer lpBuffer, + IntByReference nSize); + + @StdCall boolean SetFileTime( HANDLE hFile, FileTime lpCreationTime,
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/WindowsPOSIX.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/WindowsPOSIX.java
Changed
@@ -14,6 +14,7 @@ import java.io.FileDescriptor; import java.nio.ByteBuffer; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; @@ -318,6 +319,15 @@ return -1; } + @Override + public String gethostname() { + ByteBuffer buffer = ByteBuffer.allocate(64); + IntByReference len = new IntByReference(buffer.capacity() - 1); + if (!wlibc().GetComputerNameW(buffer, len)) return helper.gethostname(); + buffer.limit(len.intValue() * 2); + return Charset.forName("UTF-16LE").decode(buffer).toString(); + } + public FileStat fstat(int fd) { WindowsFileStat stat = new WindowsFileStat(this); if (fstat(fd, stat) < 0) handler.error(Errno.valueOf(errno()), "fstat", "" + fd); @@ -460,7 +470,7 @@ private FileTime timevalToFileTime(long timeval) { if (timeval == null) { - return nullFileTime(); + return currentFileTime(); } // timeval unit is (sec, microsec) @@ -470,7 +480,7 @@ private FileTime timespecToFileTime(long timespec) { if (timespec == null) { - return nullFileTime(); + return currentFileTime(); } // timespec unit is (sec, nanosec) @@ -518,6 +528,10 @@ return fileTime; } + private FileTime currentFileTime() { + return unixTimeToFileTime(System.currentTimeMillis() * 10000); + } + @Override public int wait(int status) { handler.unimplementedError("wait");
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/WindowsRawFileStat.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/WindowsRawFileStat.java
Changed
@@ -1,200 +1,212 @@ -package jnr.posix; - -import jnr.posix.util.WindowsHelpers; -import jnr.posix.windows.CommonFileInformation; -import jnr.posix.windows.WindowsFileInformation; - -/** - * - */ -public class WindowsRawFileStat extends JavaFileStat { - private int st_atime; - private int st_rdev; - private int st_dev; - private int st_nlink; - private int st_mode; - - public WindowsRawFileStat(POSIX posix, POSIXHandler handler) { - super(posix, handler); - } - - public void setup(String path, CommonFileInformation fileInfo) { - st_mode = fileInfo.getMode(path); - setup(fileInfo); - - if (WindowsHelpers.isDriveLetterPath(path)) { - int letterAsNumber = Character.toUpperCase(path.charAt(0)) - 'A'; - st_rdev = letterAsNumber; - st_dev = letterAsNumber; - } - } - - public void setup(CommonFileInformation fileInfo) { - st_atime = (int) fileInfo.getLastAccessTimeMicroseconds(); - st_mtime = (int) fileInfo.getLastWriteTimeMicroseconds(); - st_ctime = (int) fileInfo.getCreationTimeMicroseconds(); - st_size = isDirectory() ? 0 : fileInfo.getFileSize(); - st_nlink = 1; - st_mode &= ~(S_IWGRP | S_IWOTH); - } - - public int mode() { - return st_mode; - } - - public int gid() { - return 0; - } - - public int uid() { - return 0; - } - - public long atime() { - return st_atime; - } - - public long dev() { - return st_dev; - } - - public int nlink() { - return st_nlink; - } - - public long rdev() { - return st_rdev; - } - - @Override - public long blocks() { - return -1; - } - - @Override - public long blockSize() { - return -1; - } - - public boolean isBlockDev() { - return (mode() & S_IFMT) == S_IFBLK; - } - - public boolean isCharDev() { - return (mode() & S_IFMT) == S_IFCHR; - } - - public boolean isDirectory() { - return (mode() & S_IFMT) == S_IFDIR; - } - - public boolean isEmpty() { - return st_size() == 0; - } - - @Override - public boolean isExecutable() { - if (isOwned()) return (mode() & S_IXUSR) != 0; - if (isGroupOwned()) return (mode() & S_IXGRP) != 0; - if ((mode() & S_IXOTH) != 0) return false; - - return true; - } - - @Override - public boolean isExecutableReal() { - if (isROwned()) return (mode() & S_IXUSR) != 0; - if (groupMember(gid())) return (mode() & S_IXGRP) != 0; - if ((mode() & S_IXOTH) != 0) return false; - - return true; - } - - public boolean isFile() { - return (mode() & S_IFMT) == S_IFREG; - } - - public boolean isFifo() { - return (mode() & S_IFMT) == S_IFIFO; - } - - public boolean isGroupOwned() { - return groupMember(gid()); - } - - public boolean isIdentical(FileStat other) { - return dev() == other.dev() && ino() == other.ino(); - } - - public boolean isNamedPipe() { - return (mode() & S_IFIFO) != 0; - } - - // FIXME: Implement - @Override - public boolean isOwned() { - return true; - } - - // FIXME: Implement - @Override - public boolean isROwned() { - return true; - } - - @Override - public boolean isReadable() { - if (isOwned()) return (mode() & S_IRUSR) != 0; - if (isGroupOwned()) return (mode() & S_IRGRP) != 0; - if ((mode() & S_IROTH) != 0) return false; - - return true; - } - - @Override - public boolean isReadableReal() { - if (isROwned()) return (mode() & S_IRUSR) != 0; - if (groupMember(gid())) return (mode() & S_IRGRP) != 0; - if ((mode() & S_IROTH) != 0) return false; - - return true; - } - - public boolean isSetgid() { - return (mode() & S_ISGID) != 0; - } - - public boolean isSetuid() { - return (mode() & S_ISUID) != 0; - } - - public boolean isSocket() { - return (mode() & S_IFMT) == S_IFSOCK; - } - - public boolean isSticky() { - return (mode() & S_ISVTX) != 0; - } - - public boolean isSymlink() { - return (mode() & S_IFMT) == S_IFLNK; - } - - @Override - public boolean isWritable() { - if (isOwned()) return (mode() & S_IWUSR) != 0; - if (isGroupOwned()) return (mode() & S_IWGRP) != 0; - if ((mode() & S_IWOTH) != 0) return false; - - return true; - } - - @Override - public boolean isWritableReal() { - if (isROwned()) return (mode() & S_IWUSR) != 0; - if (groupMember(gid())) return (mode() & S_IWGRP) != 0; - if ((mode() & S_IWOTH) != 0) return false; - - return true; - }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/util/Platform.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/util/Platform.java
Changed
@@ -51,6 +51,7 @@ private static final String MAC_OS = "mac os"; private static final String DARWIN = "darwin"; private static final String FREEBSD = "freebsd"; + private static final String DRAGONFLY = "dragonfly"; private static final String OPENBSD = "openbsd"; private static final String LINUX = "linux"; private static final String SOLARIS = "sunos"; @@ -67,10 +68,11 @@ public static final boolean IS_WINDOWS_7 = IS_WINDOWS && OS_NAME_LC.indexOf(WINDOWS_7) > -1; public static final boolean IS_MAC = OS_NAME_LC.startsWith(MAC_OS) || OS_NAME_LC.startsWith(DARWIN); public static final boolean IS_FREEBSD = OS_NAME_LC.startsWith(FREEBSD); + public static final boolean IS_DRAGONFLY = OS_NAME_LC.startsWith(DRAGONFLY); public static final boolean IS_OPENBSD = OS_NAME_LC.startsWith(OPENBSD); public static final boolean IS_LINUX = OS_NAME_LC.startsWith(LINUX); public static final boolean IS_SOLARIS = OS_NAME_LC.startsWith(SOLARIS); - public static final boolean IS_BSD = IS_MAC || IS_FREEBSD || IS_OPENBSD; + public static final boolean IS_BSD = IS_MAC || IS_FREEBSD || IS_OPENBSD || IS_DRAGONFLY; public static final String envCommand() { if (IS_WINDOWS) {
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/util/SunMiscSignal.java
Added
@@ -0,0 +1,29 @@ +package jnr.posix.util; + +import jnr.posix.SignalHandler; +import sun.misc.Signal; + +public class SunMiscSignal { + public static SignalHandler signal(jnr.constants.platform.Signal sig, final SignalHandler handler) { + Signal s = new Signal(sig.name().substring("SIG".length())); + + sun.misc.SignalHandler oldHandler = Signal.handle(s, new SunMiscSignalHandler(handler)); + + if (oldHandler instanceof SunMiscSignalHandler) { + return ((SunMiscSignalHandler)oldHandler).handler; + } else { + return null; + } + } + + private static class SunMiscSignalHandler implements sun.misc.SignalHandler { + final SignalHandler handler; + public SunMiscSignalHandler(SignalHandler handler) { + this.handler = handler; + } + + public void handle(Signal signal) { + handler.handle(signal.getNumber()); + } + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/main/java/jnr/posix/windows/CommonFileInformation.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/main/java/jnr/posix/windows/CommonFileInformation.java
Changed
@@ -1,7 +1,5 @@ package jnr.posix.windows; -import jnr.posix.FileTime; - import static jnr.posix.FileStat.*; /** @@ -67,16 +65,16 @@ return mode; } - public long getLastWriteTimeMicroseconds() { - return asMicroSeconds(getLastWriteTime().getLongValue()) / MICROSECONDS; + public long getLastWriteTimeNanoseconds() { + return epochNanos(getLastWriteTime().getLongValue()); } - public long getLastAccessTimeMicroseconds() { - return asMicroSeconds(getLastAccessTime().getLongValue()) / MICROSECONDS; + public long getLastAccessTimeNanoseconds() { + return epochNanos(getLastAccessTime().getLongValue()); } - public long getCreationTimeMicroseconds() { - return asMicroSeconds(getCreationTime().getLongValue()) / MICROSECONDS; + public long getCreationTimeNanoseconds() { + return epochNanos(getCreationTime().getLongValue()); } public long getFileSize() { @@ -87,17 +85,17 @@ //private static final int HOURS = 24; //private static final int MINUTES = 60; // private static final int SECONDS = 60; - private static final int MICROSECONDS = 1000 * 1000; + public static final int NANOSECONDS = 1000 * 1000 * 1000; // on number of days a year: https://imicrothinking.wordpress.com/tag/365-2425-days/ private static final double DAYS_BETWEEN_WINDOWS_AND_UNIX = (1970 - 1601) * 365.2425; - private static final long MICROSECONDS_TO_UNIX_EPOCH_FROM_WINDOWS = 11644473600000000L; + private static final long NANOSECONDS_TO_UNIX_EPOCH_FROM_WINDOWS = 11644473600L * NANOSECONDS; // (long) (DAYS_BETWEEN_WINDOWS_AND_UNIX * HOURS * SECONDS * MINUTES * MICROSECONDS); - private long asMicroSeconds(long windowsNanosecondTime) { - return (windowsNanosecondTime / 10) - MICROSECONDS_TO_UNIX_EPOCH_FROM_WINDOWS; + private long epochNanos(long windowsNanoChunks) { + return (windowsNanoChunks * 100) - NANOSECONDS_TO_UNIX_EPOCH_FROM_WINDOWS; } public static long asNanoSeconds(long seconds) { - return (seconds * 1000 + MICROSECONDS_TO_UNIX_EPOCH_FROM_WINDOWS) * 10; + return (seconds * 1000 + NANOSECONDS_TO_UNIX_EPOCH_FROM_WINDOWS / 1000) * 10; } }
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/ConfstrTest.java
Added
@@ -0,0 +1,34 @@ +package jnr.posix; + +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; +import java.nio.ByteBuffer; +import jnr.constants.platform.Confstr; +import jnr.constants.platform.Errno; +import jnr.posix.util.Platform; + +public class ConfstrTest { + private static POSIX posix; + @BeforeClass + public static void setUpClass() throws Exception { + posix = POSIXFactory.getPOSIX(new DummyPOSIXHandler(), true); + } + + @Test + public void confstr() { + if (Platform.IS_WINDOWS) { + int len = posix.confstr(Confstr._CS_PATH, null, 0); + assertEquals(-1, len); + assertEquals(Errno.EOPNOTSUPP.intValue(), posix.errno()); + } else { + int len = posix.confstr(Confstr._CS_PATH, null, 0); + assertTrue("bad strlen", len > 0); + + ByteBuffer buf = ByteBuffer.allocate(len); + posix.confstr(Confstr._CS_PATH, buf, len); + String str = new String(buf.array()); + assertTrue("CS_PATH is blank", str.length() > 0); + } + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/test/java/jnr/posix/FileStatTest.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/FileStatTest.java
Changed
@@ -61,6 +61,7 @@ FileStat stat = posix.stat(f.getAbsolutePath()); assertNotNull("posix.stat failed", stat); assertEquals(size, stat.st_size()); + assertEquals(1, stat.nlink()); //assertNotEquals(stat.mtime(), stat.ctime()); stat = posix.allocateStat();
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/test/java/jnr/posix/FileTest.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/FileTest.java
Changed
@@ -289,7 +289,9 @@ byte outContent = "foo".getBytes(); - int newFd = posix.fcntl(fd, Fcntl.F_DUPFD); + // NOTE: This test used to call without the third argument, but this leads to undefined behavior. + // See https://github.com/jnr/jnr-posix/issues/144 + int newFd = posix.fcntl(fd, Fcntl.F_DUPFD, 0); new FileOutputStream(JavaLibCHelper.toFileDescriptor(fd)).write(outContent); posix.lseek(fd, SEEK_SET, 0); @@ -312,14 +314,15 @@ byte outContent = "foo".getBytes(); - int dupFd = posix.fcntl(oldFd, Fcntl.F_DUPFD, newFd); + int expectedFd = 100; + int dupFd = posix.fcntl(oldFd, Fcntl.F_DUPFD, expectedFd); new FileOutputStream(JavaLibCHelper.toFileDescriptor(newFd)).write(outContent); byte inContent = new byteoutContent.length; new FileInputStream(JavaLibCHelper.toFileDescriptor(dupFd)).read(inContent, 0, 3); - assertTrue(dupFd > newFd); + assertTrue(dupFd >= expectedFd); assertArrayEquals(inContent, outContent); } } @@ -501,17 +504,18 @@ jnr.constants.platform.Access.F_OK.intValue(); // Set permissions to read-only and verify we don't have permissions to write. - posix.chmod(tmp.getCanonicalPath(), 0400); - assertEquals("access: ", -1, posix.access(tmp.getCanonicalPath(), Access.W_OK.intValue())); - assertEquals("access: ", 0, posix.access(tmp.getCanonicalPath(), Access.R_OK.intValue())); + String canonicalPath = tmp.getCanonicalPath(); + assertEquals("chmod 0400: ", 0, posix.chmod(canonicalPath, 0400)); + assertEquals("access " + canonicalPath + " for write: ", -1, posix.access(canonicalPath, Access.W_OK.intValue())); + assertEquals("access " + canonicalPath + " for read: ", 0, posix.access(canonicalPath, Access.R_OK.intValue())); - // Reset the permissions to read-wrinte and verify we now have permissions to write. - posix.chmod(tmp.getCanonicalPath(), 0600); - assertEquals("access: ", 0, posix.access(tmp.getCanonicalPath(), Access.W_OK.intValue())); - assertEquals("access: ", 0, posix.access(tmp.getCanonicalPath(), Access.R_OK.intValue())); + // Reset the permissions to read-write and verify we now have permissions to write. + assertEquals("chmod 0600: ", 0, posix.chmod(canonicalPath, 0600)); + assertEquals("access " + canonicalPath + " for write: ", 0, posix.access(canonicalPath, Access.W_OK.intValue())); + assertEquals("access " + canonicalPath + " for read: ", 0, posix.access(canonicalPath, Access.R_OK.intValue())); // F_OK just checks the file exists and should pass. - assertEquals("access: ", 0, posix.access(tmp.getCanonicalPath(), Access.F_OK.intValue())); + assertEquals("access " + canonicalPath + " exists: ", 0, posix.access(canonicalPath, Access.F_OK.intValue())); } @Test
View file
_service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/HostnameTest.java
Added
@@ -0,0 +1,47 @@ +package jnr.posix; + +import org.hamcrest.Matcher; +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; +import static org.junit.Assume.*; + +import java.io.IOException; +import java.util.Scanner; + +public class HostnameTest { + private static POSIX posix; + private static POSIX jPosix; + + @BeforeClass + public static void setUpClass() throws Exception { + posix = POSIXFactory.getPOSIX(new DummyPOSIXHandler(), true); + jPosix = POSIXFactory.getJavaPOSIX(); + } + + @Test + public void testHostnameWorks() { + assertNotNull(posix.gethostname()); + } + + @Test + public void jPosixIsReasonable() { + // cast here works around a generic resolution problem in Java 11+ + assumeThat(System.getenv().keySet(), (Matcher) anyOf(hasItem("HOSTNAME"), hasItem("COMPUTERNAME"))); + assertNotNull(jPosix.gethostname()); + } + + @Test + public void testHostnameIsResonable() throws IOException { + String hostname = ""; + try { + hostname = new Scanner(Runtime.getRuntime().exec("hostname").getInputStream()).next(); + } catch (IOException e) { + assumeNoException(e); + } + assumeThat(hostname, is(not(equalTo("")))); + assertThat(posix.gethostname().toLowerCase(), equalTo(hostname.toLowerCase())); + } +}
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/test/java/jnr/posix/IOTest.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/IOTest.java
Changed
@@ -71,6 +71,27 @@ } @Test + public void testPathconf() { + if (Platform.IS_WINDOWS) { + int res = posix.fpathconf(-1, Pathconf._PC_PIPE_BUF); + Assert.assertEquals(-1, res); + Assert.assertEquals(Errno.EOPNOTSUPP.intValue(), posix.errno()); + } else { + int res = posix.fpathconf(-1, Pathconf._PC_PIPE_BUF); + Assert.assertEquals(-1, res); + + int fds = {0, 0}; + posix.pipe(fds); + res = posix.fpathconf(fds1, Pathconf._PC_PIPE_BUF); + if (Platform.IS_LINUX) { + Assert.assertEquals(4096, res); + } else { + Assert.assertTrue(res > 0); + } + } + } + + @Test public void testSocketPair() throws Throwable { if (!Platform.IS_WINDOWS) { int fds = {0, 0};
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/test/java/jnr/posix/JavaPOSIXTest.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/JavaPOSIXTest.java
Changed
@@ -8,6 +8,7 @@ import java.io.File; import java.io.IOException; +import jnr.constants.platform.Errno; import jnr.posix.JavaPOSIX; import jnr.posix.POSIX; import jnr.posix.Passwd; @@ -75,6 +76,15 @@ assertTrue(ret < 0); } + @Test public void statMissingFileTest() throws IOException { + FileStat stat = posix.allocateStat(); + + int ret = posix.stat("does not exist", stat); + + assertEquals(-1, ret); + assertEquals(Errno.ENOENT.intValue(), posix.errno()); + } + @Test public void chmodTest() throws IOException { File file = createTestFile(); @@ -102,4 +112,8 @@ return file; } + + @Test public void getpid() { + assertEquals(POSIXFactory.getNativePOSIX().getpid(), posix.getpid()); + } }
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/test/java/jnr/posix/LinuxPOSIXTest.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/LinuxPOSIXTest.java
Changed
@@ -1,5 +1,11 @@ package jnr.posix; +import jnr.constants.platform.AddressFamily; +import jnr.constants.platform.PosixFadvise; +import jnr.constants.platform.OpenFlags; +import jnr.constants.platform.Sock; +import jnr.constants.platform.SocketLevel; +import jnr.constants.platform.SocketOption; import jnr.ffi.Platform; import jnr.posix.util.ConditionalTestRule; import org.junit.Assert; @@ -7,6 +13,9 @@ import org.junit.ClassRule; import org.junit.Test; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.io.File; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; @@ -58,6 +67,129 @@ Assert.assertEquals(4, IOPRIO_PRIO_DATA(linuxPOSIX.ioprio_get(IOPRIO_WHO_PROCESS, 0))); Assert.assertEquals(IOPRIO_CLASS_BE, IOPRIO_PRIO_CLASS(linuxPOSIX.ioprio_get(IOPRIO_WHO_PROCESS, 0))); } + + @Test + public void testMessageHdrMultipleControl() { + if (jnr.posix.util.Platform.IS_WINDOWS) { + return; + } + + int fds = {0, 0}; + + int ret = linuxPOSIX.socketpair(AddressFamily.AF_UNIX.intValue(), + Sock.SOCK_STREAM.intValue(), + 0, + fds); + + + String data = "twoControlMessages"; + byte dataBytes = data.getBytes(); + + Assert.assertTrue(ret >= 0); + Assert.assertTrue(fds0 > 0); + Assert.assertTrue(fds1 > 0); + + ByteBuffer buf = ByteBuffer.allocate(4); + buf.order(ByteOrder.nativeOrder()); + buf.putInt(1).flip(); + + ret = linuxPOSIX.libc().setsockopt(fds1, + SocketLevel.SOL_SOCKET.intValue(), + SocketOption.SO_PASSCRED.intValue(), + buf, + buf.remaining()); + + Assert.assertTrue(ret >= 0); + + MsgHdr outMessage = linuxPOSIX.allocateMsgHdr(); + + ByteBuffer outIov = new ByteBuffer1; + outIov0 = ByteBuffer.allocateDirect(dataBytes.length); + outIov0.put(dataBytes); + outIov0.flip(); + + outMessage.setIov(outIov); + + CmsgHdr outControl = outMessage.allocateControls(new int{4}); + outControl0.setLevel(SocketLevel.SOL_SOCKET.intValue()); + outControl0.setType(0x01); + + ByteBuffer fdBuf = ByteBuffer.allocateDirect(4); + fdBuf.order(ByteOrder.nativeOrder()); + fdBuf.putInt(0, fds0); + outControl0.setData(fdBuf); + + int sendStatus = linuxPOSIX.sendmsg(fds0, outMessage, 0); + if (sendStatus == -1) { + String sendmsgError = "Error with sendmsg: " + linuxPOSIX.strerror(linuxPOSIX.errno()); + Assert.fail(sendmsgError); + return; + } + + Assert.assertEquals(dataBytes.length, sendStatus); + + // ---------------- + + MsgHdr inMessage = linuxPOSIX.allocateMsgHdr(); + ByteBuffer inIov = new ByteBuffer1; + inIov0 = ByteBuffer.allocateDirect(1024); + inMessage.setIov(inIov); + + inMessage.allocateControls(new int{4, 12}); + int recvStatus = linuxPOSIX.recvmsg(fds1, inMessage, 0); + + Assert.assertEquals(dataBytes.length, recvStatus); + + Assert.assertEquals(2, inMessage.getControls().length); + + CmsgHdr controls = inMessage.getControls(); + for (int x = 0; x < controls.length; x++) { + validateCmsghdr(controlsx); + } + } + + private void validateCmsghdr(CmsgHdr control) { + if (control.getLevel() == SocketLevel.SOL_SOCKET.intValue() + && control.getType() == 0x01) { + // Passing a FD + ByteBuffer inFdBuf = control.getData(); + inFdBuf.order(ByteOrder.nativeOrder()); + + int fd = inFdBuf.getInt(); + + Assert.assertTrue(fd != 0); + } else if (control.getLevel() == SocketLevel.SOL_SOCKET.intValue() + && control.getType() == 0x02) { + //Credentials + ByteBuffer data = control.getData(); + data.order(ByteOrder.nativeOrder()); + + int got_pid = data.getInt(); + int got_uid = data.getInt(); + int got_gid = data.getInt(); + + Assert.assertEquals(linuxPOSIX.getpid(), got_pid); + Assert.assertEquals(linuxPOSIX.getuid(), got_uid); + Assert.assertEquals(linuxPOSIX.getgid(), got_gid); + } else { + Assert.fail("Unable to determine cmsghdr type"); + } + } + + @Test + public void testPosixFadvise() throws Throwable { + File file = File.createTempFile("posix_fadvise", null); + int fd = linuxPOSIX.open(file.getAbsolutePath(), OpenFlags.O_RDWR.intValue(), 0444); + + Assert.assertEquals(0, linuxPOSIX.posix_fadvise(fd, 0, 0, PosixFadvise.POSIX_FADV_SEQUENTIAL)); + Assert.assertEquals(0, linuxPOSIX.posix_fadvise(fd, 0, 0, PosixFadvise.POSIX_FADV_RANDOM)); + Assert.assertEquals(0, linuxPOSIX.posix_fadvise(fd, 0, 0, PosixFadvise.POSIX_FADV_NOREUSE)); + Assert.assertEquals(0, linuxPOSIX.posix_fadvise(fd, 0, 0, PosixFadvise.POSIX_FADV_WILLNEED)); + Assert.assertEquals(0, linuxPOSIX.posix_fadvise(fd, 0, 0, PosixFadvise.POSIX_FADV_DONTNEED)); + Assert.assertEquals(0, linuxPOSIX.posix_fadvise(fd, 0, 0, PosixFadvise.POSIX_FADV_NORMAL)); // normal last to reset it + + linuxPOSIX.close(fd); + } } class RunningOnLinux extends ConditionalTestRule {
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/test/java/jnr/posix/SpawnTest.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/SpawnTest.java
Changed
@@ -127,7 +127,6 @@ } } - /* FIXME: Does not pass on seemingly only travis @Test public void inputFile() throws IOException { if (Platform.getNativePlatform().isUnix()) { File inputFile = File.createTempFile("foo", null); @@ -161,7 +160,7 @@ killChild(pid); } } - } */ + } @Test public void closeInput() throws IOException { if (Platform.getNativePlatform().isUnix()) {
View file
_service:tar_scm:jnr-posix-3.0.47.tar.gz/src/test/java/jnr/posix/windows/WindowsFileTest.java -> _service:tar_scm:jnr-posix-3.1.14.tar.gz/src/test/java/jnr/posix/windows/WindowsFileTest.java
Changed
@@ -225,27 +225,94 @@ @Test public void utimensatWindows() throws Throwable { File file = File.createTempFile("utimensat", null); - FileStat fileStat = posix.stat(file.getPath()); - - long atimeSeconds = fileStat.atime()+1; - long mtimeSeconds = fileStat.mtime()-1; - - // Windows precision is 100 ns - long atimeNanoSeconds = 123456700; - long mtimeNanoSeconds = 987654300; - - // dirfd is ignored when passing an absolute path - // flag can be used to update symlinks - posix.utimensat(0, - file.getAbsolutePath(), - new long {atimeSeconds, atimeNanoSeconds}, - new long {mtimeSeconds, mtimeNanoSeconds}, - 0); + try { + FileStat fileStat = posix.stat(file.getPath()); + + long atimeSeconds = fileStat.atime() + 1; + long mtimeSeconds = fileStat.mtime() - 1; + + // Windows precision is 100 ns + long atimeNanoSeconds = 123456700; + long mtimeNanoSeconds = 987654300; + + // dirfd is ignored when passing an absolute path + // flag can be used to update symlinks + posix.utimensat(0, + file.getAbsolutePath(), + new long{atimeSeconds, atimeNanoSeconds}, + new long{mtimeSeconds, mtimeNanoSeconds}, + 0); + + fileStat = posix.stat(file.getPath()); + assertEquals("access time should be updated", atimeSeconds, fileStat.atime()); + assertEquals("modification time should be updated", mtimeSeconds, fileStat.mtime()); + } finally { + file.delete(); + } + } + + @Test + public void utimensatWindowsCurrentTime() throws Throwable { + File file = File.createTempFile("file", null); + try { + FileStat fileStat = posix.stat(file.getPath()); + long atimeSeconds = fileStat.atime(); + long mtimeSeconds = fileStat.mtime(); + long atimeSecondsInPast = atimeSeconds - 1000; + long mtimeSecondsInPast = mtimeSeconds - 1000; + + posix.utimensat(0, + file.getAbsolutePath(), + new long{atimeSecondsInPast, 0}, + new long{mtimeSecondsInPast, 0}, 0); + fileStat = posix.stat(file.getPath()); + assertEquals("access time should be updated", fileStat.atime(), atimeSecondsInPast); + assertEquals("modification time should be updated", fileStat.mtime(), mtimeSecondsInPast); + + posix.utimensat(0, file.getAbsolutePath(), null, null, 0); + + fileStat = posix.stat(file.getPath()); + assertTrue("access time should be updated to current time", + timeWithinRange(fileStat.atime(), atimeSeconds, 10)); + assertTrue("modification time should be updated to current time", + timeWithinRange(fileStat.mtime(), mtimeSeconds, 10)); + } finally { + file.delete(); + } + } - fileStat = posix.stat(file.getPath()); - assertEquals("access time should be updated", atimeSeconds, fileStat.atime()); - assertEquals("modification time should be updated", mtimeSeconds, fileStat.mtime()); + @Test + public void utimenWindowsCurrentTime() throws Throwable { + File file = File.createTempFile("file", null); + try { + FileStat fileStat = posix.stat(file.getPath()); + long atimeSeconds = fileStat.atime(); + long mtimeSeconds = fileStat.mtime(); + long atimeSecondsInPast = atimeSeconds - 1000; + long mtimeSecondsInPast = mtimeSeconds - 1000; + + posix.utimes(file.getAbsolutePath(), + new long{atimeSecondsInPast, 0}, + new long{mtimeSecondsInPast, 0}); + fileStat = posix.stat(file.getPath()); + assertEquals("access time should be updated", + fileStat.atime(), atimeSecondsInPast); + assertEquals("modification time should be updated", + fileStat.mtime(), mtimeSecondsInPast); + + posix.utimes(file.getAbsolutePath(), null, null); + + fileStat = posix.stat(file.getPath()); + assertTrue("access time should be updated to current time", + timeWithinRange(fileStat.atime(), atimeSeconds, 10)); + assertTrue("modification time should be updated to current time", + timeWithinRange(fileStat.mtime(), mtimeSeconds, 10)); + } finally { + file.delete(); + } + } - file.delete(); + private boolean timeWithinRange(long actual, long expected, long precision) { + return actual > (expected - precision) && actual < (expected + precision); } }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2