1 /*
   2  * Copyright (c) 2008, 2018, 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
  23  * questions.
  24  */
  25 
  26 @@END_COPYRIGHT@@
  27 
  28 #include <stdio.h>
  29 #include <errno.h>
  30 #include <unistd.h>
  31 #include <fcntl.h>
  32 #include <sys/stat.h>
  33 
  34 /* To be able to name the Java constants the same as the C constants without
  35    having the preprocessor rewrite those identifiers, add PREFIX_ to all
  36    identifiers matching a C constant. The PREFIX_ is filtered out in the
  37    makefile. */
  38 
  39 @@START_HERE@@
  40 
  41 package sun.nio.fs;
  42 class UnixConstants {
  43     private UnixConstants() { }
  44     static final int PREFIX_O_RDONLY = O_RDONLY;
  45     static final int PREFIX_O_WRONLY = O_WRONLY;
  46     static final int PREFIX_O_RDWR = O_RDWR;
  47     static final int PREFIX_O_APPEND = O_APPEND;
  48     static final int PREFIX_O_CREAT = O_CREAT;
  49     static final int PREFIX_O_EXCL = O_EXCL;
  50     static final int PREFIX_O_TRUNC = O_TRUNC;
  51     static final int PREFIX_O_SYNC = O_SYNC;
  52 
  53 #ifndef O_DSYNC
  54     // At least FreeBSD doesn't define O_DSYNC
  55     static final int PREFIX_O_DSYNC = O_SYNC;
  56 #else
  57     static final int PREFIX_O_DSYNC = O_DSYNC;
  58 #endif
  59 
  60 #ifdef O_NOFOLLOW
  61     static final int PREFIX_O_NOFOLLOW = O_NOFOLLOW;
  62 #else
  63     // not supported (dummy values will not be used at runtime).
  64     static final int PREFIX_O_NOFOLLOW = 00;
  65 #endif
  66 
  67 #ifdef O_DIRECT
  68     static final int PREFIX_O_DIRECT = O_DIRECT;
  69 #else
  70     // not supported (dummy values will not be used at runtime).
  71     static final int PREFIX_O_DIRECT = 00;
  72 #endif
  73 
  74     static final int PREFIX_S_IAMB =
  75         (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
  76     static final int PREFIX_S_IRUSR = S_IRUSR;
  77     static final int PREFIX_S_IWUSR = S_IWUSR;
  78     static final int PREFIX_S_IXUSR = S_IXUSR;
  79     static final int PREFIX_S_IRGRP = S_IRGRP;
  80     static final int PREFIX_S_IWGRP = S_IWGRP;
  81     static final int PREFIX_S_IXGRP = S_IXGRP;
  82     static final int PREFIX_S_IROTH = S_IROTH;
  83     static final int PREFIX_S_IWOTH = S_IWOTH;
  84     static final int PREFIX_S_IXOTH = S_IXOTH;
  85 
  86     static final int PREFIX_S_IFMT = S_IFMT;
  87     static final int PREFIX_S_IFREG = S_IFREG;
  88     static final int PREFIX_S_IFDIR = S_IFDIR;
  89     static final int PREFIX_S_IFLNK = S_IFLNK;
  90     static final int PREFIX_S_IFCHR = S_IFCHR;
  91     static final int PREFIX_S_IFBLK = S_IFBLK;
  92     static final int PREFIX_S_IFIFO = S_IFIFO;
  93     static final int PREFIX_R_OK = R_OK;
  94     static final int PREFIX_W_OK = W_OK;
  95     static final int PREFIX_X_OK = X_OK;
  96     static final int PREFIX_F_OK = F_OK;
  97     static final int PREFIX_ENOENT = ENOENT;
  98     static final int PREFIX_ENXIO = ENXIO;
  99     static final int PREFIX_EACCES = EACCES;
 100     static final int PREFIX_EEXIST = EEXIST;
 101     static final int PREFIX_ENOTDIR = ENOTDIR;
 102     static final int PREFIX_EINVAL = EINVAL;
 103     static final int PREFIX_EXDEV = EXDEV;
 104     static final int PREFIX_EISDIR = EISDIR;
 105     static final int PREFIX_ENOTEMPTY = ENOTEMPTY;
 106     static final int PREFIX_ENOSPC = ENOSPC;
 107     static final int PREFIX_EAGAIN = EAGAIN;
 108     static final int PREFIX_EWOULDBLOCK = EWOULDBLOCK;
 109     static final int PREFIX_ENOSYS = ENOSYS;
 110     static final int PREFIX_ELOOP = ELOOP;
 111     static final int PREFIX_EROFS = EROFS;
 112 
 113 #ifndef ENODATA
 114     // Only used in Linux java source, provide any value so it compiles
 115     static final int PREFIX_ENODATA = ELAST;
 116 #else
 117     static final int PREFIX_ENODATA = ENODATA;
 118 #endif
 119 
 120     static final int PREFIX_ERANGE = ERANGE;
 121     static final int PREFIX_EMFILE = EMFILE;
 122 
 123     // flags used with openat/unlinkat/etc.
 124 #if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR)
 125     static final int PREFIX_AT_SYMLINK_NOFOLLOW = AT_SYMLINK_NOFOLLOW;
 126     static final int PREFIX_AT_REMOVEDIR = AT_REMOVEDIR;
 127 #else
 128     // not supported (dummy values will not be used at runtime).
 129     static final int PREFIX_AT_SYMLINK_NOFOLLOW = 00;
 130     static final int PREFIX_AT_REMOVEDIR = 00;
 131 #endif
 132 
 133 }