1 /* @(#)at-defs.h 1.3 18/07/23 Copyright 2011-2018 J. Schilling */ 2 /* 3 * Libschily internal definitions for openat() emulation 4 * and related functions. 5 * 6 * Copyright (c) 2011-2018 J. Schilling 7 */ 8 /* 9 * The contents of this file are subject to the terms of the 10 * Common Development and Distribution License, Version 1.0 only 11 * (the "License"). You may not use this file except in compliance 12 * with the License. 13 * 14 * See the file CDDL.Schily.txt in this distribution for details. 15 * A copy of the CDDL is also available via the Internet at 16 * http://www.opensource.org/licenses/cddl1.txt 17 * 18 * When distributing Covered Code, include this CDDL HEADER in each 19 * file and include the License file CDDL.Schily.txt from this distribution. 20 */ 21 #ifndef _AT_DEFS_H 22 23 /* 24 * This is a list of errors that are expected to be not a result of 25 * a /proc fs problem. If such an error is encountered, then we return 26 * after the open() or other call without trying to emulate the *at() 27 * interface via savewd()/fchdir()/doit()/restorewd(). 28 */ 29 #ifdef ENOSYS 30 #define __ENOSYS ENOSYS 31 #else 32 #define __ENOSYS EPERM 33 #endif 34 #ifdef EOPNOTSUPP 35 #define __EOPNOTSUPP EOPNOTSUPP 36 #else 37 #define __EOPNOTSUPP EPERM 38 #endif 39 40 /* 41 * XXX: Should we include ENOENT here as our emulation needs 42 * XXX: to be able to emulate openat(fd, name, O_CREAT, 666) or 43 * XXX: mknodat(fd, name, mode, dev). 44 * XXX: Since /proc uses symlinks, it should be safe. 45 */ 46 #define NON_PROCFS_ERRNO(e) \ 47 ((e) == ENOENT || (e) == ENOTDIR || \ 48 (e) == EACCES || (e) == EPERM || \ 49 (e) == __ENOSYS /* Solaris */ || \ 50 (e) == __EOPNOTSUPP /* FreeBSD */) 51 52 /* 53 * n refers to an absolute path name. 54 */ 55 #define ABS_NAME(n) ((n)[0] == '/') 56 57 #ifdef min 58 #undef min 59 #endif 60 #define min(a, b) ((a) < (b) ? (a):(b)) 61 62 #ifdef max 63 #undef max 64 #endif 65 #define max(a, b) ((a) < (b) ? (b):(a)) 66 67 /* 68 * From procnameat.c 69 */ 70 extern char *proc_fd2name __PR((char *buf, int fd, const char *name)); 71 72 /* 73 * From wdabort.c 74 */ 75 extern void savewd_abort __PR((int err)); 76 extern void fchdir_abort __PR((int err)); 77 extern void restorewd_abort __PR((int err)); 78 79 #ifdef HAVE_LARGEFILES 80 #define fstatat fstatat64 81 #define openat openat64 82 #endif 83 84 #endif /* _AT_DEFS_H */ 85