Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234614
b: refs/heads/master
c: f1f1d5e
h: refs/heads/master
v: v3
  • Loading branch information
Richard Cochran authored and Thomas Gleixner committed Feb 2, 2011
1 parent f104716 commit f873f5e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 65f5d80bdf83ec0d7f3887db10153bf3f36ed73c
refs/heads/master: f1f1d5ebd10ffa4242bce7a90a56a222d6b7bc77
2 changes: 2 additions & 0 deletions trunk/include/linux/posix-timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/sched.h>
#include <linux/timex.h>

union cpu_time_count {
cputime_t cpu;
Expand Down Expand Up @@ -71,6 +72,7 @@ struct k_clock {
int (*clock_set) (const clockid_t which_clock,
const struct timespec *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
struct timespec *, struct timespec __user *);
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ asmlinkage long sys_clock_settime(clockid_t which_clock,
const struct timespec __user *tp);
asmlinkage long sys_clock_gettime(clockid_t which_clock,
struct timespec __user *tp);
asmlinkage long sys_clock_adjtime(clockid_t which_clock,
struct timex __user *tx);
asmlinkage long sys_clock_getres(clockid_t which_clock,
struct timespec __user *tp);
asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags,
Expand Down
23 changes: 23 additions & 0 deletions trunk/kernel/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,29 @@ long compat_sys_clock_gettime(clockid_t which_clock,
return err;
}

long compat_sys_clock_adjtime(clockid_t which_clock,
struct compat_timex __user *utp)
{
struct timex txc;
mm_segment_t oldfs;
int err, ret;

err = compat_get_timex(&txc, utp);
if (err)
return err;

oldfs = get_fs();
set_fs(KERNEL_DS);
ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
set_fs(oldfs);

err = compat_put_timex(utp, &txc);
if (err)
return err;

return ret;
}

long compat_sys_clock_getres(clockid_t which_clock,
struct compat_timespec __user *tp)
{
Expand Down
30 changes: 30 additions & 0 deletions trunk/kernel/posix-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ static int posix_clock_realtime_set(const clockid_t which_clock,
return do_sys_settimeofday(tp, NULL);
}

static int posix_clock_realtime_adj(const clockid_t which_clock,
struct timex *t)
{
return do_adjtimex(t);
}

/*
* Get monotonic time for posix timers
*/
Expand Down Expand Up @@ -216,6 +222,7 @@ static __init int init_posix_timers(void)
.clock_getres = hrtimer_get_res,
.clock_get = posix_clock_realtime_get,
.clock_set = posix_clock_realtime_set,
.clock_adj = posix_clock_realtime_adj,
.nsleep = common_nsleep,
.nsleep_restart = hrtimer_nanosleep_restart,
.timer_create = common_timer_create,
Expand Down Expand Up @@ -948,6 +955,29 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
return error;
}

SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
struct timex __user *, utx)
{
struct k_clock *kc = clockid_to_kclock(which_clock);
struct timex ktx;
int err;

if (!kc)
return -EINVAL;
if (!kc->clock_adj)
return -EOPNOTSUPP;

if (copy_from_user(&ktx, utx, sizeof(ktx)))
return -EFAULT;

err = kc->clock_adj(which_clock, &ktx);

if (!err && copy_to_user(utx, &ktx, sizeof(ktx)))
return -EFAULT;

return err;
}

SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
struct timespec __user *, tp)
{
Expand Down

0 comments on commit f873f5e

Please sign in to comment.