aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/timerfd.c37
-rw-r--r--include/linux/timerfd.h5
2 files changed, 42 insertions, 0 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 77183f047f65..709603cac9e6 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -315,12 +315,49 @@ static int timerfd_show(struct seq_file *m, struct file *file)
315#define timerfd_show NULL 315#define timerfd_show NULL
316#endif 316#endif
317 317
318#ifdef CONFIG_CHECKPOINT_RESTORE
319static long timerfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
320{
321 struct timerfd_ctx *ctx = file->private_data;
322 int ret = 0;
323
324 switch (cmd) {
325 case TFD_IOC_SET_TICKS: {
326 u64 ticks;
327
328 if (copy_from_user(&ticks, (u64 __user *)arg, sizeof(ticks)))
329 return -EFAULT;
330 if (!ticks)
331 return -EINVAL;
332
333 spin_lock_irq(&ctx->wqh.lock);
334 if (!timerfd_canceled(ctx)) {
335 ctx->ticks = ticks;
336 if (ticks)
337 wake_up_locked(&ctx->wqh);
338 } else
339 ret = -ECANCELED;
340 spin_unlock_irq(&ctx->wqh.lock);
341 break;
342 }
343 default:
344 ret = -ENOTTY;
345 break;
346 }
347
348 return ret;
349}
350#else
351#define timerfd_ioctl NULL
352#endif
353
318static const struct file_operations timerfd_fops = { 354static const struct file_operations timerfd_fops = {
319 .release = timerfd_release, 355 .release = timerfd_release,
320 .poll = timerfd_poll, 356 .poll = timerfd_poll,
321 .read = timerfd_read, 357 .read = timerfd_read,
322 .llseek = noop_llseek, 358 .llseek = noop_llseek,
323 .show_fdinfo = timerfd_show, 359 .show_fdinfo = timerfd_show,
360 .unlocked_ioctl = timerfd_ioctl,
324}; 361};
325 362
326static int timerfd_fget(int fd, struct fd *p) 363static int timerfd_fget(int fd, struct fd *p)
diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h
index d3b57fa12225..bd36ce431e32 100644
--- a/include/linux/timerfd.h
+++ b/include/linux/timerfd.h
@@ -11,6 +11,9 @@
11/* For O_CLOEXEC and O_NONBLOCK */ 11/* For O_CLOEXEC and O_NONBLOCK */
12#include <linux/fcntl.h> 12#include <linux/fcntl.h>
13 13
14/* For _IO helpers */
15#include <linux/ioctl.h>
16
14/* 17/*
15 * CAREFUL: Check include/asm-generic/fcntl.h when defining 18 * CAREFUL: Check include/asm-generic/fcntl.h when defining
16 * new flags, since they might collide with O_* ones. We want 19 * new flags, since they might collide with O_* ones. We want
@@ -29,4 +32,6 @@
29/* Flags for timerfd_settime. */ 32/* Flags for timerfd_settime. */
30#define TFD_SETTIME_FLAGS (TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET) 33#define TFD_SETTIME_FLAGS (TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET)
31 34
35#define TFD_IOC_SET_TICKS _IOW('T', 0, u64)
36
32#endif /* _LINUX_TIMERFD_H */ 37#endif /* _LINUX_TIMERFD_H */