git: cf742faa39a5 - main - timerfd_create: accept CLOCK_UPTIME/CLOCK_BOOTTIME
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 06 Mar 2024 17:13:42 UTC
The branch main has been updated by bapt:
URL: https://cgit.FreeBSD.org/src/commit/?id=cf742faa39a58a9b43b671c66097e6880459d4ae
commit cf742faa39a58a9b43b671c66097e6880459d4ae
Author: Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2024-03-06 14:11:32 +0000
Commit: Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2024-03-06 17:13:33 +0000
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 <sys/_clock_id.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/callout.h>
@@ -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);