[PATCH v5 12/24] posix-timers: Factor out the guts of 'clock_gettime' for reusing

From: Baolin Wang
Date: Fri Jun 12 2015 - 03:50:39 EST


In order to reuse the very same logic for the year 2038 safe syscalls
which we need to introduce for 32bit system, factor out the guts of
the 'clock_gettime' syscall.

Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxx>
---
kernel/time/posix-timers.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index dcc632c..ca63626 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -1124,17 +1124,23 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
return __clock_settime(which_clock, &new_tp);
}

-SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
- struct timespec __user *,tp)
+static int __clock_gettime(clockid_t which_clock, struct timespec *ts)
{
struct k_clock *kc = clockid_to_kclock(which_clock);
- struct timespec kernel_tp;
- int error;

if (!kc)
return -EINVAL;

- error = kc->clock_get(which_clock, &kernel_tp);
+ return kc->clock_get(which_clock, ts);
+}
+
+SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
+ struct timespec __user *,tp)
+{
+ struct timespec kernel_tp;
+ int error;
+
+ error = __clock_gettime(which_clock, &kernel_tp);

if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
error = -EFAULT;
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/