aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVico Chen <vico.chern_qq.com>2023-09-05 08:53:02 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2023-09-05 08:53:02 +0000
commitaadc14bceb4e94f5b75a05de96cd9619b877b030 (patch)
tree72bbd6b4c65b340f48944fe127d551ade6493ff0
parent11e37048db35d7fcfc285b867965de1aeefec2c8 (diff)
downloadsrc-aadc14bceb4e94f5b75a05de96cd9619b877b030.tar.gz
src-aadc14bceb4e94f5b75a05de96cd9619b877b030.zip
linux(4): Convert flags in timerfd_create
The timerfd is introduced in FreeBSD 14, and the Linux ABI timerfd is also moved to FreeBSD native timerfd, but it can't work well as Linux TFD_CLOEXEC and TFD_NONBLOCK haven't been converted to FreeBSD TFD_CLOEXEC and TFD_NONBLOCK. Reviewed by: dchagin, jfree Differential revision: https://reviews.freebsd.org/D41708 MFC after: 1 week
-rw-r--r--sys/compat/linux/linux_event.c9
-rw-r--r--sys/compat/linux/linux_event.h3
2 files changed, 10 insertions, 2 deletions
diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c
index 816c68a90f1d..e88791659f1f 100644
--- a/sys/compat/linux/linux_event.c
+++ b/sys/compat/linux/linux_event.c
@@ -611,13 +611,18 @@ int
linux_timerfd_create(struct thread *td, struct linux_timerfd_create_args *args)
{
clockid_t clockid;
- int error;
+ int error, flags;
error = linux_to_native_clockid(&clockid, args->clockid);
if (error != 0)
return (error);
+ flags = 0;
+ if ((args->flags & LINUX_TFD_CLOEXEC) != 0)
+ flags |= O_CLOEXEC;
+ if ((args->flags & LINUX_TFD_NONBLOCK) != 0)
+ flags |= TFD_NONBLOCK;
- return (kern_timerfd_create(td, clockid, args->flags));
+ return (kern_timerfd_create(td, clockid, flags));
}
int
diff --git a/sys/compat/linux/linux_event.h b/sys/compat/linux/linux_event.h
index fa63371b5170..8c6758fefcc9 100644
--- a/sys/compat/linux/linux_event.h
+++ b/sys/compat/linux/linux_event.h
@@ -54,4 +54,7 @@
#define LINUX_EFD_SEMAPHORE (1 << 0)
+#define LINUX_TFD_CLOEXEC LINUX_O_CLOEXEC
+#define LINUX_TFD_NONBLOCK LINUX_O_NONBLOCK
+
#endif /* !_LINUX_EVENT_H_ */