e0818731f4506c98d25f6bd153d733fe7adc4e27
[debian/gzip] / lib / openat-priv.h
1 /* Internals for openat-like functions.
2
3    Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 /* written by Jim Meyering */
19
20 #ifndef _GL_HEADER_OPENAT_PRIV
21 #define _GL_HEADER_OPENAT_PRIV
22
23 #include <errno.h>
24 #include <stdlib.h>
25
26 #define OPENAT_BUFFER_SIZE 512
27 char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file);
28
29 /* Trying to access a BUILD_PROC_NAME file will fail on systems without
30    /proc support, and even on systems *with* ProcFS support.  Return
31    nonzero if the failure may be legitimate, e.g., because /proc is not
32    readable, or the particular .../fd/N directory is not present.  */
33 #define EXPECTED_ERRNO(Errno)                   \
34   ((Errno) == ENOTDIR || (Errno) == ENOENT      \
35    || (Errno) == EPERM || (Errno) == EACCES     \
36    || (Errno) == ENOSYS /* Solaris 8 */         \
37    || (Errno) == EOPNOTSUPP /* FreeBSD */)
38
39 /* Wrapper function shared among linkat and renameat.  */
40 int at_func2 (int fd1, char const *file1,
41               int fd2, char const *file2,
42               int (*func) (char const *file1, char const *file2));
43
44 #endif /* _GL_HEADER_OPENAT_PRIV */