[PATCH 2/3] Add generic compat_sys_sched_rr_get_intervalimplementation

From: Catalin Marinas
Date: Thu Sep 13 2012 - 04:55:17 EST


This patch adds a generic implementation for
compat_sys_sched_rr_get_interval as it is used by other architectures.

Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
---
include/linux/compat.h | 3 +++
kernel/compat.c | 17 +++++++++++++++++
2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index e2f5e9a..bbe89b8 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -599,6 +599,9 @@ asmlinkage int compat_sys_sendfile(int out_fd, int in_fd,
asmlinkage int compat_sys_sendfile64(int out_fd, int in_fd,
compat_loff_t __user *offset, s32 count);

+asmlinkage int compat_sys_sched_rr_get_interval(compat_pid_t pid,
+ struct compat_timespec __user *interval);
+
#else

#define is_compat_task() (0)
diff --git a/kernel/compat.c b/kernel/compat.c
index 5f07388..3961f67 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -1259,6 +1259,23 @@ asmlinkage int compat_sys_sendfile64(int out_fd, int in_fd,
}
#endif /* __ARCH_WANT_COMPAT_SYS_SENDFILE64 */

+#ifdef __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
+asmlinkage int compat_sys_sched_rr_get_interval(compat_pid_t pid,
+ struct compat_timespec __user *interval)
+{
+ struct timespec t;
+ int ret;
+ mm_segment_t old_fs = get_fs();
+
+ set_fs(KERNEL_DS);
+ ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
+ set_fs(old_fs);
+ if (put_compat_timespec(&t, interval))
+ return -EFAULT;
+ return ret;
+}
+#endif /* __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL */
+
/*
* Allocate user-space memory for the duration of a single system call,
* in order to marshall parameters inside a compat thunk.