[PATCH] timerfd: update flags decoding

Mike Frysinger vapier at gentoo.org
Wed Dec 31 00:08:50 UTC 2014


The current code only decodes TFD_TIMER_ABSTIME when the kernel has
a bunch of newer flags.  We have to handle fallbacks for all of them
since the kernel doesn't currently export things to userspace.

* time.c: Include fcntl.h for O_* defines.
(TFD_TIMER_ABSTIME): Move to xlat/timerfdflags.in.
* xlat/timerfdflags.in: Add more definitions.
---
note: having time.c include fcntl.h doesn't feel right, but having the
xlat headers do it directly doesn't really work.  any definitions that
show up in the file before the include could easily cause clashes :(.

note: i'll take care of sending a patch to lkml for the kernel headers.

 time.c               |  5 +----
 xlat/timerfdflags.in | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/time.c b/time.c
index 31f0846..b61a74e 100644
--- a/time.c
+++ b/time.c
@@ -28,6 +28,7 @@
  */
 
 #include "defs.h"
+#include <fcntl.h>
 #include <linux/version.h>
 #include <sys/timex.h>
 #include <linux/ioctl.h>
@@ -809,10 +810,6 @@ rtc_ioctl(struct tcb *tcp, long code, long arg)
 	return 1;
 }
 
-#ifndef TFD_TIMER_ABSTIME
-#define TFD_TIMER_ABSTIME (1 << 0)
-#endif
-
 #include "xlat/timerfdflags.h"
 
 int
diff --git a/xlat/timerfdflags.in b/xlat/timerfdflags.in
index cfd506d..0fed7f7 100644
--- a/xlat/timerfdflags.in
+++ b/xlat/timerfdflags.in
@@ -1 +1,21 @@
+/* The Linux userspace headers didn't export these for a long time. */
+
+#ifndef TFD_TIMER_ABSTIME
+#define TFD_TIMER_ABSTIME (1 << 0)
+#endif
 TFD_TIMER_ABSTIME
+
+#ifndef TFD_TIMER_CANCEL_ON_SET
+#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
+#endif
+TFD_TIMER_CANCEL_ON_SET
+
+#ifndef TFD_CLOEXEC
+#define TFD_CLOEXEC O_CLOEXEC
+#endif
+TFD_CLOEXEC
+
+#ifndef TFD_NONBLOCK
+#define TFD_NONBLOCK O_NONBLOCK
+#endif
+TFD_NONBLOCK
-- 
2.1.3





More information about the Strace-devel mailing list