[Git][java-team/jnr-posix][upstream] New upstream version 3.1.18

Miguel Landaeta (@nomadium) gitlab at salsa.debian.org
Fri Dec 1 13:43:28 GMT 2023



Miguel Landaeta pushed to branch upstream at Debian Java Maintainers / jnr-posix


Commits:
236a602b by Miguel Landaeta at 2023-11-25T22:20:13+00:00
New upstream version 3.1.18

- - - - -


9 changed files:

- pom.xml
- src/main/java/jnr/posix/LibC.java
- + src/main/java/jnr/posix/LinuxFileStatLOONGARCH64.java
- src/main/java/jnr/posix/LinuxPOSIX.java
- + src/main/java/jnr/posix/MacOSFileStat64Inode.java
- src/main/java/jnr/posix/MacOSPOSIX.java
- src/test/java/jnr/posix/FileTest.java
- src/test/java/jnr/posix/GroupTest.java
- src/test/java/jnr/posix/windows/WindowsFileTest.java


Changes:

=====================================
pom.xml
=====================================
@@ -10,7 +10,7 @@
   <groupId>com.github.jnr</groupId>
   <artifactId>jnr-posix</artifactId>
   <packaging>jar</packaging>
-  <version>3.1.10</version>
+  <version>3.1.18</version>
   <name>jnr-posix</name>
   <description>
     Common cross-project/cross-platform POSIX APIs
@@ -79,12 +79,12 @@
     <dependency>
       <groupId>com.github.jnr</groupId>
       <artifactId>jnr-ffi</artifactId>
-      <version>2.2.7</version>
+      <version>2.2.15</version>
     </dependency>
     <dependency>
       <groupId>com.github.jnr</groupId>
       <artifactId>jnr-constants</artifactId>
-      <version>0.10.2</version>
+      <version>0.10.4</version>
     </dependency>
   </dependencies>
 
@@ -178,7 +178,6 @@
           <configuration>
             <forkCount>2</forkCount>
             <reuseForks>false</reuseForks>
-            <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
             <includes>
               <include>**/*Test.java</include>
             </includes>
@@ -202,7 +201,6 @@
             <configuration>
               <forkCount>2</forkCount>
               <reuseForks>false</reuseForks>
-              <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
             </configuration>
           </plugin>
         </plugins>


=====================================
src/main/java/jnr/posix/LibC.java
=====================================
@@ -85,10 +85,14 @@ public interface LibC {
     int dup(int fd);
     int dup2(int oldFd, int newFd);
 
+    @Variadic(fixedCount = 2)
     int fcntl(int fd, int fnctl, Flock arg);
+    @Variadic(fixedCount = 2)
     int fcntl(int fd, int fnctl, Pointer arg);
+    @Variadic(fixedCount = 2)
     int fcntl(int fd, int fnctl);
-    int fcntl(int fd, int fnctl, int arg);
+    @Variadic(fixedCount = 2)
+    int fcntl(int fd, int fnctl, @u_int64_t int arg);
     @Deprecated
     int fcntl(int fd, int fnctl, int... arg);
     int access(CharSequence path, int amode);
@@ -164,7 +168,8 @@ public interface LibC {
     
     int flock(int fd, int mode);
     int unlink(CharSequence path);
-    int open(CharSequence path, int flags, int perm);
+    @Variadic(fixedCount = 2)
+    int open(CharSequence path, int flags, @u_int32_t int perm);
     int pipe(@Out int[] fds);
     int truncate(CharSequence path, long length);
     int ftruncate(int fd, long offset);


=====================================
src/main/java/jnr/posix/LinuxFileStatLOONGARCH64.java
=====================================
@@ -0,0 +1,104 @@
+package jnr.posix;
+
+import jnr.ffi.StructLayout;
+import jnr.posix.util.Platform;
+
+public final class LinuxFileStatLOONGARCH64 extends BaseFileStat implements NanosecondFileStat {
+    public static final class Layout extends StructLayout {
+
+        public Layout(jnr.ffi.Runtime runtime) {
+            super(runtime);
+        }
+
+        public final dev_t st_dev = new dev_t();
+        public final ino_t st_ino = new ino_t();
+        public final mode_t st_mode = new mode_t();
+        public final nlink_t st_nlink = new nlink_t();
+        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)
+        public final time_t st_mtime = new time_t();             // Last data modification time
+        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 Signed32 __unused4 = new Signed32();
+        public final Signed32 __unused5 = new Signed32();
+    }
+
+    private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime());
+
+    public LinuxFileStatLOONGARCH64(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);
+    }
+}


=====================================
src/main/java/jnr/posix/LinuxPOSIX.java
=====================================
@@ -43,17 +43,17 @@ final class LinuxPOSIX extends BaseNativePOSIX implements Linux {
         } else {
             if ("aarch64".equals(Platform.ARCH)) {
                 return new LinuxFileStatAARCH64(this);
-            } else {
-                if ("sparcv9".equals(Platform.ARCH)) {
-                    return new LinuxFileStatSPARCV9(this);
-                } else{
-		    if (Platform.ARCH.contains("mips64")) {
-		    	return new LinuxFileStatMIPS64(this);
-		    }
-                    return new LinuxFileStat64(this);
-                }
-            }
-        }
+            } else if ("sparcv9".equals(Platform.ARCH)) {
+		return new LinuxFileStatSPARCV9(this);
+	    } else if ("loongarch64".equals(Platform.ARCH)) {
+		return new LinuxFileStatLOONGARCH64(this);
+	    } else {
+		if (Platform.ARCH.contains("mips64")) {
+		    return new LinuxFileStatMIPS64(this);
+		}
+                return new LinuxFileStat64(this);
+	    }
+	}
     }
 
     public MsgHdr allocateMsgHdr() {
@@ -219,6 +219,7 @@ final class LinuxPOSIX extends BaseNativePOSIX implements Linux {
         static final ABI _ABI_SPARCV9 = new ABI_SPARCV9();
         static final ABI _ABI_PPC64 = new ABI_PPC64();
         static final ABI _ABI_MIPS64 = new ABI_MIPS64();
+        static final ABI _ABI_LOONGARCH64 = new ABI_LOONGARCH64();
 
         public static ABI abi() {
             if ("x86_64".equals(Platform.ARCH)) {
@@ -235,6 +236,8 @@ final class LinuxPOSIX extends BaseNativePOSIX implements Linux {
                 return _ABI_PPC64;
             } else if (Platform.ARCH.contains("mips64")) {
 	    	return _ABI_MIPS64;
+	    } else if (Platform.ARCH.contains("loongarch64")) {
+		return _ABI_LOONGARCH64;
 	    }
             return null;
         }
@@ -315,6 +318,18 @@ final class LinuxPOSIX extends BaseNativePOSIX implements Linux {
                 return 5274;
             }
         }
+
+        /** @see /usr/include/asm-generic/unistd.h */
+        final static class ABI_LOONGARCH64 implements ABI {
+            @Override
+            public int __NR_ioprio_set() {
+                return 30;
+            }
+            @Override
+            public int __NR_ioprio_get() {
+                return 31;
+            }
+        }
     }
 
     public int ioprio_get(int which, int who) {


=====================================
src/main/java/jnr/posix/MacOSFileStat64Inode.java
=====================================
@@ -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);
+    }
+}


