1 /*
2 * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
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
37
38 /**
39 * FILE *setmntent(const char *filename, const char *type);
40 */
41 static long setmntent(byte[] filename, byte[] type) throws UnixException {
42 NativeBuffer pathBuffer = NativeBuffers.asNativeBuffer(filename);
43 NativeBuffer typeBuffer = NativeBuffers.asNativeBuffer(type);
44 try {
45 return setmntent0(pathBuffer.address(), typeBuffer.address());
46 } finally {
47 typeBuffer.release();
48 pathBuffer.release();
49 }
50 }
51 private static native long setmntent0(long pathAddress, long typeAddress)
52 throws UnixException;
53
54 /**
55 * int getmntent(FILE *fp, struct mnttab *mp, int len);
56 */
57 static native int getmntent(long fp, UnixMountEntry entry)
58 throws UnixException;
59
60 /**
61 * int endmntent(FILE* filep);
62 */
63 static native void endmntent(long stream) throws UnixException;
64
65 /**
66 * ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size);
67 */
68 static int fgetxattr(int filedes, byte[] name, long valueAddress,
69 int valueLen) throws UnixException
70 {
71 NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
72 try {
73 return fgetxattr0(filedes, buffer.address(), valueAddress, valueLen);
74 } finally {
75 buffer.release();
76 }
77 }
78
79 private static native int fgetxattr0(int filedes, long nameAddress,
80 long valueAdddress, int valueLen) throws UnixException;
81
82 /**
83 * fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags);
84 */
85 static void fsetxattr(int filedes, byte[] name, long valueAddress,
|
1 /*
2 * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
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
37
38 /**
39 * FILE *setmntent(const char *filename, const char *type);
40 */
41 static long setmntent(byte[] filename, byte[] type) throws UnixException {
42 NativeBuffer pathBuffer = NativeBuffers.asNativeBuffer(filename);
43 NativeBuffer typeBuffer = NativeBuffers.asNativeBuffer(type);
44 try {
45 return setmntent0(pathBuffer.address(), typeBuffer.address());
46 } finally {
47 typeBuffer.release();
48 pathBuffer.release();
49 }
50 }
51 private static native long setmntent0(long pathAddress, long typeAddress)
52 throws UnixException;
53
54 /**
55 * int getmntent(FILE *fp, struct mnttab *mp, int len);
56 */
57
58 static int getmntent(long fp, UnixMountEntry entry, int buflen) throws UnixException {
59 NativeBuffer buffer = NativeBuffers.getNativeBuffer(buflen);
60 try {
61 return getmntent0(fp, entry, buffer.address(), buflen);
62 } finally {
63 buffer.release();
64 }
65 }
66
67 static native int getmntent0(long fp, UnixMountEntry entry, long buffer, int bufLen)
68 throws UnixException;
69
70 /**
71 * int endmntent(FILE* filep);
72 */
73 static native void endmntent(long stream) throws UnixException;
74
75 /**
76 * ssize_t getline(char **lineptr, size_t *n, FILE *stream);
77 */
78 static native int getlinelen(long stream) throws UnixException;
79
80 /**
81 * ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size);
82 */
83 static int fgetxattr(int filedes, byte[] name, long valueAddress,
84 int valueLen) throws UnixException
85 {
86 NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
87 try {
88 return fgetxattr0(filedes, buffer.address(), valueAddress, valueLen);
89 } finally {
90 buffer.release();
91 }
92 }
93
94 private static native int fgetxattr0(int filedes, long nameAddress,
95 long valueAdddress, int valueLen) throws UnixException;
96
97 /**
98 * fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags);
99 */
100 static void fsetxattr(int filedes, byte[] name, long valueAddress,
|