From cf742faa39a58a9b43b671c66097e6880459d4ae Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 6 Mar 2024 15:11:32 +0100 Subject: [PATCH] timerfd_create: accept CLOCK_UPTIME/CLOCK_BOOTTIME This is a common use case when using timerfd_create to actually use it with CLOCK_BOOTTIME on linux which is CLOCK_UPTIME for us. Note that currently on freebsd CLOCK_BOOTTIME is CLOCK_UPTIME, but the semantic is supposed to be different, this has to be fixed later. Tested with the fnott notification software Reviewed by: des, imp Differential Revision: https://reviews.freebsd.org/D44253 --- sys/kern/sys_timerfd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/kern/sys_timerfd.c b/sys/kern/sys_timerfd.c index 30c3709e59a6..f74fb87bea75 100644 --- a/sys/kern/sys_timerfd.c +++ b/sys/kern/sys_timerfd.c @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#include #include #include #include @@ -432,8 +433,18 @@ kern_timerfd_create(struct thread *td, int clockid, int flags) AUDIT_ARG_VALUE(clockid); AUDIT_ARG_FFLAGS(flags); - if (clockid != CLOCK_REALTIME && clockid != CLOCK_MONOTONIC) + switch (clockid) { + case CLOCK_REALTIME: + /* FALLTHROUGH */ + case CLOCK_MONOTONIC: + /* FALLTHROUGH */ + case CLOCK_UPTIME: + /* FALLTHROUGH */ + case CLOCK_BOOTTIME: + break; + default: return (EINVAL); + } if ((flags & ~(TFD_CLOEXEC | TFD_NONBLOCK)) != 0) return (EINVAL);