diff options
Diffstat (limited to 'sys')
47 files changed, 2722 insertions, 804 deletions
diff --git a/sys/compat/common/Makefile b/sys/compat/common/Makefile index 63bc7ec2d36..c8565ae9429 100644 --- a/sys/compat/common/Makefile +++ b/sys/compat/common/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3 1995/06/28 03:00:20 cgd Exp $ +# $NetBSD: Makefile,v 1.4 1995/10/20 00:34:15 cgd Exp $ LIB= compat NOPIC= @@ -6,7 +6,7 @@ NOPIC= .PATH: ${COMPATREL}${COMPATDIR} CC= ${COMPATCC} -CFLAGS+= ${COMPATCFLAGS:S@-I.@-I${COMPATREL}.@g} +CFLAGS= ${COMPATCFLAGS:S@-I.@-I${COMPATREL}.@g} SRCS= compat_tty.c compat_util.c kern_exit_43.c kern_info_09.c \ kern_info_43.c kern_prot_43.c kern_resource_43.c kern_sig_43.c \ diff --git a/sys/compat/common/compat_util.c b/sys/compat/common/compat_util.c index c2fe362c80b..1334e216cd7 100644 --- a/sys/compat/common/compat_util.c +++ b/sys/compat/common/compat_util.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat_util.c,v 1.2.2.1 1995/10/22 08:22:47 mycroft Exp $ */ +/* $NetBSD: compat_util.c,v 1.3 1995/10/22 08:20:44 mycroft Exp $ */ /* * Copyright (c) 1994 Christos Zoulas diff --git a/sys/compat/freebsd/freebsd_file.c b/sys/compat/freebsd/freebsd_file.c index 26f2819e7d1..d997c2b7447 100644 --- a/sys/compat/freebsd/freebsd_file.c +++ b/sys/compat/freebsd/freebsd_file.c @@ -1,4 +1,4 @@ -/* $NetBSD: freebsd_file.c,v 1.1 1995/10/10 01:19:30 mycroft Exp $ */ +/* $NetBSD: freebsd_file.c,v 1.2 1995/11/07 22:27:21 gwr Exp $ */ /* * Copyright (c) 1995 Frank van der Linden diff --git a/sys/compat/freebsd/freebsd_syscall.h b/sys/compat/freebsd/freebsd_syscall.h index 950d7035cc5..154a6749ae9 100644 --- a/sys/compat/freebsd/freebsd_syscall.h +++ b/sys/compat/freebsd/freebsd_syscall.h @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp + * created from NetBSD: syscalls.master,v 1.3 1995/10/10 18:28:40 mycroft Exp */ #define FREEBSD_SYS_syscall 0 diff --git a/sys/compat/freebsd/freebsd_syscallargs.h b/sys/compat/freebsd/freebsd_syscallargs.h index 8cd71d90c08..54fa7e0ab88 100644 --- a/sys/compat/freebsd/freebsd_syscallargs.h +++ b/sys/compat/freebsd/freebsd_syscallargs.h @@ -2,7 +2,7 @@ * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp + * created from NetBSD: syscalls.master,v 1.3 1995/10/10 18:28:40 mycroft Exp */ #define syscallarg(x) union { x datum; register_t pad; } diff --git a/sys/compat/freebsd/freebsd_syscalls.c b/sys/compat/freebsd/freebsd_syscalls.c index 0131c0fbcf7..12339cf2423 100644 --- a/sys/compat/freebsd/freebsd_syscalls.c +++ b/sys/compat/freebsd/freebsd_syscalls.c @@ -2,7 +2,7 @@ * System call names. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp + * created from NetBSD: syscalls.master,v 1.3 1995/10/10 18:28:40 mycroft Exp */ char *freebsd_syscallnames[] = { diff --git a/sys/compat/freebsd/freebsd_sysent.c b/sys/compat/freebsd/freebsd_sysent.c index 651817e1d84..98f8dc1f960 100644 --- a/sys/compat/freebsd/freebsd_sysent.c +++ b/sys/compat/freebsd/freebsd_sysent.c @@ -2,7 +2,7 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp + * created from NetBSD: syscalls.master,v 1.3 1995/10/10 18:28:40 mycroft Exp */ #include <sys/param.h> diff --git a/sys/compat/freebsd/syscalls.master b/sys/compat/freebsd/syscalls.master index 1f59e4d75e0..fc0c0743c8a 100644 --- a/sys/compat/freebsd/syscalls.master +++ b/sys/compat/freebsd/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.2.2.1 1995/10/20 16:07:40 pk Exp $ + $NetBSD: syscalls.master,v 1.3 1995/10/10 18:28:40 mycroft Exp $ ; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94 diff --git a/sys/compat/hpux/files.hpux b/sys/compat/hpux/files.hpux index a95e7509382..ef39e01b8a3 100644 --- a/sys/compat/hpux/files.hpux +++ b/sys/compat/hpux/files.hpux @@ -1,4 +1,4 @@ -# $NetBSD: files.hpux,v 1.1 1995/05/10 16:45:27 christos Exp $ +# $NetBSD: files.hpux,v 1.2 1995/11/28 08:39:52 thorpej Exp $ # # Config.new file description for machine-independent HPUX compat code. # Included by ports that need it. @@ -7,6 +7,8 @@ # own file lists. file compat/hpux/hpux_compat.c compat_hpux +file compat/hpux/hpux_file.c compat_hpux +file compat/hpux/hpux_exec.c compat_hpux file compat/hpux/hpux_net.c compat_hpux file compat/hpux/hpux_sig.c compat_hpux file compat/hpux/hpux_syscalls.c compat_hpux diff --git a/sys/compat/hpux/hpux.h b/sys/compat/hpux/hpux.h index b4ec592f366..f5d7a67f99c 100644 --- a/sys/compat/hpux/hpux.h +++ b/sys/compat/hpux/hpux.h @@ -1,6 +1,7 @@ -/* $NetBSD: hpux.h,v 1.8 1995/05/10 16:45:29 christos Exp $ */ +/* $NetBSD: hpux.h,v 1.10 1995/12/08 07:54:43 thorpej Exp $ */ /* + * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -95,28 +96,40 @@ struct hpux_sgttyb { #define bsdtohpuxdev(d) ((major(d) << 24) | minor(d)) struct hpux_stat { - long hst_dev; - u_long hst_ino; - u_short hst_mode; - short hst_nlink; - u_short hst_uid; - u_short hst_gid; - long hst_rdev; - long hst_size; - time_t hst_atime; - int hst_spare1; - time_t hst_mtime; - int hst_spare2; - time_t hst_ctime; - int hst_spare3; - long hst_blksize; - long hst_blocks; - u_int hst_remote; - long hst_netdev; - u_long hst_netino; - long hst_spare4[9]; + long hst_dev; + u_long hst_ino; + u_short hst_mode; + short hst_nlink; + u_short hst_old_uid; /* these have since moved */ + u_short hst_old_gid; /* ... */ + long hst_rdev; + long hst_size; + long hst_atime; + int hst_spare1; + long hst_mtime; + int hst_spare2; + long hst_ctime; + int hst_spare3; + long hst_blksize; + long hst_blocks; + u_int hst_remote; + long hst_netdev; + u_long hst_netino; + u_short hst_cnode; + u_short hst_rcnode; + u_short hst_netsite; + short hst_fstype; + long hst_realdev; + u_short hst_basemode; + u_short hst_spareshort1; + long hst_uid; + long hst_gid; + long hst_spare4[3]; }; +#define HST_REMOTE_REMOTE 0x01 /* set if file is remote */ +#define HST_REMOTE_ACL 0x02 /* set if file has ACL entries */ + /* from old timeb.h */ struct hpux_otimeb { time_t time; @@ -308,3 +321,10 @@ struct hpux_sigaction { * code to the HP-UX EAGAIN value. */ #define OEAGAIN 82 + +/* + * Extensions to the fd_ofileflags flags. + */ +#define HPUX_UF_NONBLOCK_ON 0x10 +#define HPUX_UF_FNDELAY_ON 0x20 +#define HPUX_UF_FIONBIO_ON 0x40 diff --git a/sys/compat/hpux/hpux_compat.c b/sys/compat/hpux/hpux_compat.c index bc127ad804c..8ec3ddde6b7 100644 --- a/sys/compat/hpux/hpux_compat.c +++ b/sys/compat/hpux/hpux_compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpux_compat.c,v 1.19 1995/10/07 06:26:34 mycroft Exp $ */ +/* $NetBSD: hpux_compat.c,v 1.22 1995/12/09 04:05:52 mycroft Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -121,20 +121,7 @@ extern char sigcode[], esigcode[]; extern struct sysent hpux_sysent[]; extern char *hpux_syscallnames[]; -struct emul emul_hpux = { - "hpux", - bsdtohpuxerrnomap, - sendsig, - HPUX_SYS_syscall, - HPUX_SYS_MAXSYSCALL, - hpux_sysent, - hpux_syscallnames, - 0, - copyargs, - setregs, - sigcode, - esigcode, -}; +static int hpux_scale __P((struct timeval *)); /* * HP-UX fork and vfork need to map the EAGAIN return value appropriately. @@ -148,7 +135,7 @@ hpux_sys_fork(p, v, retval) struct hpux_sys_fork_args *uap = v; int error; - error = sys_fork(p, (struct fork_args *) uap, retval); + error = sys_fork(p, v, retval); if (error == EAGAIN) error = OEAGAIN; return (error); @@ -163,28 +150,12 @@ hpux_sys_vfork(p, v, retval) struct hpux_sys_vfork_args *uap = v; int error; - error = sys_vfork(p, (struct vfork_args *) uap, retval); + error = sys_vfork(p, v, retval); if (error == EAGAIN) error = OEAGAIN; return (error); } -int -hpux_sys_execv(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct hpux_sys_execv_args *uap = v; - struct sys_execve_args ap; - - SCARG(&ap, path) = SCARG(uap, path); - SCARG(&ap, argp) = SCARG(uap, argp); - SCARG(&ap, envp) = NULL; - - return sys_execve(p, &ap, retval); -} - /* * HP-UX versions of wait and wait3 actually pass the parameters * (status pointer, options, rusage) into the kernel rather than @@ -306,209 +277,6 @@ hpux_sys_waitpid(p, v, retval) } /* - * Old creat system call. - */ -int -hpux_sys_creat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct hpux_sys_creat_args *uap = v; - struct sys_open_args oap; - - SCARG(&oap, path) = SCARG(uap, path); - SCARG(&oap, flags) = O_WRONLY | O_CREAT | O_TRUNC; - SCARG(&oap, mode) = SCARG(uap, mode); - - return sys_open(p, &oap, retval); -} - -/* - * XXX extensions to the fd_ofileflags flags. - * Hate to put this there, but they do need to be per-file. - */ -#define UF_NONBLOCK_ON 0x10 -#define UF_FNDELAY_ON 0x20 -#define UF_FIONBIO_ON 0x40 - -/* - * Must remap some bits in the mode mask. - * O_CREAT, O_TRUNC, and O_EXCL must be remapped, - * O_NONBLOCK is remapped and remembered, - * O_FNDELAY is remembered, - * O_SYNCIO is removed entirely. - */ -int -hpux_sys_open(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct hpux_sys_open_args *uap = v; - int mode, error; - - mode = SCARG(uap, mode); - SCARG(uap, mode) &= - ~(HPUXNONBLOCK|HPUXFSYNCIO|HPUXFEXCL|HPUXFTRUNC|HPUXFCREAT); - if (mode & HPUXFCREAT) { - /* - * simulate the pre-NFS behavior that opening a - * file for READ+CREATE ignores the CREATE (unless - * EXCL is set in which case we will return the - * proper error). - */ - if ((mode & HPUXFEXCL) || (FFLAGS(mode) & FWRITE)) - SCARG(uap, mode) |= O_CREAT; - } - if (mode & HPUXFTRUNC) - SCARG(uap, mode) |= O_TRUNC; - if (mode & HPUXFEXCL) - SCARG(uap, mode) |= O_EXCL; - if (mode & HPUXNONBLOCK) - SCARG(uap, mode) |= O_NDELAY; - error = sys_open(p, (struct open_args *) uap, retval); - /* - * Record non-blocking mode for fcntl, read, write, etc. - */ - if (error == 0 && (SCARG(uap, mode) & O_NDELAY)) - p->p_fd->fd_ofileflags[*retval] |= - (mode & HPUXNONBLOCK) ? UF_NONBLOCK_ON : UF_FNDELAY_ON; - return (error); -} - -int -hpux_sys_fcntl(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct hpux_sys_fcntl_args *uap = v; - int mode, error, flg = F_POSIX; - struct file *fp; - char *pop; - struct hpux_flock hfl; - struct flock fl; - struct vnode *vp; - - if ((unsigned)SCARG(uap, fd) >= p->p_fd->fd_nfiles || - (fp = p->p_fd->fd_ofiles[SCARG(uap, fd)]) == NULL) - return (EBADF); - pop = &p->p_fd->fd_ofileflags[SCARG(uap, fd)]; - switch (SCARG(uap, cmd)) { - case F_SETFL: - if (SCARG(uap, arg) & HPUXNONBLOCK) - *pop |= UF_NONBLOCK_ON; - else - *pop &= ~UF_NONBLOCK_ON; - if (SCARG(uap, arg) & HPUXNDELAY) - *pop |= UF_FNDELAY_ON; - else - *pop &= ~UF_FNDELAY_ON; - if (*pop & (UF_NONBLOCK_ON|UF_FNDELAY_ON|UF_FIONBIO_ON)) - SCARG(uap, arg) |= FNONBLOCK; - else - SCARG(uap, arg) &= ~FNONBLOCK; - SCARG(uap, arg) &= ~(HPUXNONBLOCK|HPUXFSYNCIO|HPUXFREMOTE); - break; - case F_GETFL: - case F_DUPFD: - case F_GETFD: - case F_SETFD: - break; - - case HPUXF_SETLKW: - flg |= F_WAIT; - /* Fall into F_SETLK */ - - case HPUXF_SETLK: - if (fp->f_type != DTYPE_VNODE) - return (EBADF); - vp = (struct vnode *)fp->f_data; - /* Copy in the lock structure */ - error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl, - sizeof (hfl)); - if (error) - return (error); - fl.l_start = hfl.hl_start; - fl.l_len = hfl.hl_len; - fl.l_pid = hfl.hl_pid; - fl.l_type = hfl.hl_type; - fl.l_whence = hfl.hl_whence; - if (fl.l_whence == SEEK_CUR) - fl.l_start += fp->f_offset; - switch (fl.l_type) { - - case F_RDLCK: - if ((fp->f_flag & FREAD) == 0) - return (EBADF); - p->p_flag |= P_ADVLOCK; - return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg)); - - case F_WRLCK: - if ((fp->f_flag & FWRITE) == 0) - return (EBADF); - p->p_flag |= P_ADVLOCK; - return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg)); - - case F_UNLCK: - return (VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &fl, - F_POSIX)); - - default: - return (EINVAL); - } - - case F_GETLK: - if (fp->f_type != DTYPE_VNODE) - return (EBADF); - vp = (struct vnode *)fp->f_data; - /* Copy in the lock structure */ - error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl, - sizeof (hfl)); - if (error) - return (error); - fl.l_start = hfl.hl_start; - fl.l_len = hfl.hl_len; - fl.l_pid = hfl.hl_pid; - fl.l_type = hfl.hl_type; - fl.l_whence = hfl.hl_whence; - if (fl.l_whence == SEEK_CUR) - fl.l_start += fp->f_offset; - if (error = VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX)) - return (error); - hfl.hl_start = fl.l_start; - hfl.hl_len = fl.l_len; - hfl.hl_pid = fl.l_pid; - hfl.hl_type = fl.l_type; - hfl.hl_whence = fl.l_whence; - return (copyout((caddr_t)&hfl, (caddr_t)SCARG(uap, arg), - sizeof (hfl))); - - default: - return (EINVAL); - } - error = sys_fcntl(p, uap, retval); - if (error == 0 && SCARG(uap, cmd) == F_GETFL) { - mode = *retval; - *retval &= ~(O_CREAT|O_TRUNC|O_EXCL); - if (mode & FNONBLOCK) { - if (*pop & UF_NONBLOCK_ON) - *retval |= HPUXNONBLOCK; - if ((*pop & UF_FNDELAY_ON) == 0) - *retval &= ~HPUXNDELAY; - } - if (mode & O_CREAT) - *retval |= HPUXFCREAT; - if (mode & O_TRUNC) - *retval |= HPUXFTRUNC; - if (mode & O_EXCL) - *retval |= HPUXFEXCL; - } - return (error); -} - -/* * Read and write calls. Same as BSD except for non-blocking behavior. * There are three types of non-blocking reads/writes in HP-UX checked * in the following order: @@ -530,10 +298,10 @@ hpux_sys_read(p, v, retval) if (error == EWOULDBLOCK) { char *fp = &p->p_fd->fd_ofileflags[SCARG(uap, fd)]; - if (*fp & UF_NONBLOCK_ON) { + if (*fp & HPUX_UF_NONBLOCK_ON) { *retval = -1; error = OEAGAIN; - } else if (*fp & UF_FNDELAY_ON) { + } else if (*fp & HPUX_UF_FNDELAY_ON) { *retval = 0; error = 0; } @@ -554,10 +322,10 @@ hpux_sys_write(p, v, retval) if (error == EWOULDBLOCK) { char *fp = &p->p_fd->fd_ofileflags[SCARG(uap, fd)]; - if (*fp & UF_NONBLOCK_ON) { + if (*fp & HPUX_UF_NONBLOCK_ON) { *retval = -1; error = OEAGAIN; - } else if (*fp & UF_FNDELAY_ON) { + } else if (*fp & HPUX_UF_FNDELAY_ON) { *retval = 0; error = 0; } @@ -578,10 +346,10 @@ hpux_sys_readv(p, v, retval) if (error == EWOULDBLOCK) { char *fp = &p->p_fd->fd_ofileflags[SCARG(uap, fd)]; - if (*fp & UF_NONBLOCK_ON) { + if (*fp & HPUX_UF_NONBLOCK_ON) { *retval = -1; error = OEAGAIN; - } else if (*fp & UF_FNDELAY_ON) { + } else if (*fp & HPUX_UF_FNDELAY_ON) { *retval = 0; error = 0; } @@ -602,10 +370,10 @@ hpux_sys_writev(p, v, retval) if (error == EWOULDBLOCK) { char *fp = &p->p_fd->fd_ofileflags[SCARG(uap, fd)]; - if (*fp & UF_NONBLOCK_ON) { + if (*fp & HPUX_UF_NONBLOCK_ON) { *retval = -1; error = OEAGAIN; - } else if (*fp & UF_FNDELAY_ON) { + } else if (*fp & HPUX_UF_FNDELAY_ON) { *retval = 0; error = 0; } @@ -798,64 +566,6 @@ hpux_sys_sysconf(p, v, retval) } int -hpux_sys_stat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct hpux_sys_stat_args *uap = v; - - return (hpux_stat1(SCARG(uap, path), SCARG(uap, sb), FOLLOW, p)); -} - -int -hpux_sys_lstat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct hpux_sys_lstat_args *uap = v; - - return (hpux_stat1(SCARG(uap, path), SCARG(uap, sb), NOFOLLOW, p)); -} - -int -hpux_sys_fstat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct hpux_sys_fstat_args *uap = v; - register struct filedesc *fdp = p->p_fd; - register struct file *fp; - struct stat sb; - int error; - - if (((unsigned)SCARG(uap, fd)) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) - return (EBADF); - - switch (fp->f_type) { - - case DTYPE_VNODE: - error = vn_stat((struct vnode *)fp->f_data, &sb, p); - break; - - case DTYPE_SOCKET: - error = soo_stat((struct socket *)fp->f_data, &sb, p); - break; - - default: - panic("fstat"); - /*NOTREACHED*/ - } - /* is this right for sockets?? */ - if (error == 0) - error = bsdtohpuxstat(&sb, SCARG(uap, sb)); - return (error); -} - -int hpux_sys_ulimit(p, v, retval) struct proc *p; void *v; @@ -1179,81 +889,6 @@ hpux_sys_mmap(p, v, retval) return (sys_mmap(p, &nargs, retval)); } -hpux_stat1(fname, hsb, follow, p) - char *fname; - struct hpux_stat *hsb; - int follow; - struct proc *p; -{ - int error; - struct stat sb; - struct nameidata nd; - - NDINIT(&nd, LOOKUP, follow | LOCKLEAF, UIO_USERSPACE, fname, p); - if (error = namei(&nd)) - return (error); - error = vn_stat(nd.ni_vp, &sb, p); - vput(nd.ni_vp); - if (error == 0) - error = bsdtohpuxstat(&sb, hsb); - return (error); -} - -#ifdef hp300 -#include "grf.h" -#define NHIL 1 /* XXX */ -#endif - -#if NGRF > 0 -extern int grfopen __P((dev_t dev, int oflags, int devtype, struct proc *p)); -#endif - -#if NHIL > 0 -extern int hilopen __P((dev_t dev, int oflags, int devtype, struct proc *p)); -#endif - -#include <sys/conf.h> - -int -bsdtohpuxstat(sb, hsb) - struct stat *sb; - struct hpux_stat *hsb; -{ - struct hpux_stat ds; - - bzero((caddr_t)&ds, sizeof(ds)); - ds.hst_dev = (u_short)sb->st_dev; - ds.hst_ino = (u_long)sb->st_ino; - ds.hst_mode = sb->st_mode; - ds.hst_nlink = sb->st_nlink; - ds.hst_uid = (u_short)sb->st_uid; - ds.hst_gid = (u_short)sb->st_gid; - ds.hst_rdev = bsdtohpuxdev(sb->st_rdev); - - /* XXX: I don't want to talk about it... */ - if ((sb->st_mode & S_IFMT) == S_IFCHR) -#if NGRF > 0 - if (cdevsw[major(sb->st_rdev)].d_open == grfopen) - ds.hst_rdev = grfdevno(sb->st_rdev); - else -#endif -#if NHIL > 0 - if (cdevsw[major(sb->st_rdev)].d_open == hilopen) - ds.hst_rdev = hildevno(sb->st_rdev); -#endif - - if (sb->st_size < (quad_t)1 << 32) - ds.hst_size = (long)sb->st_size; - else - ds.hst_size = -2; - ds.hst_atime = sb->st_atime; - ds.hst_mtime = sb->st_mtime; - ds.hst_ctime = sb->st_ctime; - ds.hst_blksize = sb->st_blksize; - ds.hst_blocks = sb->st_blocks; - return(copyout((caddr_t)&ds, (caddr_t)hsb, sizeof(ds))); -} - int hpuxtobsdioctl(com) u_long com; @@ -1358,14 +993,14 @@ hpux_sys_ioctl(p, v, retval) int tmp; if (*(int *)dt) - *ofp |= UF_FIONBIO_ON; + *ofp |= HPUX_UF_FIONBIO_ON; else - *ofp &= ~UF_FIONBIO_ON; + *ofp &= ~HPUX_UF_FIONBIO_ON; /* * Only set/clear if O_NONBLOCK/FNDELAY not in effect */ - if ((*ofp & (UF_NONBLOCK_ON|UF_FNDELAY_ON)) == 0) { - tmp = *ofp & UF_FIONBIO_ON; + if ((*ofp & (HPUX_UF_NONBLOCK_ON|HPUX_UF_FNDELAY_ON)) == 0) { + tmp = *ofp & HPUX_UF_FIONBIO_ON; error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (caddr_t)&tmp, p); } @@ -1690,7 +1325,6 @@ hpux_sys_getaccess(p, v, retval) /* * XXX: This needs to be in hpux_machdep.c !! */ -extern char kstack[]; #define UOFF(f) ((int)&((struct user *)0)->f) #define HPUOFF(f) ((int)&((struct hpux_user *)0)->f) @@ -1703,7 +1337,10 @@ struct bsdfp { /* * Brutal hack! Map HP-UX u-area offsets into BSD k-stack offsets. + * + * XXX move to hpux_machdep.c */ +int hpuxtobsduoff(off, isps, p) int *off, *isps; struct proc *p; @@ -1736,7 +1373,7 @@ hpuxtobsduoff(off, isps, p) * for simplicity. */ if (off < (int *)ctob(UPAGES)) - off = (int *)((u_int)off + (u_int)kstack); + off = (int *)((u_int)off + (u_int)p->p_addr); /* XXX */ /* * General registers. @@ -1773,7 +1410,7 @@ hpuxtobsduoff(off, isps, p) */ else raddr = (u_int) &ar0[(int)(off - ar0)]; - return((int)(raddr - (u_int)kstack)); + return((int)(raddr - (u_int)p->p_addr)); /* XXX */ } #endif /* everything else */ @@ -1784,6 +1421,8 @@ hpuxtobsduoff(off, isps, p) * Kludge up a uarea dump so that HP-UX debuggers can find out * what they need. IMPORTANT NOTE: we do not EVEN attempt to * convert the entire user struct. + * + * XXX move to hpux_machdep.c */ int hpux_dumpu(vp, cred) @@ -1852,9 +1491,10 @@ hpux_dumpu(vp, cred) (int *)NULL, p); /* * Dump the remaining UPAGES-1 pages normally + * XXX Spot the wild guess. */ if (!error) - error = vn_rdwr(UIO_WRITE, vp, kstack + ctob(1), + error = vn_rdwr(UIO_WRITE, vp, (caddr_t)p->p_addr + ctob(1), ctob(UPAGES-1), (off_t)ctob(1), UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *)NULL, p); free((caddr_t)faku, M_TEMP); @@ -1863,30 +1503,22 @@ hpux_dumpu(vp, cred) } /* - * The remaining routines are essentially the same as those in kern_xxx.c - * and vfs_xxx.c as defined under "#ifdef COMPAT". We replicate them here - * to avoid COMPAT_HPUX dependencies in those files and to make sure that - * HP-UX compatibility still works even when COMPAT is not defined. - * - * These are still needed as of HP-UX 7.05. + * Ancient HP-UX system calls. Some 9.x executables even use them! */ -#ifdef COMPAT_HPUX_6X - #define HPUX_HZ 50 -#include "sys/times.h" +#include <sys/times.h> /* * SYS V style setpgrp() */ int -compat_hpux_6x_sys_setpgrp(p, v, retval) +hpux_sys_setpgrp_6x(p, v, retval) register struct proc *p; void *v; register_t *retval; { - struct compat_hpux_6x_sys_setpgrp_args *uap = v; if (p->p_pid != p->p_pgid) enterpgrp(p, p->p_pid, 0); @@ -1895,32 +1527,34 @@ compat_hpux_6x_sys_setpgrp(p, v, retval) } int -compat_hpux_6x_sys_time(p, v, retval) +hpux_sys_time_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct compat_hpux_6x_sys_time_args *uap = v; - + struct hpux_sys_time_6x_args /* { + syscallarg(time_t *) t; + } */ *uap = v; int error = 0; struct timeval tv; microtime(&tv); - if (SCARG(uap, t)) - error = copyout(&tv.tv_sec, SCARG(uap, t), - sizeof(*(SCARG(uap, t)))); + if (SCARG(uap, t) != NULL) + error = copyout(&tv.tv_sec, SCARG(uap, t), sizeof(time_t)); - *retval = (int) tv.tv_sec; - return error; + *retval = (register_t)tv.tv_sec; + return (error); } int -compat_hpux_6x_sys_stime(p, v, retval) +hpux_sys_stime_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct compat_hpux_6x_sys_stime_args *uap = v; + struct hpux_sys_stime_6x_args /* { + syscallarg(int) time; + } */ *uap = v; struct timeval tv; int s, error; @@ -1937,12 +1571,14 @@ compat_hpux_6x_sys_stime(p, v, retval) } int -compat_hpux_6x_sys_ftime(p, v, retval) +hpux_sys_ftime_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct compat_hpux_6x_sys_ftime_args *uap = v; + struct hpux_sys_ftime_6x_args /* { + syscallarg(struct hpux_timeb *) tp; + } */ *uap = v; struct hpux_otimeb tb; int s; @@ -1956,12 +1592,14 @@ compat_hpux_6x_sys_ftime(p, v, retval) } int -compat_hpux_6x_sys_alarm(p, v, retval) +hpux_sys_alarm_6x(p, v, retval) register struct proc *p; void *v; register_t *retval; { - register struct compat_hpux_6x_sys_alarm_args *uap = v; + struct hpux_sys_alarm_6x_args /* { + syscallarg(int) deltat; + } */ *uap = v; int s = splhigh(); untimeout(realitexpire, (caddr_t)p); @@ -1983,12 +1621,14 @@ compat_hpux_6x_sys_alarm(p, v, retval) } int -compat_hpux_6x_sys_nice(p, v, retval) +hpux_sys_nice_6x(p, v, retval) register struct proc *p; void *v; register_t *retval; { - register struct compat_hpux_6x_sys_nice_args *uap = v; + struct hpux_sys_nice_6x_args /* { + syscallarg(int) nval; + } */ *uap = v; int error; error = donice(p, p, (p->p_nice-NZERO)+SCARG(uap, nval)); @@ -1998,12 +1638,14 @@ compat_hpux_6x_sys_nice(p, v, retval) } int -compat_hpux_6x_sys_times(p, v, retval) +hpux_sys_times_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct compat_hpux_6x_sys_times_args *uap = v; + struct hpux_sys_times_6x_args /* { + syscallarg(struct tms *) tms; + } */ *uap = v; struct timeval ru, rs; struct tms atms; int error; @@ -2016,7 +1658,8 @@ compat_hpux_6x_sys_times(p, v, retval) error = copyout((caddr_t)&atms, (caddr_t)SCARG(uap, tms), sizeof (atms)); if (error == 0) - *(time_t *)retval = hpux_scale(&time) - hpux_scale(&boottime); + *(time_t *)retval = hpux_scale((struct timeval *)&time) - + hpux_scale(&boottime); return (error); } @@ -2025,7 +1668,7 @@ compat_hpux_6x_sys_times(p, v, retval) * What we really do is return 1/HPUX_HZ-th of a second since that * is what HP-UX returns. */ -int +static int hpux_scale(tvp) register struct timeval *tvp; { @@ -2037,12 +1680,15 @@ hpux_scale(tvp) * Can't set ICHG. */ int -compat_hpux_6x_sys_utime(p, v, retval) +hpux_sys_utime_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct compat_hpux_6x_sys_utime_args *uap = v; + struct hpux_sys_utime_6x_args /* { + syscallarg(char *) fname; + syscallarg(time_t *) tptr; + } */ *uap = v; register struct vnode *vp; struct vattr vattr; time_t tv[2]; @@ -2075,90 +1721,13 @@ compat_hpux_6x_sys_utime(p, v, retval) } int -compat_hpux_6x_sys_pause(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct compat_hpux_6x_sys_pause_args *uap = v; - - (void) tsleep(kstack, PPAUSE | PCATCH, "pause", 0); - /* always return EINTR rather than ERESTART... */ - return (EINTR); -} - -/* - * The old fstat system call. - */ -int -compat_hpux_6x_sys_fstat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct compat_hpux_6x_sys_fstat_args *uap = v; - register struct filedesc *fdp = p->p_fd; - struct file *fp; - - if (((unsigned)SCARG(uap, fd)) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) - return (EBADF); - if (fp->f_type != DTYPE_VNODE) - return (EINVAL); - return (compat_hpux_6x_stat1((struct vnode *)fp->f_data, - SCARG(uap, sb), p)); -} - -/* - * Old stat system call. This version follows links. - */ -int -compat_hpux_6x_sys_stat(p, v, retval) +hpux_sys_pause_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct compat_hpux_6x_sys_stat_args *uap = v; - int error; - struct nameidata nd; - - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); - if (error = namei(&nd)) - return (error); - error = compat_hpux_6x_stat1(nd.ni_vp, SCARG(uap, sb), p); - vput(nd.ni_vp); - return (error); -} - -int -compat_hpux_6x_stat1(vp, ub, p) - struct vnode *vp; - struct hpux_ostat *ub; - struct proc *p; -{ - struct hpux_ostat ohsb; - struct stat sb; - int error; - - error = vn_stat(vp, &sb, p); - if (error) - return (error); + struct sys_sigsuspend_args bsa; - ohsb.hst_dev = sb.st_dev; - ohsb.hst_ino = sb.st_ino; - ohsb.hst_mode = sb.st_mode; - ohsb.hst_nlink = sb.st_nlink; - ohsb.hst_uid = sb.st_uid; - ohsb.hst_gid = sb.st_gid; - ohsb.hst_rdev = sb.st_rdev; - if (sb.st_size < (quad_t)1 << 32) - ohsb.hst_size = sb.st_size; - else - ohsb.hst_size = -2; - ohsb.hst_atime = sb.st_atime; - ohsb.hst_mtime = sb.st_mtime; - ohsb.hst_ctime = sb.st_ctime; - return (copyout((caddr_t)&ohsb, (caddr_t)ub, sizeof(ohsb))); + SCARG(&bsa, mask) = p->p_sigmask; + return (sys_sigsuspend(p, &bsa, retval)); } -#endif diff --git a/sys/compat/hpux/hpux_exec.c b/sys/compat/hpux/hpux_exec.c new file mode 100644 index 00000000000..e9102e9cbb9 --- /dev/null +++ b/sys/compat/hpux/hpux_exec.c @@ -0,0 +1,343 @@ +/* $NetBSD: hpux_exec.c,v 1.2 1995/12/08 07:54:50 thorpej Exp $ */ + +/* + * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. + * Copyright (c) 1993, 1994 Christopher G. Demetriou + * + * 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 + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +/* + * Glue for exec'ing HP-UX executables and the HP-UX execv() system call. + * Based on sys/kern/exec_aout.c + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/malloc.h> +#include <sys/mount.h> +#include <sys/namei.h> +#include <sys/user.h> +#include <sys/vnode.h> +#include <sys/mman.h> +#include <sys/stat.h> + +#include <vm/vm.h> +#include <vm/vm_param.h> +#include <vm/vm_map.h> + +#include <machine/cpu.h> +#include <machine/reg.h> + +#include <sys/syscallargs.h> + +#include <compat/hpux/hpux.h> +#include <compat/hpux/hpux_util.h> +#include <compat/hpux/hpux_syscall.h> +#include <compat/hpux/hpux_syscallargs.h> + +const char hpux_emul_path[] = "/emul/hpux"; +extern char sigcode[], esigcode[]; +extern struct sysent hpux_sysent[]; +extern char *hpux_syscallnames[]; +extern int bsdtohpuxerrnomap[]; + +static int exec_hpux_prep_nmagic __P((struct proc *, struct exec_package *)); +static int exec_hpux_prep_zmagic __P((struct proc *, struct exec_package *)); +static int exec_hpux_prep_omagic __P((struct proc *, struct exec_package *)); +static int vmcmd_hpux_copy_exec __P((struct proc *, struct exec_vmcmd *)); + +struct emul emul_hpux = { + "hpux", + bsdtohpuxerrnomap, + sendsig, + HPUX_SYS_syscall, + HPUX_SYS_MAXSYSCALL, + hpux_sysent, + hpux_syscallnames, + 0, + copyargs, + setregs, + sigcode, + esigcode, +}; + +int +exec_hpux_makecmds(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *hpux_ep = epp->ep_hdr; + short sysid, magic; + int error = ENOEXEC; + + magic = HPUX_MAGIC(hpux_ep); + sysid = HPUX_SYSID(hpux_ep); + + /* + * XXX This will lose if there's ever an hp700 port. + */ + if (sysid != MID_HPUX) + return (ENOEXEC); + + switch (magic) { + case OMAGIC: + error = exec_hpux_prep_omagic(p, epp); + break; + + case NMAGIC: + error = exec_hpux_prep_nmagic(p, epp); + break; + + case ZMAGIC: + error = exec_hpux_prep_zmagic(p, epp); + break; + } + + if (error == 0) { + /* set up command for exec header */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_hpux_copy_exec, + sizeof(struct hpux_exec), (long)epp->ep_hdr, NULLVP, 0, 0); + + /* set up our emulation information */ + epp->ep_emul = &emul_hpux; + } else + kill_vmcmds(&epp->ep_vmcmds); + + return (error); +} + +static int +exec_hpux_prep_nmagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *execp = epp->ep_hdr; + long bsize, baddr; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->ha_text; + epp->ep_daddr = epp->ep_taddr + roundup(execp->ha_text, HPUX__LDPGSZ); + epp->ep_dsize = execp->ha_data + execp->ha_bss; + epp->ep_entry = execp->ha_entry; + + /* set up command for text segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->ha_text, + epp->ep_taddr, epp->ep_vp, HPUX_TXTOFF(*execp, NMAGIC), + VM_PROT_READ|VM_PROT_EXECUTE); + + /* set up command for data segment */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->ha_data, + epp->ep_daddr, epp->ep_vp, HPUX_DATAOFF(*execp, NMAGIC), + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + baddr = roundup(epp->ep_daddr + execp->ha_data, NBPG); + bsize = epp->ep_daddr + epp->ep_dsize - baddr; + if (bsize > 0) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, + NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + return (exec_aout_setup_stack(p, epp)); +} + +static int +exec_hpux_prep_zmagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *execp = epp->ep_hdr; + long bsize, baddr; + long nontext; + int (*vm_func) __P((struct proc *, struct exec_vmcmd *)); + + /* + * Check if vnode is in open for writing, because we want to + * demand-page out of it. If it is, don't do it, for various + * reasons. + */ + if ((execp->ha_text != 0 || execp->ha_data != 0) && + epp->ep_vp->v_writecount != 0) + return (ETXTBSY); + epp->ep_vp->v_flag |= VTEXT; + + /* + * HP-UX ZMAGIC executables need to have their segment + * sizes frobbed. + */ + nontext = execp->ha_data + execp->ha_bss; + execp->ha_text = ctob(btoc(execp->ha_text)); + execp->ha_data = ctob(btoc(execp->ha_data)); + execp->ha_bss = nontext - execp->ha_data; + if (execp->ha_bss < 0) + execp->ha_bss = 0; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->ha_text; + epp->ep_daddr = epp->ep_taddr + roundup(execp->ha_text, HPUX__LDPGSZ); + epp->ep_dsize = execp->ha_data + execp->ha_bss; + epp->ep_entry = execp->ha_entry; + + /* + * If our __LDPGSZ doesn't match HP-UX's, we can't demand-page + * the executable. + */ + if (__LDPGSZ == HPUX__LDPGSZ) + vm_func = vmcmd_map_pagedvn; + else + vm_func = vmcmd_map_readvn; + + /* set up command for text segment */ + NEW_VMCMD(&epp->ep_vmcmds, vm_func, execp->ha_text, + epp->ep_taddr, epp->ep_vp, HPUX_TXTOFF(*execp, ZMAGIC), + VM_PROT_READ|VM_PROT_EXECUTE); + + /* set up command for data segment */ + NEW_VMCMD(&epp->ep_vmcmds, vm_func, execp->ha_data, + epp->ep_daddr, epp->ep_vp, HPUX_DATAOFF(*execp, ZMAGIC), + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + baddr = roundup(epp->ep_daddr + execp->ha_data, NBPG); + bsize = epp->ep_daddr + epp->ep_dsize - baddr; + if (bsize > 0) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, + NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + return (exec_aout_setup_stack(p, epp)); +} + +/* + * HP-UX's version of OMAGIC. + */ +static int +exec_hpux_prep_omagic(p, epp) + struct proc *p; + struct exec_package *epp; +{ + struct hpux_exec *execp = epp->ep_hdr; + long dsize, bsize, baddr; + + epp->ep_taddr = 0; + epp->ep_tsize = execp->ha_text; + epp->ep_daddr = epp->ep_taddr + roundup(execp->ha_text, HPUX__LDPGSZ); + epp->ep_dsize = execp->ha_data + execp->ha_bss; + epp->ep_entry = execp->ha_entry; + + /* set up command for text and data segments */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, + execp->ha_text + execp->ha_data, epp->ep_taddr, epp->ep_vp, + HPUX_TXTOFF(*execp, OMAGIC), + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* set up command for bss segment */ + baddr = roundup(epp->ep_daddr + execp->ha_data, NBPG); + bsize = epp->ep_daddr + epp->ep_dsize - baddr; + if (bsize > 0) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, + NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + /* + * Make sure (# of pages) mapped above equals (vm_tsize + vm_dsize); + * obreak(2) relies on this fact. Both `vm_tsize' and `vm_dsize' are + * computed (in execve(2)) by rounding *up* `ep_tsize' and `ep_dsize' + * respectively to page boundaries. + * Compensate `ep_dsize' for the amount of data covered by the last + * text page. + */ + dsize = epp->ep_dsize + execp->ha_text - roundup(execp->ha_text, NBPG); + epp->ep_dsize = (dsize > 0) ? dsize : 0; + return (exec_aout_setup_stack(p, epp)); +} + +/* + * We need to stash the exec header in the pcb, so we define + * this vmcmd to do it for us, since vmcmds are executed once + * we're committed to the exec (i.e. the old program has been unmapped). + * + * The address of the header is in ev->ev_addr and the length is + * in ev->ev_len. + */ +static int +vmcmd_hpux_copy_exec(p, ev) + struct proc *p; + struct exec_vmcmd *ev; +{ + struct hpux_exec *execp = (struct hpux_exec *)ev->ev_addr; + + /* + * In the event some brave soul attempts to use this on a non-hp300, + * attempt to ensure that things don't get trashed when copying + * the exec header into the pcb. + */ + if (ev->ev_len > sizeof(p->p_addr->u_md.md_exec)) + return (EINVAL); + bcopy((caddr_t)ev->ev_addr, p->p_addr->u_md.md_exec, ev->ev_len); + + /* + * Deal with misc. HP-UX process attributes. + * XXX move to hpux_machdep.c + */ + if (execp->ha_trsize & HPUXM_VALID) { + if (execp->ha_trsize & HPUXM_DATAWT) + p->p_md.md_flags &= ~MDP_CCBDATA; + + if (execp->ha_trsize & HPUXM_STKWT) + p->p_md.md_flags & ~MDP_CCBSTACK; + } + + return (0); +} + +/* + * The HP-UX execv(2) system call. + * + * Just check the alternate emulation path, and pass it on to the NetBSD + * execve(). + */ +int +hpux_sys_execv(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_execv_args /* { + syscallarg(char *) path; + syscallarg(char **) argv; + } */ *uap = v; + struct sys_execve_args ap; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&ap, path) = SCARG(uap, path); + SCARG(&ap, argp) = SCARG(uap, argp); + SCARG(&ap, envp) = NULL; + + return sys_execve(p, &ap, retval); +} diff --git a/sys/compat/hpux/hpux_exec.h b/sys/compat/hpux/hpux_exec.h index 3f524c2b9e0..6002d08a263 100644 --- a/sys/compat/hpux/hpux_exec.h +++ b/sys/compat/hpux/hpux_exec.h @@ -1,6 +1,7 @@ -/* $NetBSD: hpux_exec.h,v 1.5 1994/10/26 02:45:16 cgd Exp $ */ +/* $NetBSD: hpux_exec.h,v 1.6 1995/11/28 08:39:45 thorpej Exp $ */ /* + * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -42,22 +43,81 @@ * @(#)hpux_exec.h 8.1 (Berkeley) 6/10/93 */ +#ifndef _HPUX_EXEC_H_ +#define _HPUX_EXEC_H_ + /* * HPUX a.out header format */ struct hpux_exec { long ha_magic; /* magic number */ short ha_version; /* version ID */ - short ha_pad0; /* doesn't matter */ + short ha_shlhw; /* shared lib "highwater" mark */ long ha_misc; /* misc. info */ -unsigned long ha_text; /* size of text segment */ -unsigned long ha_data; /* size of initialized data */ -unsigned long ha_bss; /* size of uninitialized data */ -unsigned long ha_pad2[5]; /* doesn't matter */ -unsigned long ha_entry; /* entry point */ -unsigned long ha_pad3[4]; /* doesn't matter */ + long ha_text; /* size of text segment */ + long ha_data; /* size of initialized data */ + long ha_bss; /* size of uninitialized data */ + long ha_trsize; /* size of text relocation */ + long ha_drsize; /* size of data relocation */ + long ha_pascal; /* pascal section size */ + long ha_symbols; /* symbol table size */ + long ha_pad0; + long ha_entry; /* entry point */ + long ha_pad1; + long ha_supsyms; /* supplementary symbol table */ + long ha_drelocs; /* non-PIC relocation info */ + long ha_extentions; /* file offset of special extensions */ }; +#define HPUX_EXEC_HDR_SIZE (sizeof(struct hpux_exec)) + +#define HPUX_MAGIC(ha) ((ha)->ha_magic & 0xffff) +#define HPUX_SYSID(ha) (((ha)->ha_magic >> 16) & 0xffff) + +/* + * Additional values for HPUX_MAGIC() + */ +#define HPUX_MAGIC_RELOC 0x0106 /* relocatable object */ +#define HPUX_MAGIC_DL 0x010d /* dynamic load library */ +#define HPUX_MAGIC_SHL 0x010e /* shared library */ + +#define HPUX__LDPGSZ 4096 /* align to this */ +#define HPUX__LDPGSHIFT 12 /* log2(HPUX__LDPGSZ) */ + +#define HPUX__SEGMENT_ROUND(x) \ + (((x) + HPUX__LDPGSZ - 1) & ~(HPUX__LDPGSZ - 1)) + +#define HPUX_TXTOFF(x, m) \ + ((((m) == ZMAGIC) || \ + ((m) == HPUX_MAGIC_SHL) || \ + ((m) == HPUX_MAGIC_DL)) ? \ + HPUX__LDPGSZ : HPUX_EXEC_HDR_SIZE) + +#define HPUX_DATAOFF(x, m) \ + ((((m) == ZMAGIC) || \ + ((m) == HPUX_MAGIC_SHL) || \ + ((m) == HPUX_MAGIC_DL)) ? \ + (HPUX__LDPGSZ + HPUX__SEGMENT_ROUND((x).ha_text)) : \ + (HPUX_EXEC_HDR_SIZE + (x).ha_text)) + +#define HPUX_PASOFF(x, m) \ + ((((m) == ZMAGIC) || \ + ((m) == HPUX_MAGIC_SHL) || \ + ((m) == HPUX_MAGIC_DL)) ? \ + (HPUX__LDPGSZ + HPUX__SEGMENT_ROUND((x).ha_text) + \ + HPUX__SEGMENT_ROUND((x).ha_data)) : \ + (HPUX_EXEC_HDR_SIZE + (x).ha_text + (x).ha_data)) + +#define HPUX_SYMOFF(x, m) (HPUX_PASOFF((x), (m)) + (x).ha_pascal) +#define HPUX_SUPSYMOFF(x, m) (HPUX_SYMOFF((x), (m)) + (x).ha_symbols) +#define HPUX_RTEXTOFF(x, m) (HPUX_SUPSYMOFF((x), (m)) + (x).ha_supsyms) +#define HPUX_RDATAOFF(x, m) (HPUX_RTEXTOFF((x), (m)) + (x).ha_trsize) +#define HPUX_EXTOFF(x, m) ((x).ha_extentions) + #define HPUXM_VALID 0x00000001 #define HPUXM_STKWT 0x02000000 #define HPUXM_DATAWT 0x04000000 + +int exec_hpux_makecmds __P((struct proc *, struct exec_package *)); + +#endif /* _HPUX_EXEC_H_ */ diff --git a/sys/compat/hpux/hpux_file.c b/sys/compat/hpux/hpux_file.c new file mode 100644 index 00000000000..1116c577c91 --- /dev/null +++ b/sys/compat/hpux/hpux_file.c @@ -0,0 +1,892 @@ +/* $NetBSD: hpux_file.c,v 1.2 1995/12/08 07:54:53 thorpej Exp $ */ + +/* + * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. + * + * from: Utah $Hdr: hpux_compat.c 1.64 93/08/05$ + * + * @(#)hpux_compat.c 8.4 (Berkeley) 2/13/94 + */ + +/* + * File-related routines for HP-UX binary compatibility. Partially + * modeled after sys/compat/linux/linux_file.c + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/signalvar.h> +#include <sys/kernel.h> +#include <sys/filedesc.h> +#include <sys/proc.h> +#include <sys/buf.h> +#include <sys/wait.h> +#include <sys/file.h> +#include <sys/namei.h> +#include <sys/vnode.h> +#include <sys/ioctl.h> +#include <sys/ptrace.h> +#include <sys/stat.h> +#include <sys/syslog.h> +#include <sys/malloc.h> +#include <sys/mount.h> +#include <sys/ipc.h> +#include <sys/user.h> +#include <sys/mman.h> + +#include <machine/cpu.h> +#include <machine/reg.h> +#include <machine/psl.h> +#include <machine/vmparam.h> + +#include <sys/syscallargs.h> + +#include <compat/hpux/hpux.h> +#include <compat/hpux/hpux_util.h> +#include <compat/hpux/hpux_termio.h> +#include <compat/hpux/hpux_syscall.h> +#include <compat/hpux/hpux_syscallargs.h> + +static int hpux_stat1 __P((struct proc *, void *, register_t *, int)); +static void bsd_to_hpux_stat __P((struct stat *, struct hpux_stat *)); +static void bsd_to_hpux_ostat __P((struct stat *, struct hpux_ostat *)); + +/* + * HP-UX creat(2) system call. + * + * Just call open(2) with the TRUNC, CREAT and WRONLY flags. + */ +int +hpux_sys_creat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_creat_args /* { + syscallarg(char *) path; + syscallarg(int) mode; + } */ *uap = v; + + struct sys_open_args oa; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); + + SCARG(&oa, path) = SCARG(uap, path); + SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY; + SCARG(&oa, mode) = SCARG(uap, mode); + + return sys_open(p, &oa, retval); +} + +/* + * HP-UX open(2) system call. + * + * We need to remap some of the bits in the mode mask: + * + * - O_CREAT, O_TRUNC, and O_EXCL must me remapped. + * - O_NONBLOCK is remapped and remembered. + * - O_FNDELAY is remembered. + * - O_SYNCIO is removed entirely. + */ +int +hpux_sys_open(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_open_args /* { + syscallarg(char *) path; + syscallarg(int) flags; + syscallarg(int) mode; + } */ *uap = v; + struct sys_open_args oa; + int flags, nflags, error; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + + /* + * Deal with the mode flags first, since they will affect + * how we check for the alternate path. + */ + flags = SCARG(uap, flags); + nflags = + flags & ~(HPUXNONBLOCK|HPUXFSYNCIO|HPUXFEXCL|HPUXFTRUNC|HPUXFCREAT); + if (flags & HPUXFCREAT) { + /* + * Simulate the pre-NFS behavior that opening a + * file for READ+CREATE ignores the CREATE (unless + * EXCL is set in which case we will return the + * proper error). + */ + if ((flags & HPUXFEXCL) || (FFLAGS(flags) & FWRITE)) + nflags |= O_CREAT; + } + if (flags & HPUXFTRUNC) + nflags |= O_TRUNC; + if (flags & HPUXFEXCL) + nflags |= O_EXCL; + if (flags & HPUXNONBLOCK) + nflags |= O_NDELAY; + + /* + * Do the alternate pathname check. + */ + if (SCARG(&oa, flags) & O_CREAT) + HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); + else + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + /* + * Fill in the new arguments and call the NetBSD open(2). + */ + SCARG(&oa, path) = SCARG(uap, path); + SCARG(&oa, flags) = nflags; + SCARG(&oa, mode) = SCARG(uap, mode); + + error = sys_open(p, &oa, retval); + + /* + * Record non-blocking mode for fcntl, read, write, etc. + */ + if ((error == 0) && (nflags & O_NDELAY)) + p->p_fd->fd_ofileflags[*retval] |= + (flags & HPUXNONBLOCK) ? + HPUX_UF_NONBLOCK_ON : HPUX_UF_FNDELAY_ON; + + return (error); +} + +/* + * HP-UX fcntl(2) system call. + */ +int +hpux_sys_fcntl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_fcntl_args /* { + syscallarg(int) fd; + syscallarg(int) cmd; + syscallarg(int) arg; + } */ *uap = v; + int arg, mode, error, flg = F_POSIX; + struct file *fp; + char *pop; + struct hpux_flock hfl; + struct flock fl; + struct vnode *vp; + struct sys_fcntl_args fa; + + if ((u_int)SCARG(uap, fd) > p->p_fd->fd_nfiles || + (fp = p->p_fd->fd_ofiles[SCARG(uap, fd)]) == NULL) + return (EBADF); + + pop = &p->p_fd->fd_ofileflags[SCARG(uap, fd)]; + arg = SCARG(uap, arg); + + switch (SCARG(uap, cmd)) { + case F_SETFL: + if (arg & HPUXNONBLOCK) + *pop |= HPUX_UF_NONBLOCK_ON; + else + *pop &= ~HPUX_UF_NONBLOCK_ON; + + if (arg & HPUXNDELAY) + *pop |= HPUX_UF_FNDELAY_ON; + else + *pop &= ~HPUX_UF_FNDELAY_ON; + + if (*pop & (HPUX_UF_NONBLOCK_ON|HPUX_UF_FNDELAY_ON|HPUX_UF_FIONBIO_ON)) + arg |= FNONBLOCK; + else + arg &= ~FNONBLOCK; + + arg &= ~(HPUXNONBLOCK|HPUXFSYNCIO|HPUXFREMOTE); + break; + + case F_GETFL: + case F_DUPFD: + case F_GETFD: + case F_SETFD: + break; + + case HPUXF_SETLKW: + flg |= F_WAIT; + /* Fall into F_SETLK */ + + case HPUXF_SETLK: + if (fp->f_type != DTYPE_VNODE) + return (EBADF); + + vp = (struct vnode *)fp->f_data; + + /* Copy in the lock structure */ + error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl, + sizeof (hfl)); + if (error) + return (error); + + fl.l_start = hfl.hl_start; + fl.l_len = hfl.hl_len; + fl.l_pid = hfl.hl_pid; + fl.l_type = hfl.hl_type; + fl.l_whence = hfl.hl_whence; + if (fl.l_whence == SEEK_CUR) + fl.l_start += fp->f_offset; + + switch (fl.l_type) { + case F_RDLCK: + if ((fp->f_flag & FREAD) == 0) + return (EBADF); + + p->p_flag |= P_ADVLOCK; + return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg)); + + case F_WRLCK: + if ((fp->f_flag & FWRITE) == 0) + return (EBADF); + p->p_flag |= P_ADVLOCK; + return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg)); + + case F_UNLCK: + return (VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &fl, + F_POSIX)); + + default: + return (EINVAL); + } + /* NOTREACHED */ + + case F_GETLK: + if (fp->f_type != DTYPE_VNODE) + return (EBADF); + + vp = (struct vnode *)fp->f_data; + + /* Copy in the lock structure */ + error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl, + sizeof (hfl)); + if (error) + return (error); + + fl.l_start = hfl.hl_start; + fl.l_len = hfl.hl_len; + fl.l_pid = hfl.hl_pid; + fl.l_type = hfl.hl_type; + fl.l_whence = hfl.hl_whence; + if (fl.l_whence == SEEK_CUR) + fl.l_start += fp->f_offset; + + if (error = VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX)) + return (error); + + hfl.hl_start = fl.l_start; + hfl.hl_len = fl.l_len; + hfl.hl_pid = fl.l_pid; + hfl.hl_type = fl.l_type; + hfl.hl_whence = fl.l_whence; + return (copyout((caddr_t)&hfl, (caddr_t)SCARG(uap, arg), + sizeof (hfl))); + + default: + return (EINVAL); + } + + /* + * Pass whatever's left on to the NetBSD fcntl(2). + */ + SCARG(&fa, fd) = SCARG(uap, fd); + SCARG(&fa, cmd) = SCARG(uap, cmd); + SCARG(&fa, arg) = (void *)arg; + + error = sys_fcntl(p, &fa, retval); + + if ((error == 0) && (SCARG(&fa, cmd) == F_GETFL)) { + mode = *retval; + *retval &= ~(O_CREAT|O_TRUNC|O_EXCL); + if (mode & FNONBLOCK) { + if (*pop & HPUX_UF_NONBLOCK_ON) + *retval |= HPUXNONBLOCK; + + if ((*pop & HPUX_UF_FNDELAY_ON) == 0) + *retval &= ~HPUXNDELAY; + } + if (mode & O_CREAT) + *retval |= HPUXFCREAT; + + if (mode & O_TRUNC) + *retval |= HPUXFTRUNC; + + if (mode & O_EXCL) + *retval |= HPUXFEXCL; + } + return (error); +} + +/* + * HP-UX fstat(2) system call. + */ +int +hpux_sys_fstat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_fstat_args /* { + syscallarg(int) fd; + syscallarg(struct hpux_stat *) sb; + } */ *uap = v; + struct sys_fstat_args fsa; + struct hpux_stat tmphst; + struct stat *st, tmpst; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + + st = stackgap_alloc(&sg, sizeof (struct stat)); + + SCARG(&fsa, fd) = SCARG(uap, fd); + SCARG(&fsa, sb) = st; + + if ((error = sys_fstat(p, &fsa, retval))) + return (error); + + if ((error = copyin(st, &tmpst, sizeof(tmpst)))) + return (error); + + bsd_to_hpux_stat(&tmpst, &tmphst); + + return (copyout(&tmphst, SCARG(uap, sb), sizeof(struct hpux_stat))); +} + +/* + * HP-UX stat(2) system call. + */ +int +hpux_sys_stat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + + return (hpux_stat1(p, v, retval, 0)); +} + +/* + * HP-UX lstat(2) system call. + */ +int +hpux_sys_lstat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + + return (hpux_stat1(p, v, retval, 1)); +} + +/* + * Do the meat of stat(2) and lstat(2). + */ +static int +hpux_stat1(p, v, retval, dolstat) + struct proc *p; + void *v; + register_t *retval; + int dolstat; +{ + struct hpux_sys_stat_args /* { + syscallarg(char *) path; + syscallarg(struct hpux_stat *) sb; + } */ *uap = v; + struct sys_stat_args sa; + struct hpux_stat tmphst; + struct stat *st, tmpst; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + st = stackgap_alloc(&sg, sizeof (struct stat)); + SCARG(&sa, ub) = st; + SCARG(&sa, path) = SCARG(uap, path); + + if (dolstat) + error = sys_lstat(p, &sa, retval); + else + error = sys_stat(p, &sa, retval); + + if (error) + return (error); + + if ((error = copyin(st, &tmpst, sizeof(tmpst)))) + return (error); + + bsd_to_hpux_stat(&tmpst, &tmphst); + + return (copyout(&tmphst, SCARG(uap, sb), sizeof(struct hpux_stat))); +} + +/* + * The old HP-UX fstat(2) system call. + */ +int +hpux_sys_fstat_6x(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_fstat_6x_args /* { + syscallarg(int) fd; + syscallarg(struct hpux_ostat *) sb; + } */ *uap = v; + struct sys_fstat_args fsa; + struct hpux_ostat tmphst; + struct stat *st, tmpst; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + + st = stackgap_alloc(&sg, sizeof (struct stat)); + + SCARG(&fsa, fd) = SCARG(uap, fd); + SCARG(&fsa, sb) = st; + + if ((error = sys_fstat(p, &fsa, retval))) + return (error); + + if ((error = copyin(st, &tmpst, sizeof(tmpst)))) + return (error); + + bsd_to_hpux_ostat(&tmpst, &tmphst); + + return (copyout(&tmphst, SCARG(uap, sb), sizeof(struct hpux_ostat))); +} + +/* + * The old HP-UX stat(2) system call. + */ +int +hpux_sys_stat_6x(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_stat_6x_args /* { + syscallarg(char *) path; + syscallarg(struct hpux_ostat *) sb; + } */ *uap = v; + struct sys_stat_args sa; + struct hpux_ostat tmphst; + struct stat *st, tmpst; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + st = stackgap_alloc(&sg, sizeof (struct stat)); + SCARG(&sa, ub) = st; + SCARG(&sa, path) = SCARG(uap, path); + + if ((error = sys_stat(p, &sa, retval))) + return (error); + + if ((error = copyin(st, &tmpst, sizeof(tmpst)))) + return (error); + + bsd_to_hpux_ostat(&tmpst, &tmphst); + + return (copyout(&tmphst, SCARG(uap, sb), sizeof(struct hpux_ostat))); +} + +/* XXX: Set up a machdep callback. */ +#ifdef hp300 +#include "grf.h" +#define NHIL 1 /* XXX */ +#endif + +#if NGRF > 0 +extern int grfopen __P((dev_t dev, int oflags, int devtype, struct proc *p)); +#endif + +#if NHIL > 0 +extern int hilopen __P((dev_t dev, int oflags, int devtype, struct proc *p)); +#endif + +#include <sys/conf.h> + +/* + * Convert a NetBSD stat structure to an HP-UX stat structure. + */ +static void +bsd_to_hpux_stat(sb, hsb) + struct stat *sb; + struct hpux_stat *hsb; +{ + + bzero((caddr_t)hsb, sizeof(struct hpux_stat)); + hsb->hst_dev = (long)sb->st_dev; + hsb->hst_ino = (u_long)sb->st_ino; + hsb->hst_mode = (u_short)sb->st_mode; + hsb->hst_nlink = (u_short)sb->st_nlink; + hsb->hst_uid = (u_long)sb->st_uid; + hsb->hst_gid = (u_long)sb->st_gid; + hsb->hst_rdev = (long)bsdtohpuxdev(sb->st_rdev); + /* + * XXX Let's just hope that the old binary doesn't lose. + */ + hsb->hst_old_uid = (u_short)sb->st_uid; + hsb->hst_old_gid = (u_short)sb->st_gid; + + /* MACHDEP CALLBACK SHOULD GO HERE! */ + /* XXX: I don't want to talk about it... */ + if ((sb->st_mode & S_IFMT) == S_IFCHR) { +#if NGRF > 0 + if (cdevsw[major(sb->st_rdev)].d_open == grfopen) { + hsb->hst_rdev = grfdevno(sb->st_rdev); + goto xxx_out; + } +#endif +#if NHIL > 0 + if (cdevsw[major(sb->st_rdev)].d_open == hilopen) { + hsb->hst_rdev = hildevno(sb->st_rdev); + goto xxx_out; + } +#endif + } + + xxx_out: + if (sb->st_size < (off_t)(((off_t)1) << 32)) + hsb->hst_size = (long)sb->st_size; + else + hsb->hst_size = -2; + hsb->hst_atime = (long)sb->st_atime; + hsb->hst_mtime = (long)sb->st_mtime; + hsb->hst_ctime = (long)sb->st_ctime; + hsb->hst_blksize = (long)sb->st_blksize; + hsb->hst_blocks = (long)sb->st_blocks; +} + +/* + * Convert a NetBSD stat structure to an old-style HP-UX stat structure. + */ +static void +bsd_to_hpux_ostat(sb, hsb) + struct stat *sb; + struct hpux_ostat *hsb; +{ + + bzero(hsb, sizeof(struct hpux_ostat)); + hsb->hst_dev = (u_short)sb->st_dev; + hsb->hst_ino = (u_short)sb->st_ino; + hsb->hst_mode = (u_short)sb->st_mode; + hsb->hst_nlink = (u_short)sb->st_nlink; + hsb->hst_uid = (u_short)sb->st_uid; + hsb->hst_gid = (u_short)sb->st_gid; + hsb->hst_rdev = (u_short)sb->st_rdev; + if (sb->st_size < (off_t)(((off_t)1) << 32)) + hsb->hst_size = (int)sb->st_size; + else + hsb->hst_size = -2; + hsb->hst_atime = (int)sb->st_atime; + hsb->hst_mtime = (int)sb->st_mtime; + hsb->hst_ctime = (int)sb->st_ctime; +} + +/* + * HP-UX access(2) system call. + */ +int +hpux_sys_access(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_access_args /* { + syscallarg(char *) path; + syscallarg(int) flags; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + return (sys_access(p, uap, retval)); +} + +/* + * HP-UX unlink(2) system call. + */ +int +hpux_sys_unlink(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_unlink_args /* { + syscallarg(char *) path; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + return (sys_unlink(p, uap, retval)); +} + +/* + * HP-UX chdir(2) system call. + */ +int +hpux_sys_chdir(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_chdir_args /* { + syscallarg(char *) path; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + return (sys_chdir(p, uap, retval)); +} + +/* + * HP-UX mknod(2) system call. + */ +int +hpux_sys_mknod(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_mknod_args /* { + syscallarg(char *) path; + syscallarg(int) mode; + syscallarf(int) dev; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + struct sys_mkfifo_args bma; + + HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); + + /* + * BSD handles FIFOs separately. + */ + if (SCARG(uap, mode) & S_IFIFO) { + SCARG(&bma, path) = SCARG(uap, path); + SCARG(&bma, mode) = SCARG(uap, mode); + return (sys_mkfifo(p, uap, retval)); + } else + return (sys_mknod(p, uap, retval)); +} + +/* + * HP-UX chmod(2) system call. + */ +int +hpux_sys_chmod(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_chmod_args /* { + syscallarg(char *) path; + syscallarg(int) mode; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + return (sys_chmod(p, uap, retval)); +} + +/* + * HP-UX chown(2) system call. + */ +int +hpux_sys_chown(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_chown_args /* { + syscallarg(char *) path; + syscallarg(int) uid; + syscallarg(int) gid; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + /* XXX What about older HP-UX executables? */ + + return (sys_chown(p, uap, retval)); +} + +/* + * HP-UX rename(2) system call. + */ +int +hpux_sys_rename(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_rename_args /* { + syscallarg(char *) from; + syscallarg(char *) to; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, from)); + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, to)); + + return (sys_rename(p, uap, retval)); +} + +/* + * HP-UX mkdir(2) system call. + */ +int +hpux_sys_mkdir(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_mkdir_args /* { + syscallarg(char *) path; + syscallarg(int) mode; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path)); + + return (sys_mkdir(p, uap, retval)); +} + +/* + * HP-UX rmdir(2) system call. + */ +int +hpux_sys_rmdir(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_rmdir_args /* { + syscallarg(char *) path; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + return (sys_rmdir(p, uap, retval)); +} + +/* + * HP-UX symlink(2) system call. + */ +int +hpux_sys_symlink(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_symlink_args /* { + syscallarg(char *) path; + syscallarg(char *) link; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + HPUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, link)); + + return (sys_symlink(p, uap, retval)); +} + +/* + * HP-UX readlink(2) system call. + */ +int +hpux_sys_readlink(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_readlink_args /* { + syscallarg(char *) path; + syscallarg(char *) buf; + syscallarg(int) count; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + return (sys_readlink(p, uap, retval)); +} + +/* + * HP-UX truncate(2) system call. + */ +int +hpux_sys_truncate(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct hpux_sys_truncate_args /* { + syscallarg(char *) path; + syscallarg(long) length; + } */ *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + + HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + return (compat_43_sys_truncate(p, uap, retval)); +} diff --git a/sys/compat/hpux/hpux_sig.c b/sys/compat/hpux/hpux_sig.c index 8443e5ae282..07bd6633f7c 100644 --- a/sys/compat/hpux/hpux_sig.c +++ b/sys/compat/hpux/hpux_sig.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpux_sig.c,v 1.14 1995/10/07 06:26:38 mycroft Exp $ */ +/* $NetBSD: hpux_sig.c,v 1.15 1995/11/28 08:39:50 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -347,14 +347,16 @@ hpux_sys_sigaction(p, v, retval) return (0); } -#ifdef COMPAT_HPUX_6X int -compat_hpux_6x_sys_ssig(p, v, retval) +hpux_sys_ssig_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct compat_hpux_6x_sys_ssig_args *uap = v; + struct hpux_sys_ssig_6x_args /* { + syscallarg(int) signo; + syscallarg(sig_t) fun; + } */ *uap = v; register int a; struct sigaction vec; register struct sigaction *sa = &vec; @@ -383,7 +385,6 @@ compat_hpux_6x_sys_ssig(p, v, retval) #endif return (0); } -#endif /* signal numbers: convert from HPUX to BSD */ int diff --git a/sys/compat/hpux/hpux_syscall.h b/sys/compat/hpux/hpux_syscall.h index 9d1924965e4..02d1e7e2eb2 100644 --- a/sys/compat/hpux/hpux_syscall.h +++ b/sys/compat/hpux/hpux_syscall.h @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp + * created from NetBSD: syscalls.master,v 1.9 1995/11/28 08:39:56 thorpej Exp */ #define HPUX_SYS_syscall 0 @@ -18,39 +18,39 @@ #define HPUX_SYS_unlink 10 #define HPUX_SYS_execv 11 #define HPUX_SYS_chdir 12 - /* 13 is compat_hpux_6x time */ +#define HPUX_SYS_time_6x 13 #define HPUX_SYS_mknod 14 #define HPUX_SYS_chmod 15 #define HPUX_SYS_chown 16 #define HPUX_SYS_obreak 17 - /* 18 is compat_hpux_6x stat */ +#define HPUX_SYS_stat_6x 18 #define HPUX_SYS_lseek 19 #define HPUX_SYS_getpid 20 #define HPUX_SYS_setuid 23 #define HPUX_SYS_getuid 24 - /* 25 is compat_hpux_6x stime */ +#define HPUX_SYS_stime_6x 25 #define HPUX_SYS_ptrace 26 - /* 27 is compat_hpux_6x alarm */ - /* 28 is compat_hpux_6x fstat */ - /* 29 is compat_hpux_6x pause */ - /* 30 is compat_hpux_6x utime */ - /* 31 is compat_hpux_6x stty */ - /* 32 is compat_hpux_6x gtty */ +#define HPUX_SYS_alarm_6x 27 +#define HPUX_SYS_fstat_6x 28 +#define HPUX_SYS_pause_6x 29 +#define HPUX_SYS_utime_6x 30 +#define HPUX_SYS_stty_6x 31 +#define HPUX_SYS_gtty_6x 32 #define HPUX_SYS_access 33 - /* 34 is compat_hpux_6x nice */ - /* 35 is compat_hpux_6x ftime */ +#define HPUX_SYS_nice_6x 34 +#define HPUX_SYS_ftime_6x 35 #define HPUX_SYS_sync 36 #define HPUX_SYS_kill 37 #define HPUX_SYS_stat 38 - /* 39 is compat_hpux_6x setpgrp */ +#define HPUX_SYS_setpgrp_6x 39 #define HPUX_SYS_lstat 40 #define HPUX_SYS_dup 41 #define HPUX_SYS_pipe 42 - /* 43 is compat_hpux_6x times */ +#define HPUX_SYS_times_6x 43 #define HPUX_SYS_profil 44 #define HPUX_SYS_setgid 46 #define HPUX_SYS_getgid 47 - /* 48 is compat_hpux_6x ssig */ +#define HPUX_SYS_ssig_6x 48 #define HPUX_SYS_ioctl 54 #define HPUX_SYS_symlink 56 #define HPUX_SYS_utssys 57 diff --git a/sys/compat/hpux/hpux_syscallargs.h b/sys/compat/hpux/hpux_syscallargs.h index 63af42f3115..045caa1396d 100644 --- a/sys/compat/hpux/hpux_syscallargs.h +++ b/sys/compat/hpux/hpux_syscallargs.h @@ -2,7 +2,7 @@ * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp + * created from NetBSD: syscalls.master,v 1.9 1995/11/28 08:39:56 thorpej Exp */ #define syscallarg(x) union { x datum; register_t pad; } @@ -34,21 +34,46 @@ struct hpux_sys_creat_args { syscallarg(int) mode; }; +struct hpux_sys_unlink_args { + syscallarg(char *) path; +}; + struct hpux_sys_execv_args { syscallarg(char *) path; syscallarg(char **) argp; }; -struct compat_hpux_6x_sys_time_args { +struct hpux_sys_chdir_args { + syscallarg(char *) path; +}; + +struct hpux_sys_time_6x_args { syscallarg(time_t *) t; }; -struct compat_hpux_6x_sys_stat_args { +struct hpux_sys_mknod_args { + syscallarg(char *) path; + syscallarg(int) mode; + syscallarg(int) dev; +}; + +struct hpux_sys_chmod_args { + syscallarg(char *) path; + syscallarg(int) mode; +}; + +struct hpux_sys_chown_args { + syscallarg(char *) path; + syscallarg(int) uid; + syscallarg(int) gid; +}; + +struct hpux_sys_stat_6x_args { syscallarg(char *) path; syscallarg(struct hpux_ostat *) sb; }; -struct compat_hpux_6x_sys_stime_args { +struct hpux_sys_stime_6x_args { syscallarg(int) time; }; @@ -59,35 +84,40 @@ struct hpux_sys_ptrace_args { syscallarg(int) data; }; -struct compat_hpux_6x_sys_alarm_args { +struct hpux_sys_alarm_6x_args { syscallarg(int) deltat; }; -struct compat_hpux_6x_sys_fstat_args { +struct hpux_sys_fstat_6x_args { syscallarg(int) fd; syscallarg(struct hpux_ostat *) sb; }; -struct compat_hpux_6x_sys_utime_args { +struct hpux_sys_utime_6x_args { syscallarg(char *) fname; syscallarg(time_t *) tptr; }; -struct compat_hpux_6x_sys_stty_args { +struct hpux_sys_stty_6x_args { syscallarg(int) fd; syscallarg(caddr_t) arg; }; -struct compat_hpux_6x_sys_gtty_args { +struct hpux_sys_gtty_6x_args { syscallarg(int) fd; syscallarg(caddr_t) arg; }; -struct compat_hpux_6x_sys_nice_args { +struct hpux_sys_access_args { + syscallarg(char *) path; + syscallarg(int) flags; +}; + +struct hpux_sys_nice_6x_args { syscallarg(int) nval; }; -struct compat_hpux_6x_sys_ftime_args { +struct hpux_sys_ftime_6x_args { syscallarg(struct hpux_timeb *) tp; }; @@ -110,11 +140,11 @@ struct hpux_sys_dup_args { syscallarg(int) fd; }; -struct compat_hpux_6x_sys_times_args { +struct hpux_sys_times_6x_args { syscallarg(struct tms *) tms; }; -struct compat_hpux_6x_sys_ssig_args { +struct hpux_sys_ssig_6x_args { syscallarg(int) signo; syscallarg(sig_t) fun; }; @@ -125,12 +155,23 @@ struct hpux_sys_ioctl_args { syscallarg(caddr_t) data; }; +struct hpux_sys_symlink_args { + syscallarg(char *) path; + syscallarg(char *) link; +}; + struct hpux_sys_utssys_args { syscallarg(struct hpux_utsname *) uts; syscallarg(int) dev; syscallarg(int) request; }; +struct hpux_sys_readlink_args { + syscallarg(char *) path; + syscallarg(char *) buf; + syscallarg(int) count; +}; + struct hpux_sys_fcntl_args { syscallarg(int) fd; syscallarg(int) cmd; @@ -213,10 +254,29 @@ struct hpux_sys_setresgid_args { syscallarg(gid_t) s; }; +struct hpux_sys_rename_args { + syscallarg(char *) from; + syscallarg(char *) to; +}; + +struct hpux_sys_truncate_args { + syscallarg(char *) path; + syscallarg(long) length; +}; + struct hpux_sys_sysconf_args { syscallarg(int) name; }; +struct hpux_sys_mkdir_args { + syscallarg(char *) path; + syscallarg(int) mode; +}; + +struct hpux_sys_rmdir_args { + syscallarg(char *) path; +}; + struct hpux_sys_getrlimit_args { syscallarg(u_int) which; syscallarg(struct ogetrlimit *) rlp; @@ -322,46 +382,46 @@ int sys_close __P((struct proc *, void *, register_t *)); int hpux_sys_wait __P((struct proc *, void *, register_t *)); int hpux_sys_creat __P((struct proc *, void *, register_t *)); int sys_link __P((struct proc *, void *, register_t *)); -int sys_unlink __P((struct proc *, void *, register_t *)); +int hpux_sys_unlink __P((struct proc *, void *, register_t *)); int hpux_sys_execv __P((struct proc *, void *, register_t *)); -int sys_chdir __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_time __P((struct proc *, void *, register_t *)); -int sys_mknod __P((struct proc *, void *, register_t *)); -int sys_chmod __P((struct proc *, void *, register_t *)); -int sys_chown __P((struct proc *, void *, register_t *)); +int hpux_sys_chdir __P((struct proc *, void *, register_t *)); +int hpux_sys_time_6x __P((struct proc *, void *, register_t *)); +int hpux_sys_mknod __P((struct proc *, void *, register_t *)); +int hpux_sys_chmod __P((struct proc *, void *, register_t *)); +int hpux_sys_chown __P((struct proc *, void *, register_t *)); int sys_obreak __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_stat __P((struct proc *, void *, register_t *)); +int hpux_sys_stat_6x __P((struct proc *, void *, register_t *)); int compat_43_sys_lseek __P((struct proc *, void *, register_t *)); int sys_getpid __P((struct proc *, void *, register_t *)); int sys_setuid __P((struct proc *, void *, register_t *)); int sys_getuid __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_stime __P((struct proc *, void *, register_t *)); +int hpux_sys_stime_6x __P((struct proc *, void *, register_t *)); int hpux_sys_ptrace __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_alarm __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_fstat __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_pause __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_utime __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_stty __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_gtty __P((struct proc *, void *, register_t *)); -int sys_access __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_nice __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_ftime __P((struct proc *, void *, register_t *)); +int hpux_sys_alarm_6x __P((struct proc *, void *, register_t *)); +int hpux_sys_fstat_6x __P((struct proc *, void *, register_t *)); +int hpux_sys_pause_6x __P((struct proc *, void *, register_t *)); +int hpux_sys_utime_6x __P((struct proc *, void *, register_t *)); +int hpux_sys_stty_6x __P((struct proc *, void *, register_t *)); +int hpux_sys_gtty_6x __P((struct proc *, void *, register_t *)); +int hpux_sys_access __P((struct proc *, void *, register_t *)); +int hpux_sys_nice_6x __P((struct proc *, void *, register_t *)); +int hpux_sys_ftime_6x __P((struct proc *, void *, register_t *)); int sys_sync __P((struct proc *, void *, register_t *)); int hpux_sys_kill __P((struct proc *, void *, register_t *)); int hpux_sys_stat __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_setpgrp __P((struct proc *, void *, register_t *)); +int hpux_sys_setpgrp_6x __P((struct proc *, void *, register_t *)); int hpux_sys_lstat __P((struct proc *, void *, register_t *)); int hpux_sys_dup __P((struct proc *, void *, register_t *)); int sys_pipe __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_times __P((struct proc *, void *, register_t *)); +int hpux_sys_times_6x __P((struct proc *, void *, register_t *)); int sys_profil __P((struct proc *, void *, register_t *)); int sys_setgid __P((struct proc *, void *, register_t *)); int sys_getgid __P((struct proc *, void *, register_t *)); -int compat_hpux_6x_sys_ssig __P((struct proc *, void *, register_t *)); +int hpux_sys_ssig_6x __P((struct proc *, void *, register_t *)); int hpux_sys_ioctl __P((struct proc *, void *, register_t *)); -int sys_symlink __P((struct proc *, void *, register_t *)); +int hpux_sys_symlink __P((struct proc *, void *, register_t *)); int hpux_sys_utssys __P((struct proc *, void *, register_t *)); -int sys_readlink __P((struct proc *, void *, register_t *)); +int hpux_sys_readlink __P((struct proc *, void *, register_t *)); int sys_execve __P((struct proc *, void *, register_t *)); int sys_umask __P((struct proc *, void *, register_t *)); int sys_chroot __P((struct proc *, void *, register_t *)); @@ -398,12 +458,12 @@ int sys_fchown __P((struct proc *, void *, register_t *)); int sys_fchmod __P((struct proc *, void *, register_t *)); int hpux_sys_setresuid __P((struct proc *, void *, register_t *)); int hpux_sys_setresgid __P((struct proc *, void *, register_t *)); -int sys_rename __P((struct proc *, void *, register_t *)); -int compat_43_sys_truncate __P((struct proc *, void *, register_t *)); +int hpux_sys_rename __P((struct proc *, void *, register_t *)); +int hpux_sys_truncate __P((struct proc *, void *, register_t *)); int compat_43_sys_ftruncate __P((struct proc *, void *, register_t *)); int hpux_sys_sysconf __P((struct proc *, void *, register_t *)); -int sys_mkdir __P((struct proc *, void *, register_t *)); -int sys_rmdir __P((struct proc *, void *, register_t *)); +int hpux_sys_mkdir __P((struct proc *, void *, register_t *)); +int hpux_sys_rmdir __P((struct proc *, void *, register_t *)); int hpux_sys_getrlimit __P((struct proc *, void *, register_t *)); int hpux_sys_setrlimit __P((struct proc *, void *, register_t *)); int hpux_sys_rtprio __P((struct proc *, void *, register_t *)); diff --git a/sys/compat/hpux/hpux_syscalls.c b/sys/compat/hpux/hpux_syscalls.c index 58930283148..2ee02aa86f3 100644 --- a/sys/compat/hpux/hpux_syscalls.c +++ b/sys/compat/hpux/hpux_syscalls.c @@ -2,7 +2,7 @@ * System call names. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp + * created from NetBSD: syscalls.master,v 1.9 1995/11/28 08:39:56 thorpej Exp */ char *hpux_syscallnames[] = { @@ -19,42 +19,42 @@ char *hpux_syscallnames[] = { "unlink", /* 10 = unlink */ "execv", /* 11 = execv */ "chdir", /* 12 = chdir */ - "compat_hpux_6x_time", /* 13 = compat_hpux_6x time */ + "time_6x", /* 13 = time_6x */ "mknod", /* 14 = mknod */ "chmod", /* 15 = chmod */ "chown", /* 16 = chown */ "obreak", /* 17 = obreak */ - "compat_hpux_6x_stat", /* 18 = compat_hpux_6x stat */ + "stat_6x", /* 18 = stat_6x */ "lseek", /* 19 = lseek */ "getpid", /* 20 = getpid */ "#21 (unimplemented mount)", /* 21 = unimplemented mount */ "#22 (unimplemented umount)", /* 22 = unimplemented umount */ "setuid", /* 23 = setuid */ "getuid", /* 24 = getuid */ - "compat_hpux_6x_stime", /* 25 = compat_hpux_6x stime */ + "stime_6x", /* 25 = stime_6x */ "ptrace", /* 26 = ptrace */ - "compat_hpux_6x_alarm", /* 27 = compat_hpux_6x alarm */ - "compat_hpux_6x_fstat", /* 28 = compat_hpux_6x fstat */ - "compat_hpux_6x_pause", /* 29 = compat_hpux_6x pause */ - "compat_hpux_6x_utime", /* 30 = compat_hpux_6x utime */ - "compat_hpux_6x_stty", /* 31 = compat_hpux_6x stty */ - "compat_hpux_6x_gtty", /* 32 = compat_hpux_6x gtty */ + "alarm_6x", /* 27 = alarm_6x */ + "fstat_6x", /* 28 = fstat_6x */ + "pause_6x", /* 29 = pause_6x */ + "utime_6x", /* 30 = utime_6x */ + "stty_6x", /* 31 = stty_6x */ + "gtty_6x", /* 32 = gtty_6x */ "access", /* 33 = access */ - "compat_hpux_6x_nice", /* 34 = compat_hpux_6x nice */ - "compat_hpux_6x_ftime", /* 35 = compat_hpux_6x ftime */ + "nice_6x", /* 34 = nice_6x */ + "ftime_6x", /* 35 = ftime_6x */ "sync", /* 36 = sync */ "kill", /* 37 = kill */ "stat", /* 38 = stat */ - "compat_hpux_6x_setpgrp", /* 39 = compat_hpux_6x setpgrp */ + "setpgrp_6x", /* 39 = setpgrp_6x */ "lstat", /* 40 = lstat */ "dup", /* 41 = dup */ "pipe", /* 42 = pipe */ - "compat_hpux_6x_times", /* 43 = compat_hpux_6x times */ + "times_6x", /* 43 = times_6x */ "profil", /* 44 = profil */ "#45 (unimplemented ki_syscall)", /* 45 = unimplemented ki_syscall */ "setgid", /* 46 = setgid */ "getgid", /* 47 = getgid */ - "compat_hpux_6x_ssig", /* 48 = compat_hpux_6x ssig */ + "ssig_6x", /* 48 = ssig_6x */ "#49 (unimplemented reserved for USG)", /* 49 = unimplemented reserved for USG */ "#50 (unimplemented reserved for USG)", /* 50 = unimplemented reserved for USG */ "#51 (unimplemented acct)", /* 51 = unimplemented acct */ diff --git a/sys/compat/hpux/hpux_sysent.c b/sys/compat/hpux/hpux_sysent.c index bad0ac8abd6..22e9507d10d 100644 --- a/sys/compat/hpux/hpux_sysent.c +++ b/sys/compat/hpux/hpux_sysent.c @@ -2,23 +2,18 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp + * created from NetBSD: syscalls.master,v 1.9 1995/11/28 08:39:56 thorpej Exp */ #include <sys/param.h> #include <sys/systm.h> #include <sys/signal.h> #include <sys/mount.h> +#include <sys/exec.h> #include <sys/syscallargs.h> #include <compat/hpux/hpux.h> #include <compat/hpux/hpux_syscallargs.h> -#ifdef COMPAT_HPUX_6X -#define compat_hpux_6x(func) __CONCAT(compat_hpux_6x_,func) -#else -#define compat_hpux_6x(func) sys_nosys -#endif - #define s(type) sizeof(type) struct sysent hpux_sysent[] = { @@ -42,24 +37,24 @@ struct sysent hpux_sysent[] = { hpux_sys_creat }, /* 8 = creat */ { 2, s(struct sys_link_args), sys_link }, /* 9 = link */ - { 1, s(struct sys_unlink_args), - sys_unlink }, /* 10 = unlink */ + { 1, s(struct hpux_sys_unlink_args), + hpux_sys_unlink }, /* 10 = unlink */ { 2, s(struct hpux_sys_execv_args), hpux_sys_execv }, /* 11 = execv */ - { 1, s(struct sys_chdir_args), - sys_chdir }, /* 12 = chdir */ - { 1, s(struct compat_hpux_6x_sys_time_args), - compat_hpux_6x(sys_time) }, /* 13 = compat_hpux_6x time */ - { 3, s(struct sys_mknod_args), - sys_mknod }, /* 14 = mknod */ - { 2, s(struct sys_chmod_args), - sys_chmod }, /* 15 = chmod */ - { 3, s(struct sys_chown_args), - sys_chown }, /* 16 = chown */ + { 1, s(struct hpux_sys_chdir_args), + hpux_sys_chdir }, /* 12 = chdir */ + { 1, s(struct hpux_sys_time_6x_args), + hpux_sys_time_6x }, /* 13 = time_6x */ + { 3, s(struct hpux_sys_mknod_args), + hpux_sys_mknod }, /* 14 = mknod */ + { 2, s(struct hpux_sys_chmod_args), + hpux_sys_chmod }, /* 15 = chmod */ + { 3, s(struct hpux_sys_chown_args), + hpux_sys_chown }, /* 16 = chown */ { 1, s(struct sys_obreak_args), sys_obreak }, /* 17 = obreak */ - { 2, s(struct compat_hpux_6x_sys_stat_args), - compat_hpux_6x(sys_stat) }, /* 18 = compat_hpux_6x stat */ + { 2, s(struct hpux_sys_stat_6x_args), + hpux_sys_stat_6x }, /* 18 = stat_6x */ { 3, s(struct compat_43_sys_lseek_args), compat_43_sys_lseek }, /* 19 = lseek */ { 0, 0, @@ -72,28 +67,28 @@ struct sysent hpux_sysent[] = { sys_setuid }, /* 23 = setuid */ { 0, 0, sys_getuid }, /* 24 = getuid */ - { 1, s(struct compat_hpux_6x_sys_stime_args), - compat_hpux_6x(sys_stime) }, /* 25 = compat_hpux_6x stime */ + { 1, s(struct hpux_sys_stime_6x_args), + hpux_sys_stime_6x }, /* 25 = stime_6x */ { 4, s(struct hpux_sys_ptrace_args), hpux_sys_ptrace }, /* 26 = ptrace */ - { 1, s(struct compat_hpux_6x_sys_alarm_args), - compat_hpux_6x(sys_alarm) }, /* 27 = compat_hpux_6x alarm */ - { 2, s(struct compat_hpux_6x_sys_fstat_args), - compat_hpux_6x(sys_fstat) }, /* 28 = compat_hpux_6x fstat */ - { 0, 0, - compat_hpux_6x(sys_pause) }, /* 29 = compat_hpux_6x pause */ - { 2, s(struct compat_hpux_6x_sys_utime_args), - compat_hpux_6x(sys_utime) }, /* 30 = compat_hpux_6x utime */ - { 2, s(struct compat_hpux_6x_sys_stty_args), - compat_hpux_6x(sys_stty) }, /* 31 = compat_hpux_6x stty */ - { 2, s(struct compat_hpux_6x_sys_gtty_args), - compat_hpux_6x(sys_gtty) }, /* 32 = compat_hpux_6x gtty */ - { 2, s(struct sys_access_args), - sys_access }, /* 33 = access */ - { 1, s(struct compat_hpux_6x_sys_nice_args), - compat_hpux_6x(sys_nice) }, /* 34 = compat_hpux_6x nice */ - { 1, s(struct compat_hpux_6x_sys_ftime_args), - compat_hpux_6x(sys_ftime) }, /* 35 = compat_hpux_6x ftime */ + { 1, s(struct hpux_sys_alarm_6x_args), + hpux_sys_alarm_6x }, /* 27 = alarm_6x */ + { 2, s(struct hpux_sys_fstat_6x_args), + hpux_sys_fstat_6x }, /* 28 = fstat_6x */ + { 0, 0, + hpux_sys_pause_6x }, /* 29 = pause_6x */ + { 2, s(struct hpux_sys_utime_6x_args), + hpux_sys_utime_6x }, /* 30 = utime_6x */ + { 2, s(struct hpux_sys_stty_6x_args), + hpux_sys_stty_6x }, /* 31 = stty_6x */ + { 2, s(struct hpux_sys_gtty_6x_args), + hpux_sys_gtty_6x }, /* 32 = gtty_6x */ + { 2, s(struct hpux_sys_access_args), + hpux_sys_access }, /* 33 = access */ + { 1, s(struct hpux_sys_nice_6x_args), + hpux_sys_nice_6x }, /* 34 = nice_6x */ + { 1, s(struct hpux_sys_ftime_6x_args), + hpux_sys_ftime_6x }, /* 35 = ftime_6x */ { 0, 0, sys_sync }, /* 36 = sync */ { 2, s(struct hpux_sys_kill_args), @@ -101,15 +96,15 @@ struct sysent hpux_sysent[] = { { 2, s(struct hpux_sys_stat_args), hpux_sys_stat }, /* 38 = stat */ { 0, 0, - compat_hpux_6x(sys_setpgrp) }, /* 39 = compat_hpux_6x setpgrp */ + hpux_sys_setpgrp_6x }, /* 39 = setpgrp_6x */ { 2, s(struct hpux_sys_lstat_args), hpux_sys_lstat }, /* 40 = lstat */ { 1, s(struct hpux_sys_dup_args), hpux_sys_dup }, /* 41 = dup */ { 0, 0, sys_pipe }, /* 42 = pipe */ - { 1, s(struct compat_hpux_6x_sys_times_args), - compat_hpux_6x(sys_times) }, /* 43 = compat_hpux_6x times */ + { 1, s(struct hpux_sys_times_6x_args), + hpux_sys_times_6x }, /* 43 = times_6x */ { 4, s(struct sys_profil_args), sys_profil }, /* 44 = profil */ { 0, 0, @@ -118,8 +113,8 @@ struct sysent hpux_sysent[] = { sys_setgid }, /* 46 = setgid */ { 0, 0, sys_getgid }, /* 47 = getgid */ - { 2, s(struct compat_hpux_6x_sys_ssig_args), - compat_hpux_6x(sys_ssig) }, /* 48 = compat_hpux_6x ssig */ + { 2, s(struct hpux_sys_ssig_6x_args), + hpux_sys_ssig_6x }, /* 48 = ssig_6x */ { 0, 0, sys_nosys }, /* 49 = unimplemented reserved for USG */ { 0, 0, @@ -134,12 +129,12 @@ struct sysent hpux_sysent[] = { hpux_sys_ioctl }, /* 54 = ioctl */ { 0, 0, sys_nosys }, /* 55 = unimplemented reboot */ - { 2, s(struct sys_symlink_args), - sys_symlink }, /* 56 = symlink */ + { 2, s(struct hpux_sys_symlink_args), + hpux_sys_symlink }, /* 56 = symlink */ { 3, s(struct hpux_sys_utssys_args), hpux_sys_utssys }, /* 57 = utssys */ - { 3, s(struct sys_readlink_args), - sys_readlink }, /* 58 = readlink */ + { 3, s(struct hpux_sys_readlink_args), + hpux_sys_readlink }, /* 58 = readlink */ { 3, s(struct sys_execve_args), sys_execve }, /* 59 = execve */ { 1, s(struct sys_umask_args), @@ -278,10 +273,10 @@ struct sysent hpux_sysent[] = { hpux_sys_setresuid }, /* 126 = setresuid */ { 3, s(struct hpux_sys_setresgid_args), hpux_sys_setresgid }, /* 127 = setresgid */ - { 2, s(struct sys_rename_args), - sys_rename }, /* 128 = rename */ - { 2, s(struct compat_43_sys_truncate_args), - compat_43_sys_truncate }, /* 129 = truncate */ + { 2, s(struct hpux_sys_rename_args), + hpux_sys_rename }, /* 128 = rename */ + { 2, s(struct hpux_sys_truncate_args), + hpux_sys_truncate }, /* 129 = truncate */ { 2, s(struct compat_43_sys_ftruncate_args), compat_43_sys_ftruncate }, /* 130 = ftruncate */ { 0, 0, @@ -294,10 +289,10 @@ struct sysent hpux_sysent[] = { sys_nosys }, /* 134 = unimplemented */ { 0, 0, sys_nosys }, /* 135 = unimplemented */ - { 2, s(struct sys_mkdir_args), - sys_mkdir }, /* 136 = mkdir */ - { 1, s(struct sys_rmdir_args), - sys_rmdir }, /* 137 = rmdir */ + { 2, s(struct hpux_sys_mkdir_args), + hpux_sys_mkdir }, /* 136 = mkdir */ + { 1, s(struct hpux_sys_rmdir_args), + hpux_sys_rmdir }, /* 137 = rmdir */ { 0, 0, sys_nosys }, /* 138 = unimplemented */ { 0, 0, diff --git a/sys/compat/hpux/hpux_tty.c b/sys/compat/hpux/hpux_tty.c index d95e1731b5f..505e00b2481 100644 --- a/sys/compat/hpux/hpux_tty.c +++ b/sys/compat/hpux/hpux_tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpux_tty.c,v 1.11 1995/10/07 06:26:40 mycroft Exp $ */ +/* $NetBSD: hpux_tty.c,v 1.13 1995/12/11 16:32:46 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -459,7 +459,7 @@ int hpuxtobsdbaud(hpux_speed) int hpux_speed; { - static char hpuxtobsdbaudtab[32] = { + static int hpuxtobsdbaudtab[32] = { B0, B50, B75, B110, B134, B150, B200, B300, B600, B0, B1200, B1800, B2400, B0, B4800, B0, B9600, B19200, B38400, B0, B0, B0, B0, B0, @@ -469,26 +469,30 @@ hpuxtobsdbaud(hpux_speed) return(hpuxtobsdbaudtab[hpux_speed & TIO_CBAUD]); } -#ifdef COMPAT_HPUX_6X - int -compat_hpux_6x_sys_gtty(p, v, retval) +hpux_sys_stty_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct compat_hpux_6x_sys_gtty_args *uap = v; + struct hpux_sys_stty_6x_args /* { + syscallarg(int) fd; + syscallarg(caddr_t) arg; + } */ *uap = v; return (getsettty(p, SCARG(uap, fd), HPUXTIOCGETP, SCARG(uap, arg))); } int -compat_hpux_6x_sys_stty(p, v, retval) +hpux_sys_gtty_6x(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct compat_hpux_6x_sys_stty_args *uap = v; + struct hpux_sys_gtty_6x_args /* { + syscallarg(int) fd; + syscallarg(caddr_t) arg; + } */ *uap = v; return (getsettty(p, SCARG(uap, fd), HPUXTIOCSETP, SCARG(uap, arg))); } @@ -545,4 +549,3 @@ getsettty(p, fdes, com, cmarg) } return (error); } -#endif diff --git a/sys/compat/hpux/hpux_util.h b/sys/compat/hpux/hpux_util.h index bd59abddaac..319a2e57923 100644 --- a/sys/compat/hpux/hpux_util.h +++ b/sys/compat/hpux/hpux_util.h @@ -1,4 +1,4 @@ -/* $NetBSD: hpux_util.h,v 1.2 1995/06/24 20:17:57 christos Exp $ */ +/* $NetBSD: hpux_util.h,v 1.3 1995/12/08 07:45:34 thorpej Exp $ */ /* * Copyright (c) 1995 Christos Zoulas @@ -32,6 +32,14 @@ #include <compat/common/compat_util.h> +extern const char hpux_emul_path[]; + +#define HPUX_CHECK_ALT_EXIST(p, sgp, path) \ + CHECK_ALT_EXIST(p, sgp, hpux_emul_path, path) + +#define HPUX_CHECK_ALT_CREAT(p, sgp, path) \ + CHECK_ALT_CREAT(p, sgp, hpux_emul_path, path) + #ifdef DEBUG_HPUX #define DPRINTF(a) printf a; #else diff --git a/sys/compat/hpux/syscalls.conf b/sys/compat/hpux/syscalls.conf index 27cb8450905..15f32874734 100644 --- a/sys/compat/hpux/syscalls.conf +++ b/sys/compat/hpux/syscalls.conf @@ -1,10 +1,10 @@ -# $NetBSD: syscalls.conf,v 1.1 1995/05/10 16:45:46 christos Exp $ +# $NetBSD: syscalls.conf,v 1.2 1995/11/28 08:39:54 thorpej Exp $ sysnames="hpux_syscalls.c" sysnumhdr="hpux_syscall.h" syssw="hpux_sysent.c" sysarghdr="hpux_syscallargs.h" -compatopts="compat_hpux_6x" +compatopts="" libcompatopts="" switchname="hpux_sysent" diff --git a/sys/compat/hpux/syscalls.master b/sys/compat/hpux/syscalls.master index aadc7871f9d..0c5c30f56f1 100644 --- a/sys/compat/hpux/syscalls.master +++ b/sys/compat/hpux/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp $ + $NetBSD: syscalls.master,v 1.9 1995/11/28 08:39:56 thorpej Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -35,6 +35,7 @@ #include <sys/systm.h> #include <sys/signal.h> #include <sys/mount.h> +#include <sys/exec.h> #include <sys/syscallargs.h> #include <compat/hpux/hpux.h> @@ -50,15 +51,16 @@ 7 STD { int hpux_sys_wait(int *status); } 8 STD { int hpux_sys_creat(char *path, int mode); } 9 NOARGS { int sys_link(char *path, char *link); } -10 NOARGS { int sys_unlink(char *path); } +10 STD { int hpux_sys_unlink(char *path); } 11 STD { int hpux_sys_execv(char * path, char * * argp); } -12 NOARGS { int sys_chdir(char *path); } -13 COMPAT_HPUX_6X { int sys_time(time_t *t); } -14 NOARGS { int sys_mknod(char *path, int mode, int dev); } -15 NOARGS { int sys_chmod(char *path, int mode); } -16 NOARGS { int sys_chown(char *path, int uid, int gid); } +12 STD { int hpux_sys_chdir(char *path); } +13 STD { int hpux_sys_time_6x(time_t *t); } +14 STD { int hpux_sys_mknod(char *path, int mode, int dev); } +15 STD { int hpux_sys_chmod(char *path, int mode); } +16 STD { int hpux_sys_chown(char *path, int uid, int gid); } 17 NOARGS { int sys_obreak(char *nsize); } -18 COMPAT_HPUX_6X { int sys_stat(char *path, struct hpux_ostat *sb); } +18 STD { int hpux_sys_stat_6x(char *path, \ + struct hpux_ostat *sb); } 19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \ int whence); } 20 NOARGS { pid_t sys_getpid(void); } @@ -66,33 +68,34 @@ 22 UNIMPL umount 23 NOARGS { int sys_setuid(uid_t uid); } 24 NOARGS { uid_t sys_getuid(void); } -25 COMPAT_HPUX_6X { int sys_stime(int time); } +25 STD { int hpux_sys_stime_6x(int time); } 26 STD { int hpux_sys_ptrace(int req, int pid, int *addr, \ int data); } -27 COMPAT_HPUX_6X { int sys_alarm(int deltat); } -28 COMPAT_HPUX_6X { int sys_fstat(int fd, struct hpux_ostat *sb); } -29 COMPAT_HPUX_6X { int sys_pause(void); } -30 COMPAT_HPUX_6X { int sys_utime(char *fname, time_t *tptr); } -31 COMPAT_HPUX_6X { int sys_stty(int fd, caddr_t arg); } -32 COMPAT_HPUX_6X { int sys_gtty(int fd, caddr_t arg); } -33 NOARGS { int sys_access(char *path, int flags); } -34 COMPAT_HPUX_6X { int sys_nice(int nval); } -35 COMPAT_HPUX_6X { int sys_ftime(struct hpux_timeb *tp); } +27 STD { int hpux_sys_alarm_6x(int deltat); } +28 STD { int hpux_sys_fstat_6x(int fd, \ + struct hpux_ostat *sb); } +29 STD { int hpux_sys_pause_6x(void); } +30 STD { int hpux_sys_utime_6x(char *fname, time_t *tptr); } +31 STD { int hpux_sys_stty_6x(int fd, caddr_t arg); } +32 STD { int hpux_sys_gtty_6x(int fd, caddr_t arg); } +33 STD { int hpux_sys_access(char *path, int flags); } +34 STD { int hpux_sys_nice_6x(int nval); } +35 STD { int hpux_sys_ftime_6x(struct hpux_timeb *tp); } 36 NOARGS { int sys_sync(void); } 37 STD { int hpux_sys_kill(pid_t pid, int signo); } 38 STD { int hpux_sys_stat(char *path, struct hpux_stat *sb); } -39 COMPAT_HPUX_6X { int sys_setpgrp(void); } +39 STD { int hpux_sys_setpgrp_6x(void); } 40 STD { int hpux_sys_lstat(char *path, struct hpux_stat *sb); } 41 STD { int hpux_sys_dup(int fd); } 42 NOARGS { int sys_pipe(void); } -43 COMPAT_HPUX_6X { int sys_times(struct tms *tms); } +43 STD { int hpux_sys_times_6x(struct tms *tms); } 44 NOARGS { int sys_profil(caddr_t samples, u_int size, \ u_int offset, u_int scale); } 45 UNIMPL ki_syscall 46 NOARGS { int sys_setgid(gid_t gid); } 47 NOARGS { gid_t sys_getgid(void); } -48 COMPAT_HPUX_6X { int sys_ssig(int signo, sig_t fun); } +48 STD { int hpux_sys_ssig_6x(int signo, sig_t fun); } 49 UNIMPL reserved for USG 50 UNIMPL reserved for USG 51 UNIMPL acct @@ -100,10 +103,11 @@ 53 UNIMPL 54 STD { int hpux_sys_ioctl(int fd, int com, caddr_t data); } 55 UNIMPL reboot -56 NOARGS { int sys_symlink(char *path, char *link); } +56 STD { int hpux_sys_symlink(char *path, char *link); } 57 STD { int hpux_sys_utssys(struct hpux_utsname *uts, \ int dev, int request); } -58 NOARGS { int sys_readlink(char *path, char *buf, int count); } +58 STD { int hpux_sys_readlink(char *path, char *buf, \ + int count); } 59 NOARGS { int sys_execve(char *path, char **argp, \ char **envp); } 60 NOARGS { int sys_umask(int newmask); } @@ -185,16 +189,16 @@ 125 UNIMPL 126 STD { int hpux_sys_setresuid(uid_t r, uid_t e, uid_t s); } 127 STD { int hpux_sys_setresgid(gid_t r, gid_t e, gid_t s); } -128 NOARGS { int sys_rename(char *from, char *to); } -129 NOARGS { int compat_43_sys_truncate(char *path, long length); } +128 STD { int hpux_sys_rename(char *from, char *to); } +129 STD { int hpux_sys_truncate(char *path, long length); } 130 NOARGS { int compat_43_sys_ftruncate(int fd, long length); } 131 UNIMPL 132 STD { int hpux_sys_sysconf(int name); } 133 UNIMPL 134 UNIMPL 135 UNIMPL -136 NOARGS { int sys_mkdir(char *path, int mode); } -137 NOARGS { int sys_rmdir(char *path); } +136 STD { int hpux_sys_mkdir(char *path, int mode); } +137 STD { int hpux_sys_rmdir(char *path); } 138 UNIMPL 139 UNIMPL 140 UNIMPL diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index a244225896a..be0bdcc4986 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.22 1995/10/09 11:24:05 mycroft Exp $ */ +/* $NetBSD: linux_misc.c,v 1.23 1995/12/09 04:01:42 mycroft Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -506,27 +506,6 @@ linux_sys_mmap(p, v, retval) } /* - * Linux doesn't use the retval[1] value to determine whether - * we are the child or parent. - */ -int -linux_sys_fork(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - int error; - - if ((error = sys_fork(p, v, retval))) - return error; - - if (retval[1] == 1) - retval[0] = 0; - - return 0; -} - -/* * This code is partly stolen from src/lib/libc/compat-43/times.c * XXX - CLK_TCK isn't declared in /sys, just in <time.h>, done here */ diff --git a/sys/compat/linux/linux_syscallargs.h b/sys/compat/linux/linux_syscallargs.h index a4d393b1a83..eaa503f0d8f 100644 --- a/sys/compat/linux/linux_syscallargs.h +++ b/sys/compat/linux/linux_syscallargs.h @@ -2,7 +2,7 @@ * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:15 mycroft Exp + * created from NetBSD: syscalls.master,v 1.14 1995/12/09 04:01:47 mycroft Exp */ #define syscallarg(x) union { x datum; register_t pad; } @@ -314,7 +314,7 @@ struct linux_sys_select_args { int sys_nosys __P((struct proc *, void *, register_t *)); int sys_exit __P((struct proc *, void *, register_t *)); -int linux_sys_fork __P((struct proc *, void *, register_t *)); +int sys_fork __P((struct proc *, void *, register_t *)); int sys_read __P((struct proc *, void *, register_t *)); int sys_write __P((struct proc *, void *, register_t *)); int linux_sys_open __P((struct proc *, void *, register_t *)); diff --git a/sys/compat/linux/linux_sysent.c b/sys/compat/linux/linux_sysent.c index 0469f99ecd1..b2fd1cbb220 100644 --- a/sys/compat/linux/linux_sysent.c +++ b/sys/compat/linux/linux_sysent.c @@ -2,7 +2,7 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:15 mycroft Exp + * created from NetBSD: syscalls.master,v 1.14 1995/12/09 04:01:47 mycroft Exp */ #include <sys/param.h> @@ -23,7 +23,7 @@ struct sysent linux_sysent[] = { { 1, s(struct sys_exit_args), sys_exit }, /* 1 = exit */ { 0, 0, - linux_sys_fork }, /* 2 = fork */ + sys_fork }, /* 2 = fork */ { 3, s(struct sys_read_args), sys_read }, /* 3 = read */ { 3, s(struct sys_write_args), diff --git a/sys/compat/linux/syscalls.master b/sys/compat/linux/syscalls.master index 20241fba899..eb2bf883da1 100644 --- a/sys/compat/linux/syscalls.master +++ b/sys/compat/linux/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:15 mycroft Exp $ + $NetBSD: syscalls.master,v 1.14 1995/12/09 04:01:47 mycroft Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -45,7 +45,7 @@ 0 NOARGS { int sys_nosys(void); } syscall 1 NOARGS { int sys_exit(int rval); } -2 STD { int linux_sys_fork(void); } +2 NOARGS { int sys_fork(void); } 3 NOARGS { int sys_read(int fd, char *buf, u_int nbyte); } 4 NOARGS { int sys_write(int fd, char *buf, u_int nbyte); } 5 STD { int linux_sys_open(char *path, int flags, int mode); } diff --git a/sys/compat/osf1/files.osf1 b/sys/compat/osf1/files.osf1 index 97585145d11..4d880eab8c6 100644 --- a/sys/compat/osf1/files.osf1 +++ b/sys/compat/osf1/files.osf1 @@ -1,4 +1,4 @@ -# $NetBSD: files.osf1,v 1.2 1995/10/07 06:27:17 mycroft Exp $ +# $NetBSD: files.osf1,v 1.3 1995/11/15 05:42:17 cgd Exp $ # # Config file description for machine-independent OSF/1 compat code. # Included by ports that need it. @@ -6,6 +6,8 @@ # ports should define any machine-specific files they need in their # own file lists. +# XXX COMPAT_OSF1 requires ECOFF + file compat/osf1/osf1_ioctl.c compat_osf1 file compat/osf1/osf1_misc.c compat_osf1 file compat/osf1/osf1_mount.c compat_osf1 diff --git a/sys/compat/svr4/Makefile b/sys/compat/svr4/Makefile new file mode 100644 index 00000000000..a5a4401770d --- /dev/null +++ b/sys/compat/svr4/Makefile @@ -0,0 +1,11 @@ +# $NetBSD: Makefile,v 1.1 1995/10/14 20:24:14 christos Exp $ + +DEP= syscalls.conf syscalls.master ../../kern/makesyscalls.sh +OBJS= svr4_sysent.c svr4_syscalls.c svr4_syscall.h svr4_syscallargs.h + +${OBJS}: ${DEP} + -mv -f svr4_sysent.c svr4_sysent.c.bak + -mv -f svr4_syscalls.c svr4_syscalls.c.bak + -mv -f svr4_syscall.h svr4_syscall.h.bak + -mv -f svr4_syscallargs.h svr4_syscallargs.h.bak + sh ../../kern/makesyscalls.sh syscalls.conf syscalls.master diff --git a/sys/compat/svr4/files.svr4 b/sys/compat/svr4/files.svr4 index fd59078d07e..23bf3e57a67 100644 --- a/sys/compat/svr4/files.svr4 +++ b/sys/compat/svr4/files.svr4 @@ -1,4 +1,4 @@ -# $NetBSD: files.svr4,v 1.4 1995/08/14 01:34:12 mycroft Exp $ +# $NetBSD: files.svr4,v 1.5 1995/10/14 20:24:17 christos Exp $ # # Config.new file description for machine-independent SVR4 compat code. # Included by ports that need it. @@ -6,18 +6,19 @@ # ports should define any machine-specific files they need in their # own file lists. -file compat/svr4/svr4_error.c compat_svr4 file compat/svr4/svr4_exec.c compat_svr4 file compat/svr4/svr4_fcntl.c compat_svr4 -file compat/svr4/svr4_filio.c compat_svr4 file compat/svr4/svr4_ioctl.c compat_svr4 file compat/svr4/svr4_misc.c compat_svr4 -file compat/svr4/svr4_net.c compat_svr4 file compat/svr4/svr4_signal.c compat_svr4 -file compat/svr4/svr4_sockio.c compat_svr4 file compat/svr4/svr4_stat.c compat_svr4 -file compat/svr4/svr4_stream.c compat_svr4 file compat/svr4/svr4_syscalls.c compat_svr4 file compat/svr4/svr4_sysent.c compat_svr4 +file compat/svr4/svr4_net.c compat_svr4 file compat/svr4/svr4_termios.c compat_svr4 +file compat/svr4/svr4_stream.c compat_svr4 file compat/svr4/svr4_ttold.c compat_svr4 +file compat/svr4/svr4_filio.c compat_svr4 +file compat/svr4/svr4_sockio.c compat_svr4 +file compat/svr4/svr4_error.c compat_svr4 +file compat/svr4/svr4_ipc.c compat_svr4 diff --git a/sys/compat/svr4/svr4_exec.c b/sys/compat/svr4/svr4_exec.c index 9393f63736a..866d421d9c8 100644 --- a/sys/compat/svr4/svr4_exec.c +++ b/sys/compat/svr4/svr4_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_exec.c,v 1.15 1995/06/24 20:29:19 christos Exp $ */ +/* $NetBSD: svr4_exec.c,v 1.16 1995/10/14 20:24:20 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -82,7 +82,6 @@ svr4_copyargs(pack, arginfo, stack, argp) void *argp; { AuxInfo *a; - struct elf_args *ap; if (!(a = (AuxInfo *) elf_copyargs(pack, arginfo, stack, argp))) return NULL; diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c index a2421d32fc7..11f7d5f46f5 100644 --- a/sys/compat/svr4/svr4_fcntl.c +++ b/sys/compat/svr4/svr4_fcntl.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_fcntl.c,v 1.13 1995/10/09 23:56:17 thorpej Exp $ */ +/* $NetBSD: svr4_fcntl.c,v 1.14 1995/10/14 20:24:24 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -48,11 +48,18 @@ #include <compat/svr4/svr4_fcntl.h> #include <compat/svr4/svr4_poll.h> +static u_long svr4_to_bsd_cmd __P((u_long)); +static int svr4_to_bsd_flags __P((int)); +static int bsd_to_svr4_flags __P((int)); +static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *)); +static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *)); +static void svr4_pollscan __P((struct proc *, struct svr4_pollfd *, int, + register_t *)); + static u_long svr4_to_bsd_cmd(cmd) - u_long cmd; + u_long cmd; { - switch (cmd) { case SVR4_F_DUPFD: return F_DUPFD; @@ -276,7 +283,8 @@ svr4_sys_fcntl(p, v, retval) return error; case F_SETFL: - SCARG(&fa, arg) = (void *) svr4_to_bsd_flags(SCARG(uap, arg)); + SCARG(&fa, arg) = + (void *) svr4_to_bsd_flags((u_long) SCARG(uap, arg)); return sys_fcntl(p, &fa, retval); case F_GETLK: @@ -377,13 +385,12 @@ svr4_sys_poll(p, v, retval) int msec = SCARG(uap, timeout); struct timeval atv; int timo; - u_int ni; int ncoll; extern int nselcoll, selwait; pl = (struct svr4_pollfd *) malloc(sz, M_TEMP, M_WAITOK); - if (error = copyin(SCARG(uap, fds), pl, sz)) + if ((error = copyin(SCARG(uap, fds), pl, sz)) != 0) goto bad; for (i = 0; i < SCARG(uap, nfds); i++) { @@ -440,7 +447,7 @@ done: if (error == EWOULDBLOCK) error = 0; - if (error2 = copyout(pl, SCARG(uap, fds), sz)) + if ((error2 = copyout(pl, SCARG(uap, fds), sz)) != 0) error = error2; bad: diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c index 355e5135c87..ffb57cf9f09 100644 --- a/sys/compat/svr4/svr4_ioctl.c +++ b/sys/compat/svr4/svr4_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_ioctl.c,v 1.12 1995/10/07 06:27:41 mycroft Exp $ */ +/* $NetBSD: svr4_ioctl.c,v 1.13 1995/10/14 20:24:27 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -55,10 +55,11 @@ #include <compat/svr4/svr4_sockio.h> #ifdef DEBUG_SVR4 +static void svr4_decode_cmd __P((u_long, char *, char *, int *, int *)); /* * Decode an ioctl command symbolically */ -void +static void svr4_decode_cmd(cmd, dir, c, num, argsiz) u_long cmd; char *dir, *c; @@ -100,7 +101,7 @@ svr4_sys_ioctl(p, v, retval) svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz); printf("svr4_ioctl(%d, _IO%s(%c, %d, %d), %x);\n", SCARG(uap, fd), - dir, c, num, argsiz, SCARG(uap, data)); + dir, c, num, argsiz, (unsigned int) SCARG(uap, data)); #endif fdp = p->p_fd; cmd = SCARG(uap, com); diff --git a/sys/compat/svr4/svr4_ipc.c b/sys/compat/svr4/svr4_ipc.c new file mode 100644 index 00000000000..76da560f0c8 --- /dev/null +++ b/sys/compat/svr4/svr4_ipc.c @@ -0,0 +1,744 @@ +/* $NetBSD: svr4_ipc.c,v 1.1 1995/10/14 20:24:30 christos Exp $ */ + +/* + * Copyright (c) 1995 Christos Zoulas. All rights reserved. + * + * 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 Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * + * Mostly stolen from: linux_ipc.c,v 1.4 1995/06/24 20:20:22 christos Exp + */ + +#include <sys/types.h> +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/shm.h> +#include <sys/msg.h> +#include <sys/sem.h> +#include <sys/proc.h> +#include <sys/uio.h> +#include <sys/time.h> +#include <sys/malloc.h> +#include <sys/mman.h> +#include <sys/systm.h> +#include <sys/stat.h> + +#include <sys/mount.h> +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_ipc.h> + +#define syscallarg(x) union { x datum; register_t pad; } + +#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM) +static void svr4_to_bsd_ipc_perm __P((const struct svr4_ipc_perm *, + struct ipc_perm *)); +static void bsd_to_svr4_ipc_perm __P((const struct ipc_perm *, + struct svr4_ipc_perm *)); +#endif + +#ifdef SYSVSEM +static void bsd_to_svr4_semid_ds __P((const struct semid_ds *, + struct svr4_semid_ds *)); +static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *, + struct semid_ds *)); +static int svr4_semop __P((struct proc *, void *, register_t *)); +static int svr4_semget __P((struct proc *, void *, register_t *)); +static int svr4_semctl __P((struct proc *, void *, register_t *)); +#endif + +#ifdef SYSVMSG +static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *, + struct svr4_msqid_ds *)); +static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *, + struct msqid_ds *)); +static int svr4_msgsnd __P((struct proc *, void *, register_t *)); +static int svr4_msgrcv __P((struct proc *, void *, register_t *)); +static int svr4_msgget __P((struct proc *, void *, register_t *)); +static int svr4_msgctl __P((struct proc *, void *, register_t *)); +#endif + +#ifdef SYSVSHM +static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *, + struct svr4_shmid_ds *)); +static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *, + struct shmid_ds *)); +static int svr4_shmat __P((struct proc *, void *, register_t *)); +static int svr4_shmdt __P((struct proc *, void *, register_t *)); +static int svr4_shmget __P((struct proc *, void *, register_t *)); +static int svr4_shmctl __P((struct proc *, void *, register_t *)); +#endif + +#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM) + +static void +svr4_to_bsd_ipc_perm(spp, bpp) + const struct svr4_ipc_perm *spp; + struct ipc_perm *bpp; +{ + bpp->key = spp->key; + bpp->uid = spp->uid; + bpp->gid = spp->gid; + bpp->cuid = spp->cuid; + bpp->cgid = spp->cgid; + bpp->mode = spp->mode; + bpp->seq = spp->seq; +} + +static void +bsd_to_svr4_ipc_perm(bpp, spp) + const struct ipc_perm *bpp; + struct svr4_ipc_perm *spp; +{ + spp->key = bpp->key; + spp->uid = bpp->uid; + spp->gid = bpp->gid; + spp->cuid = bpp->cuid; + spp->cgid = bpp->cgid; + spp->mode = bpp->mode; + spp->seq = bpp->seq; +} +#endif + +#ifdef SYSVSEM +static void +bsd_to_svr4_semid_ds(bds, sds) + const struct semid_ds *bds; + struct svr4_semid_ds *sds; +{ + bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm); + sds->sem_base = (struct svr4_sem *) bds->sem_base; + sds->sem_nsems = bds->sem_nsems; + sds->sem_otime = bds->sem_otime; + sds->sem_pad1 = bds->sem_pad1; + sds->sem_ctime = bds->sem_ctime; + sds->sem_pad2 = bds->sem_pad2; +} + +static void +svr4_to_bsd_semid_ds(sds, bds) + const struct svr4_semid_ds *sds; + struct semid_ds *bds; +{ + svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm); + bds->sem_base = (struct sem *) bds->sem_base; + bds->sem_nsems = sds->sem_nsems; + bds->sem_otime = sds->sem_otime; + bds->sem_pad1 = sds->sem_pad1; + bds->sem_ctime = sds->sem_ctime; + bds->sem_pad2 = sds->sem_pad2; +} + +struct svr4_sys_semctl_args { + syscallarg(int) what; + syscallarg(int) semid; + syscallarg(int) semnum; + syscallarg(int) cmd; + syscallarg(void *) arg; +}; + +static int +svr4_semctl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + int error; + struct svr4_sys_semctl_args *uap = v; + struct sys___semctl_args ap; + struct svr4_semid_ds ss; + struct semid_ds bs; + caddr_t sg = stackgap_init(p->p_emul); + + SCARG(&ap, semid) = SCARG(uap, semid); + SCARG(&ap, semnum) = SCARG(uap, semnum); + + switch (SCARG(uap, cmd)) { + case SVR4_SEM_GETZCNT: + case SVR4_SEM_GETNCNT: + case SVR4_SEM_GETPID: + case SVR4_SEM_GETVAL: + switch (SCARG(uap, cmd)) { + case SVR4_SEM_GETZCNT: + SCARG(&ap, cmd) = GETZCNT; + break; + case SVR4_SEM_GETNCNT: + SCARG(&ap, cmd) = GETNCNT; + break; + case SVR4_SEM_GETPID: + SCARG(&ap, cmd) = GETPID; + break; + case SVR4_SEM_GETVAL: + SCARG(&ap, cmd) = GETVAL; + break; + } + return sys___semctl(p, &ap, retval); + + case SVR4_SEM_SETVAL: + SCARG(&ap, arg)->val = (int) SCARG(uap, arg); + SCARG(&ap, cmd) = SETVAL; + return sys___semctl(p, &ap, retval); + + case SVR4_SEM_GETALL: + SCARG(&ap, arg)->array = SCARG(uap, arg); + SCARG(&ap, cmd) = GETVAL; + return sys___semctl(p, &ap, retval); + + case SVR4_SEM_SETALL: + SCARG(&ap, arg)->array = SCARG(uap, arg); + SCARG(&ap, cmd) = SETVAL; + return sys___semctl(p, &ap, retval); + + case SVR4_IPC_STAT: + SCARG(&ap, cmd) = IPC_STAT; + SCARG(&ap, arg)->buf = stackgap_alloc(&sg, sizeof(bs)); + if ((error = sys___semctl(p, &ap, retval)) != 0) + return error; + error = copyin(&bs, SCARG(&ap, arg)->buf, sizeof bs); + if (error) + return error; + bsd_to_svr4_semid_ds(&bs, &ss); + return copyout(&ss, SCARG(uap, arg), sizeof ss); + + case SVR4_IPC_SET: + SCARG(&ap, cmd) = IPC_SET; + SCARG(&ap, arg)->buf = stackgap_alloc(&sg, sizeof(bs)); + error = copyin(SCARG(uap, arg), (caddr_t) &ss, sizeof ss); + if (error) + return error; + svr4_to_bsd_semid_ds(&ss, &bs); + error = copyout(&bs, SCARG(&ap, arg)->buf, sizeof bs); + if (error) + return error; + return sys___semctl(p, &ap, retval); + + case SVR4_IPC_RMID: + SCARG(&ap, cmd) = IPC_RMID; + SCARG(&ap, arg)->buf = stackgap_alloc(&sg, sizeof(bs)); + error = copyin(SCARG(uap, arg), &ss, sizeof ss); + if (error) + return error; + svr4_to_bsd_semid_ds(&ss, &bs); + error = copyout(&bs, SCARG(&ap, arg)->buf, sizeof bs); + if (error) + return error; + return sys___semctl(p, &ap, retval); + + default: + return EINVAL; + } +} + +struct svr4_sys_semget_args { + syscallarg(int) what; + syscallarg(svr4_key_t) key; + syscallarg(int) nsems; + syscallarg(int) semflg; +}; + +static int +svr4_semget(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_semget_args *uap = v; + struct sys_semget_args ap; + + SCARG(&ap, key) = SCARG(uap, key); + SCARG(&ap, nsems) = SCARG(uap, nsems); + SCARG(&ap, semflg) = SCARG(uap, semflg); + + return sys_semget(p, &ap, retval); +} + +struct svr4_sys_semop_args { + syscallarg(int) what; + syscallarg(int) semid; + syscallarg(struct svr4_sembuf *) sops; + syscallarg(u_int) nsops; +}; + +static int +svr4_semop(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_semop_args *uap = v; + struct sys_semop_args ap; + + SCARG(&ap, semid) = SCARG(uap, semid); + /* These are the same */ + SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops); + SCARG(&ap, nsops) = SCARG(uap, nsops); + + return sys_semop(p, &ap, retval); +} + +int +svr4_sys_semsys(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_semsys_args *uap = v; + + DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what))); + + switch (SCARG(uap, what)) { + case SVR4_semctl: + return svr4_semctl(p, v, retval); + case SVR4_semget: + return svr4_semget(p, v, retval); + case SVR4_semop: + return svr4_semop(p, v, retval); + default: + return EINVAL; + } +} +#endif + +#ifdef SYSVMSG +static void +bsd_to_svr4_msqid_ds(bds, sds) + const struct msqid_ds *bds; + struct svr4_msqid_ds *sds; +{ + bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm); + sds->msg_first = (struct svr4_msg *) bds->msg_first; + sds->msg_last = (struct svr4_msg *) bds->msg_last; + sds->msg_cbytes = bds->msg_cbytes; + sds->msg_qnum = bds->msg_qnum; + sds->msg_qbytes = bds->msg_qbytes; + sds->msg_lspid = bds->msg_lspid; + sds->msg_lrpid = bds->msg_lrpid; + sds->msg_stime = bds->msg_stime; + sds->msg_pad1 = bds->msg_pad1; + sds->msg_rtime = bds->msg_rtime; + sds->msg_pad2 = bds->msg_pad2; + sds->msg_ctime = bds->msg_ctime; + sds->msg_pad3 = bds->msg_pad3; + + /* use the padding for the rest of the fields */ + { + short *pad = (short *) bds->msg_pad4; + sds->msg_cv = pad[0]; + sds->msg_qnum_cv = pad[1]; + } +} + +static void +svr4_to_bsd_msqid_ds(sds, bds) + const struct svr4_msqid_ds *sds; + struct msqid_ds *bds; +{ + svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm); + bds->msg_first = (struct msg *) sds->msg_first; + bds->msg_last = (struct msg *) sds->msg_last; + bds->msg_cbytes = sds->msg_cbytes; + bds->msg_qnum = sds->msg_qnum; + bds->msg_qbytes = sds->msg_qbytes; + bds->msg_lspid = sds->msg_lspid; + bds->msg_lrpid = sds->msg_lrpid; + bds->msg_stime = sds->msg_stime; + bds->msg_pad1 = sds->msg_pad1; + bds->msg_rtime = sds->msg_rtime; + bds->msg_pad2 = sds->msg_pad2; + bds->msg_ctime = sds->msg_ctime; + bds->msg_pad3 = sds->msg_pad3; + + /* use the padding for the rest of the fields */ + { + short *pad = (short *) bds->msg_pad4; + pad[0] = sds->msg_cv; + pad[1] = sds->msg_qnum_cv; + } +} + +struct svr4_sys_msgsnd_args { + syscallarg(int) what; + syscallarg(int) msqid; + syscallarg(void *) msgp; + syscallarg(size_t) msgsz; + syscallarg(int) msgflg; +}; + +static int +svr4_msgsnd(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_msgsnd_args *uap = v; + struct sys_msgsnd_args ap; + + SCARG(&ap, msqid) = SCARG(uap, msqid); + SCARG(&ap, msgp) = SCARG(uap, msgp); + SCARG(&ap, msgsz) = SCARG(uap, msgsz); + SCARG(&ap, msgflg) = SCARG(uap, msgflg); + + return sys_msgsnd(p, &ap, retval); +} + +struct svr4_sys_msgrcv_args { + syscallarg(int) what; + syscallarg(int) msqid; + syscallarg(void *) msgp; + syscallarg(size_t) msgsz; + syscallarg(long) msgtyp; + syscallarg(int) msgflg; +}; + +static int +svr4_msgrcv(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_msgrcv_args *uap = v; + struct sys_msgrcv_args ap; + + SCARG(&ap, msqid) = SCARG(uap, msqid); + SCARG(&ap, msgp) = SCARG(uap, msgp); + SCARG(&ap, msgsz) = SCARG(uap, msgsz); + SCARG(&ap, msgtyp) = SCARG(uap, msgtyp); + SCARG(&ap, msgflg) = SCARG(uap, msgflg); + + return sys_msgrcv(p, &ap, retval); +} + +struct svr4_sys_msgget_args { + syscallarg(int) what; + syscallarg(svr4_key_t) key; + syscallarg(int) msgflg; +}; + +static int +svr4_msgget(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_msgget_args *uap = v; + struct sys_msgget_args ap; + + SCARG(&ap, key) = SCARG(uap, key); + SCARG(&ap, msgflg) = SCARG(uap, msgflg); + + return sys_msgget(p, &ap, retval); +} + +struct svr4_sys_msgctl_args { + syscallarg(int) what; + syscallarg(int) msqid; + syscallarg(int) cmd; + syscallarg(struct svr4_msqid_ds *) buf; +}; + +static int +svr4_msgctl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + int error; + struct svr4_sys_msgctl_args *uap = v; + struct sys_msgctl_args ap; + struct svr4_msqid_ds ss; + struct msqid_ds bs; + caddr_t sg = stackgap_init(p->p_emul); + + SCARG(&ap, msqid) = SCARG(uap, msqid); + SCARG(&ap, cmd) = SCARG(uap, cmd); + SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs)); + + switch (SCARG(uap, cmd)) { + case SVR4_IPC_STAT: + SCARG(&ap, cmd) = IPC_STAT; + if ((error = sys_msgctl(p, &ap, retval)) != 0) + return error; + error = copyin(&bs, SCARG(&ap, buf), sizeof bs); + if (error) + return error; + bsd_to_svr4_msqid_ds(&bs, &ss); + return copyout(&ss, SCARG(uap, buf), sizeof ss); + + case SVR4_IPC_SET: + SCARG(&ap, cmd) = IPC_SET; + error = copyin(SCARG(uap, buf), &ss, sizeof ss); + if (error) + return error; + svr4_to_bsd_msqid_ds(&ss, &bs); + error = copyout(&bs, SCARG(&ap, buf), sizeof bs); + if (error) + return error; + return sys_msgctl(p, &ap, retval); + + case SVR4_IPC_RMID: + SCARG(&ap, cmd) = IPC_RMID; + error = copyin(SCARG(uap, buf), &ss, sizeof ss); + if (error) + return error; + svr4_to_bsd_msqid_ds(&ss, &bs); + error = copyout(&bs, SCARG(&ap, buf), sizeof bs); + if (error) + return error; + return sys_msgctl(p, &ap, retval); + + default: + return EINVAL; + } +} + +int +svr4_sys_msgsys(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_msgsys_args *uap = v; + + DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what))); + + switch (SCARG(uap, what)) { + case SVR4_msgsnd: + return svr4_msgsnd(p, v, retval); + case SVR4_msgrcv: + return svr4_msgrcv(p, v, retval); + case SVR4_msgget: + return svr4_msgget(p, v, retval); + case SVR4_msgctl: + return svr4_msgctl(p, v, retval); + default: + return EINVAL; + } +} +#endif + +#ifdef SYSVSHM + +static void +bsd_to_svr4_shmid_ds(bds, sds) + const struct shmid_ds *bds; + struct svr4_shmid_ds *sds; +{ + bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm); + sds->shm_segsz = bds->shm_segsz; + sds->shm_lkcnt = 0; + sds->shm_lpid = bds->shm_lpid; + sds->shm_cpid = bds->shm_cpid; + sds->shm_amp = bds->shm_internal; + sds->shm_nattch = bds->shm_nattch; + sds->shm_cnattch = 0; + sds->shm_atime = bds->shm_atime; + sds->shm_pad1 = 0; + sds->shm_dtime = bds->shm_dtime; + sds->shm_pad2 = 0; + sds->shm_ctime = bds->shm_ctime; + sds->shm_pad3 = 0; +} + +static void +svr4_to_bsd_shmid_ds(sds, bds) + const struct svr4_shmid_ds *sds; + struct shmid_ds *bds; +{ + svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm); + bds->shm_segsz = sds->shm_segsz; + bds->shm_lpid = sds->shm_lpid; + bds->shm_cpid = sds->shm_cpid; + bds->shm_internal = sds->shm_amp; + bds->shm_nattch = sds->shm_nattch; + bds->shm_atime = sds->shm_atime; + bds->shm_dtime = sds->shm_dtime; + bds->shm_ctime = sds->shm_ctime; +} + +struct svr4_sys_shmat_args { + syscallarg(int) what; + syscallarg(int) shmid; + syscallarg(void *) shmaddr; + syscallarg(int) shmflg; +}; + +static int +svr4_shmat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_shmat_args *uap = v; + struct sys_shmat_args ap; + + SCARG(&ap, shmid) = SCARG(uap, shmid); + SCARG(&ap, shmaddr) = SCARG(uap, shmaddr); + SCARG(&ap, shmflg) = SCARG(uap, shmflg); + + return sys_shmat(p, &ap, retval); +} + +struct svr4_sys_shmdt_args { + syscallarg(int) what; + syscallarg(void *) shmaddr; +}; + +static int +svr4_shmdt(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_shmdt_args *uap = v; + struct sys_shmdt_args ap; + + SCARG(&ap, shmaddr) = SCARG(uap, shmaddr); + + return sys_shmdt(p, &ap, retval); +} + +struct svr4_sys_shmget_args { + syscallarg(int) what; + syscallarg(key_t) key; + syscallarg(int) size; + syscallarg(int) shmflg; +}; + +static int +svr4_shmget(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_shmget_args *uap = v; + struct sys_shmget_args ap; + + SCARG(&ap, key) = SCARG(uap, key); + SCARG(&ap, size) = SCARG(uap, size); + SCARG(&ap, shmflg) = SCARG(uap, shmflg); + + return sys_shmget(p, &ap, retval); +} + +struct svr4_sys_shmctl_args { + syscallarg(int) what; + syscallarg(int) shmid; + syscallarg(int) cmd; + syscallarg(struct svr4_shmid_ds *) buf; +}; + +int +svr4_shmctl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_shmctl_args *uap = v; + int error; + caddr_t sg = stackgap_init(p->p_emul); + struct sys_shmctl_args ap; + struct shmid_ds bs; + struct svr4_shmid_ds ss; + + SCARG(&ap, shmid) = SCARG(uap, shmid); + SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof (struct shmid_ds)); + switch (SCARG(uap, cmd)) { + case SVR4_IPC_STAT: + SCARG(&ap, cmd) = IPC_STAT; + if ((error = sys_shmctl(p, &ap, retval)) != 0) + return error; + error = copyin(&bs, SCARG(&ap, buf), sizeof bs); + if (error) + return error; + bsd_to_svr4_shmid_ds(&bs, &ss); + return copyout(&ss, SCARG(uap, buf), sizeof ss); + + case SVR4_IPC_SET: + SCARG(&ap, cmd) = IPC_SET; + error = copyin(SCARG(uap, buf), (caddr_t) &ss, sizeof ss); + if (error) + return error; + svr4_to_bsd_shmid_ds(&ss, &bs); + error = copyout(&bs, SCARG(&ap, buf), sizeof bs); + if (error) + return error; + return sys_shmctl(p, &ap, retval); + + case SVR4_IPC_RMID: + case SVR4_SHM_LOCK: + case SVR4_SHM_UNLOCK: + switch (SCARG(uap, cmd)) { + case SVR4_IPC_RMID: + SCARG(&ap, cmd) = IPC_RMID; + break; + case SVR4_SHM_LOCK: + SCARG(&ap, cmd) = SHM_LOCK; + break; + case SVR4_SHM_UNLOCK: + SCARG(&ap, cmd) = SHM_UNLOCK; + break; + } + error = copyin(SCARG(uap, buf), &ss, sizeof ss); + if (error) + return error; + svr4_to_bsd_shmid_ds(&ss, &bs); + error = copyout(&bs, SCARG(&ap, buf), sizeof bs); + if (error) + return error; + return sys_shmctl(p, &ap, retval); + + default: + return EINVAL; + } +} + +int +svr4_sys_shmsys(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_shmsys_args *uap = v; + + DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what))); + + switch (SCARG(uap, what)) { + case SVR4_shmat: + return svr4_shmat(p, v, retval); + case SVR4_shmdt: + return svr4_shmdt(p, v, retval); + case SVR4_shmget: + return svr4_shmget(p, v, retval); + case SVR4_shmctl: + return svr4_shmctl(p, v, retval); + default: + return ENOSYS; + } +} +#endif /* SYSVSHM */ diff --git a/sys/compat/svr4/svr4_ipc.h b/sys/compat/svr4/svr4_ipc.h new file mode 100644 index 00000000000..b87555d4280 --- /dev/null +++ b/sys/compat/svr4/svr4_ipc.h @@ -0,0 +1,175 @@ +/* $NetBSD: svr4_ipc.h,v 1.1 1995/10/14 20:24:32 christos Exp $ */ + +/* + * Copyright (c) 1995 Christos Zoulas. All rights reserved. + * + * 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 Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#ifndef _SVR4_IPC_H_ +#define _SVR4_IPC_H_ + +/* + * General IPC + */ +#define SVR4_IPC_RMID 10 +#define SVR4_IPC_SET 11 +#define SVR4_IPC_STAT 12 + +struct svr4_ipc_perm { + svr4_uid_t uid; + svr4_gid_t gid; + svr4_uid_t cuid; + svr4_gid_t cgid; + svr4_mode_t mode; + u_long seq; + svr4_key_t key; + long pad[4]; +}; + +/* + * Message queues + */ +#define SVR4_msgget 0 +#define SVR4_msgctl 1 +#define SVR4_msgrcv 2 +#define SVR4_msgsnd 3 + +struct svr4_msg { + struct svr4_msg *msg_next; + long msg_type; + u_short msg_ts; + short msg_spot; +}; + +struct svr4_msqid_ds { + struct svr4_ipc_perm msg_perm; + struct svr4_msg *msg_first; + struct svr4_msg *msg_last; + u_long msg_cbytes; + u_long msg_qnum; + u_long msg_qbytes; + svr4_pid_t msg_lspid; + svr4_pid_t msg_lrpid; + svr4_time_t msg_stime; + long msg_pad1; + svr4_time_t msg_rtime; + long msg_pad2; + svr4_time_t msg_ctime; + long msg_pad3; + short msg_cv; + short msg_qnum_cv; + long msg_pad4[3]; +}; + +struct svr4_msgbuf { + long mtype; /* message type */ + char mtext[1]; /* message text */ +}; + +struct svr4_msginfo { + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + u_short msgseg; +}; + +/* + * Shared memory + */ +#define SVR4_shmat 0 +#define SVR4_shmctl 1 +#define SVR4_shmdt 2 +#define SVR4_shmget 3 + +/* shmctl() operations */ +#define SVR4_SHM_LOCK 3 +#define SVR4_SHM_UNLOCK 4 + +struct svr4_shmid_ds { + struct svr4_ipc_perm shm_perm; + int shm_segsz; + void *shm_amp; + u_short shm_lkcnt; + svr4_pid_t shm_lpid; + svr4_pid_t shm_cpid; + u_long shm_nattch; + u_long shm_cnattch; + svr4_time_t shm_atime; + long shm_pad1; + svr4_time_t shm_dtime; + long shm_pad2; + svr4_time_t shm_ctime; + long shm_pad3; + long shm_pad4[4]; +}; + +/* + * Semaphores + */ +#define SVR4_semctl 0 +#define SVR4_semget 1 +#define SVR4_semop 2 + +/* semctl() operations */ +#define SVR4_SEM_GETNCNT 3 +#define SVR4_SEM_GETPID 4 +#define SVR4_SEM_GETVAL 5 +#define SVR4_SEM_GETALL 6 +#define SVR4_SEM_GETZCNT 7 +#define SVR4_SEM_SETVAL 8 +#define SVR4_SEM_SETALL 9 + +struct svr4_sem { + u_short semval; + svr4_pid_t sempid; + u_short semncnt; + u_short semzcnt; + u_short semncnt_cv; + u_short semzcnt_cv; +}; + +struct svr4_semid_ds { + struct svr4_ipc_perm sem_perm; + struct svr4_sem *sem_base; + u_short sem_nsems; + svr4_time_t sem_otime; + long sem_pad1; + svr4_time_t sem_ctime; + long sem_pad2; + long sem_pad3[4]; +}; + +struct svr4_sembuf { + u_short sem_num; + short sem_op; + short sem_flg; +}; + +#endif /* _SVR4_IPC_H */ diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index bab1d019d8d..106c4f5ad05 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_misc.c,v 1.28 1995/10/09 11:24:17 mycroft Exp $ */ +/* $NetBSD: svr4_misc.c,v 1.29 1995/10/14 20:24:35 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -60,6 +60,8 @@ #include <sys/times.h> #include <sys/sem.h> #include <sys/msg.h> +#include <sys/ptrace.h> +#include <sys/signalvar.h> #include <netinet/in.h> #include <sys/syscallargs.h> @@ -79,7 +81,6 @@ #include <compat/svr4/svr4_sysconfig.h> #include <vm/vm.h> -/* XXX */ extern struct proc *pfind(); static __inline clock_t timeval_to_clock_t __P((struct timeval *)); static int svr4_setinfo __P((struct proc *, int, svr4_siginfo_t *)); @@ -306,9 +307,6 @@ svr4_sys_mmap(p, v, retval) register_t *retval; { struct svr4_sys_mmap_args *uap = v; - struct filedesc *fdp; - struct file *fp; - struct vnode *vp; struct sys_mmap_args mm; caddr_t rp; #define _MAP_NEW 0x80000000 @@ -618,7 +616,7 @@ svr4_sys_times(p, v, retval) if (error) return error; - if (error = copyin(ru, &r, sizeof r)) + if ((error = copyin(ru, &r, sizeof r)) != 0) return error; tms.tms_utime = timeval_to_clock_t(&r.ru_utime); @@ -629,7 +627,7 @@ svr4_sys_times(p, v, retval) if (error) return error; - if (error = copyin(ru, &r, sizeof r)) + if ((error = copyin(ru, &r, sizeof r)) != 0) return error; tms.tms_cutime = timeval_to_clock_t(&r.ru_utime); @@ -945,7 +943,8 @@ svr4_sys_waitsys(p, v, retval) } DPRINTF(("waitsys(%d, %d, %x, %x)\n", - SCARG(uap, grp), SCARG(uap, id), SCARG(uap, info), + SCARG(uap, grp), SCARG(uap, id), + (unsigned int) SCARG(uap, info), SCARG(uap, options))); loop: @@ -1049,7 +1048,7 @@ loop: return 0; } - if (error = tsleep((caddr_t)p, PWAIT | PCATCH, "svr4_wait", 0)) + if ((error = tsleep((caddr_t)p, PWAIT | PCATCH, "svr4_wait", 0)) != 0) return error; goto loop; } diff --git a/sys/compat/svr4/svr4_net.c b/sys/compat/svr4/svr4_net.c index 42f50403f54..e46b95c12df 100644 --- a/sys/compat/svr4/svr4_net.c +++ b/sys/compat/svr4/svr4_net.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_net.c,v 1.4 1994/12/14 20:20:26 mycroft Exp $ */ +/* $NetBSD: svr4_net.c,v 1.5 1995/10/14 20:24:38 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -68,6 +68,8 @@ enum { dev_udp = 36 }; +int svr4_netattach __P((int)); + static int svr4_netclose __P((struct file *fp, struct proc *p)); static struct fileops svr4_netops = { diff --git a/sys/compat/svr4/svr4_signal.h b/sys/compat/svr4/svr4_signal.h index 8dfeee42749..fad82523a19 100644 --- a/sys/compat/svr4/svr4_signal.h +++ b/sys/compat/svr4/svr4_signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_signal.h,v 1.13 1995/08/14 02:22:20 mycroft Exp $ */ +/* $NetBSD: svr4_signal.h,v 1.14 1995/10/14 20:24:41 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -76,13 +76,14 @@ #define SVR4_SIGIGNORE_MASK 0x0800 #define SVR4_SIGPAUSE_MASK 0x1000 -#define SVR4_SIGNO(x) ((x) & SVR4_SIGNO_MASK) -#define SVR4_SIGCALL(x) ((x) & ~SVR4_SIGNO_MASK) +typedef void (*svr4_sig_t) __P((int, svr4_siginfo_t *, void *)); +#define SVR4_SIG_DFL (svr4_sig_t) 0 +#define SVR4_SIG_ERR (svr4_sig_t) -1 +#define SVR4_SIG_IGN (svr4_sig_t) 1 +#define SVR4_SIG_HOLD (svr4_sig_t) 2 -#define SVR4_SIG_DFL (void(*)())0 -#define SVR4_SIG_ERR (void(*)())-1 -#define SVR4_SIG_IGN (void(*)())1 -#define SVR4_SIG_HOLD (void(*)())2 +#define SVR4_SIGNO(a) ((a) & SVR4_SIGNO_MASK) +#define SVR4_SIGCALL(a) ((a) & ~SVR4_SIGNO_MASK) #define SVR4_SIG_BLOCK 1 #define SVR4_SIG_UNBLOCK 2 @@ -91,7 +92,6 @@ typedef struct { u_long bits[4]; } svr4_sigset_t; -typedef void (*svr4_sig_t) __P((int)); struct svr4_sigaction { int sa_flags; diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c index b49e517b4fa..f8db45508d6 100644 --- a/sys/compat/svr4/svr4_stat.c +++ b/sys/compat/svr4/svr4_stat.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_stat.c,v 1.13 1995/10/07 06:27:49 mycroft Exp $ */ +/* $NetBSD: svr4_stat.c,v 1.14 1995/10/14 20:24:43 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -66,6 +66,12 @@ # define SVR4_NO_OSTAT #endif +static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *)); + + +#ifndef SVR4_NO_OSTAT +static void bsd_to_svr4_stat __P((struct stat *, struct svr4_stat *)); + static void bsd_to_svr4_stat(st, st4) struct stat *st; @@ -84,6 +90,8 @@ bsd_to_svr4_stat(st, st4) st4->st_mtim = st->st_mtimespec.ts_sec; st4->st_ctim = st->st_ctimespec.ts_sec; } +#endif + static void @@ -351,7 +359,7 @@ svr4_ustat(p, uap, retval) * XXX: should set f_tfree and f_tinode at least * How do we translate dev -> fstat? (and then to svr4_ustat) */ - if (error = copyout(&us, SCARG(uap, name), sizeof us)) + if ((error = copyout(&us, SCARG(uap, name), sizeof us)) != 0) return (error); return 0; @@ -445,16 +453,16 @@ svr4_sys_systeminfo(p, v, retval) break; case SVR4_SI_SET_HOSTNAME: - if (error = suser(p->p_ucred, &p->p_acflag)) + if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) return error; name = KERN_HOSTNAME; - return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen); + return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p); case SVR4_SI_SET_SRPC_DOMAIN: - if (error = suser(p->p_ucred, &p->p_acflag)) + if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) return error; name = KERN_DOMAINNAME; - return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen); + return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p); default: DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what))); diff --git a/sys/compat/svr4/svr4_syscall.h b/sys/compat/svr4/svr4_syscall.h index 2a3076df8e8..ed736807598 100644 --- a/sys/compat/svr4/svr4_syscall.h +++ b/sys/compat/svr4/svr4_syscall.h @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp + * created from NetBSD: syscalls.master,v 1.14 1995/10/14 20:25:06 christos Exp */ #define SVR4_SYS_syscall 0 @@ -40,7 +40,10 @@ #define SVR4_SYS_setgid 46 #define SVR4_SYS_getgid 47 #define SVR4_SYS_signal 48 +#define SVR4_SYS_msgsys 49 #define SVR4_SYS_sysarch 50 +#define SVR4_SYS_shmsys 52 +#define SVR4_SYS_semsys 53 #define SVR4_SYS_ioctl 54 #define SVR4_SYS_utssys 57 #define SVR4_SYS_fsync 58 diff --git a/sys/compat/svr4/svr4_syscallargs.h b/sys/compat/svr4/svr4_syscallargs.h index 79b22a29872..9823845dfa3 100644 --- a/sys/compat/svr4/svr4_syscallargs.h +++ b/sys/compat/svr4/svr4_syscallargs.h @@ -2,7 +2,7 @@ * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp + * created from NetBSD: syscalls.master,v 1.14 1995/10/14 20:25:06 christos Exp */ #define syscallarg(x) union { x datum; register_t pad; } @@ -80,11 +80,34 @@ struct svr4_sys_signal_args { syscallarg(svr4_sig_t) handler; }; +struct svr4_sys_msgsys_args { + syscallarg(int) what; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; + syscallarg(int) a5; +}; + struct svr4_sys_sysarch_args { syscallarg(int) op; syscallarg(void *) a1; }; +struct svr4_sys_shmsys_args { + syscallarg(int) what; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; +}; + +struct svr4_sys_semsys_args { + syscallarg(int) what; + syscallarg(int) a2; + syscallarg(int) a3; + syscallarg(int) a4; + syscallarg(int) a5; +}; + struct svr4_sys_ioctl_args { syscallarg(int) fd; syscallarg(u_long) com; @@ -302,13 +325,16 @@ int sys_setgid __P((struct proc *, void *, register_t *)); int sys_getgid __P((struct proc *, void *, register_t *)); int svr4_sys_signal __P((struct proc *, void *, register_t *)); #ifdef SYSVMSG +int svr4_sys_msgsys __P((struct proc *, void *, register_t *)); #else #endif int svr4_sys_sysarch __P((struct proc *, void *, register_t *)); #ifdef SYSVSHM +int svr4_sys_shmsys __P((struct proc *, void *, register_t *)); #else #endif #ifdef SYSVSEM +int svr4_sys_semsys __P((struct proc *, void *, register_t *)); #else #endif int svr4_sys_ioctl __P((struct proc *, void *, register_t *)); diff --git a/sys/compat/svr4/svr4_syscalls.c b/sys/compat/svr4/svr4_syscalls.c index 8019c68e7e8..3998cdb8eee 100644 --- a/sys/compat/svr4/svr4_syscalls.c +++ b/sys/compat/svr4/svr4_syscalls.c @@ -2,7 +2,7 @@ * System call names. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp + * created from NetBSD: syscalls.master,v 1.14 1995/10/14 20:25:06 christos Exp */ char *svr4_syscallnames[] = { @@ -56,19 +56,19 @@ char *svr4_syscallnames[] = { "getgid", /* 47 = getgid */ "signal", /* 48 = signal */ #ifdef SYSVMSG - "#49 (unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; })", /* 49 = unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; } */ + "msgsys", /* 49 = msgsys */ #else "#49 (unimplemented msgsys)", /* 49 = unimplemented msgsys */ #endif "sysarch", /* 50 = sysarch */ "#51 (unimplemented acct)", /* 51 = unimplemented acct */ #ifdef SYSVSHM - "#52 (unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; })", /* 52 = unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; } */ + "shmsys", /* 52 = shmsys */ #else "#52 (unimplemented shmsys)", /* 52 = unimplemented shmsys */ #endif #ifdef SYSVSEM - "#53 (unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; })", /* 53 = unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; } */ + "semsys", /* 53 = semsys */ #else "#53 (unimplemented semsys)", /* 53 = unimplemented semsys */ #endif diff --git a/sys/compat/svr4/svr4_sysent.c b/sys/compat/svr4/svr4_sysent.c index 0ebc6629df5..c48f9ebf9e1 100644 --- a/sys/compat/svr4/svr4_sysent.c +++ b/sys/compat/svr4/svr4_sysent.c @@ -2,7 +2,7 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp + * created from NetBSD: syscalls.master,v 1.14 1995/10/14 20:25:06 christos Exp */ #include <sys/param.h> @@ -136,8 +136,8 @@ struct sysent svr4_sysent[] = { { 2, s(struct svr4_sys_signal_args), svr4_sys_signal }, /* 48 = signal */ #ifdef SYSVMSG - { 0, 0, - sys_nosys }, /* 49 = unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; } */ + { 5, s(struct svr4_sys_msgsys_args), + svr4_sys_msgsys }, /* 49 = msgsys */ #else { 0, 0, sys_nosys }, /* 49 = unimplemented msgsys */ @@ -147,15 +147,15 @@ struct sysent svr4_sysent[] = { { 0, 0, sys_nosys }, /* 51 = unimplemented acct */ #ifdef SYSVSHM - { 0, 0, - sys_nosys }, /* 52 = unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; } */ + { 4, s(struct svr4_sys_shmsys_args), + svr4_sys_shmsys }, /* 52 = shmsys */ #else { 0, 0, sys_nosys }, /* 52 = unimplemented shmsys */ #endif #ifdef SYSVSEM - { 0, 0, - sys_nosys }, /* 53 = unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; } */ + { 5, s(struct svr4_sys_semsys_args), + svr4_sys_semsys }, /* 53 = semsys */ #else { 0, 0, sys_nosys }, /* 53 = unimplemented semsys */ diff --git a/sys/compat/svr4/svr4_termios.c b/sys/compat/svr4/svr4_termios.c index 984c7b514a1..b9c4a2f8b6e 100644 --- a/sys/compat/svr4/svr4_termios.c +++ b/sys/compat/svr4/svr4_termios.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_termios.c,v 1.5 1995/10/07 06:27:55 mycroft Exp $ */ +/* $NetBSD: svr4_termios.c,v 1.6 1995/10/14 20:24:58 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -46,6 +46,7 @@ #include <compat/svr4/svr4_types.h> #include <compat/svr4/svr4_util.h> #include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_ioctl.h> #include <compat/svr4/svr4_syscallargs.h> #include <compat/svr4/svr4_stropts.h> #include <compat/svr4/svr4_termios.h> @@ -458,7 +459,7 @@ svr4_termioctl(fp, cmd, data, p, retval) { int i; printf("iflag=%o oflag=%o cflag=%o lflag=%o\n", - bt.c_iflag, bt.c_oflag, bt.c_lflag); + bt.c_iflag, bt.c_oflag, bt.c_cflag, bt.c_lflag); printf("cc: "); for (i = 0; i < NCCS; i++) printf("%o ", bt.c_cc[i]); @@ -474,7 +475,7 @@ svr4_termioctl(fp, cmd, data, p, retval) { int i; printf("iflag=%o oflag=%o cflag=%o lflag=%o\n", - st.c_iflag, st.c_oflag, st.c_lflag); + bt.c_iflag, bt.c_oflag, bt.c_cflag, bt.c_lflag); printf("cc: "); for (i = 0; i < SVR4_NCCS; i++) printf("%o ", st.c_cc[i]); diff --git a/sys/compat/svr4/svr4_ttold.c b/sys/compat/svr4/svr4_ttold.c index dd71697e779..0ce97072dad 100644 --- a/sys/compat/svr4/svr4_ttold.c +++ b/sys/compat/svr4/svr4_ttold.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_ttold.c,v 1.6 1995/10/07 06:27:56 mycroft Exp $ */ +/* $NetBSD: svr4_ttold.c,v 1.7 1995/10/14 20:25:01 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -49,6 +49,7 @@ #include <compat/svr4/svr4_syscallargs.h> #include <compat/svr4/svr4_stropts.h> #include <compat/svr4/svr4_ttold.h> +#include <compat/svr4/svr4_ioctl.h> static void svr4_tchars_to_bsd_tchars __P((const struct svr4_tchars *st, struct tchars *bt)); diff --git a/sys/compat/svr4/svr4_types.h b/sys/compat/svr4/svr4_types.h index ba553d432fd..542fa328b40 100644 --- a/sys/compat/svr4/svr4_types.h +++ b/sys/compat/svr4/svr4_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_types.h,v 1.6 1995/08/14 01:12:50 mycroft Exp $ */ +/* $NetBSD: svr4_types.h,v 1.7 1995/10/14 20:25:04 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -51,6 +51,7 @@ typedef short svr4_o_nlink_t; typedef u_short svr4_o_uid_t; typedef u_short svr4_o_gid_t; typedef long svr4_clock_t; +typedef int svr4_key_t; typedef struct timespec svr4_timestruc_t; diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master index 23c9202537a..2b8a3f11a3d 100644 --- a/sys/compat/svr4/syscalls.master +++ b/sys/compat/svr4/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp $ + $NetBSD: syscalls.master,v 1.14 1995/10/14 20:25:06 christos Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -93,21 +93,22 @@ 47 NOARGS { gid_t sys_getgid(void); } 48 STD { int svr4_sys_signal(int signum, svr4_sig_t handler); } #ifdef SYSVMSG -49 UNIMPL { int sys_msgsys(int which, int a2, int a3, int a4, \ - int a5, int a6); } +49 STD { int svr4_sys_msgsys(int what, int a2, int a3, \ + int a4, int a5); } #else 49 UNIMPL msgsys #endif 50 STD { int svr4_sys_sysarch(int op, void *a1); } 51 UNIMPL acct #ifdef SYSVSHM -52 UNIMPL { int sys_shmsys(int which, int a2, int a3, int a4); } +52 STD { int svr4_sys_shmsys(int what, int a2, int a3, \ + int a4); } #else 52 UNIMPL shmsys #endif #ifdef SYSVSEM -53 UNIMPL { int sys_semsys(int which, int a2, int a3, int a4, \ - int a5); } +53 STD { int svr4_sys_semsys(int what, int a2, int a3, \ + int a4, int a5); } #else 53 UNIMPL semsys #endif |