Skip to content

Commit ca2406e

Browse files
author
Al Viro
committed
times(2): move compat to native
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 1e1fc13 commit ca2406e

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

include/linux/time.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ extern int do_getitimer(int which, struct itimerval *value);
171171

172172
extern long do_utimes(int dfd, const char __user *filename, struct timespec *times, int flags);
173173

174-
struct tms;
175-
extern void do_sys_times(struct tms *);
176-
177174
/*
178175
* Similar to the struct tm in userspace <time.h>, but it needs to be here so
179176
* that the kernel source is self contained.

kernel/compat.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -350,30 +350,6 @@ COMPAT_SYSCALL_DEFINE3(setitimer, int, which,
350350
return 0;
351351
}
352352

353-
static compat_clock_t clock_t_to_compat_clock_t(clock_t x)
354-
{
355-
return compat_jiffies_to_clock_t(clock_t_to_jiffies(x));
356-
}
357-
358-
COMPAT_SYSCALL_DEFINE1(times, struct compat_tms __user *, tbuf)
359-
{
360-
if (tbuf) {
361-
struct tms tms;
362-
struct compat_tms tmp;
363-
364-
do_sys_times(&tms);
365-
/* Convert our struct tms to the compat version. */
366-
tmp.tms_utime = clock_t_to_compat_clock_t(tms.tms_utime);
367-
tmp.tms_stime = clock_t_to_compat_clock_t(tms.tms_stime);
368-
tmp.tms_cutime = clock_t_to_compat_clock_t(tms.tms_cutime);
369-
tmp.tms_cstime = clock_t_to_compat_clock_t(tms.tms_cstime);
370-
if (copy_to_user(tbuf, &tmp, sizeof(tmp)))
371-
return -EFAULT;
372-
}
373-
force_successful_syscall_return();
374-
return compat_jiffies_to_clock_t(jiffies);
375-
}
376-
377353
#ifdef __ARCH_WANT_SYS_SIGPENDING
378354

379355
/*

kernel/sys.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ SYSCALL_DEFINE0(getegid)
886886
return from_kgid_munged(current_user_ns(), current_egid());
887887
}
888888

889-
void do_sys_times(struct tms *tms)
889+
static void do_sys_times(struct tms *tms)
890890
{
891891
u64 tgutime, tgstime, cutime, cstime;
892892

@@ -912,6 +912,32 @@ SYSCALL_DEFINE1(times, struct tms __user *, tbuf)
912912
return (long) jiffies_64_to_clock_t(get_jiffies_64());
913913
}
914914

915+
#ifdef CONFIG_COMPAT
916+
static compat_clock_t clock_t_to_compat_clock_t(clock_t x)
917+
{
918+
return compat_jiffies_to_clock_t(clock_t_to_jiffies(x));
919+
}
920+
921+
COMPAT_SYSCALL_DEFINE1(times, struct compat_tms __user *, tbuf)
922+
{
923+
if (tbuf) {
924+
struct tms tms;
925+
struct compat_tms tmp;
926+
927+
do_sys_times(&tms);
928+
/* Convert our struct tms to the compat version. */
929+
tmp.tms_utime = clock_t_to_compat_clock_t(tms.tms_utime);
930+
tmp.tms_stime = clock_t_to_compat_clock_t(tms.tms_stime);
931+
tmp.tms_cutime = clock_t_to_compat_clock_t(tms.tms_cutime);
932+
tmp.tms_cstime = clock_t_to_compat_clock_t(tms.tms_cstime);
933+
if (copy_to_user(tbuf, &tmp, sizeof(tmp)))
934+
return -EFAULT;
935+
}
936+
force_successful_syscall_return();
937+
return compat_jiffies_to_clock_t(jiffies);
938+
}
939+
#endif
940+
915941
/*
916942
* This needs some heavy checking ...
917943
* I just haven't the stomach for it. I also don't fully

0 commit comments

Comments
 (0)