Improved the accuracy of gettimeofday/settimeofday: Linux stores a srtuct

timezone in the kernel. We now keep track of it for emulated processes.
Tested for powerpc and i386. Untested on m68k, but it should be ok
Alpha has a particular implementation (osf1_sys_gettimeofday), and it has
therefore not been touched.
This commit is contained in:
manu 2001-05-13 20:54:42 +00:00
parent 2cd8833615
commit d473f5bd8a
17 changed files with 189 additions and 43 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscall.h,v 1.36 2001/03/30 18:02:28 jdolecek Exp $ */
/* $NetBSD: linux_syscall.h,v 1.37 2001/05/13 20:54:43 manu Exp $ */
/*
* System call numbers.

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscallargs.h,v 1.36 2001/03/30 18:02:28 jdolecek Exp $ */
/* $NetBSD: linux_syscallargs.h,v 1.37 2001/05/13 20:54:43 manu Exp $ */
/*
* System call argument lists.
@ -8,7 +8,7 @@
*/
#ifndef _LINUX_SYS__SYSCALLARGS_H_
#define _LINUX_SYS__SYSCALLARGS_H_
#define _LINUX_SYS__SYSCALLARGS_H_
#ifdef syscallarg
#undef syscallarg
@ -198,6 +198,16 @@ struct linux_sys_sigpending_args {
syscallarg(linux_old_sigset_t *) set;
};
struct linux_sys_gettimeofday_args {
syscallarg(struct timeval *) tp;
syscallarg(struct timezone *) tzp;
};
struct linux_sys_settimeofday_args {
syscallarg(struct timeval *) tp;
syscallarg(struct timezone *) tzp;
};
struct linux_sys_getgroups16_args {
syscallarg(int) gidsetsize;
syscallarg(linux_gid_t *) gidset;
@ -635,8 +645,8 @@ int compat_43_sys_sethostname(struct proc *, void *, register_t *);
int compat_43_sys_setrlimit(struct proc *, void *, register_t *);
int compat_43_sys_getrlimit(struct proc *, void *, register_t *);
int sys_getrusage(struct proc *, void *, register_t *);
int sys_gettimeofday(struct proc *, void *, register_t *);
int sys_settimeofday(struct proc *, void *, register_t *);
int linux_sys_gettimeofday(struct proc *, void *, register_t *);
int linux_sys_settimeofday(struct proc *, void *, register_t *);
int linux_sys_getgroups16(struct proc *, void *, register_t *);
int linux_sys_setgroups16(struct proc *, void *, register_t *);
int linux_sys_oldselect(struct proc *, void *, register_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscalls.c,v 1.37 2001/03/30 18:02:28 jdolecek Exp $ */
/* $NetBSD: linux_syscalls.c,v 1.38 2001/05/13 20:54:43 manu Exp $ */
/*
* System call names.

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_sysent.c,v 1.36 2001/03/30 18:02:29 jdolecek Exp $ */
/* $NetBSD: linux_sysent.c,v 1.37 2001/05/13 20:54:43 manu Exp $ */
/*
* System call switch table.
@ -181,10 +181,10 @@ struct sysent linux_sysent[] = {
compat_43_sys_getrlimit }, /* 76 = getrlimit */
{ 2, s(struct sys_getrusage_args), 0,
sys_getrusage }, /* 77 = getrusage */
{ 2, s(struct sys_gettimeofday_args), 0,
sys_gettimeofday }, /* 78 = gettimeofday */
{ 2, s(struct sys_settimeofday_args), 0,
sys_settimeofday }, /* 79 = settimeofday */
{ 2, s(struct linux_sys_gettimeofday_args), 0,
linux_sys_gettimeofday }, /* 78 = gettimeofday */
{ 2, s(struct linux_sys_settimeofday_args), 0,
linux_sys_settimeofday }, /* 79 = settimeofday */
{ 2, s(struct linux_sys_getgroups16_args), 0,
linux_sys_getgroups16 }, /* 80 = getgroups16 */
{ 2, s(struct linux_sys_setgroups16_args), 0,

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.56 2001/03/30 17:59:46 jdolecek Exp $
$NetBSD: syscalls.master,v 1.57 2001/05/13 20:54:43 manu Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -149,9 +149,9 @@
76 NOARGS { int compat_43_sys_getrlimit(u_int which, \
struct orlimit *rlp); }
77 NOARGS { int sys_getrusage(int who, struct rusage *rusage); }
78 NOARGS { int sys_gettimeofday(struct timeval *tp, \
78 STD { int linux_sys_gettimeofday(struct timeval *tp, \
struct timezone *tzp); }
79 NOARGS { int sys_settimeofday(struct timeval *tp, \
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
struct timezone *tzp); }
80 STD { int linux_sys_getgroups16(int gidsetsize, linux_gid_t *gidset); }
81 STD { int linux_sys_setgroups16(int gidsetsize, linux_gid_t *gidset); }

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscall.h,v 1.34 2001/03/30 18:33:22 jdolecek Exp $ */
/* $NetBSD: linux_syscall.h,v 1.35 2001/05/13 20:54:44 manu Exp $ */
/*
* System call numbers.

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscallargs.h,v 1.34 2001/03/30 18:33:22 jdolecek Exp $ */
/* $NetBSD: linux_syscallargs.h,v 1.35 2001/05/13 20:54:44 manu Exp $ */
/*
* System call argument lists.
@ -8,7 +8,7 @@
*/
#ifndef _LINUX_SYS__SYSCALLARGS_H_
#define _LINUX_SYS__SYSCALLARGS_H_
#define _LINUX_SYS__SYSCALLARGS_H_
#ifdef syscallarg
#undef syscallarg
@ -190,6 +190,16 @@ struct linux_sys_sigpending_args {
syscallarg(linux_old_sigset_t *) set;
};
struct linux_sys_gettimeofday_args {
syscallarg(struct timeval *) tp;
syscallarg(struct timezone *) tzp;
};
struct linux_sys_settimeofday_args {
syscallarg(struct timeval *) tp;
syscallarg(struct timezone *) tzp;
};
struct linux_sys_getgroups16_args {
syscallarg(u_int) gidsetsize;
syscallarg(linux_gid_t *) gidset;
@ -610,8 +620,8 @@ int compat_43_sys_getrlimit(struct proc *, void *, register_t *);
#else
#endif
int sys_getrusage(struct proc *, void *, register_t *);
int sys_gettimeofday(struct proc *, void *, register_t *);
int sys_settimeofday(struct proc *, void *, register_t *);
int linux_sys_gettimeofday(struct proc *, void *, register_t *);
int linux_sys_settimeofday(struct proc *, void *, register_t *);
int linux_sys_getgroups16(struct proc *, void *, register_t *);
int linux_sys_setgroups16(struct proc *, void *, register_t *);
int linux_sys_oldselect(struct proc *, void *, register_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscalls.c,v 1.35 2001/03/30 18:33:22 jdolecek Exp $ */
/* $NetBSD: linux_syscalls.c,v 1.36 2001/05/13 20:54:44 manu Exp $ */
/*
* System call names.

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_sysent.c,v 1.34 2001/03/30 18:33:22 jdolecek Exp $ */
/* $NetBSD: linux_sysent.c,v 1.35 2001/05/13 20:54:44 manu Exp $ */
/*
* System call switch table.
@ -196,10 +196,10 @@ struct sysent linux_sysent[] = {
#endif
{ 2, s(struct sys_getrusage_args), 0,
sys_getrusage }, /* 77 = getrusage */
{ 2, s(struct sys_gettimeofday_args), 0,
sys_gettimeofday }, /* 78 = gettimeofday */
{ 2, s(struct sys_settimeofday_args), 0,
sys_settimeofday }, /* 79 = settimeofday */
{ 2, s(struct linux_sys_gettimeofday_args), 0,
linux_sys_gettimeofday }, /* 78 = gettimeofday */
{ 2, s(struct linux_sys_settimeofday_args), 0,
linux_sys_settimeofday }, /* 79 = settimeofday */
{ 2, s(struct linux_sys_getgroups16_args), 0,
linux_sys_getgroups16 }, /* 80 = getgroups16 */
{ 2, s(struct linux_sys_setgroups16_args), 0,

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.32 2001/03/30 18:01:20 jdolecek Exp $
$NetBSD: syscalls.master,v 1.33 2001/05/13 20:54:44 manu Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -160,9 +160,9 @@
76 UNIMPL compat_43_sys_getrlimit
#endif
77 NOARGS { int sys_getrusage(int who, struct rusage *rusage); }
78 NOARGS { int sys_gettimeofday(struct timeval *tp, \
78 STD { int linux_sys_gettimeofday(struct timeval *tp, \
struct timezone *tzp); }
79 NOARGS { int sys_settimeofday(struct timeval *tp, \
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
struct timezone *tzp); }
80 STD { int linux_sys_getgroups16(u_int gidsetsize, linux_gid_t *gidset); }
81 STD { int linux_sys_setgroups16(u_int gidsetsize, linux_gid_t *gidset); }

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscall.h,v 1.7 2001/03/30 18:33:23 jdolecek Exp $ */
/* $NetBSD: linux_syscall.h,v 1.8 2001/05/13 20:54:45 manu Exp $ */
/*
* System call numbers.

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscallargs.h,v 1.7 2001/03/30 18:33:23 jdolecek Exp $ */
/* $NetBSD: linux_syscallargs.h,v 1.8 2001/05/13 20:54:45 manu Exp $ */
/*
* System call argument lists.
@ -8,7 +8,7 @@
*/
#ifndef _LINUX_SYS__SYSCALLARGS_H_
#define _LINUX_SYS__SYSCALLARGS_H_
#define _LINUX_SYS__SYSCALLARGS_H_
#ifdef syscallarg
#undef syscallarg
@ -184,6 +184,16 @@ struct linux_sys_sigpending_args {
syscallarg(linux_old_sigset_t *) set;
};
struct linux_sys_gettimeofday_args {
syscallarg(struct timeval *) tp;
syscallarg(struct timezone *) tzp;
};
struct linux_sys_settimeofday_args {
syscallarg(struct timeval *) tp;
syscallarg(struct timezone *) tzp;
};
struct linux_sys_select_args {
syscallarg(int) nfds;
syscallarg(fd_set *) readfds;
@ -559,8 +569,8 @@ int compat_43_sys_sethostname(struct proc *, void *, register_t *);
int compat_43_sys_setrlimit(struct proc *, void *, register_t *);
int compat_43_sys_getrlimit(struct proc *, void *, register_t *);
int sys_getrusage(struct proc *, void *, register_t *);
int sys_gettimeofday(struct proc *, void *, register_t *);
int sys_settimeofday(struct proc *, void *, register_t *);
int linux_sys_gettimeofday(struct proc *, void *, register_t *);
int linux_sys_settimeofday(struct proc *, void *, register_t *);
int sys_getgroups(struct proc *, void *, register_t *);
int sys_setgroups(struct proc *, void *, register_t *);
int linux_sys_select(struct proc *, void *, register_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscalls.c,v 1.7 2001/03/30 18:33:23 jdolecek Exp $ */
/* $NetBSD: linux_syscalls.c,v 1.8 2001/05/13 20:54:45 manu Exp $ */
/*
* System call names.

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_sysent.c,v 1.7 2001/03/30 18:33:23 jdolecek Exp $ */
/* $NetBSD: linux_sysent.c,v 1.8 2001/05/13 20:54:45 manu Exp $ */
/*
* System call switch table.
@ -183,10 +183,10 @@ struct sysent linux_sysent[] = {
compat_43_sys_getrlimit }, /* 76 = getrlimit */
{ 2, s(struct sys_getrusage_args), 0,
sys_getrusage }, /* 77 = getrusage */
{ 2, s(struct sys_gettimeofday_args), 0,
sys_gettimeofday }, /* 78 = gettimeofday */
{ 2, s(struct sys_settimeofday_args), 0,
sys_settimeofday }, /* 79 = settimeofday */
{ 2, s(struct linux_sys_gettimeofday_args), 0,
linux_sys_gettimeofday }, /* 78 = gettimeofday */
{ 2, s(struct linux_sys_settimeofday_args), 0,
linux_sys_settimeofday }, /* 79 = settimeofday */
{ 2, s(struct sys_getgroups_args), 0,
sys_getgroups }, /* 80 = getgroups */
{ 2, s(struct sys_setgroups_args), 0,

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.4 2001/03/30 17:59:47 jdolecek Exp $
$NetBSD: syscalls.master,v 1.5 2001/05/13 20:54:45 manu Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -177,9 +177,9 @@
76 NOARGS { int compat_43_sys_getrlimit(u_int which, \
struct orlimit *rlp); }
77 NOARGS { int sys_getrusage(int who, struct rusage *rusage); }
78 NOARGS { int sys_gettimeofday(struct timeval *tp, \
78 STD { int linux_sys_gettimeofday(struct timeval *tp, \
struct timezone *tzp); }
79 NOARGS { int sys_settimeofday(struct timeval *tp, \
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
struct timezone *tzp); }
80 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
81 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }

View File

@ -0,0 +1,115 @@
/* $NetBSD: linux_time.c,v 1.1 2001/05/13 20:54:45 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
#include <sys/signal.h>
#include <sys/stdint.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/syscallargs.h>
#include <compat/linux/common/linux_types.h>
#include <compat/linux/common/linux_signal.h>
#include <compat/linux/linux_syscallargs.h>
/*
* Linux keeps track of a system timezone in the kernel. It is readen
* by gettimeofday and set by settimeofday. This emulates this behavior
* See linux/kernel/time.c
*/
struct timezone linux_sys_tz;
int linux_sys_gettimeofday(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct linux_sys_gettimeofday_args /* {
syscallarg(struct timeval *) tz;
syscallarg(struct timezone *) tzp;
} */ *uap = v;
int error = 0;
if (SCARG(uap, tp)) {
error = sys_gettimeofday (p, v, retval);
if (error)
return (error);
}
if (SCARG(uap, tzp)) {
error = copyout(&linux_sys_tz, SCARG(uap, tzp), sizeof(linux_sys_tz));
if (error)
return (error);
}
return (0);
}
int linux_sys_settimeofday(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct linux_sys_settimeofday_args /* {
syscallarg(struct timeval *) tz;
syscallarg(struct timezone *) tzp;
} */ *uap = v;
int error = 0;
if (SCARG(uap, tp)) {
error = sys_settimeofday(p, v, retval);
if (error)
return (error);
}
/*
* If user is not the superuser, we returned
* after the sys_settimeofday() call.
*/
if (SCARG(uap, tzp)) {
error = copyin(SCARG(uap, tzp), &linux_sys_tz, sizeof(linux_sys_tz));
if (error)
return (error);
}
return (0);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: files.linux,v 1.13 2001/01/10 02:29:29 fvdl Exp $
# $NetBSD: files.linux,v 1.14 2001/05/13 20:54:42 manu Exp $
#
# Config file description for machine-independent Linux compat code.
# Included by ports that need it.
@ -24,3 +24,4 @@ file compat/linux/common/linux_signal.c compat_linux
file compat/linux/common/linux_socket.c compat_linux
file compat/linux/common/linux_termios.c compat_linux
file compat/linux/common/linux_uselib.c compat_linux & exec_aout
file compat/linux/common/linux_time.c compat_linux