linux(4): Implement timer_settime64 syscall.

MFC after:		2 weeks
This commit is contained in:
Dmitry Chagin 2022-05-04 13:06:49 +03:00
parent 9038a0b74c
commit a1fd2911dd
3 changed files with 39 additions and 7 deletions

View File

@ -68,7 +68,6 @@ DUMMY(mq_getsetattr);
DUMMY(arch_prctl);
/* Linux 5.0: */
DUMMY(clock_adjtime64);
DUMMY(timer_settime64);
DUMMY(timerfd_gettime64);
DUMMY(timerfd_settime64);
DUMMY(io_pgetevents_time64);

View File

@ -123,21 +123,55 @@ linux_timer_settime(struct thread *td, struct linux_timer_settime_args *uap)
{
struct l_itimerspec l_val, l_oval;
struct itimerspec val, oval, *ovalp;
int error;
int flags, error;
error = copyin(uap->new, &l_val, sizeof(l_val));
if (error != 0)
return (error);
ITS_CP(l_val, val);
error = linux_to_native_itimerspec(&val, &l_val);
if (error != 0)
return (error);
ovalp = uap->old != NULL ? &oval : NULL;
error = kern_ktimer_settime(td, uap->timerid, uap->flags, &val, ovalp);
error = linux_to_native_timerflags(&flags, uap->flags);
if (error != 0)
return (error);
error = kern_ktimer_settime(td, uap->timerid, flags, &val, ovalp);
if (error == 0 && uap->old != NULL) {
ITS_CP(oval, l_oval);
error = copyout(&l_oval, uap->old, sizeof(l_oval));
error = native_to_linux_itimerspec(&l_val, &val);
if (error == 0)
error = copyout(&l_oval, uap->old, sizeof(l_oval));
}
return (error);
}
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
int
linux_timer_settime64(struct thread *td, struct linux_timer_settime64_args *uap)
{
struct l_itimerspec64 l_val, l_oval;
struct itimerspec val, oval, *ovalp;
int flags, error;
error = copyin(uap->new, &l_val, sizeof(l_val));
if (error != 0)
return (error);
error = linux_to_native_itimerspec64(&val, &l_val);
if (error != 0)
return (error);
ovalp = uap->old != NULL ? &oval : NULL;
error = linux_to_native_timerflags(&flags, uap->flags);
if (error != 0)
return (error);
error = kern_ktimer_settime(td, uap->timerid, flags, &val, ovalp);
if (error == 0 && uap->old != NULL) {
error = native_to_linux_itimerspec64(&l_val, &val);
if (error == 0)
error = copyout(&l_oval, uap->old, sizeof(l_oval));
}
return (error);
}
#endif
int
linux_timer_gettime(struct thread *td, struct linux_timer_gettime_args *uap)
{

View File

@ -70,7 +70,6 @@ DUMMY(vm86old);
DUMMY(arch_prctl);
/* Linux 5.0: */
DUMMY(clock_adjtime64);
DUMMY(timer_settime64);
DUMMY(timerfd_gettime64);
DUMMY(timerfd_settime64);
DUMMY(io_pgetevents_time64);