1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Internals for openat-like functions.
5 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* written by Jim Meyering */
22 #ifndef _GL_HEADER_OPENAT_PRIV
23 #define _GL_HEADER_OPENAT_PRIV
29 /* Maximum number of bytes that it is safe to allocate as a single
30 array on the stack, and that is known as a compile-time constant.
31 The assumption is that we'll touch the array very quickly, or a
32 temporary very near the array, provoking an out-of-memory trap. On
33 some operating systems, there is only one guard page for the stack,
34 and a page size can be as small as 4096 bytes. Subtract 64 in the
35 hope that this will let the compiler touch a nearby temporary and
37 #define SAFER_ALLOCA_MAX (4096 - 64)
39 #define SAFER_ALLOCA(m) ((m) < SAFER_ALLOCA_MAX ? (m) : SAFER_ALLOCA_MAX)
42 # define OPENAT_BUFFER_SIZE SAFER_ALLOCA (PATH_MAX)
43 #elif defined _XOPEN_PATH_MAX
44 # define OPENAT_BUFFER_SIZE SAFER_ALLOCA (_XOPEN_PATH_MAX)
46 # define OPENAT_BUFFER_SIZE SAFER_ALLOCA (1024)
49 char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file);
51 /* Trying to access a BUILD_PROC_NAME file will fail on systems without
52 /proc support, and even on systems *with* ProcFS support. Return
53 nonzero if the failure may be legitimate, e.g., because /proc is not
54 readable, or the particular .../fd/N directory is not present. */
55 #define EXPECTED_ERRNO(Errno) \
56 ((Errno) == ENOTDIR || (Errno) == ENOENT \
57 || (Errno) == EPERM || (Errno) == EACCES \
58 || (Errno) == ENOSYS /* Solaris 8 */ \
59 || (Errno) == EOPNOTSUPP /* FreeBSD */)
61 /* Wrapper function shared among linkat and renameat. */
62 int at_func2 (int fd1, char const *file1,
63 int fd2, char const *file2,
64 int (*func) (char const *file1, char const *file2));
66 #endif /* _GL_HEADER_OPENAT_PRIV */