src/java.base/aix/classes/sun/nio/fs/AixNativeDispatcher.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2013 SAP AG. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as

@@ -22,35 +22,111 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
+/*
+ * Portions Copyright (c) 2014 IBM Corporation
+ */
+
 package sun.nio.fs;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.List;
 
 /**
  * AIX specific system calls.
  */
 
 class AixNativeDispatcher extends UnixNativeDispatcher {
     private AixNativeDispatcher() { }
 
+    // initialize
+    private static native void init();
+
     /**
      * Special implementation of 'getextmntent' (see SolarisNativeDispatcher)
      * that returns all entries at once.
      */
     static native UnixMountEntry[] getmntctl() throws UnixException;
 
-    // initialize
-    private static native void init();
-
     static {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
             public Void run() {
                 System.loadLibrary("nio");
                 return null;
         }});
         init();
     }
+
+
+    static void getAixMountEntries(List<UnixMountEntry> entries) {
+        int size = queryMountEntrySize();
+        if (size != 0) {
+            NativeBuffer buffer = NativeBuffers.allocNativeBuffer(size);
+            getAixMountEntries(entries, buffer.address(), size);
+            buffer.release();
+        }
+    }
+
+    private static native int queryMountEntrySize();
+
+    private static native void getAixMountEntries(List<UnixMountEntry> entries, long bufferAddress, int size);
+
+    /**
+     * ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size);
+     */
+    static int fgetxattr(int filedes, byte[] name, long valueAddress,
+                         int valueLen) throws UnixException
+    {
+        NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
+        try {
+            return fgetxattr0(filedes, buffer.address(), valueAddress, valueLen);
+        } finally {
+            buffer.release();
+        }
+    }
+
+    private static native int fgetxattr0(int filedes, long nameAddress,
+        long valueAdddress, int valueLen) throws UnixException;
+
+    /**
+     *  fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags);
+     */
+    static void fsetxattr(int filedes, byte[] name, long valueAddress,
+        int valueLen) throws UnixException
+    {
+        NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
+        try {
+            fsetxattr0(filedes, buffer.address(), valueAddress, valueLen);
+        } finally {
+            buffer.release();
+        }
+    }
+
+    private static native void fsetxattr0(int filedes, long nameAddress,
+        long valueAdddress, int valueLen) throws UnixException;
+
+
+    /**
+     * fremovexattr(int filedes, const char *name);
+     */
+    static void fremovexattr(int filedes, byte[] name) throws UnixException {
+        NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
+        try {
+            fremovexattr0(filedes, buffer.address());
+        } finally {
+            buffer.release();
+        }
+    }
+
+    private static native void fremovexattr0(int filedes, long nameAddress)
+        throws UnixException;
+
+    /**
+     * size_t flistxattr(int filedes, const char *list, size_t size)
+     */
+    static native int flistxattr(int filedes, long listAddress, int size)
+        throws UnixException;
+
 }