X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Ftimerfd.c;h=c502c60e4f54ddfe6ac9402c2c550a274485b003;hb=8266602033d6adc6d10cb8811c1fd694767909b0;hp=10c80b59ec4bb7e542b8864f369ec10da7dc34f5;hpb=4f4ae0d42680889c62db4e1f3e6b4aa7787a7257;p=linux-2.6 diff --git a/fs/timerfd.c b/fs/timerfd.c index 10c80b59ec..c502c60e4f 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -20,6 +20,7 @@ #include #include #include +#include struct timerfd_ctx { struct hrtimer tmr; @@ -180,12 +181,14 @@ static struct file *timerfd_fget(int fd) asmlinkage long sys_timerfd_create(int clockid, int flags) { - int error, ufd; + int ufd; struct timerfd_ctx *ctx; - struct file *file; - struct inode *inode; - if (flags) + /* Check the TFD_* constants for consistency. */ + BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC); + BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK); + + if (flags & ~(TFD_CLOEXEC | TFD_NONBLOCK)) return -EINVAL; if (clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME) @@ -199,12 +202,10 @@ asmlinkage long sys_timerfd_create(int clockid, int flags) ctx->clockid = clockid; hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); - error = anon_inode_getfd(&ufd, &inode, &file, "[timerfd]", - &timerfd_fops, ctx); - if (error) { + ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, + flags & (O_CLOEXEC | O_NONBLOCK)); + if (ufd < 0) kfree(ctx); - return error; - } return ufd; }