git: 80b763d4a539 - releng/14.0 - linux(4): Convert flags in timerfd_create
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 12 Sep 2023 16:44:16 UTC
The branch releng/14.0 has been updated by dchagin:
URL: https://cgit.FreeBSD.org/src/commit/?id=80b763d4a539854d43535b2f9dcd0b2f739a6502
commit 80b763d4a539854d43535b2f9dcd0b2f739a6502
Author: Vico Chen <vico.chern_qq.com>
AuthorDate: 2023-09-05 08:53:02 +0000
Commit: Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-09-12 16:43:20 +0000
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.
Approved by: re (gjb)
Reviewed by: dchagin, jfree
PR: 273662
Differential revision: https://reviews.freebsd.org/D41708
MFC after: 1 week
(cherry picked from commit aadc14bceb4e94f5b75a05de96cd9619b877b030)
(cherry picked from commit 3c93ba3d7f7cf0d61f6b98c08319c729a6d31d71)
---
sys/compat/linux/linux_event.c | 9 +++++++--
sys/compat/linux/linux_event.h | 3 +++
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_ */