1 /* 2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. 3 * 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. Oracle designates this 9 * particular file as subject to the "Classpath" exception as provided 10 * by Oracle in the LICENSE file that accompanied this code. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 * or visit www.oracle.com if you need additional information or have any 24 * questions. 25 * 26 */ 27 28 @@END_COPYRIGHT@@ 29 30 #define _GNU_SOURCE 31 32 #include <stdio.h> 33 #include <errno.h> 34 #include <unistd.h> 35 #include <fcntl.h> 36 #include <sys/stat.h> 37 38 /* On Solaris, "sun" is defined as a macro. Undefine to make package 39 declaration valid */ 40 #undef sun 41 42 /* To be able to name the Java constants the same as the C constants without 43 having the preprocessor rewrite those identifiers, add PREFIX_ to all 44 identifiers matching a C constant. The PREFIX_ is filtered out in the 45 makefile. */ 46 47 @@START_HERE@@ 48 49 package sun.nio.fs; 50 class UnixConstants { 51 private UnixConstants() { } 52 static final int PREFIX_O_RDONLY = O_RDONLY; 53 static final int PREFIX_O_WRONLY = O_WRONLY; 54 static final int PREFIX_O_RDWR = O_RDWR; 55 static final int PREFIX_O_APPEND = O_APPEND; 56 static final int PREFIX_O_CREAT = O_CREAT; 57 static final int PREFIX_O_EXCL = O_EXCL; 58 static final int PREFIX_O_TRUNC = O_TRUNC; 59 static final int PREFIX_O_SYNC = O_SYNC; 60 static final int PREFIX_O_DIRECT = O_DIRECT; 61 62 #ifndef O_DSYNC 63 // At least FreeBSD doesn't define O_DSYNC 64 static final int PREFIX_O_DSYNC = O_SYNC; 65 #else 66 static final int PREFIX_O_DSYNC = O_DSYNC; 67 #endif 68 69 #ifdef O_NOFOLLOW 70 static final int PREFIX_O_NOFOLLOW = O_NOFOLLOW; 71 #else 72 // not supported (dummy values will not be used at runtime). 73 static final int PREFIX_O_NOFOLLOW = 00; 74 #endif 75 76 77 static final int PREFIX_S_IAMB = 78 (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); 79 static final int PREFIX_S_IRUSR = S_IRUSR; 80 static final int PREFIX_S_IWUSR = S_IWUSR; 81 static final int PREFIX_S_IXUSR = S_IXUSR; 82 static final int PREFIX_S_IRGRP = S_IRGRP; 83 static final int PREFIX_S_IWGRP = S_IWGRP; 84 static final int PREFIX_S_IXGRP = S_IXGRP; 85 static final int PREFIX_S_IROTH = S_IROTH; 86 static final int PREFIX_S_IWOTH = S_IWOTH; 87 static final int PREFIX_S_IXOTH = S_IXOTH; 88 89 static final int PREFIX_S_IFMT = S_IFMT; 90 static final int PREFIX_S_IFREG = S_IFREG; 91 static final int PREFIX_S_IFDIR = S_IFDIR; 92 static final int PREFIX_S_IFLNK = S_IFLNK; 93 static final int PREFIX_S_IFCHR = S_IFCHR; 94 static final int PREFIX_S_IFBLK = S_IFBLK; 95 static final int PREFIX_S_IFIFO = S_IFIFO; 96 static final int PREFIX_R_OK = R_OK; 97 static final int PREFIX_W_OK = W_OK; 98 static final int PREFIX_X_OK = X_OK; 99 static final int PREFIX_F_OK = F_OK; 100 static final int PREFIX_ENOENT = ENOENT; 101 static final int PREFIX_ENXIO = ENXIO; 102 static final int PREFIX_EACCES = EACCES; 103 static final int PREFIX_EEXIST = EEXIST; 104 static final int PREFIX_ENOTDIR = ENOTDIR; 105 static final int PREFIX_EINVAL = EINVAL; 106 static final int PREFIX_EXDEV = EXDEV; 107 static final int PREFIX_EISDIR = EISDIR; 108 static final int PREFIX_ENOTEMPTY = ENOTEMPTY; 109 static final int PREFIX_ENOSPC = ENOSPC; 110 static final int PREFIX_EAGAIN = EAGAIN; 111 static final int PREFIX_ENOSYS = ENOSYS; 112 static final int PREFIX_ELOOP = ELOOP; 113 static final int PREFIX_EROFS = EROFS; 114 115 #ifndef ENODATA 116 // Only used in Linux java source, provide any value so it compiles 117 static final int PREFIX_ENODATA = ELAST; 118 #else 119 static final int PREFIX_ENODATA = ENODATA; 120 #endif 121 122 static final int PREFIX_ERANGE = ERANGE; 123 static final int PREFIX_EMFILE = EMFILE; 124 125 // flags used with openat/unlinkat/etc. 126 #if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR) 127 static final int PREFIX_AT_SYMLINK_NOFOLLOW = AT_SYMLINK_NOFOLLOW; 128 static final int PREFIX_AT_REMOVEDIR = AT_REMOVEDIR; 129 #else 130 // not supported (dummy values will not be used at runtime). 131 static final int PREFIX_AT_SYMLINK_NOFOLLOW = 00; 132 static final int PREFIX_AT_REMOVEDIR = 00; 133 #endif 134 135 }