4 * Copyright IBM, Corp. 2017
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef QEMU_9P_UTIL_H
14 #define QEMU_9P_UTIL_H
16 static inline void close_preserve_errno(int fd)
23 static inline int openat_dir(int dirfd, const char *name)
26 #define OPENAT_DIR_O_PATH O_PATH
28 #define OPENAT_DIR_O_PATH 0
30 return openat(dirfd, name,
31 O_DIRECTORY | O_RDONLY | O_NOFOLLOW | OPENAT_DIR_O_PATH);
34 static inline int openat_file(int dirfd, const char *name, int flags,
39 fd = openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK,
46 /* O_NONBLOCK was only needed to open the file. Let's drop it. */
47 ret = fcntl(fd, F_SETFL, flags);
53 int relative_openat_nofollow(int dirfd, const char *path, int flags,
55 ssize_t fgetxattrat_nofollow(int dirfd, const char *path, const char *name,
56 void *value, size_t size);
57 int fsetxattrat_nofollow(int dirfd, const char *path, const char *name,
58 void *value, size_t size, int flags);