diff options
-rw-r--r-- | sys/compat/linux/linux_misc.c | 57 | ||||
-rw-r--r-- | sys/compat/linux/linux_signal.c | 9 | ||||
-rw-r--r-- | sys/i386/linux/linux_misc.c | 57 | ||||
-rw-r--r-- | sys/i386/linux/linux_proto.h | 6 | ||||
-rw-r--r-- | sys/i386/linux/linux_signal.c | 9 | ||||
-rw-r--r-- | sys/i386/linux/linux_syscall.h | 2 | ||||
-rw-r--r-- | sys/i386/linux/linux_sysent.c | 4 |
7 files changed, 105 insertions, 39 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 069ca28..6e736b5 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_misc.c,v 1.12 1996/02/16 18:40:50 peter Exp $ + * $Id: linux_misc.c,v 1.13 1996/03/02 19:37:57 peter Exp $ */ #include <sys/param.h> @@ -675,25 +675,36 @@ struct linux_times_argv { long tms_cstime; }; +#define CLK_TCK 100 /* Linux uses 100 */ +#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) + int linux_times(struct proc *p, struct linux_times_args *args, int *retval) { struct timeval tv; struct linux_times_argv tms; + struct rusage ru; + int error, s; #ifdef DEBUG printf("Linux-emul(%d): times(*)\n", p->p_pid); #endif - tms.tms_utime = p->p_uticks; - tms.tms_stime = p->p_sticks; - tms.tms_cutime = p->p_stats->p_cru.ru_utime.tv_sec * hz + - ((p->p_stats->p_cru.ru_utime.tv_usec * hz)/1000000); - tms.tms_cstime = p->p_stats->p_cru.ru_stime.tv_sec * hz + - ((p->p_stats->p_cru.ru_stime.tv_usec * hz)/1000000); + calcru(p, &ru.ru_utime, &ru.ru_stime, NULL); + + tms.tms_utime = CONVTCK(ru.ru_utime); + tms.tms_stime = CONVTCK(ru.ru_stime); + + tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime); + tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime); + + if ((error = copyout((caddr_t)&tms, (caddr_t)args->buf, + sizeof(struct linux_times_argv)))) + return error; + microtime(&tv); - *retval = tv.tv_sec * hz + (tv.tv_usec * hz)/1000000; - return (copyout((caddr_t)&tms, (caddr_t)args->buf, - sizeof(struct linux_times_argv))); + timevalsub(&tv, &boottime); + *retval = (int)CONVTCK(tv); + return 0; } /* XXX move */ @@ -725,6 +736,10 @@ linux_newuname(struct proc *p, struct linux_newuname_args *args, int *retval) sizeof(struct linux_newuname_t))); } +struct linux_utimbuf { + linux_time_t l_actime; + linux_time_t l_modtime; +}; int linux_utime(struct proc *p, struct linux_utime_args *args, int *retval) @@ -733,7 +748,9 @@ linux_utime(struct proc *p, struct linux_utime_args *args, int *retval) char *path; struct timeval *tptr; } */ bsdutimes; - struct timeval tv; + struct timeval tv[2], *tvp; + struct linux_utimbuf lut; + int error; caddr_t sg; sg = stackgap_init(); @@ -742,9 +759,21 @@ linux_utime(struct proc *p, struct linux_utime_args *args, int *retval) #ifdef DEBUG printf("Linux-emul(%d): utime(%s, *)\n", p->p_pid, args->fname); #endif - tv.tv_sec = (long)args->timeptr; /* XXX: wrong?? */ - tv.tv_usec = 0; - bsdutimes.tptr = &tv; + if (args->times) { + if ((error = copyin(args->times, &lut, sizeof lut))) + return error; + tv[0].tv_sec = lut.l_actime; + tv[0].tv_usec = 0; + tv[1].tv_sec = lut.l_modtime; + tv[1].tv_usec = 0; + /* so that utimes can copyin */ + tvp = (struct timeval *)stackgap_alloc(&sg, sizeof(tv)); + if ((error = copyout(tv, tvp, sizeof(tv)))) + return error; + bsdutimes.tptr = tvp; + } else + bsdutimes.tptr = NULL; + bsdutimes.path = args->fname; return utimes(p, &bsdutimes, retval); } diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index 7bcbef7..92fd23b 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_signal.c,v 1.4 1996/03/02 19:37:58 peter Exp $ + * $Id: linux_signal.c,v 1.5 1996/03/02 21:00:11 peter Exp $ */ #include <sys/param.h> @@ -267,11 +267,15 @@ linux_sigpending(struct proc *p, struct linux_sigpending_args *args,int *retval) return copyout(&linux_sig, args->mask, sizeof(linux_sig)); } +/* + * Linux has two extra args, restart and oldmask. We dont use these, + * but it seems that "restart" is actually a context pointer that + * enables the signal to happen with a different register set. + */ int linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args,int *retval) { struct sigsuspend_args tmp; - int error; #ifdef DEBUG printf("Linux-emul(%d): sigsuspend(%08x)\n", p->p_pid, args->mask); @@ -284,7 +288,6 @@ int linux_pause(struct proc *p, struct linux_pause_args *args,int *retval) { struct sigsuspend_args tmp; - int error; #ifdef DEBUG printf("Linux-emul(%d): pause()\n", p->p_pid); diff --git a/sys/i386/linux/linux_misc.c b/sys/i386/linux/linux_misc.c index 069ca28..6e736b5 100644 --- a/sys/i386/linux/linux_misc.c +++ b/sys/i386/linux/linux_misc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_misc.c,v 1.12 1996/02/16 18:40:50 peter Exp $ + * $Id: linux_misc.c,v 1.13 1996/03/02 19:37:57 peter Exp $ */ #include <sys/param.h> @@ -675,25 +675,36 @@ struct linux_times_argv { long tms_cstime; }; +#define CLK_TCK 100 /* Linux uses 100 */ +#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) + int linux_times(struct proc *p, struct linux_times_args *args, int *retval) { struct timeval tv; struct linux_times_argv tms; + struct rusage ru; + int error, s; #ifdef DEBUG printf("Linux-emul(%d): times(*)\n", p->p_pid); #endif - tms.tms_utime = p->p_uticks; - tms.tms_stime = p->p_sticks; - tms.tms_cutime = p->p_stats->p_cru.ru_utime.tv_sec * hz + - ((p->p_stats->p_cru.ru_utime.tv_usec * hz)/1000000); - tms.tms_cstime = p->p_stats->p_cru.ru_stime.tv_sec * hz + - ((p->p_stats->p_cru.ru_stime.tv_usec * hz)/1000000); + calcru(p, &ru.ru_utime, &ru.ru_stime, NULL); + + tms.tms_utime = CONVTCK(ru.ru_utime); + tms.tms_stime = CONVTCK(ru.ru_stime); + + tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime); + tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime); + + if ((error = copyout((caddr_t)&tms, (caddr_t)args->buf, + sizeof(struct linux_times_argv)))) + return error; + microtime(&tv); - *retval = tv.tv_sec * hz + (tv.tv_usec * hz)/1000000; - return (copyout((caddr_t)&tms, (caddr_t)args->buf, - sizeof(struct linux_times_argv))); + timevalsub(&tv, &boottime); + *retval = (int)CONVTCK(tv); + return 0; } /* XXX move */ @@ -725,6 +736,10 @@ linux_newuname(struct proc *p, struct linux_newuname_args *args, int *retval) sizeof(struct linux_newuname_t))); } +struct linux_utimbuf { + linux_time_t l_actime; + linux_time_t l_modtime; +}; int linux_utime(struct proc *p, struct linux_utime_args *args, int *retval) @@ -733,7 +748,9 @@ linux_utime(struct proc *p, struct linux_utime_args *args, int *retval) char *path; struct timeval *tptr; } */ bsdutimes; - struct timeval tv; + struct timeval tv[2], *tvp; + struct linux_utimbuf lut; + int error; caddr_t sg; sg = stackgap_init(); @@ -742,9 +759,21 @@ linux_utime(struct proc *p, struct linux_utime_args *args, int *retval) #ifdef DEBUG printf("Linux-emul(%d): utime(%s, *)\n", p->p_pid, args->fname); #endif - tv.tv_sec = (long)args->timeptr; /* XXX: wrong?? */ - tv.tv_usec = 0; - bsdutimes.tptr = &tv; + if (args->times) { + if ((error = copyin(args->times, &lut, sizeof lut))) + return error; + tv[0].tv_sec = lut.l_actime; + tv[0].tv_usec = 0; + tv[1].tv_sec = lut.l_modtime; + tv[1].tv_usec = 0; + /* so that utimes can copyin */ + tvp = (struct timeval *)stackgap_alloc(&sg, sizeof(tv)); + if ((error = copyout(tv, tvp, sizeof(tv)))) + return error; + bsdutimes.tptr = tvp; + } else + bsdutimes.tptr = NULL; + bsdutimes.path = args->fname; return utimes(p, &bsdutimes, retval); } diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index a227f2c..ba0a870 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -2,7 +2,7 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * created from Id: syscalls.master,v 1.1 1996/03/02 19:04:15 peter Exp + * created from Id: syscalls.master,v 1.2 1996/03/04 20:58:47 peter Exp */ #ifndef _LINUX_SYSPROTO_H_ @@ -96,7 +96,7 @@ struct linux_pause_args { }; struct linux_utime_args { char * fname; - struct linux_time_t * timeptr; + struct linux_utimbuf * times; }; struct linux_stty_args { int dummy; @@ -185,6 +185,8 @@ struct linux_sigsetmask_args { linux_sigset_t mask; }; struct linux_sigsuspend_args { + int restart; + linux_sigset_t oldmask; linux_sigset_t mask; }; struct linux_sigpending_args { diff --git a/sys/i386/linux/linux_signal.c b/sys/i386/linux/linux_signal.c index 7bcbef7..92fd23b 100644 --- a/sys/i386/linux/linux_signal.c +++ b/sys/i386/linux/linux_signal.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_signal.c,v 1.4 1996/03/02 19:37:58 peter Exp $ + * $Id: linux_signal.c,v 1.5 1996/03/02 21:00:11 peter Exp $ */ #include <sys/param.h> @@ -267,11 +267,15 @@ linux_sigpending(struct proc *p, struct linux_sigpending_args *args,int *retval) return copyout(&linux_sig, args->mask, sizeof(linux_sig)); } +/* + * Linux has two extra args, restart and oldmask. We dont use these, + * but it seems that "restart" is actually a context pointer that + * enables the signal to happen with a different register set. + */ int linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args,int *retval) { struct sigsuspend_args tmp; - int error; #ifdef DEBUG printf("Linux-emul(%d): sigsuspend(%08x)\n", p->p_pid, args->mask); @@ -284,7 +288,6 @@ int linux_pause(struct proc *p, struct linux_pause_args *args,int *retval) { struct sigsuspend_args tmp; - int error; #ifdef DEBUG printf("Linux-emul(%d): pause()\n", p->p_pid); diff --git a/sys/i386/linux/linux_syscall.h b/sys/i386/linux/linux_syscall.h index 6e0c5fd..02503a1 100644 --- a/sys/i386/linux/linux_syscall.h +++ b/sys/i386/linux/linux_syscall.h @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from Id: syscalls.master,v 1.1 1996/03/02 19:04:15 peter Exp + * created from Id: syscalls.master,v 1.2 1996/03/04 20:58:47 peter Exp */ #define LINUX_SYS_linux_setup 0 diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c index 4e32271..10fa638 100644 --- a/sys/i386/linux/linux_sysent.c +++ b/sys/i386/linux/linux_sysent.c @@ -2,7 +2,7 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from Id: syscalls.master,v 1.1 1996/03/02 19:04:15 peter Exp + * created from Id: syscalls.master,v 1.2 1996/03/04 20:58:47 peter Exp */ #include <sys/types.h> @@ -93,7 +93,7 @@ struct sysent linux_sysent[] = { { 1, (sy_call_t *)linux_sigsetmask }, /* 69 = linux_sigsetmask */ { 2, (sy_call_t *)setreuid }, /* 70 = setreuid */ { 2, (sy_call_t *)setregid }, /* 71 = setregid */ - { 1, (sy_call_t *)linux_sigsuspend }, /* 72 = linux_sigsuspend */ + { 3, (sy_call_t *)linux_sigsuspend }, /* 72 = linux_sigsuspend */ { 1, (sy_call_t *)linux_sigpending }, /* 73 = linux_sigpending */ { 2, (sy_call_t *)osethostname }, /* 74 = osethostname */ { 2, (sy_call_t *)osetrlimit }, /* 75 = osetrlimit */ |