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
This commit is contained in:
Vico Chen 2023-09-05 11:53:02 +03:00 committed by Dmitry Chagin
parent 11e37048db
commit aadc14bceb
2 changed files with 10 additions and 2 deletions

View file

@ -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

View file

@ -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_ */