diff --git a/fs/timerfd.c b/fs/timerfd.c index c6ef5e33cb34ed2cefc257e3e20a9706f4bf4faa..75d44efe346ca93bcded0b3a5df75568bd809aa1 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -184,7 +184,7 @@ asmlinkage long sys_timerfd_create(int clockid, int flags) int ufd; struct timerfd_ctx *ctx; - if (flags & ~TFD_CLOEXEC) + if (flags & ~(TFD_CLOEXEC | TFD_NONBLOCK)) return -EINVAL; if (clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME) @@ -199,7 +199,7 @@ asmlinkage long sys_timerfd_create(int clockid, int flags) hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, - flags & O_CLOEXEC); + flags & (O_CLOEXEC | O_NONBLOCK)); if (ufd < 0) kfree(ctx); diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h index 96ed97dff00f3114e6f03f2ad412acfff7203d56..86cb0501d3e20428b749eb2156bf5abc301e1c20 100644 --- a/include/linux/timerfd.h +++ b/include/linux/timerfd.h @@ -8,7 +8,7 @@ #ifndef _LINUX_TIMERFD_H #define _LINUX_TIMERFD_H -/* For O_CLOEXEC */ +/* For O_CLOEXEC and O_NONBLOCK */ #include /* Flags for timerfd_settime. */ @@ -16,6 +16,7 @@ /* Flags for timerfd_create. */ #define TFD_CLOEXEC O_CLOEXEC +#define TFD_NONBLOCK O_NONBLOCK #endif /* _LINUX_TIMERFD_H */