< prev index next >

src/java.base/macosx/classes/sun/nio/fs/BsdNativeDispatcher.java

Print this page

  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package sun.nio.fs;
 27 
 28 import jdk.internal.misc.Blocker;
 29 
 30 /**
 31  * Bsd specific system calls.
 32  */
 33 
 34 class BsdNativeDispatcher extends UnixNativeDispatcher {
 35     protected BsdNativeDispatcher() { }
 36 
 37    /**
 38     * struct fsstat_iter *getfsstat();
 39     */
 40     static native long getfsstat() throws UnixException;
 41 
 42    /**
 43     * int fsstatEntry(struct fsstat_iter * iter, UnixMountEntry entry);
 44     */
 45     static native int fsstatEntry(long iter, UnixMountEntry entry)
 46         throws UnixException;
 47 
 48    /**
 49     * void endfsstat(struct fsstat_iter * iter);

 52 
 53     /**
 54      * int statfs(const char *path, struct statfs *buf);
 55      * returns buf->f_mntonname (directory on which mounted)
 56      */
 57     static byte[] getmntonname(UnixPath path) throws UnixException {
 58         try (NativeBuffer pathBuffer = copyToNativeBuffer(path)) {
 59             return getmntonname0(pathBuffer.address());
 60         }
 61     }
 62     static native byte[] getmntonname0(long pathAddress) throws UnixException;
 63 
 64     /**
 65      * int clonefile(const char * src, const char * dst, int flags);
 66      */
 67     static int clonefile(UnixPath src, UnixPath dst, int flags)
 68         throws UnixException
 69     {
 70         try (NativeBuffer srcBuffer = copyToNativeBuffer(src);
 71             NativeBuffer dstBuffer = copyToNativeBuffer(dst)) {
 72             long comp = Blocker.begin();
 73             try {
 74                 return clonefile0(srcBuffer.address(), dstBuffer.address(),
 75                                   flags);
 76             } finally {
 77                 Blocker.end(comp);
 78             }
 79         }
 80     }
 81     private static native int clonefile0(long srcAddress, long dstAddress,
 82                                          int flags);
 83 
 84     /**
 85      * setattrlist(const char* path, struct attrlist* attrList, void* attrBuf,
 86      *             size_t attrBufSize, unsigned long options)
 87      */
 88     static void setattrlist(UnixPath path, int commonattr, long modTime,
 89                             long accTime, long createTime, long options)
 90         throws UnixException
 91     {
 92         try (NativeBuffer buffer = copyToNativeBuffer(path)) {
 93             long comp = Blocker.begin();
 94             try {
 95                 setattrlist0(buffer.address(), commonattr, modTime, accTime,
 96                              createTime, options);
 97             } finally {
 98                 Blocker.end(comp);
 99             }
100         }
101     }
102     private static native void setattrlist0(long pathAddress, int commonattr,
103                                             long modTime, long accTime,
104                                             long createTime, long options)
105         throws UnixException;
106 
107     /**
108      * fsetattrlist(int fd, struct attrlist* attrList, void* attrBuf,
109      *              size_t attrBufSize, unsigned long options)
110      */
111     static void fsetattrlist(int fd, int commonattr, long modTime,
112                              long accTime, long createTime, long options)
113         throws UnixException
114     {
115         long comp = Blocker.begin();
116         try {
117             fsetattrlist0(fd, commonattr, modTime, accTime,
118                           createTime, options);
119         } finally {
120             Blocker.end(comp);
121         }
122     }
123     private static native void fsetattrlist0(int fd, int commonattr,
124                                              long modTime, long accTime,
125                                              long createTime, long options)
126         throws UnixException;
127 
128     // initialize field IDs
129     private static native void initIDs();
130 
131     static {
132          initIDs();
133     }
134 }

  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package sun.nio.fs;
 27 


 28 /**
 29  * Bsd specific system calls.
 30  */
 31 
 32 class BsdNativeDispatcher extends UnixNativeDispatcher {
 33     protected BsdNativeDispatcher() { }
 34 
 35    /**
 36     * struct fsstat_iter *getfsstat();
 37     */
 38     static native long getfsstat() throws UnixException;
 39 
 40    /**
 41     * int fsstatEntry(struct fsstat_iter * iter, UnixMountEntry entry);
 42     */
 43     static native int fsstatEntry(long iter, UnixMountEntry entry)
 44         throws UnixException;
 45 
 46    /**
 47     * void endfsstat(struct fsstat_iter * iter);

 50 
 51     /**
 52      * int statfs(const char *path, struct statfs *buf);
 53      * returns buf->f_mntonname (directory on which mounted)
 54      */
 55     static byte[] getmntonname(UnixPath path) throws UnixException {
 56         try (NativeBuffer pathBuffer = copyToNativeBuffer(path)) {
 57             return getmntonname0(pathBuffer.address());
 58         }
 59     }
 60     static native byte[] getmntonname0(long pathAddress) throws UnixException;
 61 
 62     /**
 63      * int clonefile(const char * src, const char * dst, int flags);
 64      */
 65     static int clonefile(UnixPath src, UnixPath dst, int flags)
 66         throws UnixException
 67     {
 68         try (NativeBuffer srcBuffer = copyToNativeBuffer(src);
 69             NativeBuffer dstBuffer = copyToNativeBuffer(dst)) {
 70             return clonefile0(srcBuffer.address(), dstBuffer.address(), flags);






 71         }
 72     }
 73     private static native int clonefile0(long srcAddress, long dstAddress,
 74                                          int flags);
 75 
 76     /**
 77      * setattrlist(const char* path, struct attrlist* attrList, void* attrBuf,
 78      *             size_t attrBufSize, unsigned long options)
 79      */
 80     static void setattrlist(UnixPath path, int commonattr, long modTime,
 81                             long accTime, long createTime, long options)
 82         throws UnixException
 83     {
 84         try (NativeBuffer buffer = copyToNativeBuffer(path)) {
 85             setattrlist0(buffer.address(), commonattr, modTime, accTime,
 86                          createTime, options);





 87         }
 88     }
 89     private static native void setattrlist0(long pathAddress, int commonattr,
 90                                             long modTime, long accTime,
 91                                             long createTime, long options)
 92         throws UnixException;
 93 
 94     /**
 95      * fsetattrlist(int fd, struct attrlist* attrList, void* attrBuf,
 96      *              size_t attrBufSize, unsigned long options)
 97      */
 98     static void fsetattrlist(int fd, int commonattr, long modTime,
 99                              long accTime, long createTime, long options)
100         throws UnixException
101     {
102         fsetattrlist0(fd, commonattr, modTime, accTime, createTime, options);






103     }
104     private static native void fsetattrlist0(int fd, int commonattr,
105                                              long modTime, long accTime,
106                                              long createTime, long options)
107         throws UnixException;
108 
109     // initialize field IDs
110     private static native void initIDs();
111 
112     static {
113          initIDs();
114     }
115 }
< prev index next >