1 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 /* 4 * Copyright (C) 2023 Cyril Hrubis <[email protected]> 5 */ 6 7 #ifndef TST_FD_H__ 8 #define TST_FD_H__ 9 10 enum tst_fd_type { 11 TST_FD_FILE, 12 TST_FD_PATH, 13 TST_FD_DIR, 14 TST_FD_DEV_ZERO, 15 TST_FD_PROC_MAPS, 16 TST_FD_PIPE_READ, 17 TST_FD_PIPE_WRITE, 18 TST_FD_UNIX_SOCK, 19 TST_FD_INET_SOCK, 20 TST_FD_EPOLL, 21 TST_FD_EVENTFD, 22 TST_FD_SIGNALFD, 23 TST_FD_TIMERFD, 24 TST_FD_PIDFD, 25 TST_FD_FANOTIFY, 26 TST_FD_INOTIFY, 27 TST_FD_USERFAULTFD, 28 TST_FD_PERF_EVENT, 29 TST_FD_IO_URING, 30 TST_FD_BPF_MAP, 31 TST_FD_FSOPEN, 32 TST_FD_FSPICK, 33 TST_FD_OPEN_TREE, 34 TST_FD_MEMFD, 35 TST_FD_MEMFD_SECRET, 36 TST_FD_MAX, 37 }; 38 39 struct tst_fd { 40 enum tst_fd_type type; 41 int fd; 42 /* used by the library, do not touch! */ 43 long priv; 44 }; 45 46 #define TST_FD_INIT {.type = TST_FD_FILE, .fd = -1} 47 48 /* 49 * Advances the iterator to the next fd type, returns zero at the end. 50 */ 51 int tst_fd_next(struct tst_fd *fd); 52 53 #define TST_FD_FOREACH(fd) \ 54 for (struct tst_fd fd = TST_FD_INIT; tst_fd_next(&fd); ) 55 56 /* 57 * Returns human readable name for the file descriptor type. 58 */ 59 const char *tst_fd_desc(struct tst_fd *fd); 60 61 #endif /* TST_FD_H__ */ 62