diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-18 18:12:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-18 18:12:41 -0400 |
commit | 58f9b52ee8712283f7ffedb661df678c61e88a91 (patch) | |
tree | fe6d2e1bca6befd8ca347487a7c053b8136320ad /kernel/compat.c | |
parent | 2af170dd241810212cbdbdc802ba7d39e3fb23b9 (diff) | |
parent | c70878b4e0b6cf8d2f1e46319e48e821ef4a8aba (diff) |
Merge ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-hrt
* ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-hrt:
hrtimer: hook compat_sys_nanosleep up to high res timer code
hrtimer: Rework hrtimer_nanosleep to make sys_compat_nanosleep easier
Diffstat (limited to 'kernel/compat.c')
-rw-r--r-- | kernel/compat.c | 57 |
1 files changed, 11 insertions, 46 deletions
diff --git a/kernel/compat.c b/kernel/compat.c index b78328af19ad..42a1ed4b61b1 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
@@ -40,62 +40,27 @@ int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user | |||
40 | __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; | 40 | __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; |
41 | } | 41 | } |
42 | 42 | ||
43 | static long compat_nanosleep_restart(struct restart_block *restart) | ||
44 | { | ||
45 | unsigned long expire = restart->arg0, now = jiffies; | ||
46 | struct compat_timespec __user *rmtp; | ||
47 | |||
48 | /* Did it expire while we handled signals? */ | ||
49 | if (!time_after(expire, now)) | ||
50 | return 0; | ||
51 | |||
52 | expire = schedule_timeout_interruptible(expire - now); | ||
53 | if (expire == 0) | ||
54 | return 0; | ||
55 | |||
56 | rmtp = (struct compat_timespec __user *)restart->arg1; | ||
57 | if (rmtp) { | ||
58 | struct compat_timespec ct; | ||
59 | struct timespec t; | ||
60 | |||
61 | jiffies_to_timespec(expire, &t); | ||
62 | ct.tv_sec = t.tv_sec; | ||
63 | ct.tv_nsec = t.tv_nsec; | ||
64 | if (copy_to_user(rmtp, &ct, sizeof(ct))) | ||
65 | return -EFAULT; | ||
66 | } | ||
67 | /* The 'restart' block is already filled in */ | ||
68 | return -ERESTART_RESTARTBLOCK; | ||
69 | } | ||
70 | |||
71 | asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, | 43 | asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, |
72 | struct compat_timespec __user *rmtp) | 44 | struct compat_timespec __user *rmtp) |
73 | { | 45 | { |
74 | struct timespec t; | 46 | struct timespec tu, rmt; |
75 | struct restart_block *restart; | 47 | long ret; |
76 | unsigned long expire; | ||
77 | 48 | ||
78 | if (get_compat_timespec(&t, rqtp)) | 49 | if (get_compat_timespec(&tu, rqtp)) |
79 | return -EFAULT; | 50 | return -EFAULT; |
80 | 51 | ||
81 | if ((t.tv_nsec >= 1000000000L) || (t.tv_nsec < 0) || (t.tv_sec < 0)) | 52 | if (!timespec_valid(&tu)) |
82 | return -EINVAL; | 53 | return -EINVAL; |
83 | 54 | ||
84 | expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec); | 55 | ret = hrtimer_nanosleep(&tu, rmtp ? &rmt : NULL, HRTIMER_MODE_REL, |
85 | expire = schedule_timeout_interruptible(expire); | 56 | CLOCK_MONOTONIC); |
86 | if (expire == 0) | ||
87 | return 0; | ||
88 | 57 | ||
89 | if (rmtp) { | 58 | if (ret && rmtp) { |
90 | jiffies_to_timespec(expire, &t); | 59 | if (put_compat_timespec(&rmt, rmtp)) |
91 | if (put_compat_timespec(&t, rmtp)) | ||
92 | return -EFAULT; | 60 | return -EFAULT; |
93 | } | 61 | } |
94 | restart = ¤t_thread_info()->restart_block; | 62 | |
95 | restart->fn = compat_nanosleep_restart; | 63 | return ret; |
96 | restart->arg0 = jiffies + expire; | ||
97 | restart->arg1 = (unsigned long) rmtp; | ||
98 | return -ERESTART_RESTARTBLOCK; | ||
99 | } | 64 | } |
100 | 65 | ||
101 | static inline long get_compat_itimerval(struct itimerval *o, | 66 | static inline long get_compat_itimerval(struct itimerval *o, |