Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* -*- buffer-read-only: t -*- vi: set ro: */ 00002 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 00003 /* Internals for openat-like functions. 00004 00005 Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc. 00006 00007 This program is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 /* written by Jim Meyering */ 00021 00022 #ifndef _GL_HEADER_OPENAT_PRIV 00023 #define _GL_HEADER_OPENAT_PRIV 00024 00025 #include <errno.h> 00026 #include <limits.h> 00027 #include <stdlib.h> 00028 00029 /* Maximum number of bytes that it is safe to allocate as a single 00030 array on the stack, and that is known as a compile-time constant. 00031 The assumption is that we'll touch the array very quickly, or a 00032 temporary very near the array, provoking an out-of-memory trap. On 00033 some operating systems, there is only one guard page for the stack, 00034 and a page size can be as small as 4096 bytes. Subtract 64 in the 00035 hope that this will let the compiler touch a nearby temporary and 00036 provoke a trap. */ 00037 #define SAFER_ALLOCA_MAX (4096 - 64) 00038 00039 #define SAFER_ALLOCA(m) ((m) < SAFER_ALLOCA_MAX ? (m) : SAFER_ALLOCA_MAX) 00040 00041 #if defined PATH_MAX 00042 # define OPENAT_BUFFER_SIZE SAFER_ALLOCA (PATH_MAX) 00043 #elif defined _XOPEN_PATH_MAX 00044 # define OPENAT_BUFFER_SIZE SAFER_ALLOCA (_XOPEN_PATH_MAX) 00045 #else 00046 # define OPENAT_BUFFER_SIZE SAFER_ALLOCA (1024) 00047 #endif 00048 00049 char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file); 00050 00051 /* Trying to access a BUILD_PROC_NAME file will fail on systems without 00052 /proc support, and even on systems *with* ProcFS support. Return 00053 nonzero if the failure may be legitimate, e.g., because /proc is not 00054 readable, or the particular .../fd/N directory is not present. */ 00055 #define EXPECTED_ERRNO(Errno) \ 00056 ((Errno) == ENOTDIR || (Errno) == ENOENT \ 00057 || (Errno) == EPERM || (Errno) == EACCES \ 00058 || (Errno) == ENOSYS /* Solaris 8 */ \ 00059 || (Errno) == EOPNOTSUPP /* FreeBSD */) 00060 00061 /* Wrapper function shared among linkat and renameat. */ 00062 int at_func2 (int fd1, char const *file1, 00063 int fd2, char const *file2, 00064 int (*func) (char const *file1, char const *file2)); 00065 00066 #endif /* _GL_HEADER_OPENAT_PRIV */