=====================================
src/main/java/jnr/posix/MacOSPOSIX.java
=====================================
@@ -21,6 +21,10 @@ final class MacOSPOSIX extends BaseNativePOSIX {
     }
 
     public FileStat allocateStat() {
+        if (Platform.getNativePlatform().getCPU() == Platform.CPU.AARCH64) {
+            return new MacOSFileStat64Inode(this);
+        }
+
         return new MacOSFileStat(this);
     }
 


=====================================
src/test/java/jnr/posix/FileTest.java
=====================================
@@ -380,6 +380,15 @@ public class FileTest {
 
         result = posix.close(fd);
         assertEquals(-1, result);
+
+        fd = posix.open("jnr-posix-filetest.txt", OpenFlags.O_CREAT.intValue() | OpenFlags.O_RDWR.intValue(), 0600);
+
+        assertEquals(0600, posix.stat("jnr-posix-filetest.txt").mode() & 0777);
+
+        result = posix.close(fd);
+        assertEquals(0, result);
+
+        new File("jnr-posix-filetest.txt").delete();
     }
 
     @Test


=====================================
src/test/java/jnr/posix/GroupTest.java
=====================================
@@ -89,7 +89,7 @@ public class GroupTest {
     @Test
     public void getgroups() throws Throwable {
         if (jnr.ffi.Platform.getNativePlatform().isUnix()) {
-            String[] groupIdsAsStrings = exec("id -G").split(" ");
+            String[] groupIdsAsStrings = exec("id", "-G").split(" ");
             long[] expectedGroupIds = new long[groupIdsAsStrings.length];
 
             for (int i = 0; i < groupIdsAsStrings.length; i++) {
@@ -103,7 +103,7 @@ public class GroupTest {
             // If the actual list is shorter than the expected list by 1, alter the expected list by removing the
             // effective group ID before comparing the two arrays.
             if (actualGroupIds.length == expectedGroupIds.length - 1) {
-                long effectiveGroupId = Long.parseLong(exec("id -g"));
+                long effectiveGroupId = Long.parseLong(exec("id", "-g"));
                 expectedGroupIds = removeElement(expectedGroupIds, effectiveGroupId);
             }
 
@@ -114,7 +114,7 @@ public class GroupTest {
         }
     }
 
-    private String exec(String command) throws IOException {
+    private String exec(String... command) throws IOException {
         InputStreamReader isr = null;
         BufferedReader reader = null;
 


=====================================
src/test/java/jnr/posix/windows/WindowsFileTest.java
=====================================
@@ -2,7 +2,8 @@ package jnr.posix.windows;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.RandomAccessFile;
+import java.io.RandomAccessFile;
+import java.nio.file.Files;
 import java.text.NumberFormat;
 import jnr.posix.DummyPOSIXHandler;
 import jnr.posix.FileStat;
@@ -15,8 +16,8 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
+import static org.junit.Assert.assertTrue;
+
 public class WindowsFileTest {
     private static POSIX posix;
 
@@ -52,9 +53,7 @@ public class WindowsFileTest {
     // FIXME: This is a broken method since it does not delete any of the generated dirs.
     private static final String DIR_NAME = "0123456789";
     private Pair makeLongPath() throws IOException {
-        File tmp = File.createTempFile("temp", Long.toHexString(System.nanoTime()));
-
-        if (!(tmp.delete() && tmp.mkdir())) throw new IOException("Could not make a long path");
+        File tmp = Files.createTempDirectory("temp" + Long.toHexString(System.nanoTime())).toFile();
 
         StringBuilder buf = new StringBuilder(DIR_NAME);
         for (int i = 0; i < 30; i++) {



View it on GitLab: https://salsa.debian.org/java-team/jnr-posix/-/commit/236a602b581cc29aa2331fb44515e4b2114242cf

-- 
View it on GitLab: https://salsa.debian.org/java-team/jnr-posix/-/commit/236a602b581cc29aa2331fb44515e4b2114242cf
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20231201/082f67f7/attachment.htm>


More information about the pkg-java-commits mailing list