diff options
author | Eric Jackson <ericj@cvs.openbsd.org> | 2000-08-04 15:47:56 +0000 |
---|---|---|
committer | Eric Jackson <ericj@cvs.openbsd.org> | 2000-08-04 15:47:56 +0000 |
commit | 9863a155a1fef7eb589b7e96e7a38bde61e92e3f (patch) | |
tree | f438371a10a4285317e5681bfcfa88c91a16d130 /sys/compat | |
parent | 2f06eab90d1767ad671a20e8390f4a40403ac020 (diff) |
Merge in NetBSD changes. This now works for most statically compiled osf1
bins. Shared osf1 libs don't work quite yet.
Diffstat (limited to 'sys/compat')
29 files changed, 4906 insertions, 1649 deletions
diff --git a/sys/compat/osf1/Makefile b/sys/compat/osf1/Makefile index df0262d81ef..2791a967572 100644 --- a/sys/compat/osf1/Makefile +++ b/sys/compat/osf1/Makefile @@ -1,4 +1,3 @@ -# $OpenBSD: Makefile,v 1.2 1996/08/02 20:35:23 niklas Exp $ # $NetBSD: Makefile,v 1.1 1995/02/13 21:39:00 cgd Exp $ DEP= syscalls.conf syscalls.master ../../kern/makesyscalls.sh @@ -10,3 +9,6 @@ ${OBJS}: ${DEP} -mv -f osf1_syscall.h osf1_syscall.h.bak -mv -f osf1_syscallargs.h osf1_syscallargs.h.bak sh ../../kern/makesyscalls.sh syscalls.conf syscalls.master + +clean: + rm -f ${OBJS} diff --git a/sys/compat/osf1/README.dynamic b/sys/compat/osf1/README.dynamic index 0545a15b72c..5f60ad0efee 100644 --- a/sys/compat/osf1/README.dynamic +++ b/sys/compat/osf1/README.dynamic @@ -1,78 +1,54 @@ -$OpenBSD: README.dynamic,v 1.3 1998/02/15 21:19:14 niklas Exp $ -$NetBSD: README.dynamic,v 1.1 1995/02/13 21:39:01 cgd Exp $ +$NetBSD: README.dynamic,v 1.2 1999/04/27 06:39:49 cgd Exp $ -Currently, the OpenBSD OSF/1 emulation code only supports statically -linked OSF/1 binaries. This document is meant to be a quick -description of what would need to happen to support dynamically linked -OSF/1 binaries, and to provide an indication of the amount of work -that would be required to add such support. +Dynamically linked programs are supported by NetBSD's Digital UNIX +(formerly DEC OSF/1) emulation. The OSF/1 dynamic linker scheme is +described in fair detail in: -To support dynamically linked OSF/1 binaries, three steps would have -to be taken: - (1) The osf1_exec_with_loader() syscall emulation code would - have to be written. - (2) Execve() would have to be changed to support invocation of - a loader for dynamically linked binaries. - (3) The pmap code would have to be extended to allow process - virtual spaces that are much larger than are currently - allowed. + %A Larry W. Allen + %A Harminder G. Singh + %A Kevin G. Wallace + %A Melanie B. Weaver + %T Program Loading in OSF/1 + %P 145-160 + %I USENIX + %B USENIX Conference Proceedings + %D January 21-25, 1991 + %C Dallas, TX + %W Open Software Foundation -1. Implementing osf1_exec_with_loader(). +Additionally, the object file formats in use are described in the +Digital UNIX _Assembly Language Programmer's Guide_ which can be +found (among other places) on a version-specific page off of: -The description of osf1_exec_with_loader is as follows: + http://www.unix.digital.com/faqs/publications/pub_page/doc_list.html - int exec_with_loader(int flags, const char *loader, - const char *file, char * const argv[], - char * const envp[]); +Finally, the actual representation of Auxiliary Vectors came from information +in the Digital UNIX auxv.h header file. -It invokes the program named by file, with the given argv and envp, -by starting the specified loader (or /sbin/loader) and somehow passing -the flags, file name, argv, and envp in such a way that the -appropriate things will happen with them. This interface is -completely undocumented (in the documentation that we have available), -and so the only way to figure it out is to disassemble the OSF/1 -kernel and/or /sbin/loader. +There are at least two potential issues with the implementation as it +currently exists: -2. Changing execve() to support OSF/1 dynamically linked executables. +1. exec_with_loader() is not emulated. -Normally, dynamically linked executables are invoked using execve(), -in the normal fashion. The kernel transforms that request into one -that uses the loader, and causes the loader to be invoked with the -appropriate information to run the target executable. + Most uses of dynamically linked programs come through execve() + and use the default loader (/sbin/loader). In Digital UNIX + (and OSF/1) you can also force a specific loader to always be + invoked to load an executable by using the exec_with_loader() + system call. Few, if any, programs use this feature. -The mechanism by which this is done is unknown; it may be possible to -completely replace the OSF/1 loader with one designed for NetBSD, but -that is rather prohibitive. (Additionally, it wouldn't solve the -problem of needing to implement the osf1_exec_with_loader() -functionality.) +2. It is not immediately obvious that the right values are used for + text and data locations when invoking a dynamically linked executable. -In any case, this would not be insignificant; it and/or the -implementation of osf1_exec_with_loader() would probably require a -complete rewrite or duplication of the current execve() code. + The text and data sections, and the break, are set up as if + /sbin/loader itself had been executed. It's not clear that this + is correct, but /sbin/loader seems to expect that at least the + break will be set up this way. -3. Extending the pmap code to handle larger virtual spaces. + This has certain implications for the way mmap() behaves. See + the comment in the osf1_mmap() function in osf1_misc.c. -OSF/1's /sbin/loader wants to be loaded at 0x3ff80000000. Currently, -because of a simplifying assumption (specifically, to only use the -first level-one pte for user-space mappings, effectively turning the -pmap into one that looks much like one for a mc68030), only 8Gb -(0x200000000 bytes) of user virtual space are supported. +3. The stack location is used is the normal NetBSD/alpha stack location. -It is unclear that the extra virtual space is necessary for any -applications that NetBSD/Alpha would be used for, and support for it -would add a significant amount of complexity to the pmap module. -Adding that support would probably require a from-scratch rewrite of -the pmap module. - - -Because of the difficulties in emulating the system call interface -used to run dynamic executables, and the difficulties in allowing -support for the address space the OSF/1 loader needs, I do not think -that it is feasible to support dynamically linked OSF/1 executables -with the OSF/1 loading mechanism. It may be possible to do so with a -new loading mechanism which could be written for NetBSD, but it is -unclear that the necessary interfaces to do even that could be -discovered, and the effort required to implement a new loading -mechanism would be prohibitive. - --- cgd + No attempt is made to put the stack in the place where + Digital UNIX would normally put it. This may confuse some + programs. diff --git a/sys/compat/osf1/README.mach-traps b/sys/compat/osf1/README.mach-traps index c1326769f92..545e626c298 100644 --- a/sys/compat/osf1/README.mach-traps +++ b/sys/compat/osf1/README.mach-traps @@ -1,4 +1,3 @@ -$OpenBSD: README.mach-traps,v 1.2 1996/08/02 20:35:24 niklas Exp $ $NetBSD: README.mach-traps,v 1.1 1995/02/13 21:39:02 cgd Exp $ Some Alpha AXP OSF/1 binaries directly use the facilities provided by @@ -35,15 +34,25 @@ msg_receive_trap -21 5 msg_rpc_trap -22 6 lw_wire -30 3 lw_unwire -31 1 -inode_swap_preference -40 3 +nxm_task_init -33 2 +nxm_sched_thread -34 1 +nxm_idle -35 1 +nxm_wakeup_idle -36 1 +nxm_set_pthid -37 2 +nxm_thread_kill -38 2 +nxm_thread_block -39 1 +nxm_thread_wakeup -40 1 +inode_swap_preference -40 3 old call? init_process -41 0 map_fd -43 5 +nxm_resched -44 2 htg_unix_syscall -52 3 host_self -55 1 host_priv_self -56 1 swtch_pri -59 1 swtch -60 0 thread_switch -61 3 +semop_fast -62 4 mach_sctimes_0 -70 0 only if MACH_SCTIMES defined mach_sctimes_1 -71 1 only if MACH_SCTIMES defined mach_sctimes_2 -72 2 only if MACH_SCTIMES defined diff --git a/sys/compat/osf1/README.syscalls b/sys/compat/osf1/README.syscalls index 0e5cb85dc3b..6b0af772c31 100644 --- a/sys/compat/osf1/README.syscalls +++ b/sys/compat/osf1/README.syscalls @@ -1,5 +1,7 @@ -$OpenBSD: README.syscalls,v 1.2 1996/08/02 20:35:25 niklas Exp $ -$NetBSD: README.syscalls,v 1.1 1995/02/13 21:39:03 cgd Exp $ +$NetBSD: README.syscalls,v 1.2 1999/04/27 16:09:28 cgd Exp $ + +XXX this file should be gutted. functions' comments should go with +XXX the functions. Further, this file is ... very out of date. Once the new syscall argument-handling method was implemented, most OSF/1 syscalls boiled down to their NetBSD equivalents. The @@ -16,7 +18,7 @@ but which seem strange enough to merit a bit more explanation. OSF/1 compatibility is helped by the fact that the sigcontext structure was created for NetBSD/Alpha to be the same as the OSF/1 sigcontext structure. Because of this, only one sendsig() function is -needed, and the the NetBSD sigreturn() function can be used for OSF/1 +needed, and then the NetBSD sigreturn() function can be used for OSF/1 sigreturn(), as well. The system calls are split out among the three files: diff --git a/sys/compat/osf1/files.osf1 b/sys/compat/osf1/files.osf1 index 4c1292ad6a2..b853b3c9d7f 100644 --- a/sys/compat/osf1/files.osf1 +++ b/sys/compat/osf1/files.osf1 @@ -1,5 +1,5 @@ -# $OpenBSD: files.osf1,v 1.4 1999/11/10 15:55:22 mickey Exp $ -# $NetBSD: files.osf1,v 1.3 1995/11/15 05:42:17 cgd Exp $ +# $OpenBSD: files.osf1,v 1.5 2000/08/04 15:47:54 ericj Exp $ +# $NetBSD: files.osf1,v 1.15 1999/05/01 05:49:01 cgd Exp $ # # Config file description for machine-independent OSF/1 compat code. # Included by ports that need it. @@ -9,9 +9,27 @@ # XXX COMPAT_OSF1 requires ECOFF +# syscall table-related files +file compat/osf1/osf1_syscalls.c compat_osf1 & syscall_debug +file compat/osf1/osf1_sysent.c compat_osf1 + +# OSF/1 <-> OpenBSD structure, flag, and value conversion files +file compat/osf1/osf1_cvt.c compat_osf1 +file compat/osf1/osf1_cvt_errno.c compat_osf1 +file compat/osf1/osf1_cvt_signal.c compat_osf1 + +# functionality emulation files +file compat/osf1/osf1_descrip.c compat_osf1 +file compat/osf1/osf1_exec.c compat_osf1 +file compat/osf1/osf1_file.c compat_osf1 +file compat/osf1/osf1_generic.c compat_osf1 file compat/osf1/osf1_ioctl.c compat_osf1 file compat/osf1/osf1_misc.c compat_osf1 +file compat/osf1/osf1_mmap.c compat_osf1 file compat/osf1/osf1_mount.c compat_osf1 +file compat/osf1/osf1_prot.c compat_osf1 +file compat/osf1/osf1_resource.c compat_osf1 file compat/osf1/osf1_signal.c compat_osf1 -file compat/osf1/osf1_syscalls.c compat_osf1 & syscall_debug -file compat/osf1/osf1_sysent.c compat_osf1 +file compat/osf1/osf1_socket.c compat_osf1 +file compat/osf1/osf1_sysv_ipc.c compat_osf1 +file compat/osf1/osf1_time.c compat_osf1 diff --git a/sys/compat/osf1/osf1.h b/sys/compat/osf1/osf1.h new file mode 100644 index 00000000000..f485096d36d --- /dev/null +++ b/sys/compat/osf1/osf1.h @@ -0,0 +1,599 @@ +/* $OpenBSD */ +/* $NetBSD: osf1.h,v 1.20 1999/05/10 21:41:07 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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 _COMPAT_OSF1_OSF1_H_ +#define _COMPAT_OSF1_OSF1_H_ + +/* + * Collected OSF/1 definitions and structures, sorted by OSF/1 header. + * Error numbers (errno.h) aren't here, since they're likely to change + * (additions) more often. + * + * This file is up to date as of Digital UNIX V4.0. + */ + +#include <sys/types.h> +#include <compat/osf1/osf1_errno.h> +#include <compat/osf1/osf1_signal.h> + +/* + * type and structure definitions used by other structures + */ + +typedef int16_t osf1_short; +typedef int32_t osf1_int; +typedef int64_t osf1_long; +typedef u_int32_t osf1_u_int; + +typedef int32_t osf1_dev_t; +typedef u_int32_t osf1_ino_t; +typedef u_int32_t osf1_mode_t; +typedef u_int16_t osf1_nlink_t; +typedef u_int32_t osf1_uid_t; +typedef u_int32_t osf1_gid_t; +typedef u_int64_t osf1_off_t; +typedef int32_t osf1_time_t; +typedef u_int32_t osf1_uint_t; +typedef u_int64_t osf1_sigset_t; +typedef u_int64_t osf1_size_t; +typedef u_int64_t osf1_fsid_t; +typedef u_int64_t osf1_rlim_t; +typedef void *osf1_data_ptr; /* XXX hard to fix size */ +typedef void *osf1_fcn_ptr; /* XXX hard to fix size, bogus */ +typedef osf1_int osf1_key_t; +typedef osf1_int osf1_pid_t; +typedef void (*osf1_handler_t) __P((int)); + +struct osf1_timeval { /* time.h */ + osf1_time_t tv_sec; + osf1_int tv_usec; +}; + + +/* access.h */ + +#define OSF1_F_OK 0 /* pseudo-flag */ +#define OSF1_X_OK 0x01 +#define OSF1_W_OK 0x02 +#define OSF1_R_OK 0x04 + + +/* auxv.h */ + +union osf1_auxv_data { + osf1_long a_val; + osf1_data_ptr a_ptr; + osf1_fcn_ptr a_fcn; +}; + +struct osf1_auxv { + osf1_int a_type; + union osf1_auxv_data a_un; +}; + +/* auxv entry types */ +#define OSF1_AT_NULL 0 +#define OSF1_AT_IGNORE 1 +#define OSF1_AT_EXECFD 2 +#define OSF1_AT_PHDR 3 +#define OSF1_AT_PHENT 4 +#define OSF1_AT_PHNUM 5 +#define OSF1_AT_PAGESZ 6 +#define OSF1_AT_BASE 7 +#define OSF1_AT_FLAGS 8 +#define OSF1_AT_ENTRY 9 +#define OSF1_AT_EXEC_FILENAME 1001 +#define OSF1_AT_EXEC_LOADER_FILENAME 1002 +#define OSF1_AT_EXEC_LOADER_FLAGS 1003 + + +/* exec.h/ldr_exec.h */ + +#define OSF1_LDR_EXEC_DEFAULT_LOADER "/sbin/loader" + +/* exec_with_loader()/OSF1_AT_EXEC_LOADER_FLAGS flags regions */ +#define OSF1_LDR_EXEC_SYSTEM_MASK 0xffff0000 +#define OSF1_LDR_EXEC_USER_MASK 0xffff0000 + +/* OSF1_AT_EXEC_LOADER_FLAGS flags */ +#define OSF1_LDR_EXEC_NOPRIVS_F 0x10000000 +#define OSF1_LDR_EXEC_PTRACE_F 0x20000000 +#define OSF1_LDR_EXEC_SETGID_F 0x40000000 +#define OSF1_LDR_EXEC_SETUID_F 0x80000000 + + +/* fcntl.h */ + +/* fcntl ops */ +#define OSF1_F_DUPFD 0 +#define OSF1_F_GETFD 1 /* uses flags, see below */ +#define OSF1_F_SETFD 2 /* uses flags, see below */ +#define OSF1_F_GETFL 3 /* uses flags, see below */ +#define OSF1_F_SETFL 4 /* uses flags, see below */ +#define OSF1_F_GETOWN 5 +#define OSF1_F_SETOWN 6 +#define OSF1_F_GETLK 7 /* uses osf1_flock, see below */ +#define OSF1_F_SETLK 8 /* uses osf1_flock, see below */ +#define OSF1_F_SETLKW 9 /* uses osf1_flock, see below */ +#define OSF1_F_RGETLK 10 /* [lock mgr op] */ +#define OSF1_F_RSETLK 11 /* [lock mgr op] */ +#define OSF1_F_CNVT 12 /* [lock mgr op] */ +#define OSF1_F_RSETLKW 13 /* [lock mgr op] */ +#define OSF1_F_PURGEFS 14 /* [lock mgr op] */ +#define OSF1_F_PURGENFS 15 /* [DECsafe op] */ + +/* fcntl GETFD/SETFD flags */ +#define OSF1_FD_CLOEXEC 1 + +/* fcntl GETFL/SETFL flags, in addition to the O_* flags below */ +#define OSF1_FASYNC 0x00000040 + +/* struct osf1_flock, for GETLK/SETLK/SETLKW */ +struct osf1_flock { + osf1_short l_type; + osf1_short l_whence; + osf1_off_t l_start; + osf1_off_t l_len; + osf1_pid_t l_pid; +}; + +/* GETLK/SETLK/SETLKW locking types */ +#define OSF1_F_RDLCK 1 +#define OSF1_F_WRLCK 2 +#define OSF1_F_UNLCK 8 + +/* open flags */ +#define OSF1_O_RDONLY 0x00000000 +#define OSF1_O_WRONLY 0x00000001 +#define OSF1_O_RDWR 0x00000002 +#define OSF1_O_ACCMODE 0x00000003 /* mask of RD and WR bits */ +#define OSF1_O_NONBLOCK 0x00000004 +#define OSF1_O_APPEND 0x00000008 +/* no 0x00000010 */ +#define OSF1_O_DEFER 0x00000020 +/* no 0x00000040 */ +/* no 0x00000080 */ +/* no 0x00000100 */ +#define OSF1_O_CREAT 0x00000200 +#define OSF1_O_TRUNC 0x00000400 +#define OSF1_O_EXCL 0x00000800 +#define OSF1_O_NOCTTY 0x00001000 +#define OSF1_O_SYNC 0x00004000 +#define OSF1_O_NDELAY 0x00008000 +#define OSF1_O_DRD 0x00008000 /* == O_NDELAY, DON'T USE */ +/* no 0x00010000 */ +/* no 0x00020000 */ +/* no 0x00040000 */ +#define OSF1_O_DSYNC 0x00080000 +#define OSF1_O_RSYNC 0x00100000 +/* no 0x00200000+ */ + + +/* ioctl.h */ + +#define OSF1_IOCPARM_MASK 0x1fff +#define OSF1_IOCPARM_LEN(x) (((x) >> 16) & OSF1_IOCPARM_MASK) +#define OSF1_IOCGROUP(x) (((x) >> 8) & 0xff) +#define OSF1_IOCCMD(x) ((x) & 0xff) + +#define OSF1_IOCPARM_MAX 8192 +#define OSF1_IOC_VOID 0x20000000 +#define OSF1_IOC_OUT 0x40000000 +#define OSF1_IOC_IN 0x80000000 +#define OSF1_IOC_INOUT (OSF1_IOC_IN|OSF1_IOC_OUT) +#define OSF1_IOC_DIRMASK 0xe0000000 + + +/* mman.h */ + +/* protection mask */ +#define OSF1_PROT_NONE 0 /* pseudo-flag */ +#define OSF1_PROT_READ 0x0001 +#define OSF1_PROT_WRITE 0x0002 +#define OSF1_PROT_EXEC 0x0004 + +/* mmap flags */ +#define OSF1_MAP_SHARED 0x0001 +#define OSF1_MAP_PRIVATE 0x0002 + +#define OSF1_MAP_FILE 0 /* pseudo-flag */ +#define OSF1_MAP_ANON 0x0010 +#define OSF1_MAP_TYPE 0x00f0 + +#define OSF1_MAP_FIXED 0x0100 +#define OSF1_MAP_VARIABLE 0 /* pseudo-flag */ + +#define OSF1_MAP_HASSEMAPHORE 0x0200 +#define OSF1_MAP_INHERIT 0x0400 +#define OSF1_MAP_UNALIGNED 0x0800 + +/* madvise operations */ +#define OSF1_MADV_NORMAL 0 +#define OSF1_MADV_RANDOM 1 +#define OSF1_MADV_SEQUENTIAL 2 +#define OSF1_MADV_WILLNEED 3 +#define OSF1_MADV_DONTNEED_COMPAT 4 +#define OSF1_MADV_SPACEAVAIL 5 +#define OSF1_MADV_DONTNEED 6 + + +/* mount.h */ + +/* file system type numbers */ +#define OSF1_MOUNT_NONE 0 +#define OSF1_MOUNT_UFS 1 +#define OSF1_MOUNT_NFS 2 +#define OSF1_MOUNT_MFS 3 +#define OSF1_MOUNT_PC 4 +#define OSF1_MOUNT_S5FS 5 +#define OSF1_MOUNT_CDFS 6 +#define OSF1_MOUNT_DFS 7 +#define OSF1_MOUNT_EFS 8 +#define OSF1_MOUNT_PROCFS 9 +#define OSF1_MOUNT_MSFS 10 +#define OSF1_MOUNT_FFM 11 +#define OSF1_MOUNT_FDFS 12 +#define OSF1_MOUNT_ADDON 13 +#define OSF1_MOUNT_NFS3 14 + +#define OSF1_MNAMELEN 90 + +/* MFS mount argument structure */ +struct osf1_mfs_args { + osf1_data_ptr name; + osf1_data_ptr base; + osf1_u_int size; +}; + +/* NFS mount argument structure */ +struct osf1_nfs_args { + osf1_data_ptr addr; + osf1_data_ptr fh; + osf1_int flags; + osf1_int wsize; + osf1_int rsize; + osf1_int timeo; + osf1_int retrans; + osf1_data_ptr hostname; + osf1_int acregmin; + osf1_int acregmax; + osf1_int acdirmin; + osf1_int acdirmax; + osf1_data_ptr netname; + osf1_data_ptr pathconf; +}; + +/* NFS mount argument structure flags */ +#define OSF1_NFSMNT_SOFT 0x00000001 +#define OSF1_NFSMNT_WSIZE 0x00000002 +#define OSF1_NFSMNT_RSIZE 0x00000004 +#define OSF1_NFSMNT_TIMEO 0x00000008 +#define OSF1_NFSMNT_RETRANS 0x00000010 +#define OSF1_NFSMNT_HOSTNAME 0x00000020 +#define OSF1_NFSMNT_INT 0x00000040 +#define OSF1_NFSMNT_NOCONN 0x00000080 +#define OSF1_NFSMNT_NOAC 0x00000100 +#define OSF1_NFSMNT_ACREGMIN 0x00000200 +#define OSF1_NFSMNT_ACREGMAX 0x00000400 +#define OSF1_NFSMNT_ACDIRMIN 0x00000800 +#define OSF1_NFSMNT_ACDIRMAX 0x00001000 +#define OSF1_NFSMNT_NOCTO 0x00002000 +#define OSF1_NFSMNT_POSIX 0x00004000 +#define OSF1_NFSMNT_AUTO 0x00008000 +#define OSF1_NFSMNT_SEC 0x00010000 +#define OSF1_NFSMNT_TCP 0x00020000 +#define OSF1_NFSMNT_PROPLIST 0x00040000 +/* no 0x00080000+ */ + +/* union of all mount argument structures */ +union osf1_mount_info { + struct osf1_mfs_args mfs_args; + struct osf1_nfs_args nfs_args; + char pad[80]; +}; + +/* statfs structure */ +struct osf1_statfs { + osf1_short f_type; + osf1_short f_flags; + osf1_int f_fsize; + osf1_int f_bsize; + osf1_int f_blocks; + osf1_int f_bfree; + osf1_int f_bavail; + osf1_int f_files; + osf1_int f_ffree; + osf1_fsid_t f_fsid; + osf1_int f_spare[9]; + char f_mntonname[OSF1_MNAMELEN]; + char f_mntfromname[OSF1_MNAMELEN]; + union osf1_mount_info mount_info; +}; + + +/* reboot.h */ + +/* reboot flags */ +#define OSF1_RB_AUTOBOOT 0 /* pseudo-flag */ + +#define OSF1_RB_ASKNAME 0x0001 +#define OSF1_RB_SINGLE 0x0002 +#define OSF1_RB_NOSYNC 0x0004 +#define OSF1_RB_KDB 0x0004 /* == RB_NOSYNC; boot only? */ +#define OSF1_RB_HALT 0x0008 +#define OSF1_RB_INITNAME 0x0010 +#define OSF1_RB_DFLTROOT 0x0020 +#define OSF1_RB_ALTBOOT 0x0040 +#define OSF1_RB_UNIPROC 0x0080 +#define OSF1_RB_PARAM 0x0100 +#define OSF1_RB_DUMP 0x0200 + + +/* resource.h */ + +#define OSF1_RUSAGE_THREAD 1 +#define OSF1_RUSAGE_SELF 0 +#define OSF1_RUSAGE_CHILDREN -1 + +struct osf1_rusage { + struct osf1_timeval ru_utime; + struct osf1_timeval ru_stime; + osf1_long ru_maxrss; + osf1_long ru_ixrss; + osf1_long ru_idrss; + osf1_long ru_isrss; + osf1_long ru_minflt; + osf1_long ru_majflt; + osf1_long ru_nswap; + osf1_long ru_inblock; + osf1_long ru_oublock; + osf1_long ru_msgsnd; + osf1_long ru_msgrcv; + osf1_long ru_nsignals; + osf1_long ru_nvcsw; + osf1_long ru_nivcsw; +}; + +#define OSF1_RLIMIT_CPU 0 +#define OSF1_RLIMIT_FSIZE 1 +#define OSF1_RLIMIT_DATA 2 +#define OSF1_RLIMIT_STACK 3 +#define OSF1_RLIMIT_CORE 4 +#define OSF1_RLIMIT_RSS 5 +#define OSF1_RLIMIT_NOFILE 6 +#define OSF1_RLIMIT_AS 7 + +#define OSF1_RLIM_INFINITY 0x7fffffffffffffffL + +struct osf1_rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; +}; + + +/* seek.h */ + +#define OSF1_SEEK_SET 0 +#define OSF1_SEEK_CUR 1 +#define OSF1_SEEK_END 2 + + +/* signal.h (some in machine/signal.h) */ + +#define sigemptyset(s) bzero((s), sizeof(*(s))) +#define sigismember(s, n) (*(s) & sigmask(n)) +#define sigaddset(s, n) (*(s) |= sigmask(n)) + +struct osf1_sigaction { + osf1_handler_t sa__handler; + osf1_sigset_t sa_mask; + int sa_flags; +}; + +/* actually from sysmisc.h */ +struct osf1_sigaltstack { + osf1_data_ptr ss_sp; + osf1_int ss_flags; + osf1_size_t ss_size; +}; + +/* sigaction flags */ +#define OSF1_SA_ONSTACK 0x00000001 +#define OSF1_SA_RESTART 0x00000002 +#define OSF1_SA_NOCLDSTOP 0x00000004 +#define OSF1_SA_NODEFER 0x00000008 +#define OSF1_SA_RESETHAND 0x00000010 +#define OSF1_SA_NOCLDWAIT 0x00000020 +#define OSF1_SA_SIGINFO 0x00000040 + +/* sigaltstack flags */ +#define OSF1_SS_ONSTACK 0x00000001 +#define OSF1_SS_DISABLE 0x00000002 +#define OSF1_SS_NOMASK 0x00000004 +#define OSF1_SS_UCONTEXT 0x00000008 + +/* signal set manipulation macros */ +#define osf1_sigmask(n) ((osf1_sigset_t)1 << ((n) - 1)) +#define osf1_sigemptyset(s) (*(s) = (osf1_sigset_t)0) +#define osf1_sigismember(s, n) (*(s) & osf1_sigmask(n)) +#define osf1_sigaddset(s, n) (*(s) |= osf1_sigmask(n)) + + +/* socket.h */ + +struct osf1_msghdr { + osf1_data_ptr msg_name; + osf1_u_int msg_namelen; + osf1_data_ptr msg_iov; /* struct osf1_iovec_xopen * */ + osf1_u_int msg_iovlen; + osf1_data_ptr msg_control; + osf1_u_int msg_controllen; + osf1_int msg_flags; +}; + +struct osf1_msghdr_xopen { + osf1_data_ptr msg_name; + osf1_size_t msg_namelen; + osf1_data_ptr msg_iov; /* struct osf1_iovec_xopen * */ + osf1_int msg_iovlen; + osf1_data_ptr msg_control; + osf1_size_t msg_controllen; + osf1_int msg_flags; +}; + +/* max message iov len */ +#define OSF1_MSG_MAXIOVLEN 16 + +/* send/recv-family message flags */ +#define OSF1_MSG_OOB 0x0001 +#define OSF1_MSG_PEEK 0x0002 +#define OSF1_MSG_DONTROUTE 0x0004 +#define OSF1_MSG_EOR 0x0008 +#define OSF1_MSG_TRUNC 0x0010 +#define OSF1_MSG_CTRUNC 0x0020 +#define OSF1_MSG_WAITALL 0x0040 + + +/* stat.h */ + +struct osf1_stat { + osf1_dev_t st_dev; + osf1_ino_t st_ino; + osf1_mode_t st_mode; + osf1_nlink_t st_nlink; + osf1_uid_t st_uid; + osf1_gid_t st_gid; + osf1_dev_t st_rdev; + osf1_off_t st_size; + osf1_time_t st_atime_sec; + osf1_int st_spare1; + osf1_time_t st_mtime_sec; + osf1_int st_spare2; + osf1_time_t st_ctime_sec; + osf1_int st_spare3; + osf1_uint_t st_blksize; + osf1_int st_blocks; + osf1_uint_t st_flags; + osf1_uint_t st_gen; +}; + + +/* systeminfo.h */ + +#define OSF1_SI_SYSNAME 1 +#define OSF1_SI_HOSTNAME 2 +#define OSF1_SI_RELEASE 3 +#define OSF1_SI_VERSION 4 +#define OSF1_SI_MACHINE 5 +#define OSF1_SI_ARCHITECTURE 6 +#define OSF1_SI_HW_SERIAL 7 +#define OSF1_SI_HW_PROVIDER 8 +#define OSF1_SI_SRPC_DOMAIN 9 +#define OSF1_SI_SET_HOSTNAME 258 +#define OSF1_SI_SET_SYSNAME 259 +#define OSF1_SI_SET_SRPC_DOMAIN 265 + + +/* time.h */ + +struct osf1_itimerval { + struct osf1_timeval it_interval; + struct osf1_timeval it_value; +}; + +#define OSF1_ITIMER_REAL 0 +#define OSF1_ITIMER_VIRTUAL 1 +#define OSF1_ITIMER_PROF 2 + +struct osf1_timezone { + osf1_int tz_minuteswest; + osf1_int tz_dsttime; +}; + + +/* types.h */ + +#define osf1_major(x) ((((dev_t)(x)) >> 20) & 0x00000fff) +#define osf1_minor(x) ((((dev_t)(x)) >> 0) & 0x000fffff) +#define osf1_makedev(x,y) ((((dev_t)(x)) << 20) | ((dev_t)(y))) + + +/* uio.h */ + +struct osf1_iovec { + osf1_data_ptr iov_base; + osf1_int iov_len; +}; + +struct osf1_iovec_xopen { + osf1_data_ptr iov_base; + osf1_size_t iov_len; +}; + + +/* unistd.h (user-land header) */ + +#define OSF1__PC_CHOWN_RESTRICTED 10 +#define OSF1__PC_LINK_MAX 11 +#define OSF1__PC_MAX_CANON 12 +#define OSF1__PC_MAX_INPUT 13 +#define OSF1__PC_NAME_MAX 14 +#define OSF1__PC_NO_TRUNC 15 +#define OSF1__PC_PATH_MAX 16 +#define OSF1__PC_PIPE_BUF 17 +#define OSF1__PC_VDISABLE 18 + + +/* utsname.h */ + +#define OSF1__SYS_NMLN 32 + +struct osf1_utsname { + char sysname[OSF1__SYS_NMLN]; + char nodename[OSF1__SYS_NMLN]; + char release[OSF1__SYS_NMLN]; + char version[OSF1__SYS_NMLN]; + char machine[OSF1__SYS_NMLN]; +}; + + +/* wait.h */ + +/* wait3() and wait4() options. */ +#define OSF1_WNOHANG 0x01 +#define OSF1_WUNTRACED 0x02 + +/* XXX should have status word bits */ + + +#endif /* _COMPAT_OSF1_OSF1_H_ */ diff --git a/sys/compat/osf1/osf1_cvt.c b/sys/compat/osf1/osf1_cvt.c new file mode 100644 index 00000000000..d8c99097ee5 --- /dev/null +++ b/sys/compat/osf1/osf1_cvt.c @@ -0,0 +1,705 @@ +/* $OpenBSD: osf1_cvt.c,v 1.1 2000/08/04 15:47:54 ericj Exp $ */ +/* $NetBSD: osf1_cvt.c,v 1.7 1999/06/26 01:23:23 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/stat.h> +#include <sys/filedesc.h> +#include <sys/kernel.h> +#include <sys/malloc.h> +#include <sys/mman.h> +#include <sys/mount.h> +#include <sys/signal.h> +#include <sys/signalvar.h> +#include <sys/reboot.h> +#include <sys/syscallargs.h> +#include <sys/exec.h> +#include <sys/vnode.h> +#include <sys/socketvar.h> +#include <sys/resource.h> +#include <sys/resourcevar.h> +#include <sys/wait.h> +#include <vm/vm.h> /* XXX see mmap emulation */ + +#include <nfs/rpcv2.h> +#include <nfs/nfsproto.h> +#include <nfs/nfs.h> +#include <nfs/nfsmount.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_util.h> +#include <compat/osf1/osf1_cvt.h> + +const struct emul_flags_xtab osf1_access_flags_xtab[] = { +#if 0 /* pseudo-flag */ + { OSF1_F_OK, OSF1_F_OK, F_OK }, +#endif + { OSF1_X_OK, OSF1_X_OK, X_OK }, + { OSF1_W_OK, OSF1_W_OK, W_OK }, + { OSF1_R_OK, OSF1_R_OK, R_OK }, + { 0 } +}; + +const struct emul_flags_xtab osf1_fcntl_getsetfd_flags_rxtab[] = { + { FD_CLOEXEC, FD_CLOEXEC, OSF1_FD_CLOEXEC }, + { 0 } +}; + +const struct emul_flags_xtab osf1_fcntl_getsetfd_flags_xtab[] = { + { OSF1_FD_CLOEXEC, OSF1_FD_CLOEXEC, FD_CLOEXEC }, + { 0 } +}; + +/* flags specific to GETFL/SETFL; also uses open rxtab */ +const struct emul_flags_xtab osf1_fcntl_getsetfl_flags_rxtab[] = { + { FASYNC, FASYNC, OSF1_FASYNC }, + { 0 } +}; + +/* flags specific to GETFL/SETFL; also uses open xtab */ +const struct emul_flags_xtab osf1_fcntl_getsetfl_flags_xtab[] = { + { OSF1_FASYNC, OSF1_FASYNC, FASYNC }, + { 0 } +}; + +const struct emul_flags_xtab osf1_mmap_flags_xtab[] = { + { OSF1_MAP_SHARED, OSF1_MAP_SHARED, MAP_SHARED }, + { OSF1_MAP_PRIVATE, OSF1_MAP_PRIVATE, MAP_PRIVATE }, + { OSF1_MAP_TYPE, OSF1_MAP_FILE, MAP_FILE }, + { OSF1_MAP_TYPE, OSF1_MAP_ANON, MAP_ANON }, + { OSF1_MAP_FIXED, OSF1_MAP_FIXED, MAP_FIXED }, +#if 0 /* pseudo-flag, and the default */ + { OSF1_MAP_VARIABLE, OSF1_MAP_VARIABLE, 0 }, +#endif + { OSF1_MAP_HASSEMAPHORE, OSF1_MAP_HASSEMAPHORE, MAP_HASSEMAPHORE }, + { OSF1_MAP_INHERIT, OSF1_MAP_INHERIT, MAP_INHERIT }, +#if 0 /* no equivalent +++ */ + { OSF1_MAP_UNALIGNED, OSF1_MAP_UNALIGNED, ??? }, +#endif + { 0 } +}; + +const struct emul_flags_xtab osf1_mmap_prot_xtab[] = { +#if 0 /* pseudo-flag */ + { OSF1_PROT_NONE, OSF1_PROT_NONE, PROT_NONE }, +#endif + { OSF1_PROT_READ, OSF1_PROT_READ, PROT_READ }, + { OSF1_PROT_WRITE, OSF1_PROT_WRITE, PROT_READ|PROT_WRITE }, + { OSF1_PROT_EXEC, OSF1_PROT_EXEC, PROT_READ|PROT_EXEC }, + { 0 } +}; + +const struct emul_flags_xtab osf1_nfs_mount_flags_xtab[] = { + { OSF1_NFSMNT_SOFT, OSF1_NFSMNT_SOFT, NFSMNT_SOFT, }, + { OSF1_NFSMNT_WSIZE, OSF1_NFSMNT_WSIZE, NFSMNT_WSIZE, }, + { OSF1_NFSMNT_RSIZE, OSF1_NFSMNT_RSIZE, NFSMNT_RSIZE, }, + { OSF1_NFSMNT_TIMEO, OSF1_NFSMNT_TIMEO, NFSMNT_TIMEO, }, + { OSF1_NFSMNT_RETRANS, OSF1_NFSMNT_RETRANS, NFSMNT_RETRANS, }, +#if 0 /* no equivalent; needs special handling, see below */ + { OSF1_NFSMNT_HOSTNAME, OSF1_NFSMNT_HOSTNAME, ???, }, +#endif + { OSF1_NFSMNT_INT, OSF1_NFSMNT_INT, NFSMNT_INT, }, + { OSF1_NFSMNT_NOCONN, OSF1_NFSMNT_NOCONN, NFSMNT_NOCONN, }, +#if 0 /* no equivalents */ + { OSF1_NFSMNT_NOAC, OSF1_NFSMNT_NOAC, ???, }, + { OSF1_NFSMNT_ACREGMIN, OSF1_NFSMNT_ACREGMIN, ???, }, + { OSF1_NFSMNT_ACREGMAX, OSF1_NFSMNT_ACREGMAX, ???, }, + { OSF1_NFSMNT_ACDIRMIN, OSF1_NFSMNT_ACDIRMIN, ???, }, + { OSF1_NFSMNT_ACDIRMAX, OSF1_NFSMNT_ACDIRMAX, ???, }, + { OSF1_NFSMNT_NOCTO, OSF1_NFSMNT_NOCTO, ???, }, + { OSF1_NFSMNT_POSIX, OSF1_NFSMNT_POSIX, ???, }, + { OSF1_NFSMNT_AUTO, OSF1_NFSMNT_AUTO, ???, }, + { OSF1_NFSMNT_SEC, OSF1_NFSMNT_SEC, ???, }, + { OSF1_NFSMNT_TCP, OSF1_NFSMNT_TCP, ???, }, + { OSF1_NFSMNT_PROPLIST, OSF1_NFSMNT_PROPLIST, ???, }, +#endif + { 0 } +}; + +const struct emul_flags_xtab osf1_open_flags_rxtab[] = { + { O_ACCMODE, O_RDONLY, OSF1_O_RDONLY }, + { O_ACCMODE, O_WRONLY, OSF1_O_WRONLY }, + { O_ACCMODE, O_RDWR, OSF1_O_RDWR }, + { O_NONBLOCK, O_NONBLOCK, OSF1_O_NONBLOCK }, + { O_APPEND, O_APPEND, OSF1_O_APPEND }, +#if 0 /* no equivalent +++ */ + { ???, ???, O_DEFER }, +#endif + { O_CREAT, O_CREAT, OSF1_O_CREAT }, + { O_TRUNC, O_TRUNC, OSF1_O_TRUNC }, + { O_EXCL, O_EXCL, OSF1_O_EXCL }, + { O_NOCTTY, O_NOCTTY, OSF1_O_NOCTTY }, + { O_SYNC, O_SYNC, OSF1_O_SYNC }, + { O_NDELAY, O_NDELAY, OSF1_O_NDELAY }, +#if 0 /* no equivalent, also same value as O_NDELAY! */ + { ???, ???, O_DRD }, +#endif + { O_DSYNC, O_DSYNC, OSF1_O_DSYNC }, + { O_RSYNC, O_RSYNC, OSF1_O_RSYNC }, + { 0 } +}; + +const struct emul_flags_xtab osf1_open_flags_xtab[] = { + { OSF1_O_ACCMODE, OSF1_O_RDONLY, O_RDONLY }, + { OSF1_O_ACCMODE, OSF1_O_WRONLY, O_WRONLY }, + { OSF1_O_ACCMODE, OSF1_O_RDWR, O_RDWR }, + { OSF1_O_NONBLOCK, OSF1_O_NONBLOCK, O_NONBLOCK }, + { OSF1_O_APPEND, OSF1_O_APPEND, O_APPEND }, +#if 0 /* no equivalent +++ */ + { OSF1_O_DEFER, OSF1_O_DEFER, ??? }, +#endif + { OSF1_O_CREAT, OSF1_O_CREAT, O_CREAT }, + { OSF1_O_TRUNC, OSF1_O_TRUNC, O_TRUNC }, + { OSF1_O_EXCL, OSF1_O_EXCL, O_EXCL }, + { OSF1_O_NOCTTY, OSF1_O_NOCTTY, O_NOCTTY }, + { OSF1_O_SYNC, OSF1_O_SYNC, O_SYNC }, + { OSF1_O_NDELAY, OSF1_O_NDELAY, O_NDELAY }, +#if 0 /* no equivalent, also same value as O_NDELAY! */ + { OSF1_O_DRD, OSF1_O_DRD, ??? }, +#endif + { OSF1_O_DSYNC, OSF1_O_DSYNC, O_DSYNC }, + { OSF1_O_RSYNC, OSF1_O_RSYNC, O_RSYNC }, + { 0 } +}; + +const struct emul_flags_xtab osf1_reboot_opt_xtab[] = { +#if 0 /* pseudo-flag */ + { OSF1_RB_AUTOBOOT, OSF1_RB_AUTOBOOT, RB_AUTOBOOT }, +#endif + { OSF1_RB_ASKNAME, OSF1_RB_ASKNAME, RB_ASKNAME }, + { OSF1_RB_SINGLE, OSF1_RB_SINGLE, RB_SINGLE }, + { OSF1_RB_NOSYNC, OSF1_RB_NOSYNC, RB_NOSYNC }, +#if 0 /* same value as O_NDELAY, only used at boot time? */ + { OSF1_RB_KDB, OSF1_RB_KDB, RB_KDB }, +#endif + { OSF1_RB_HALT, OSF1_RB_HALT, RB_HALT }, + { OSF1_RB_INITNAME, OSF1_RB_INITNAME, RB_INITNAME }, + { OSF1_RB_DFLTROOT, OSF1_RB_DFLTROOT, RB_DFLTROOT }, +#if 0 /* no equivalents +++ */ + { OSF1_RB_ALTBOOT, OSF1_RB_ALTBOOT, ??? }, + { OSF1_RB_UNIPROC, OSF1_RB_UNIPROC, ??? }, + { OSF1_RB_PARAM, OSF1_RB_PARAM, ??? }, +#endif + { OSF1_RB_DUMP, OSF1_RB_DUMP, RB_DUMP }, + { 0 } +}; + +const struct emul_flags_xtab osf1_sendrecv_msg_flags_xtab[] = { + { OSF1_MSG_OOB, OSF1_MSG_OOB, MSG_OOB }, + { OSF1_MSG_PEEK, OSF1_MSG_PEEK, MSG_PEEK }, + { OSF1_MSG_DONTROUTE, OSF1_MSG_DONTROUTE, MSG_DONTROUTE }, + { OSF1_MSG_EOR, OSF1_MSG_EOR, MSG_EOR }, + { OSF1_MSG_TRUNC, OSF1_MSG_TRUNC, MSG_TRUNC }, + { OSF1_MSG_CTRUNC, OSF1_MSG_CTRUNC, MSG_CTRUNC }, + { OSF1_MSG_WAITALL, OSF1_MSG_WAITALL, MSG_WAITALL }, + { 0 } +}; + +const struct emul_flags_xtab osf1_sigaction_flags_rxtab[] = { + { SA_ONSTACK, SA_ONSTACK, OSF1_SA_ONSTACK }, + { SA_RESTART, SA_RESTART, OSF1_SA_RESTART }, + { SA_NOCLDSTOP, SA_NOCLDSTOP, OSF1_SA_NOCLDSTOP }, + { SA_NODEFER, SA_NODEFER, OSF1_SA_NODEFER }, + { SA_RESETHAND, SA_RESETHAND, OSF1_SA_RESETHAND }, + { SA_NOCLDWAIT, SA_NOCLDWAIT, OSF1_SA_NOCLDWAIT }, +#if 0 /* XXX not yet */ + { SA_SIGINFO, SA_SIGINFO, OSF1_SA_SIGINFO }, +#endif + { 0 }, +}; + +const struct emul_flags_xtab osf1_sigaction_flags_xtab[] = { + { OSF1_SA_ONSTACK, OSF1_SA_ONSTACK, SA_ONSTACK }, + { OSF1_SA_RESTART, OSF1_SA_RESTART, SA_RESTART }, + { OSF1_SA_NOCLDSTOP, OSF1_SA_NOCLDSTOP, SA_NOCLDSTOP }, + { OSF1_SA_NODEFER, OSF1_SA_NODEFER, SA_NODEFER }, + { OSF1_SA_RESETHAND, OSF1_SA_RESETHAND, SA_RESETHAND }, + { OSF1_SA_NOCLDWAIT, OSF1_SA_NOCLDWAIT, SA_NOCLDWAIT }, +#if 0 /* XXX not yet */ + { OSF1_SA_SIGINFO, OSF1_SA_SIGINFO, SA_SIGINFO }, +#endif + { 0 }, +}; + +const struct emul_flags_xtab osf1_sigaltstack_flags_rxtab[] = { + { SS_ONSTACK, SS_ONSTACK, OSF1_SS_ONSTACK }, + { SS_DISABLE, SS_DISABLE, OSF1_SS_DISABLE }, +#if 0 /* XXX no equivalents */ + { ???, ???, OSF1_SS_NOMASK }, + { ???, ???, OSF1_SS_UCONTEXT }, +#endif + { 0 }, +}; + +const struct emul_flags_xtab osf1_sigaltstack_flags_xtab[] = { + { OSF1_SS_ONSTACK, OSF1_SS_ONSTACK, SS_ONSTACK }, + { OSF1_SS_DISABLE, OSF1_SS_DISABLE, SS_DISABLE }, +#if 0 /* XXX no equivalents */ + { OSF1_SS_NOMASK, OSF1_SS_NOMASK, ??? }, + { OSF1_SS_UCONTEXT, OSF1_SS_UCONTEXT, ??? }, +#endif + { 0 }, +}; + +const struct emul_flags_xtab osf1_wait_options_xtab[] = { + { OSF1_WNOHANG, OSF1_WNOHANG, WNOHANG }, + { OSF1_WUNTRACED, OSF1_WUNTRACED, WUNTRACED }, + { 0 } +}; + +void +osf1_cvt_flock_from_native(nf, of) + const struct flock *nf; + struct osf1_flock *of; +{ + + memset(of, 0, sizeof of); + + of->l_start = nf->l_start; + of->l_len = nf->l_len; + of->l_pid = nf->l_pid; + + switch (nf->l_type) { + case F_RDLCK: + of->l_type = OSF1_F_RDLCK; + break; + + case F_WRLCK: + of->l_type = OSF1_F_WRLCK; + break; + + case F_UNLCK: + of->l_type = OSF1_F_UNLCK; + break; + } + + switch (nf->l_whence) { + case SEEK_SET: + of->l_whence = OSF1_SEEK_SET; + break; + + case SEEK_CUR: + of->l_whence = OSF1_SEEK_CUR; + break; + + case SEEK_END: + of->l_whence = OSF1_SEEK_END; + break; + } +} + +int +osf1_cvt_flock_to_native(of, nf) + const struct osf1_flock *of; + struct flock *nf; +{ + + memset(nf, 0, sizeof nf); + + nf->l_start = of->l_start; + nf->l_len = of->l_len; + nf->l_pid = of->l_pid; + + switch (of->l_type) { + case OSF1_F_RDLCK: + nf->l_type = F_RDLCK; + break; + + case OSF1_F_WRLCK: + nf->l_type = F_WRLCK; + break; + + case OSF1_F_UNLCK: + nf->l_type = F_UNLCK; + break; + + default: + return (EINVAL); + } + + switch (of->l_whence) { + case OSF1_SEEK_SET: + nf->l_whence = SEEK_SET; + break; + + case OSF1_SEEK_CUR: + nf->l_whence = SEEK_CUR; + break; + + case OSF1_SEEK_END: + nf->l_whence = SEEK_END; + break; + + default: + return (EINVAL); + } + + return (0); +} + +int +osf1_cvt_msghdr_xopen_to_native(omh, bmh) + const struct osf1_msghdr_xopen *omh; + struct msghdr *bmh; +{ + unsigned long leftovers; + + memset(bmh, 0, sizeof bmh); + bmh->msg_name = omh->msg_name; /* XXX sockaddr translation */ + bmh->msg_namelen = omh->msg_namelen; + bmh->msg_iov = NULL; /* iovec xlation separate */ + bmh->msg_iovlen = omh->msg_iovlen; + + /* XXX we don't translate control messages (yet) */ + if (bmh->msg_control != NULL || bmh->msg_controllen != 0) +{ +printf("osf1_cvt_msghdr_xopen_to_native: control\n"); + return (EINVAL); +} + + /* translate flags */ + bmh->msg_flags = emul_flags_translate(osf1_sendrecv_msg_flags_xtab, + omh->msg_flags, &leftovers); + if (leftovers != 0) +{ +printf("osf1_cvt_msghdr_xopen_to_native: leftovers 0x%lx\n", leftovers); + return (EINVAL); +} + + return (0); +} + +int +osf1_cvt_pathconf_name_to_native(oname, bnamep) + int oname, *bnamep; +{ + int error; + + error = 0; + switch (oname) { + case OSF1__PC_CHOWN_RESTRICTED: + *bnamep = _PC_CHOWN_RESTRICTED; + break; + + case OSF1__PC_LINK_MAX: + *bnamep = _PC_LINK_MAX; + break; + + case OSF1__PC_MAX_CANON: + *bnamep = _PC_MAX_CANON; + break; + + case OSF1__PC_MAX_INPUT: + *bnamep = _PC_MAX_INPUT; + break; + + case OSF1__PC_NAME_MAX: + *bnamep = _PC_NAME_MAX; + break; + + case OSF1__PC_NO_TRUNC: + *bnamep = _PC_NO_TRUNC; + break; + + case OSF1__PC_PATH_MAX: + *bnamep = _PC_PATH_MAX; + break; + + case OSF1__PC_PIPE_BUF: + *bnamep = _PC_PIPE_BUF; + break; + + case OSF1__PC_VDISABLE: + *bnamep = _PC_VDISABLE; + break; + + default: + error = EINVAL; + break; + } + + return (error); +} + +/* + * Convert from as rusage structure to an osf1 rusage structure. + */ +void +osf1_cvt_rusage_from_native(ru, oru) + const struct rusage *ru; + struct osf1_rusage *oru; +{ + + oru->ru_utime.tv_sec = ru->ru_utime.tv_sec; + oru->ru_utime.tv_usec = ru->ru_utime.tv_usec; + + oru->ru_stime.tv_sec = ru->ru_stime.tv_sec; + oru->ru_stime.tv_usec = ru->ru_stime.tv_usec; + + oru->ru_maxrss = ru->ru_maxrss; + oru->ru_ixrss = ru->ru_ixrss; + oru->ru_idrss = ru->ru_idrss; + oru->ru_isrss = ru->ru_isrss; + oru->ru_minflt = ru->ru_minflt; + oru->ru_majflt = ru->ru_majflt; + oru->ru_nswap = ru->ru_nswap; + oru->ru_inblock = ru->ru_inblock; + oru->ru_oublock = ru->ru_oublock; + oru->ru_msgsnd = ru->ru_msgsnd; + oru->ru_msgrcv = ru->ru_msgrcv; + oru->ru_nsignals = ru->ru_nsignals; + oru->ru_nvcsw = ru->ru_nvcsw; + oru->ru_nivcsw = ru->ru_nivcsw; +} + +/* + * XXX: Only a subset of the flags is currently implemented. + */ +void +osf1_cvt_sigaction_from_native(bsa, osa) + const struct sigaction *bsa; + struct osf1_sigaction *osa; +{ + osa->sa__handler = bsa->sa_handler; + osf1_cvt_sigset_from_native(&bsa->sa_mask, &osa->sa_mask); + osa->sa_flags = 0; + + /* Translate by hand */ + if ((bsa->sa_flags & SA_ONSTACK) != 0) + osa->sa_flags |= OSF1_SA_ONSTACK; + if ((bsa->sa_flags & SA_RESTART) != 0) + osa->sa_flags |= OSF1_SA_RESTART; + if ((bsa->sa_flags & SA_NOCLDSTOP) != 0) + osa->sa_flags |= OSF1_SA_NOCLDSTOP; + if ((bsa->sa_flags & SA_NOCLDWAIT) != 0) + osa->sa_flags |= OSF1_SA_NOCLDWAIT; + if ((bsa->sa_flags & SA_NODEFER) != 0) + osa->sa_flags |= OSF1_SA_NODEFER; + if ((bsa->sa_flags & SA_RESETHAND) != 0) + osa->sa_flags |= OSF1_SA_RESETHAND; + if ((bsa->sa_flags & SA_SIGINFO) != 0) + osa->sa_flags |= OSF1_SA_SIGINFO; +} + +int +osf1_cvt_sigaction_to_native(osa, bsa) + const struct osf1_sigaction *osa; + struct sigaction *bsa; +{ + bsa->sa_handler = osa->sa__handler; + osf1_cvt_sigset_to_native(&osa->sa_mask, &bsa->sa_mask); + bsa->sa_flags = 0; + + /* Translate by hand */ + if ((osa->sa_flags & OSF1_SA_ONSTACK) != 0) + bsa->sa_flags |= SA_ONSTACK; + if ((osa->sa_flags & OSF1_SA_RESTART) != 0) + bsa->sa_flags |= SA_RESTART; + if ((osa->sa_flags & OSF1_SA_RESETHAND) != 0) + bsa->sa_flags |= SA_RESETHAND; + if ((osa->sa_flags & OSF1_SA_NOCLDSTOP) != 0) + bsa->sa_flags |= SA_NOCLDSTOP; + if ((osa->sa_flags & OSF1_SA_NOCLDWAIT) != 0) + bsa->sa_flags |= SA_NOCLDWAIT; + if ((osa->sa_flags & OSF1_SA_NODEFER) != 0) + bsa->sa_flags |= SA_NODEFER; + if ((osa->sa_flags & OSF1_SA_SIGINFO) != 0) + bsa->sa_flags |= SA_SIGINFO; + + return(0); +} + +void +osf1_cvt_sigaltstack_from_native(bss, oss) + const struct sigaltstack *bss; + struct osf1_sigaltstack *oss; +{ + + oss->ss_sp = bss->ss_sp; + oss->ss_size = bss->ss_size; + + /* translate flags */ + oss->ss_flags = emul_flags_translate(osf1_sigaltstack_flags_rxtab, + bss->ss_flags, NULL); +} + +int +osf1_cvt_sigaltstack_to_native(oss, bss) + const struct osf1_sigaltstack *oss; + struct sigaltstack *bss; +{ + unsigned long leftovers; + + bss->ss_sp = oss->ss_sp; + bss->ss_size = oss->ss_size; + + /* translate flags */ + bss->ss_flags = emul_flags_translate(osf1_sigaltstack_flags_xtab, + oss->ss_flags, &leftovers); + + if (leftovers != 0) { + printf("osf1_cvt_sigaltstack_to_native: leftovers = 0x%lx\n", + leftovers); + return (EINVAL); + } + + return (0); +} + +void +osf1_cvt_sigset_from_native(bss, oss) + const sigset_t *bss; + osf1_sigset_t *oss; +{ + int i, newsig; + + osf1_sigemptyset(oss); + for (i = 1; i < NSIG; i++) { + if (sigismember(bss, i)) { + newsig = osf1_signal_rxlist[i]; + if (newsig) + osf1_sigaddset(oss, newsig); + } + } +} + +int +osf1_cvt_sigset_to_native(oss, bss) + const osf1_sigset_t *oss; + sigset_t *bss; +{ + int i, newsig; + + sigemptyset(bss); + for (i = 1; i < OSF1_NSIG; i++) { + if (osf1_sigismember(oss, i)) { + newsig = osf1_signal_xlist[i]; + if (newsig) + sigaddset(bss, newsig); + } + } + return (0); +} + +/* + * Convert from a stat structure to an osf1 stat structure. + */ +void +osf1_cvt_stat_from_native(st, ost) + const struct stat *st; + struct osf1_stat *ost; +{ + + ost->st_dev = osf1_cvt_dev_from_native(st->st_dev); + ost->st_ino = st->st_ino; + ost->st_mode = st->st_mode; + ost->st_nlink = st->st_nlink; + ost->st_uid = st->st_uid == -2 ? (u_int16_t) -2 : st->st_uid; + ost->st_gid = st->st_gid == -2 ? (u_int16_t) -2 : st->st_gid; + ost->st_rdev = osf1_cvt_dev_from_native(st->st_rdev); + ost->st_size = st->st_size; + ost->st_atime_sec = st->st_atime; + ost->st_spare1 = 0; + ost->st_mtime_sec = st->st_mtime; + ost->st_spare2 = 0; + ost->st_ctime_sec = st->st_ctime; + ost->st_spare3 = 0; + ost->st_blksize = st->st_blksize; + ost->st_blocks = st->st_blocks; + ost->st_flags = st->st_flags; + ost->st_gen = st->st_gen; +} + +void +osf1_cvt_statfs_from_native(bsfs, osfs) + const struct statfs *bsfs; + struct osf1_statfs *osfs; +{ + + memset(osfs, 0, sizeof (struct osf1_statfs)); + if (!strncmp(MOUNT_FFS, bsfs->f_fstypename, MFSNAMELEN)) + osfs->f_type = OSF1_MOUNT_UFS; + else if (!strncmp(MOUNT_NFS, bsfs->f_fstypename, MFSNAMELEN)) + osfs->f_type = OSF1_MOUNT_NFS; + else if (!strncmp(MOUNT_MFS, bsfs->f_fstypename, MFSNAMELEN)) + osfs->f_type = OSF1_MOUNT_MFS; + else + /* uh oh... XXX = PC, CDFS, PROCFS, etc. */ + osfs->f_type = OSF1_MOUNT_ADDON; + osfs->f_flags = bsfs->f_flags; /* XXX translate */ + osfs->f_fsize = bsfs->f_bsize; + osfs->f_bsize = bsfs->f_iosize; + osfs->f_blocks = bsfs->f_blocks; + osfs->f_bfree = bsfs->f_bfree; + osfs->f_bavail = bsfs->f_bavail; + osfs->f_files = bsfs->f_files; + osfs->f_ffree = bsfs->f_ffree; + memcpy(&osfs->f_fsid, &bsfs->f_fsid, + max(sizeof bsfs->f_fsid, sizeof osfs->f_fsid)); + /* osfs->f_spare zeroed above */ + memcpy(osfs->f_mntonname, bsfs->f_mntonname, + max(sizeof bsfs->f_mntonname, sizeof osfs->f_mntonname)); + memcpy(osfs->f_mntfromname, bsfs->f_mntfromname, + max(sizeof bsfs->f_mntfromname, sizeof osfs->f_mntfromname)); + /* XXX osfs->f_xxx should be filled in... */ +} diff --git a/sys/compat/osf1/osf1_cvt.h b/sys/compat/osf1/osf1_cvt.h new file mode 100644 index 00000000000..1f8dd8f43b1 --- /dev/null +++ b/sys/compat/osf1/osf1_cvt.h @@ -0,0 +1,98 @@ +/* $OpenBSD: osf1_cvt.h,v 1.1 2000/08/04 15:47:54 ericj Exp $ */ +/* $NetBSD: osf1_cvt.h,v 1.5 1999/05/10 05:58:44 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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 _COMPAT_OSF1_OSF1_CVT_H_ +#define _COMPAT_OSF1_OSF1_CVT_H_ + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/mount.h> +#include <sys/resource.h> +#include <sys/signal.h> +#include <sys/stat.h> +#include <sys/fcntl.h> + +#include <compat/common/compat_util.h> + +#define osf1_cvt_dev_from_native(dev) \ + osf1_makedev(major(dev), minor(dev)) +#define osf1_cvt_dev_to_native(dev) \ + makedev(osf1_major(dev), osf1_minor(dev)) + +void osf1_cvt_flock_from_native(const struct flock *nf, + struct osf1_flock *of); +int osf1_cvt_flock_to_native(const struct osf1_flock *of, + struct flock *nf); +int osf1_cvt_msghdr_xopen_to_native(const struct osf1_msghdr_xopen *omh, + struct msghdr *nmh); +int osf1_cvt_pathconf_name_to_native(int oname, int *bnamep); +void osf1_cvt_rusage_from_native(const struct rusage *nru, + struct osf1_rusage *oru); +void osf1_cvt_sigaction_from_native(const struct sigaction *nsa, + struct osf1_sigaction *osa); +int osf1_cvt_sigaction_to_native(const struct osf1_sigaction *osa, + struct sigaction *nsa); +void osf1_cvt_sigaltstack_from_native(const struct sigaltstack *nss, + struct osf1_sigaltstack *oss); +int osf1_cvt_sigaltstack_to_native(const struct osf1_sigaltstack *oss, + struct sigaltstack *nss); +void osf1_cvt_sigset_from_native(const sigset_t *nss, osf1_sigset_t *oss); +int osf1_cvt_sigset_to_native(const osf1_sigset_t *oss, sigset_t *nss); +void osf1_cvt_stat_from_native(const struct stat *nst, + struct osf1_stat *ost); +void osf1_cvt_statfs_from_native(const struct statfs *nsfs, + struct osf1_statfs *osfs); + +extern const int osf1_errno_rxlist[]; +extern const int osf1_signal_xlist[]; +extern const int osf1_signal_rxlist[]; + +extern const struct emul_flags_xtab osf1_access_flags_xtab[]; +extern const struct emul_flags_xtab osf1_fcntl_getsetfd_flags_rxtab[]; +extern const struct emul_flags_xtab osf1_fcntl_getsetfd_flags_xtab[]; +extern const struct emul_flags_xtab osf1_fcntl_getsetfl_flags_rxtab[]; +extern const struct emul_flags_xtab osf1_fcntl_getsetfl_flags_xtab[]; +extern const struct emul_flags_xtab osf1_mmap_flags_xtab[]; +extern const struct emul_flags_xtab osf1_mmap_prot_xtab[]; +extern const struct emul_flags_xtab osf1_nfs_mount_flags_xtab[]; +extern const struct emul_flags_xtab osf1_open_flags_rxtab[]; +extern const struct emul_flags_xtab osf1_open_flags_xtab[]; +extern const struct emul_flags_xtab osf1_reboot_opt_xtab[]; +extern const struct emul_flags_xtab osf1_sendrecv_msg_flags_xtab[]; +extern const struct emul_flags_xtab osf1_sigaction_flags_rxtab[]; +extern const struct emul_flags_xtab osf1_sigaction_flags_xtab[]; +extern const struct emul_flags_xtab osf1_sigaltstack_flags_rxtab[]; +extern const struct emul_flags_xtab osf1_sigaltstack_flags_xtab[]; +extern const struct emul_flags_xtab osf1_wait_options_xtab[]; + +#endif /* _COMPAT_OSF1_OSF1_CVT_H_ */ diff --git a/sys/compat/osf1/osf1_cvt_errno.c b/sys/compat/osf1/osf1_cvt_errno.c new file mode 100644 index 00000000000..f31b2a5a1c0 --- /dev/null +++ b/sys/compat/osf1/osf1_cvt_errno.c @@ -0,0 +1,130 @@ +/* $OpenBSD: osf1_cvt_errno.c,v 1.1 2000/08/04 15:47:54 ericj Exp $ */ +/* $NetBSD: osf1_cvt_errno.c,v 1.4 1999/05/01 02:16:01 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_cvt.h> + +/* + * This table is used to translate NetBSD errnos to OSF/1 errnos + * when returning from a system call. + * + * It is up to date as of Digital UNIX V4.0 and NetBSD 1.4. + */ + +const int osf1_errno_rxlist[] = { + 0, + OSF1_EPERM, /* EPERM (1) -> 1 */ + OSF1_ENOENT, /* ENOENT (2) -> 2 */ + OSF1_ESRCH, /* ESRCH (3) -> 3 */ + OSF1_EINTR, /* EINTR (4) -> 4 */ + OSF1_EIO, /* EIO (5) -> 5 */ + OSF1_ENXIO, /* ENXIO (6) -> 6 */ + OSF1_E2BIG, /* E2BIG (7) -> 7 */ + OSF1_ENOEXEC, /* ENOEXEC (8) -> 8 */ + OSF1_EBADF, /* EBADF (9) -> 9 */ + OSF1_ECHILD, /* ECHILD (10) -> 10 */ + OSF1_EDEADLK, /* EDEADLK (11) -> 11 */ + OSF1_ENOMEM, /* ENOMEM (12) -> 12 */ + OSF1_EACCES, /* EACCES (13) -> 13 */ + OSF1_EFAULT, /* EFAULT (14) -> 14 */ + OSF1_ENOTBLK, /* ENOTBLK (15) -> 15 */ + OSF1_EBUSY, /* EBUSY (16) -> 16 */ + OSF1_EEXIST, /* EEXIST (17) -> 17 */ + OSF1_EXDEV, /* EXDEV (18) -> 18 */ + OSF1_ENODEV, /* ENODEV (19) -> 19 */ + OSF1_ENOTDIR, /* ENOTDIR (20) -> 20 */ + OSF1_EISDIR, /* EISDIR (21) -> 21 */ + OSF1_EINVAL, /* EINVAL (22) -> 22 */ + OSF1_ENFILE, /* ENFILE (23) -> 23 */ + OSF1_EMFILE, /* EMFILE (24) -> 24 */ + OSF1_ENOTTY, /* ENOTTY (25) -> 25 */ + OSF1_ETXTBSY, /* ETXTBSY (26) -> 26 */ + OSF1_EFBIG, /* EFBIG (27) -> 27 */ + OSF1_ENOSPC, /* ENOSPC (28) -> 28 */ + OSF1_ESPIPE, /* ESPIPE (29) -> 29 */ + OSF1_EROFS, /* EROFS (30) -> 30 */ + OSF1_EMLINK, /* EMLINK (31) -> 31 */ + OSF1_EPIPE, /* EPIPE (32) -> 32 */ + OSF1_EDOM, /* EDOM (33) -> 33 */ + OSF1_ERANGE, /* ERANGE (34) -> 34 */ + OSF1_EWOULDBLOCK, /* EAGAIN (35) -> OSF1_EWOULDBLOCK (35) */ + OSF1_EINPROGRESS, /* EINPROGRESS (36) -> 36 */ + OSF1_EALREADY, /* EALREADY (37) -> 37 */ + OSF1_ENOTSOCK, /* ENOTSOCK (38) -> 38 */ + OSF1_EDESTADDRREQ, /* EDESTADDRREQ (39) -> 39 */ + OSF1_EMSGSIZE, /* EMSGSIZE (40) -> 40 */ + OSF1_EPROTOTYPE, /* EPROTOTYPE (41) -> 41 */ + OSF1_ENOPROTOOPT, /* ENOPROTOOPT (42) -> 42 */ + OSF1_EPROTONOSUPPORT, /* EPROTONOSUPPORT (43) -> 43 */ + OSF1_ESOCKTNOSUPPORT, /* ESOCKTNOSUPPORT (44) -> 44 */ + OSF1_EOPNOTSUPP, /* EOPNOTSUPP (45) -> 45 */ + OSF1_EPFNOSUPPORT, /* EPFNOSUPPORT (46) -> 46 */ + OSF1_EAFNOSUPPORT, /* EAFNOSUPPORT (47) -> 47 */ + OSF1_EADDRINUSE, /* EADDRINUSE (48) -> 48 */ + OSF1_EADDRNOTAVAIL, /* EADDRNOTAVAIL (49) -> 49 */ + OSF1_ENETDOWN, /* ENETDOWN (50) -> 50 */ + OSF1_ENETUNREACH, /* ENETUNREACH (51) -> 51 */ + OSF1_ENETRESET, /* ENETRESET (52) -> 52 */ + OSF1_ECONNABORTED, /* ECONNABORTED (53) -> 53 */ + OSF1_ECONNRESET, /* ECONNRESET (54) -> 54 */ + OSF1_ENOBUFS, /* ENOBUFS (55) -> 55 */ + OSF1_EISCONN, /* EISCONN (56) -> 56 */ + OSF1_ENOTCONN, /* ENOTCONN (57) -> 57 */ + OSF1_ESHUTDOWN, /* ESHUTDOWN (58) -> 58 */ + OSF1_ETOOMANYREFS, /* ETOOMANYREFS (59) -> 59 */ + OSF1_ETIMEDOUT, /* ETIMEDOUT (60) -> 60 */ + OSF1_ECONNREFUSED, /* ECONNREFUSED (61) -> 61 */ + OSF1_ELOOP, /* ELOOP (62) -> 62 */ + OSF1_ENAMETOOLONG, /* ENAMETOOLONG (63) -> 63 */ + OSF1_EHOSTDOWN, /* EHOSTDOWN (64) -> 64 */ + OSF1_EHOSTUNREACH, /* EHOSTUNREACH (65) -> 65 */ + OSF1_ENOTEMPTY, /* ENOTEMPTY (66) -> 66 */ + OSF1_EPROCLIM, /* EPROCLIM (67) -> 67 */ + OSF1_EUSERS, /* EUSERS (68) -> 68 */ + OSF1_EDQUOT, /* EDQUOT (69) -> 69 */ + OSF1_ESTALE, /* ESTALE (70) -> 70 */ + OSF1_EREMOTE, /* EREMOTE (71) -> 71 */ + OSF1_EBADRPC, /* EBADRPC (72) -> 72 */ + OSF1_ERPCMISMATCH, /* ERPCMISMATCH (73) -> 73 */ + OSF1_EPROGUNAVAIL, /* EPROGUNAVAIL (74) -> 74 */ + OSF1_EPROGMISMATCH, /* EPROGMISMATCH (75) -> 75 */ + OSF1_EPROCUNAVAIL, /* EPROCUNAVAIL (76) -> 76 */ + OSF1_ENOLCK, /* ENOLCK (77) -> 77 */ + OSF1_ENOSYS, /* ENOSYS (78) -> 78 */ + OSF1_EFTYPE, /* EFTYPE (79) -> 79 */ + OSF1_ENOSYS, /* EAUTH (80) has no equivalent */ + OSF1_ENOSYS, /* ENEEDAUTH (81) has no equivalent */ + OSF1_EIDRM, /* EIDRM (82) -> 81 */ + OSF1_ENOMSG, /* ENOMSG (83) -> 80 */ + OSF1_EOVERFLOW, /* EOVERFLOW (84) -> 103 */ +}; diff --git a/sys/compat/osf1/osf1_cvt_signal.c b/sys/compat/osf1/osf1_cvt_signal.c new file mode 100644 index 00000000000..1ae4d84e7a3 --- /dev/null +++ b/sys/compat/osf1/osf1_cvt_signal.c @@ -0,0 +1,112 @@ +/* $OpenBSD: osf1_cvt_signal.c,v 1.1 2000/08/04 15:47:54 ericj Exp $ */ +/* $NetBSD: osf1_signal.c,v 1.13 1999/04/30 05:24:04 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_cvt.h> + +/* + * These tables are used to translate between NetBSD and OSF/1 signal + * numbers. + * + * XXX IT IS NOT UP TO DATE. + */ + +const int osf1_signal_rxlist[] = { + 0, + OSF1_SIGHUP, + OSF1_SIGINT, + OSF1_SIGQUIT, + OSF1_SIGILL, + OSF1_SIGTRAP, + OSF1_SIGABRT, + OSF1_SIGEMT, + OSF1_SIGFPE, + OSF1_SIGKILL, + OSF1_SIGBUS, + OSF1_SIGSEGV, + OSF1_SIGSYS, + OSF1_SIGPIPE, + OSF1_SIGALRM, + OSF1_SIGTERM, + OSF1_SIGURG, + OSF1_SIGSTOP, + OSF1_SIGTSTP, + OSF1_SIGCONT, + OSF1_SIGCHLD, + OSF1_SIGTTIN, + OSF1_SIGTTOU, + OSF1_SIGIO, + OSF1_SIGXCPU, + OSF1_SIGXFSZ, + OSF1_SIGVTALRM, + OSF1_SIGPROF, + OSF1_SIGWINCH, + OSF1_SIGINFO, + OSF1_SIGUSR1, + OSF1_SIGUSR2, +}; + +const int osf1_signal_xlist[] = { + 0, + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGTRAP, + SIGABRT, + SIGEMT, + SIGFPE, + SIGKILL, + SIGBUS, + SIGSEGV, + SIGSYS, + SIGPIPE, + SIGALRM, + SIGTERM, + SIGURG, + SIGSTOP, + SIGTSTP, + SIGCONT, + SIGCHLD, + SIGTTIN, + SIGTTOU, + SIGIO, + SIGXCPU, + SIGXFSZ, + SIGVTALRM, + SIGPROF, + SIGWINCH, + SIGINFO, + SIGUSR1, + SIGUSR2, +}; diff --git a/sys/compat/osf1/osf1_descrip.c b/sys/compat/osf1/osf1_descrip.c new file mode 100644 index 00000000000..a9123899768 --- /dev/null +++ b/sys/compat/osf1/osf1_descrip.c @@ -0,0 +1,305 @@ +/* $OpenBSD: osf1_descrip.c,v 1.1 2000/08/04 15:47:54 ericj Exp $ */ +/* $NetBSD: osf1_descrip.c,v 1.5 1999/06/26 01:24:41 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/stat.h> +#include <sys/filedesc.h> +#include <sys/kernel.h> +#include <sys/malloc.h> +#include <sys/mman.h> +#include <sys/mount.h> +#include <sys/signal.h> +#include <sys/signalvar.h> +#include <sys/reboot.h> +#include <sys/syscallargs.h> +#include <sys/exec.h> +#include <sys/vnode.h> +#include <sys/socketvar.h> +#include <sys/resource.h> +#include <sys/resourcevar.h> +#include <sys/wait.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_cvt.h> + +int +osf1_sys_fcntl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_fcntl_args *uap = v; + struct sys_fcntl_args a; + struct osf1_flock oflock; + struct flock nflock; + unsigned long xfl, leftovers; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + + SCARG(&a, fd) = SCARG(uap, fd); + + leftovers = 0; + switch (SCARG(uap, cmd)) { + case OSF1_F_DUPFD: + SCARG(&a, cmd) = F_DUPFD; + SCARG(&a, arg) = SCARG(uap, arg); + break; + + case OSF1_F_GETFD: + SCARG(&a, cmd) = F_GETFD; + SCARG(&a, arg) = 0; /* ignored */ + break; + + case OSF1_F_SETFD: + SCARG(&a, cmd) = F_SETFD; + SCARG(&a, arg) = (void *)emul_flags_translate( + osf1_fcntl_getsetfd_flags_xtab, + (unsigned long)SCARG(uap, arg), &leftovers); + break; + + case OSF1_F_GETFL: + SCARG(&a, cmd) = F_GETFL; + SCARG(&a, arg) = 0; /* ignored */ + break; + + case OSF1_F_SETFL: + SCARG(&a, cmd) = F_SETFL; + xfl = emul_flags_translate(osf1_open_flags_xtab, + (unsigned long)SCARG(uap, arg), &leftovers); + xfl |= emul_flags_translate(osf1_fcntl_getsetfl_flags_xtab, + leftovers, &leftovers); + SCARG(&a, arg) = (void *)xfl; + break; + + case OSF1_F_GETOWN: /* XXX not yet supported */ + case OSF1_F_SETOWN: /* XXX not yet supported */ + /* XXX translate. */ + return (EINVAL); + + case OSF1_F_GETLK: + case OSF1_F_SETLK: + case OSF1_F_SETLKW: + if (SCARG(uap, cmd) == OSF1_F_GETLK) + SCARG(&a, cmd) = F_GETLK; + else if (SCARG(uap, cmd) == OSF1_F_SETLK) + SCARG(&a, cmd) = F_SETLK; + else if (SCARG(uap, cmd) == OSF1_F_SETLKW) + SCARG(&a, cmd) = F_SETLKW; + SCARG(&a, arg) = stackgap_alloc(&sg, sizeof nflock); + + error = copyin(SCARG(uap, arg), &oflock, sizeof oflock); + if (error == 0) + error = osf1_cvt_flock_to_native(&oflock, &nflock); + if (error == 0) + error = copyout(&nflock, SCARG(&a, arg), + sizeof nflock); + if (error != 0) + return (error); + break; + + case OSF1_F_RGETLK: /* [lock mgr op] XXX not supported */ + case OSF1_F_RSETLK: /* [lock mgr op] XXX not supported */ + case OSF1_F_CNVT: /* [lock mgr op] XXX not supported */ + case OSF1_F_RSETLKW: /* [lock mgr op] XXX not supported */ + case OSF1_F_PURGEFS: /* [lock mgr op] XXX not supported */ + case OSF1_F_PURGENFS: /* [DECsafe op] XXX not supported */ + default: + /* XXX syslog? */ + return (EINVAL); + } + if (leftovers != 0) + return (EINVAL); + + error = sys_fcntl(p, &a, retval); + + if (error) + return error; + + switch (SCARG(uap, cmd)) { + case OSF1_F_GETFD: + retval[0] = emul_flags_translate( + osf1_fcntl_getsetfd_flags_rxtab, retval[0], NULL); + break; + + case OSF1_F_GETFL: + xfl = emul_flags_translate(osf1_open_flags_rxtab, + retval[0], &leftovers); + xfl |= emul_flags_translate(osf1_fcntl_getsetfl_flags_rxtab, + leftovers, NULL); + retval[0] = xfl; + break; + + case OSF1_F_GETLK: + error = copyin(SCARG(&a, arg), &nflock, sizeof nflock); + if (error == 0) { + osf1_cvt_flock_from_native(&nflock, &oflock); + error = copyout(&oflock, SCARG(uap, arg), + sizeof oflock); + } + break; + } + + return error; +} + +int +osf1_sys_fpathconf(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_fpathconf_args *uap = v; + struct sys_fpathconf_args a; + int error; + + SCARG(&a, fd) = SCARG(uap, fd); + + error = osf1_cvt_pathconf_name_to_native(SCARG(uap, name), + &SCARG(&a, name)); + + if (error == 0) + error = sys_fpathconf(p, &a, retval); + + return (error); +} + +/* + * Return status information about a file descriptor. + */ +int +osf1_sys_fstat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_fstat_args *uap = v; + struct filedesc *fdp = p->p_fd; + struct file *fp; + struct stat ub; + struct osf1_stat oub; + int error; + + /* XXX */ + if ((unsigned)SCARG(uap, fd) >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) /* || + (fp->f_iflags & FIF_WANTCLOSE) != 0) */ + return (EBADF); + + switch (fp->f_type) { + + case DTYPE_VNODE: + error = vn_stat((struct vnode *)fp->f_data, &ub, p); + break; + + case DTYPE_SOCKET: + error = soo_stat((struct socket *)fp->f_data, &ub); + break; + + default: + panic("ofstat"); + /*NOTREACHED*/ + } + osf1_cvt_stat_from_native(&ub, &oub); + if (error == 0) + error = copyout((caddr_t)&oub, (caddr_t)SCARG(uap, sb), + sizeof (oub)); + + return (error); +} + +int +osf1_sys_ftruncate(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_ftruncate_args *uap = v; + struct sys_ftruncate_args a; + + SCARG(&a, fd) = SCARG(uap, fd); + SCARG(&a, pad) = 0; + SCARG(&a, length) = SCARG(uap, length); + + return sys_ftruncate(p, &a, retval); +} + +int +osf1_sys_lseek(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_lseek_args *uap = v; + struct sys_lseek_args a; + + SCARG(&a, fd) = SCARG(uap, fd); + SCARG(&a, pad) = 0; + SCARG(&a, offset) = SCARG(uap, offset); + SCARG(&a, whence) = SCARG(uap, whence); + + return sys_lseek(p, &a, retval); +} diff --git a/sys/compat/osf1/osf1_errno.h b/sys/compat/osf1/osf1_errno.h new file mode 100644 index 00000000000..c69e14321ea --- /dev/null +++ b/sys/compat/osf1/osf1_errno.h @@ -0,0 +1,149 @@ +/* $OpenBSD: osf1_errno.h,v 1.1 2000/08/04 15:47:54 ericj Exp $ */ +/* $NetBSD: osf1_errno.h,v 1.2 1999/04/23 18:00:34 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +/* + * OSF/1 error number definitions, as described by the Digital UNIX V4.0 + * <sys/errno.h>. + */ + +#ifndef _COMPAT_OSF1_OSF1_ERRNO_H_ +#define _COMPAT_OSF1_OSF1_ERRNO_H_ + +#define OSF1_ESUCCESS 0 +#define OSF1_EPERM 1 +#define OSF1_ENOENT 2 +#define OSF1_ESRCH 3 +#define OSF1_EINTR 4 +#define OSF1_EIO 5 +#define OSF1_ENXIO 6 +#define OSF1_E2BIG 7 +#define OSF1_ENOEXEC 8 +#define OSF1_EBADF 9 +#define OSF1_ECHILD 10 +#define OSF1_EDEADLK 11 +#define OSF1_ENOMEM 12 +#define OSF1_EACCES 13 +#define OSF1_EFAULT 14 +#define OSF1_ENOTBLK 15 +#define OSF1_EBUSY 16 +#define OSF1_EEXIST 17 +#define OSF1_EXDEV 18 +#define OSF1_ENODEV 19 +#define OSF1_ENOTDIR 20 +#define OSF1_EISDIR 21 +#define OSF1_EINVAL 22 +#define OSF1_ENFILE 23 +#define OSF1_EMFILE 24 +#define OSF1_ENOTTY 25 +#define OSF1_ETXTBSY 26 +#define OSF1_EFBIG 27 +#define OSF1_ENOSPC 28 +#define OSF1_ESPIPE 29 +#define OSF1_EROFS 30 +#define OSF1_EMLINK 31 +#define OSF1_EPIPE 32 +#define OSF1_EDOM 33 +#define OSF1_ERANGE 34 +#define OSF1_EWOULDBLOCK 35 +#define OSF1_EINPROGRESS 36 +#define OSF1_EALREADY 37 +#define OSF1_ENOTSOCK 38 +#define OSF1_EDESTADDRREQ 39 +#define OSF1_EMSGSIZE 40 +#define OSF1_EPROTOTYPE 41 +#define OSF1_ENOPROTOOPT 42 +#define OSF1_EPROTONOSUPPORT 43 +#define OSF1_ESOCKTNOSUPPORT 44 +#define OSF1_EOPNOTSUPP 45 +#define OSF1_EPFNOSUPPORT 46 +#define OSF1_EAFNOSUPPORT 47 +#define OSF1_EADDRINUSE 48 +#define OSF1_EADDRNOTAVAIL 49 +#define OSF1_ENETDOWN 50 +#define OSF1_ENETUNREACH 51 +#define OSF1_ENETRESET 52 +#define OSF1_ECONNABORTED 53 +#define OSF1_ECONNRESET 54 +#define OSF1_ENOBUFS 55 +#define OSF1_EISCONN 56 +#define OSF1_ENOTCONN 57 +#define OSF1_ESHUTDOWN 58 +#define OSF1_ETOOMANYREFS 59 +#define OSF1_ETIMEDOUT 60 +#define OSF1_ECONNREFUSED 61 +#define OSF1_ELOOP 62 +#define OSF1_ENAMETOOLONG 63 +#define OSF1_EHOSTDOWN 64 +#define OSF1_EHOSTUNREACH 65 +#define OSF1_ENOTEMPTY 66 +#define OSF1_EPROCLIM 67 +#define OSF1_EUSERS 68 +#define OSF1_EDQUOT 69 +#define OSF1_ESTALE 70 +#define OSF1_EREMOTE 71 +#define OSF1_EBADRPC 72 +#define OSF1_ERPCMISMATCH 73 +#define OSF1_EPROGUNAVAIL 74 +#define OSF1_EPROGMISMATCH 75 +#define OSF1_EPROCUNAVAIL 76 +#define OSF1_ENOLCK 77 +#define OSF1_ENOSYS 78 +#define OSF1_EFTYPE 79 +#define OSF1_ENOMSG 80 +#define OSF1_EIDRM 81 +#define OSF1_ENOSR 82 +#define OSF1_ETIME 83 +#define OSF1_EBADMSG 84 +#define OSF1_EPROTO 85 +#define OSF1_ENODATA 86 +#define OSF1_ENOSTR 87 +#define OSF1_ECLONEME 88 +#define OSF1_EDIRTY 89 +#define OSF1_EDUPPKG 90 +#define OSF1_EVERSION 91 +#define OSF1_ENOPKG 92 +#define OSF1_ENOSYM 93 +#define OSF1_ECANCELED 94 +#define OSF1_EFAIL 95 +#define OSF1_EINPROG 97 +#define OSF1_EMTIMERS 98 +#define OSF1_ENOTSUP 99 +#define OSF1_EAIO 100 +#define OSF1_EMULTIHOP 101 +#define OSF1_ENOLINK 102 +#define OSF1_EOVERFLOW 103 +#define OSF1_EILSEQ 116 +#define OSF1_ESOFT 123 +#define OSF1_EMEDIA 124 + +#endif /* _COMPAT_OSF1_OSF1_ERRNO_H_ */ diff --git a/sys/compat/osf1/osf1_exec.c b/sys/compat/osf1/osf1_exec.c new file mode 100644 index 00000000000..036c36cc3f1 --- /dev/null +++ b/sys/compat/osf1/osf1_exec.c @@ -0,0 +1,352 @@ +/* $OpenBSD: osf1_exec.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD$ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/malloc.h> +#include <sys/namei.h> +#include <sys/vnode.h> +#include <sys/mount.h> +#include <sys/exec.h> +#include <sys/exec_ecoff.h> +#include <sys/signalvar.h> +#include <sys/fcntl.h> +#include <sys/stat.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscall.h> +#include <compat/osf1/osf1_util.h> +#include <compat/osf1/osf1_cvt.h> + +extern int scdebug; +extern char *osf1_syscallnames[]; + + +struct osf1_exec_emul_arg { + int flags; +#define OSF1_EXEC_EMUL_FLAGS_HAVE_LOADER 0x01 + + char exec_name[MAXPATHLEN+1]; + char loader_name[MAXPATHLEN+1]; +}; + +#if 0 +static void *osf1_copyargs(struct exec_package *pack, + struct ps_strings *arginfo, void *stack, void *argp); + +#define MAX_AUX_ENTRIES 4 /* max we'll ever push (right now) */ +#endif + +extern struct sysent osf1_sysent[]; +extern void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *, + u_long, register_t *)); +extern char sigcode[], esigcode[]; + +struct emul emul_osf1 = { + "osf1", + NULL, + sendsig, + OSF1_SYS_syscall, + OSF1_SYS_MAXSYSCALL, + osf1_sysent, +#ifdef SYSCALL_DEBUG + osf1_syscallnames, +#else + NULL, +#endif + 0, + copyargs, + cpu_exec_ecoff_setregs, + NULL, + sigcode, + esigcode, +}; + +#if 0 +int +osf1_exec_ecoff_hook(struct proc *p, struct exec_package *epp) +{ + struct ecoff_exechdr *execp = (struct ecoff_exechdr *)epp->ep_hdr; + struct osf1_exec_emul_arg *emul_arg; + int error; + + /* if we're here and we're exec-able at all, we're an OSF/1 binary */ + epp->ep_emul = &emul_osf1; + + /* set up the exec package emul arg as appropriate */ + emul_arg = malloc(sizeof *emul_arg, M_TEMP, M_WAITOK); + epp->ep_emul_arg = emul_arg; + + emul_arg->flags = 0; + if (epp->ep_ndp->ni_segflg == UIO_SYSSPACE) + error = copystr(epp->ep_ndp->ni_dirp, emul_arg->exec_name, + MAXPATHLEN + 1, NULL); + else + error = copyinstr(epp->ep_ndp->ni_dirp, emul_arg->exec_name, + MAXPATHLEN + 1, NULL); +#ifdef DIAGNOSTIC + if (error != 0) + panic("osf1_exec_ecoff_hook: copyinstr failed"); +#endif + + /* do any special object file handling */ + switch (execp->f.f_flags & ECOFF_FLAG_OBJECT_TYPE_MASK) { + case ECOFF_OBJECT_TYPE_SHARABLE: + /* can't exec a shared library! */ +#if 0 + uprintf("can't execute OSF/1 shared libraries\n"); +#endif + error = ENOEXEC; + break; + + case ECOFF_OBJECT_TYPE_CALL_SHARED: + error = osf1_exec_ecoff_dynamic(p, epp); + break; + + default: + /* just let the normal ECOFF handlers deal with it. */ + error = 0; + break; + } + + if (error) { + free(epp->ep_emul_arg, M_TEMP); + epp->ep_emul_arg = NULL; + kill_vmcmds(&epp->ep_vmcmds); /* if any */ + } + + return (error); +} + +/* + * copy arguments onto the stack in the normal way, then copy out + * any ELF-like AUX entries used by the dynamic loading scheme. + */ +static void * +osf1_copyargs(pack, arginfo, stack, argp) + struct exec_package *pack; + struct ps_strings *arginfo; + void *stack; + void *argp; +{ + struct proc *p = curproc; /* XXX !!! */ + struct osf1_exec_emul_arg *emul_arg = pack->ep_emul_arg; + struct osf1_auxv ai[MAX_AUX_ENTRIES], *a; + char *prognameloc, *loadernameloc; + size_t len; + + stack = copyargs(pack, arginfo, stack, argp); + if (!stack) + goto bad; + + a = ai; + memset(ai, 0, sizeof ai); + + prognameloc = (char *)stack + sizeof ai; + if (copyoutstr(emul_arg->exec_name, prognameloc, MAXPATHLEN + 1, NULL)) + goto bad; + a->a_type = OSF1_AT_EXEC_FILENAME; + a->a_un.a_ptr = prognameloc; + a++; + + /* + * if there's a loader, push additional auxv entries on the stack. + */ + if (emul_arg->flags & OSF1_EXEC_EMUL_FLAGS_HAVE_LOADER) { + + loadernameloc = prognameloc + MAXPATHLEN + 1; + if (copyoutstr(emul_arg->loader_name, loadernameloc, + MAXPATHLEN + 1, NULL)) + goto bad; + a->a_type = OSF1_AT_EXEC_LOADER_FILENAME; + a->a_un.a_ptr = loadernameloc; + a++; + + a->a_type = OSF1_AT_EXEC_LOADER_FLAGS; + a->a_un.a_val = 0; + if (pack->ep_vap->va_mode & S_ISUID) + a->a_un.a_val |= OSF1_LDR_EXEC_SETUID_F; + if (pack->ep_vap->va_mode & S_ISGID) + a->a_un.a_val |= OSF1_LDR_EXEC_SETGID_F; + if (p->p_flag & P_TRACED) + a->a_un.a_val |= OSF1_LDR_EXEC_PTRACE_F; + a++; + } + + a->a_type = OSF1_AT_NULL; + a->a_un.a_val = 0; + a++; + + len = (a - ai) * sizeof(struct osf1_auxv); + if (copyout(ai, stack, len)) + goto bad; + stack = (caddr_t)stack + len; + +out: + free(pack->ep_emul_arg, M_TEMP); + pack->ep_emul_arg = NULL; + return stack; + +bad: + stack = NULL; + goto out; +} + +static int +osf1_exec_ecoff_dynamic(struct proc *p, struct exec_package *epp) +{ + struct osf1_exec_emul_arg *emul_arg = epp->ep_emul_arg; + struct ecoff_exechdr ldr_exechdr; + struct nameidata nd; + struct vnode *ldr_vp; + const char *pathbuf; + size_t resid; + int error; + + /* + * locate the loader + */ + error = emul_find(p, NULL, osf1_emul_path, + OSF1_LDR_EXEC_DEFAULT_LOADER, &pathbuf, 0); + /* includes /emul/osf1 if appropriate */ + strncpy(emul_arg->loader_name, pathbuf, MAXPATHLEN + 1); + emul_arg->flags |= OSF1_EXEC_EMUL_FLAGS_HAVE_LOADER; + if (!error) + free((char *)pathbuf, M_TEMP); + +#if 0 + uprintf("loader is %s\n", emul_arg->loader_name); +#endif + + /* + * open the loader, see if it's an ECOFF executable, + * make sure the object type is amenable, then arrange to + * load it up. + */ + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, + emul_arg->loader_name, p); + if ((error = namei(&nd)) != 0) + goto bad_no_vp; + ldr_vp = nd.ni_vp; + + /* + * Basic access checks. Reject if: + * not a regular file + * exec not allowed on binary + * exec not allowed on mount point + */ + if (ldr_vp->v_type != VREG) { + error = EACCES; + goto badunlock; + } + + if ((error = VOP_ACCESS(ldr_vp, VEXEC, p->p_ucred, p)) != 0) + goto badunlock; + + if (ldr_vp->v_mount->mnt_flag & MNT_NOEXEC) { + error = EACCES; + goto badunlock; + } + + /* + * If loader's mount point disallows set-id execution, + * disable set-id. + */ + if (ldr_vp->v_mount->mnt_flag & MNT_NOSUID) + epp->ep_vap->va_mode &= ~(S_ISUID | S_ISGID); + + VOP_UNLOCK(ldr_vp, 0); + + /* + * read the header, and make sure we got all of it. + */ + if ((error = vn_rdwr(UIO_READ, ldr_vp, (caddr_t)&ldr_exechdr, + sizeof ldr_exechdr, 0, UIO_SYSSPACE, 0, p->p_ucred, + &resid, p)) != 0) + goto bad; + if (resid != 0) { + error = ENOEXEC; + goto bad; + } + + /* + * Check the magic. We expect it to be the native Alpha ECOFF + * (Digital UNIX) magic number. Also make sure it's not a shared + * lib or dynamically linked executable. + */ + if (ldr_exechdr.f.f_magic != ECOFF_MAGIC_ALPHA) { + error = ENOEXEC; + goto bad; + } + switch (ldr_exechdr.f.f_flags & ECOFF_FLAG_OBJECT_TYPE_MASK) { + case ECOFF_OBJECT_TYPE_SHARABLE: + case ECOFF_OBJECT_TYPE_CALL_SHARED: + /* can't exec shared lib or dynamically linked executable. */ + error = ENOEXEC; + goto bad; + } + + switch (ldr_exechdr.a.magic) { + case ECOFF_OMAGIC: + error = exec_ecoff_prep_omagic(p, epp, &ldr_exechdr, ldr_vp); + break; + case ECOFF_NMAGIC: + error = exec_ecoff_prep_nmagic(p, epp, &ldr_exechdr, ldr_vp); + break; + case ECOFF_ZMAGIC: + error = exec_ecoff_prep_zmagic(p, epp, &ldr_exechdr, ldr_vp); + break; + default: + error = ENOEXEC; + } + if (error) + goto bad; + + /* finally, set up the stack. */ + error = exec_ecoff_setup_stack(p, epp); + if (error) + goto bad; + + vrele(ldr_vp); + return (0); + +badunlock: + VOP_UNLOCK(ldr_vp, 0); +bad: + vrele(ldr_vp); +bad_no_vp: + return (error); +} +#endif diff --git a/sys/compat/osf1/osf1_file.c b/sys/compat/osf1/osf1_file.c new file mode 100644 index 00000000000..23e472e6ff9 --- /dev/null +++ b/sys/compat/osf1/osf1_file.c @@ -0,0 +1,348 @@ +/* $OpenBSD: osf1_file.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_file.c,v 1.6 2000/06/06 19:04:17 soren Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/stat.h> +#include <sys/filedesc.h> +#include <sys/kernel.h> +#include <sys/malloc.h> +#include <sys/mman.h> +#include <sys/mount.h> +#include <sys/signal.h> +#include <sys/signalvar.h> +#include <sys/reboot.h> +#include <sys/syscallargs.h> +#include <sys/exec.h> +#include <sys/vnode.h> +#include <sys/socketvar.h> +#include <sys/resource.h> +#include <sys/resourcevar.h> +#include <sys/wait.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_util.h> +#include <compat/osf1/osf1_cvt.h> + +int +osf1_sys_access(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_access_args *uap = v; + struct sys_access_args a; + unsigned long leftovers; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&a, path) = SCARG(uap, path); + + /* translate flags */ + SCARG(&a, flags) = emul_flags_translate(osf1_access_flags_xtab, + SCARG(uap, flags), &leftovers); + if (leftovers != 0) + return (EINVAL); + + return sys_access(p, &a, retval); +} + +int +osf1_sys_execve(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_execve_args *uap = v; + struct sys_execve_args ap; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&ap, path) = SCARG(uap, path); + SCARG(&ap, argp) = SCARG(uap, argp); + SCARG(&ap, envp) = SCARG(uap, envp); + + return sys_execve(p, &ap, retval); +} + +/* + * Get file status; this version does not follow links. + */ +/* ARGSUSED */ +int +osf1_sys_lstat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_lstat_args *uap = v; + struct stat sb; + struct osf1_stat osb; + int error; + struct nameidata nd; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, + SCARG(uap, path), p); + if ((error = namei(&nd))) + return (error); + error = vn_stat(nd.ni_vp, &sb, p); + vput(nd.ni_vp); + if (error) + return (error); + osf1_cvt_stat_from_native(&sb, &osb); + error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb)); + return (error); +} + +int +osf1_sys_mknod(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_mknod_args *uap = v; + struct sys_mknod_args a; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&a, path) = SCARG(uap, path); + SCARG(&a, mode) = SCARG(uap, mode); + SCARG(&a, dev) = osf1_cvt_dev_to_native(SCARG(uap, dev)); + + return sys_mknod(p, &a, retval); +} + +int +osf1_sys_open(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_open_args *uap = v; + struct sys_open_args a; + char *path; + caddr_t sg; + unsigned long leftovers; +#ifdef SYSCALL_DEBUG + char pnbuf[1024]; + + if (scdebug && + copyinstr(SCARG(uap, path), pnbuf, sizeof pnbuf, NULL) == 0) + printf("osf1_open: open: %s\n", pnbuf); +#endif + + sg = stackgap_init(p->p_emul); + + /* translate flags */ + SCARG(&a, flags) = emul_flags_translate(osf1_open_flags_xtab, + SCARG(uap, flags), &leftovers); + if (leftovers != 0) + return (EINVAL); + + /* copy mode, no translation necessary */ + SCARG(&a, mode) = SCARG(uap, mode); + + /* pick appropriate path */ + path = SCARG(uap, path); + if (SCARG(&a, flags) & O_CREAT) + OSF1_CHECK_ALT_CREAT(p, &sg, path); + else + OSF1_CHECK_ALT_EXIST(p, &sg, path); + SCARG(&a, path) = path; + + return sys_open(p, &a, retval); +} + +int +osf1_sys_pathconf(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_pathconf_args *uap = v; + struct sys_pathconf_args a; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + + OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + SCARG(&a, path) = SCARG(uap, path); + + error = osf1_cvt_pathconf_name_to_native(SCARG(uap, name), + &SCARG(&a, name)); + + if (error == 0) + error = sys_pathconf(p, &a, retval); + + return (error); +} + +/* + * Get file status; this version follows links. + */ +/* ARGSUSED */ +int +osf1_sys_stat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_stat_args *uap = v; + struct stat sb; + struct osf1_stat osb; + int error; + struct nameidata nd; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, + SCARG(uap, path), p); + if ((error = namei(&nd))) + return (error); + error = vn_stat(nd.ni_vp, &sb, p); + vput(nd.ni_vp); + if (error) + return (error); + osf1_cvt_stat_from_native(&sb, &osb); + error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb)); + return (error); +} + +int +osf1_sys_truncate(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_truncate_args *uap = v; + struct sys_truncate_args a; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&a, path) = SCARG(uap, path); + SCARG(&a, pad) = 0; + SCARG(&a, length) = SCARG(uap, length); + + return sys_truncate(p, &a, retval); +} + +int +osf1_sys_utimes(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_utimes_args *uap = v; + struct sys_utimes_args a; + struct osf1_timeval otv; + struct timeval tv; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + + OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + SCARG(&a, path) = SCARG(uap, path); + + error = 0; + if (SCARG(uap, tptr) == NULL) + SCARG(&a, tptr) = NULL; + else { + SCARG(&a, tptr) = stackgap_alloc(&sg, sizeof tv); + + /* get the OSF/1 timeval argument */ + error = copyin((caddr_t)SCARG(uap, tptr), + (caddr_t)&otv, sizeof otv); + if (error == 0) { + + /* fill in and copy out the NetBSD timeval */ + memset(&tv, 0, sizeof tv); + tv.tv_sec = otv.tv_sec; + tv.tv_usec = otv.tv_usec; + + error = copyout((caddr_t)&tv, + (caddr_t)SCARG(&a, tptr), sizeof tv); + } + } + + if (error == 0) + error = sys_utimes(p, &a, retval); + + return (error); +} diff --git a/sys/compat/osf1/osf1_generic.c b/sys/compat/osf1/osf1_generic.c new file mode 100644 index 00000000000..853608877a5 --- /dev/null +++ b/sys/compat/osf1/osf1_generic.c @@ -0,0 +1,213 @@ +/* $OpenBSD: osf1_generic.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_generic.c,v 1.1 1999/05/01 05:06:46 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/stat.h> +#include <sys/malloc.h> +#include <sys/mman.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <sys/exec.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_cvt.h> + +/* + * The structures end up being the same... but we can't be sure that + * the other word of our iov_len is zero! + */ +int +osf1_sys_readv(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_readv_args *uap = v; + struct sys_readv_args a; + struct osf1_iovec *oio; + struct iovec *nio; + caddr_t sg = stackgap_init(p->p_emul); + int error, osize, nsize, i; + + if (SCARG(uap, iovcnt) > (STACKGAPLEN / sizeof (struct iovec))) + return (EINVAL); + + osize = SCARG(uap, iovcnt) * sizeof (struct osf1_iovec); + nsize = SCARG(uap, iovcnt) * sizeof (struct iovec); + + oio = malloc(osize, M_TEMP, M_WAITOK); + nio = malloc(nsize, M_TEMP, M_WAITOK); + + error = 0; + if ((error = copyin(SCARG(uap, iovp), oio, osize))) + goto punt; + for (i = 0; i < SCARG(uap, iovcnt); i++) { + nio[i].iov_base = oio[i].iov_base; + nio[i].iov_len = oio[i].iov_len; + } + + SCARG(&a, fd) = SCARG(uap, fd); + SCARG(&a, iovp) = stackgap_alloc(&sg, nsize); + SCARG(&a, iovcnt) = SCARG(uap, iovcnt); + + if ((error = copyout(nio, (caddr_t)SCARG(&a, iovp), nsize))) + goto punt; + error = sys_readv(p, &a, retval); + +punt: + free(oio, M_TEMP); + free(nio, M_TEMP); + return (error); +} + +int +osf1_sys_select(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_select_args *uap = v; + struct sys_select_args a; + struct osf1_timeval otv; + struct timeval tv; + int error; + caddr_t sg; + + SCARG(&a, nd) = SCARG(uap, nd); + SCARG(&a, in) = SCARG(uap, in); + SCARG(&a, ou) = SCARG(uap, ou); + SCARG(&a, ex) = SCARG(uap, ex); + + error = 0; + if (SCARG(uap, tv) == NULL) + SCARG(&a, tv) = NULL; + else { + sg = stackgap_init(p->p_emul); + SCARG(&a, tv) = stackgap_alloc(&sg, sizeof tv); + + /* get the OSF/1 timeval argument */ + error = copyin((caddr_t)SCARG(uap, tv), + (caddr_t)&otv, sizeof otv); + if (error == 0) { + + /* fill in and copy out the NetBSD timeval */ + memset(&tv, 0, sizeof tv); + tv.tv_sec = otv.tv_sec; + tv.tv_usec = otv.tv_usec; + + error = copyout((caddr_t)&tv, + (caddr_t)SCARG(&a, tv), sizeof tv); + } + } + + if (error == 0) + error = sys_select(p, &a, retval); + + return (error); +} + +int +osf1_sys_writev(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_writev_args *uap = v; + struct sys_writev_args a; + struct osf1_iovec *oio; + struct iovec *nio; + caddr_t sg = stackgap_init(p->p_emul); + int error, osize, nsize, i; + + if (SCARG(uap, iovcnt) > (STACKGAPLEN / sizeof (struct iovec))) + return (EINVAL); + + osize = SCARG(uap, iovcnt) * sizeof (struct osf1_iovec); + nsize = SCARG(uap, iovcnt) * sizeof (struct iovec); + + oio = malloc(osize, M_TEMP, M_WAITOK); + nio = malloc(nsize, M_TEMP, M_WAITOK); + + error = 0; + if ((error = copyin(SCARG(uap, iovp), oio, osize))) + goto punt; + for (i = 0; i < SCARG(uap, iovcnt); i++) { + nio[i].iov_base = oio[i].iov_base; + nio[i].iov_len = oio[i].iov_len; + } + + SCARG(&a, fd) = SCARG(uap, fd); + SCARG(&a, iovp) = stackgap_alloc(&sg, nsize); + SCARG(&a, iovcnt) = SCARG(uap, iovcnt); + + if ((error = copyout(nio, (caddr_t)SCARG(&a, iovp), nsize))) + goto punt; + error = sys_writev(p, &a, retval); + +punt: + free(oio, M_TEMP); + free(nio, M_TEMP); + return (error); +} diff --git a/sys/compat/osf1/osf1_ioctl.c b/sys/compat/osf1/osf1_ioctl.c index 8ad73d211a3..cba166475c5 100644 --- a/sys/compat/osf1/osf1_ioctl.c +++ b/sys/compat/osf1/osf1_ioctl.c @@ -1,5 +1,35 @@ -/* $OpenBSD: osf1_ioctl.c,v 1.2 1996/08/02 20:35:26 niklas Exp $ */ -/* $NetBSD: osf1_ioctl.c,v 1.3 1995/10/07 06:27:19 mycroft Exp $ */ +/* $OpenBSD: osf1_ioctl.c,v 1.3 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_ioctl.c,v 1.11 1999/05/05 01:51:33 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -32,31 +62,21 @@ #include <sys/systm.h> #include <sys/ioctl.h> #include <sys/termios.h> - #include <sys/mount.h> #include <sys/syscallargs.h> + +#include <compat/osf1/osf1.h> #include <compat/osf1/osf1_syscallargs.h> #ifdef SYSCALL_DEBUG extern int scdebug; #endif -#define OSF1_IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */ -#define OSF1_IOCPARM_LEN(x) (((x) >> 16) & OSF1_IOCPARM_MASK) -#define OSF1_IOCGROUP(x) (((x) >> 8) & 0xff) - -#define OSF1_IOCPARM_MAX NBPG /* max size of ioctl */ -#define OSF1_IOC_VOID 0x20000000 /* no parameters */ -#define OSF1_IOC_OUT 0x40000000 /* copy out parameters */ -#define OSF1_IOC_IN 0x80000000 /* copy in parameters */ -#define OSF1_IOC_INOUT (OSF1_IOC_IN|OSF1_IOC_OUT) -#define OSF1_IOC_DIRMASK 0xe0000000 /* mask for IN/OUT/VOID */ - -#define OSF1_IOCCMD(x) ((x) & 0xff) - -int osf1_ioctl_i __P((struct proc *p, struct sys_ioctl_args *nuap, +static int osf1_ioctl_f __P((struct proc *p, struct sys_ioctl_args *nuap, register_t *retval, int cmd, int dir, int len)); -int osf1_ioctl_t __P((struct proc *p, struct sys_ioctl_args *nuap, +static int osf1_ioctl_i __P((struct proc *p, struct sys_ioctl_args *nuap, + register_t *retval, int cmd, int dir, int len)); +static int osf1_ioctl_t __P((struct proc *p, struct sys_ioctl_args *nuap, register_t *retval, int cmd, int dir, int len)); int @@ -65,16 +85,8 @@ osf1_sys_ioctl(p, v, retval) void *v; register_t *retval; { - struct osf1_sys_ioctl_args /* { - syscallarg(int) fd; - syscallarg(int) com; - syscallarg(caddr_t) data; - } */ *uap = v; - struct sys_ioctl_args /* { - syscallarg(int) fd; - syscallarg(u_long) com; - syscallarg(caddr_t) data; - } */ a; + struct osf1_sys_ioctl_args *uap = v; + struct sys_ioctl_args a; int op, dir, group, cmd, len; #ifdef SYSCALL_DEBUG char *dirstr; @@ -123,9 +135,11 @@ osf1_sys_ioctl(p, v, retval) #endif SCARG(&a, fd) = SCARG(uap, fd); - SCARG(&a, com) = SCARG(uap, com); + SCARG(&a, com) = SCARG(uap, com) & 0xffffffff; /* XXX */ SCARG(&a, data) = SCARG(uap, data); switch (group) { + case 'f': + return osf1_ioctl_f(p, &a, retval, cmd, dir, len); case 'i': return osf1_ioctl_i(p, &a, retval, cmd, dir, len); case 't': @@ -135,14 +149,38 @@ osf1_sys_ioctl(p, v, retval) } } -int +static int +osf1_ioctl_f(p, uap, retval, cmd, dir, len) + struct proc *p; + struct sys_ioctl_args *uap; + register_t *retval; + int cmd; + int dir; + int len; +{ + + switch (cmd) { + case 1: /* OSF/1 FIOCLEX */ + case 2: /* OSF/1 FIONCLEX */ + case 123: /* OSF/1 FIOGETOWN */ + case 124: /* OSF/1 FIOSETOWN */ + case 125: /* OSF/1 FIOASYNC */ + case 126: /* OSF/1 FIONBIO */ + case 127: /* OSF/1 FIONREAD */ + /* same as in NetBSD */ + break; + + default: + return (ENOTTY); + } + + return sys_ioctl(p, uap, retval); +} + +static int osf1_ioctl_i(p, uap, retval, cmd, dir, len) struct proc *p; - struct sys_ioctl_args /* { - syscallarg(int) fd; - syscallarg(int) com; - syscallarg(caddr_t) data; - } */ *uap; + struct sys_ioctl_args *uap; register_t *retval; int cmd; int dir; @@ -173,14 +211,10 @@ osf1_ioctl_i(p, uap, retval, cmd, dir, len) return sys_ioctl(p, uap, retval); } -int +static int osf1_ioctl_t(p, uap, retval, cmd, dir, len) struct proc *p; - struct sys_ioctl_args /* { - syscallarg(int) fd; - syscallarg(int) com; - syscallarg(caddr_t) data; - } */ *uap; + struct sys_ioctl_args *uap; register_t *retval; int cmd; int dir; diff --git a/sys/compat/osf1/osf1_misc.c b/sys/compat/osf1/osf1_misc.c index 272308b3272..0800adcce1b 100644 --- a/sys/compat/osf1/osf1_misc.c +++ b/sys/compat/osf1/osf1_misc.c @@ -1,5 +1,35 @@ -/* $OpenBSD: osf1_misc.c,v 1.11 1999/11/10 15:55:23 mickey Exp $ */ -/* $NetBSD: osf1_misc.c,v 1.7 1995/10/07 06:53:04 mycroft Exp $ */ +/* $OpenBSD: osf1_misc.c,v 1.12 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_misc.c,v 1.55 2000/06/28 15:39:33 mrg Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -41,949 +71,282 @@ #include <sys/mount.h> #include <sys/signal.h> #include <sys/signalvar.h> -#include <sys/socketvar.h> #include <sys/reboot.h> #include <sys/syscallargs.h> +#include <sys/exec.h> #include <sys/vnode.h> +#include <sys/socketvar.h> +#include <sys/resource.h> +#include <sys/resourcevar.h> +#include <sys/wait.h> -#include <compat/osf1/osf1_syscall.h> +#include <compat/osf1/osf1.h> #include <compat/osf1/osf1_syscallargs.h> #include <compat/osf1/osf1_util.h> - -#include <vm/vm.h> +#include <compat/osf1/osf1_cvt.h> #ifdef SYSCALL_DEBUG extern int scdebug; -extern char *osf1_syscallnames[]; -#endif - -extern struct sysent osf1_sysent[]; -extern void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *, - u_long, register_t *)); - -extern char sigcode[], esigcode[]; - -void cvtstat2osf1 __P((struct stat *, struct osf1_stat *)); - -struct emul emul_osf1 = { - "osf1", - NULL, - sendsig, - OSF1_SYS_syscall, - OSF1_SYS_MAXSYSCALL, - osf1_sysent, -#ifdef SYSCALL_DEBUG - osf1_syscallnames, -#else - NULL, -#endif - 0, - copyargs, - cpu_exec_ecoff_setregs, - NULL, - sigcode, - esigcode, -}; - -int -osf1_sys_open(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_open_args /* { - syscallarg(char *) path; - syscallarg(int) flags; - syscallarg(int) mode; - } */ *uap = v; - struct sys_open_args /* { - syscallarg(char *) path; - syscallarg(int) flags; - syscallarg(int) mode; - } */ a; -#ifdef SYSCALL_DEBUG - char pnbuf[1024]; - - if (scdebug && - copyinstr(SCARG(uap, path), pnbuf, sizeof pnbuf, NULL) == 0) - printf("osf1_open: open: %s\n", pnbuf); #endif - SCARG(&a, path) = SCARG(uap, path); - SCARG(&a, flags) = SCARG(uap, flags); /* XXX translate */ - SCARG(&a, mode) = SCARG(uap, mode); - - return sys_open(p, &a, retval); -} +const char osf1_emul_path[] = "/emul/osf1"; int -osf1_sys_setsysinfo(p, v, retval) +osf1_sys_classcntl(p, v, retval) struct proc *p; void *v; register_t *retval; { -#if 0 - struct osf1_setsysinfo_args /* { - syscallarg(u_long) op; - syscallarg(caddr_t) buffer; - syscallarg(u_long) nbytes; - syscallarg(caddr_t) arg; - syscallarg(u_long) flag; - } */ *uap = v; -#endif; - return (0); + /* XXX */ + return (ENOSYS); } -#define OSF1_RLIMIT_LASTCOMMON 5 /* last one that's common */ -#define OSF1_RLIMIT_NOFILE 6 /* OSF1's RLIMIT_NOFILE */ -#define OSF1_RLIMIT_NLIMITS 8 /* Number of OSF1 rlimits */ - int -osf1_sys_getrlimit(p, v, retval) +osf1_sys_reboot(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct osf1_sys_getrlimit_args /* { - syscallarg(u_int) which; - syscallarg(struct rlimit *) rlp; - } */ *uap = v; - struct sys_getrlimit_args /* { - syscallarg(u_int) which; - syscallarg(struct rlimit *) rlp; - } */ a; - - if (SCARG(uap, which) >= OSF1_RLIMIT_NLIMITS) - return (EINVAL); - - if (SCARG(uap, which) <= OSF1_RLIMIT_LASTCOMMON) - SCARG(&a, which) = SCARG(uap, which); - else if (SCARG(uap, which) == OSF1_RLIMIT_NOFILE) - SCARG(&a, which) = RLIMIT_NOFILE; - else - return (0); - SCARG(&a, rlp) = SCARG(uap, rlp); - - return sys_getrlimit(p, &a, retval); -} + struct osf1_sys_reboot_args *uap = v; + struct sys_reboot_args a; + unsigned long leftovers; -int -osf1_sys_setrlimit(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_setrlimit_args /* { - syscallarg(u_int) which; - syscallarg(struct rlimit *) rlp; - } */ *uap = v; - struct sys_setrlimit_args /* { - syscallarg(u_int) which; - syscallarg(struct rlimit *) rlp; - } */ a; - - if (SCARG(uap, which) >= OSF1_RLIMIT_NLIMITS) + /* translate opt */ + SCARG(&a, opt) = emul_flags_translate(osf1_reboot_opt_xtab, + SCARG(uap, opt), &leftovers); + if (leftovers != 0) return (EINVAL); - if (SCARG(uap, which) <= OSF1_RLIMIT_LASTCOMMON) - SCARG(&a, which) = SCARG(uap, which); - else if (SCARG(uap, which) == OSF1_RLIMIT_NOFILE) - SCARG(&a, which) = RLIMIT_NOFILE; - else - return (0); - SCARG(&a, rlp) = SCARG(uap, rlp); - - return sys_setrlimit(p, &a, retval); -} - -#define OSF1_MAP_SHARED 0x001 -#define OSF1_MAP_PRIVATE 0x002 -#define OSF1_MAP_ANONYMOUS 0x010 -#define OSF1_MAP_FILE 0x000 -#define OSF1_MAP_TYPE 0x0f0 -#define OSF1_MAP_FIXED 0x100 -#define OSF1_MAP_HASSEMAPHORE 0x200 -#define OSF1_MAP_INHERIT 0x400 -#define OSF1_MAP_UNALIGNED 0x800 - -int -osf1_sys_mmap(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_mmap_args /* { - syscallarg(caddr_t) addr; - syscallarg(size_t) len; - syscallarg(int) prot; - syscallarg(int) flags; - syscallarg(int) fd; - syscallarg(off_t) pos; - } */ *uap = v; - struct sys_mmap_args /* { - syscallarg(caddr_t) addr; - syscallarg(size_t) len; - syscallarg(int) prot; - syscallarg(int) flags; - syscallarg(int) fd; - syscallarg(long) pad; - syscallarg(off_t) pos; - } */ a; - - SCARG(&a, addr) = SCARG(uap, addr); - SCARG(&a, len) = SCARG(uap, len); - SCARG(&a, prot) = SCARG(uap, prot); - SCARG(&a, fd) = SCARG(uap, fd); - SCARG(&a, pad) = 0; - SCARG(&a, pos) = SCARG(uap, pos); - - SCARG(&a, flags) = 0; - if (SCARG(uap, flags) & OSF1_MAP_SHARED) - SCARG(&a, flags) |= MAP_SHARED; - if (SCARG(uap, flags) & OSF1_MAP_PRIVATE) - SCARG(&a, flags) |= MAP_PRIVATE; - switch (SCARG(uap, flags) & OSF1_MAP_TYPE) { - case OSF1_MAP_ANONYMOUS: - SCARG(&a, flags) |= MAP_ANON; - break; - case OSF1_MAP_FILE: - SCARG(&a, flags) |= MAP_FILE; - break; - default: - return (EINVAL); - } - if (SCARG(uap, flags) & OSF1_MAP_FIXED) - SCARG(&a, flags) |= MAP_FIXED; - if (SCARG(uap, flags) & OSF1_MAP_HASSEMAPHORE) - SCARG(&a, flags) |= MAP_HASSEMAPHORE; - if (SCARG(uap, flags) & OSF1_MAP_INHERIT) - SCARG(&a, flags) |= MAP_INHERIT; - if (SCARG(uap, flags) & OSF1_MAP_UNALIGNED) - return (EINVAL); + /* SCARG(&a, bootstr) = NULL; */ - return sys_mmap(p, &a, retval); + return sys_reboot(p, &a, retval); } int -osf1_sys_usleep_thread(p, v, retval) +osf1_sys_set_program_attributes(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct osf1_sys_usleep_thread_args /* { - syscallarg(struct timeval *) sleep; - syscallarg(struct timeval *) slept; - } */ *uap = v; - struct timeval tv, endtv; - u_long ticks; - int error, s; - - if ((error = copyin(SCARG(uap, sleep), &tv, sizeof tv)) != 0) - return (error); + struct osf1_sys_set_program_attributes_args *uap = v; + segsz_t tsize, dsize; - ticks = ((u_long)tv.tv_sec * 1000000 + tv.tv_usec) / tick; - s = splclock(); - tv = time; - splx(s); + tsize = btoc(SCARG(uap, tsize)); + dsize = btoc(SCARG(uap, dsize)); - tsleep(p, PUSER|PCATCH, "OSF/1", ticks); /* XXX */ + if (dsize > p->p_rlimit[RLIMIT_DATA].rlim_cur) + return (ENOMEM); + if (tsize > MAXTSIZ) + return (ENOMEM); - if (SCARG(uap, slept) != NULL) { - s = splclock(); - timersub(&time, &tv, &endtv); - splx(s); - if (tv.tv_sec < 0 || tv.tv_usec < 0) - tv.tv_sec = tv.tv_usec = 0; + p->p_vmspace->vm_taddr = SCARG(uap, taddr); + p->p_vmspace->vm_tsize = tsize; + p->p_vmspace->vm_daddr = SCARG(uap, daddr); + p->p_vmspace->vm_dsize = dsize; - error = copyout(&endtv, SCARG(uap, slept), sizeof endtv); - } - return (error); -} - -struct osf1_stat { - int32_t st_dev; - u_int32_t st_ino; - u_int32_t st_mode; - u_int16_t st_nlink; - u_int32_t st_uid; - u_int32_t st_gid; - int32_t st_rdev; - u_int64_t st_size; - int32_t st_atime_sec; - int32_t st_spare1; - int32_t st_mtime_sec; - int32_t st_spare2; - int32_t st_ctime_sec; - int32_t st_spare3; - u_int32_t st_blksize; - int32_t st_blocks; - u_int32_t st_flags; - u_int32_t st_gen; -}; - -/* - * Get file status; this version follows links. - */ -/* ARGSUSED */ -int -osf1_sys_stat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct osf1_sys_stat_args /* { - syscallarg(char *) path; - syscallarg(struct osf1_stat *) ub; - } */ *uap = v; - struct stat sb; - struct osf1_stat osb; - int error; - struct nameidata nd; - - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); - if ((error = namei(&nd)) != 0) - return (error); - error = vn_stat(nd.ni_vp, &sb, p); - vput(nd.ni_vp); - if (error) - return (error); - cvtstat2osf1(&sb, &osb); - error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb)); - return (error); + return (0); } -/* - * Get file status; this version does not follow links. - */ -/* ARGSUSED */ int -osf1_sys_lstat(p, v, retval) +osf1_sys_setsysinfo(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct osf1_sys_lstat_args /* { - syscallarg(char *) path; - syscallarg(struct osf1_stat *) ub; - } */ *uap = v; - struct stat sb; - struct osf1_stat osb; - int error; - struct nameidata nd; - NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, - SCARG(uap, path), p); - if ((error = namei(&nd)) != 0) - return (error); - error = vn_stat(nd.ni_vp, &sb, p); - vput(nd.ni_vp); - if (error) - return (error); - cvtstat2osf1(&sb, &osb); - error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb)); - return (error); + /* XXX */ + return (0); } -/* - * Return status information about a file descriptor. - */ int -osf1_sys_fstat(p, v, retval) +osf1_sys_sysinfo(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct osf1_sys_fstat_args /* { - syscallarg(int) fd; - syscallarg(struct osf1_stat *) sb; - } */ *uap = v; - register struct filedesc *fdp = p->p_fd; - register struct file *fp; - struct stat ub; - struct osf1_stat oub; + struct osf1_sys_sysinfo_args *uap = v; + const char *string; 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, &ub, p); + error = 0; + switch (SCARG(uap, cmd)) { + case OSF1_SI_SYSNAME: + goto should_handle; + /* string = ostype; */ break; - case DTYPE_SOCKET: - error = soo_stat((struct socket *)fp->f_data, &ub); + case OSF1_SI_HOSTNAME: + string = hostname; break; - default: - panic("ofstat"); - /*NOTREACHED*/ - } - cvtstat2osf1(&ub, &oub); - if (error == 0) - error = copyout((caddr_t)&oub, (caddr_t)SCARG(uap, sb), - sizeof (oub)); - return (error); -} - -#define bsd2osf_dev(dev) (major(dev) << 20 | minor(dev)) -#define osf2bsd_dev(dev) makedev((dev >> 20) & 0xfff, dev & 0xfffff) - -/* - * Convert from a stat structure to an osf1 stat structure. - */ -void -cvtstat2osf1(st, ost) - struct stat *st; - struct osf1_stat *ost; -{ - - ost->st_dev = bsd2osf_dev(st->st_dev); - ost->st_ino = st->st_ino; - ost->st_mode = st->st_mode; - ost->st_nlink = st->st_nlink; - ost->st_uid = st->st_uid == -2 ? (u_int16_t) -2 : st->st_uid; - ost->st_gid = st->st_gid == -2 ? (u_int16_t) -2 : st->st_gid; - ost->st_rdev = bsd2osf_dev(st->st_rdev); - ost->st_size = st->st_size; - ost->st_atime_sec = st->st_atime; - ost->st_spare1 = 0; - ost->st_mtime_sec = st->st_mtime; - ost->st_spare2 = 0; - ost->st_ctime_sec = st->st_ctime; - ost->st_spare3 = 0; - ost->st_blksize = st->st_blksize; - ost->st_blocks = st->st_blocks; - ost->st_flags = st->st_flags; - ost->st_gen = st->st_gen; -} - -int -osf1_sys_mknod(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_mknod_args /* { - syscallarg(char *) path; - syscallarg(int) mode; - syscallarg(int) dev; - } */ *uap = v; - struct sys_mknod_args a; - - SCARG(&a, path) = SCARG(uap, path); - SCARG(&a, mode) = SCARG(uap, mode); - SCARG(&a, dev) = osf2bsd_dev(SCARG(uap, dev)); - - return sys_mknod(p, &a, retval); -} - -#define OSF1_F_DUPFD 0 -#define OSF1_F_GETFD 1 -#define OSF1_F_SETFD 2 -#define OSF1_F_GETFL 3 -#define OSF1_F_SETFL 4 - -#define OSF1_FAPPEND 0x00008 /* XXX OSF1_O_APPEND */ -#define OSF1_FNONBLOCK 0x00004 /* XXX OSF1_O_NONBLOCK */ -#define OSF1_FASYNC 0x00040 -#define OSF1_FSYNC 0x04000 /* XXX OSF1_O_SYNC */ - -int -osf1_sys_fcntl(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_fcntl_args /* { - syscallarg(int) fd; - syscallarg(int) cmd; - syscallarg(void *) arg; - } */ *uap = v; - struct sys_fcntl_args a; - long tmp; - int error; + case OSF1_SI_RELEASE: + string = version; + break; - SCARG(&a, fd) = SCARG(uap, fd); + case OSF1_SI_VERSION: + goto should_handle; - switch (SCARG(uap, cmd)) { - case OSF1_F_DUPFD: - SCARG(&a, cmd) = F_DUPFD; - SCARG(&a, arg) = SCARG(uap, arg); + case OSF1_SI_MACHINE: + string = MACHINE; break; - case OSF1_F_GETFD: - SCARG(&a, cmd) = F_GETFD; - SCARG(&a, arg) = SCARG(uap, arg); + case OSF1_SI_ARCHITECTURE: + string = MACHINE_ARCH; break; - case OSF1_F_SETFD: - SCARG(&a, cmd) = F_SETFD; - SCARG(&a, arg) = SCARG(uap, arg); + case OSF1_SI_HW_SERIAL: + string = "666"; /* OSF/1 emulation? YES! */ break; - case OSF1_F_GETFL: - SCARG(&a, cmd) = F_GETFL; - SCARG(&a, arg) = SCARG(uap, arg); /* ignored */ + case OSF1_SI_HW_PROVIDER: + string = "unknown"; break; - case OSF1_F_SETFL: - SCARG(&a, cmd) = F_SETFL; - tmp = 0; - if ((long)SCARG(uap, arg) & OSF1_FAPPEND) - tmp |= FAPPEND; - if ((long)SCARG(uap, arg) & OSF1_FNONBLOCK) - tmp |= FNONBLOCK; - if ((long)SCARG(uap, arg) & OSF1_FASYNC) - tmp |= FASYNC; - if ((long)SCARG(uap, arg) & OSF1_FSYNC) - tmp |= FFSYNC; - SCARG(&a, arg) = (void *)tmp; - break; + case OSF1_SI_SRPC_DOMAIN: + goto dont_care; - default: /* XXX other cases */ - return (EINVAL); - } + case OSF1_SI_SET_HOSTNAME: + goto should_handle; - error = sys_fcntl(p, &a, retval); + case OSF1_SI_SET_SYSNAME: + goto should_handle; - if (error) - return error; + case OSF1_SI_SET_SRPC_DOMAIN: + goto dont_care; - switch (SCARG(uap, cmd)) { - case OSF1_F_GETFL: - /* XXX */ + default: +should_handle: + printf("osf1_sys_sysinfo(%d, %p, 0x%lx)\n", SCARG(uap, cmd), + SCARG(uap, buf), SCARG(uap,len)); +dont_care: + error = EINVAL; break; - } - - return error; -} + }; -int -osf1_sys_poll(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct osf1_sys_poll_args /* { - syscallarg(struct pollfd *) fds; - syscallarg(unsigned int) nfds; - syscallarg(int) timeout; - } */ *uap = v; - struct sys_poll_args a; - - SCARG(&a, fds) = SCARG(uap, fds); - SCARG(&a, nfds) = SCARG(uap, nfds); - SCARG(&a, timeout) = SCARG(uap, timeout); - - return sys_poll(p, &a, retval); -} - -int -osf1_sys_socket(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct osf1_sys_socket_args /* { - syscallarg(int) domain; - syscallarg(int) type; - syscallarg(int) protocol; - } */ *uap = v; - struct sys_socket_args a; - - if (SCARG(uap, type) > AF_LINK) - return (EINVAL); /* XXX After AF_LINK, divergence. */ - - SCARG(&a, domain) = SCARG(uap, domain); - SCARG(&a, type) = SCARG(uap, type); - SCARG(&a, protocol) = SCARG(uap, protocol); + if (error == 0) + error = copyoutstr(string, SCARG(uap, buf), SCARG(uap, len), + NULL); - return sys_socket(p, &a, retval); + return (error); } int -osf1_sys_sendto(p, v, retval) +osf1_sys_uname(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct osf1_sys_sendto_args /* { - syscallarg(int) s; - syscallarg(const void *) buf; - syscallarg(size_t) len; - syscallarg(int) flags; - syscallarg(const struct sockaddr *) to; - syscallarg(int) tolen; - } */ *uap = v; - struct sys_sendto_args a; - - if (SCARG(uap, flags) & ~0x7f) /* unsupported flags */ - return (EINVAL); - - SCARG(&a, s) = SCARG(uap, s); - SCARG(&a, buf) = SCARG(uap, buf); - SCARG(&a, len) = SCARG(uap, len); - SCARG(&a, flags) = SCARG(uap, flags); - SCARG(&a, to) = SCARG(uap, to); - SCARG(&a, tolen) = SCARG(uap, tolen); - - return sys_sendto(p, &a, retval); + struct osf1_sys_uname_args *uap = v; + struct osf1_utsname u; + const char *cp; + char *dp, *ep; + + /* XXX would use stackgap, but our struct utsname is too big! */ + /* + * strncpy(u.sysname, ostype, sizeof(u.sysname)); + */ + strncpy(u.sysname, "OpenBSD", sizeof(u.sysname)); + strncpy(u.nodename, hostname, sizeof(u.nodename)); + strncpy(u.release, version, sizeof(u.release)); + dp = u.version; + ep = &u.version[sizeof(u.version) - 1]; + for (cp = version; *cp && *cp != '('; cp++) + ; + for (cp++; *cp && *cp != ')' && dp < ep; cp++) + *dp++ = *cp; + for (; *cp && *cp != '#'; cp++) + ; + for (; *cp && *cp != ':' && dp < ep; cp++) + *dp++ = *cp; + *dp = '\0'; + strncpy(u.machine, MACHINE, sizeof(u.machine)); + return (copyout((caddr_t)&u, (caddr_t)SCARG(uap, name), sizeof u)); } -#define OSF1_RB_ASKNAME 0x001 -#define OSF1_RB_SINGLE 0x002 -#define OSF1_RB_NOSYNC 0x004 -#define OSF1_RB_HALT 0x008 -#define OSF1_RB_INITNAME 0x010 -#define OSF1_RB_DFLTROOT 0x020 -#define OSF1_RB_ALTBOOT 0x040 -#define OSF1_RB_UNIPROC 0x080 -#define OSF1_RB_ALLFLAGS 0x0ff /* all of the above */ - int -osf1_sys_reboot(p, v, retval) +osf1_sys_usleep_thread(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct osf1_sys_reboot_args /* { - syscallarg(int) opt; - } */ *uap = v; - struct sys_reboot_args a; + struct osf1_sys_usleep_thread_args *uap = v; + struct osf1_timeval otv, endotv; + struct timeval tv, endtv; + u_long ticks; + int error, s; - if (SCARG(uap, opt) & ~OSF1_RB_ALLFLAGS && - SCARG(uap, opt) & (OSF1_RB_ALTBOOT|OSF1_RB_UNIPROC)) - return (EINVAL); + if ((error = copyin(SCARG(uap, sleep), &otv, sizeof otv))) + return (error); + tv.tv_sec = otv.tv_sec; + tv.tv_usec = otv.tv_usec; - SCARG(&a, opt) = 0; - if (SCARG(uap, opt) & OSF1_RB_ASKNAME) - SCARG(&a, opt) |= RB_ASKNAME; - if (SCARG(uap, opt) & OSF1_RB_SINGLE) - SCARG(&a, opt) |= RB_SINGLE; - if (SCARG(uap, opt) & OSF1_RB_NOSYNC) - SCARG(&a, opt) |= RB_NOSYNC; - if (SCARG(uap, opt) & OSF1_RB_HALT) - SCARG(&a, opt) |= RB_HALT; - if (SCARG(uap, opt) & OSF1_RB_INITNAME) - SCARG(&a, opt) |= RB_INITNAME; - if (SCARG(uap, opt) & OSF1_RB_DFLTROOT) - SCARG(&a, opt) |= RB_DFLTROOT; + ticks = howmany((u_long)tv.tv_sec * 1000000 + tv.tv_usec, tick); + if (ticks == 0) + ticks = 1; - return sys_reboot(p, &a, retval); -} + s = splclock(); + tv = time; + splx(s); -int -osf1_sys_lseek(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_lseek_args /* { - syscallarg(int) fd; - syscallarg(off_t) offset; - syscallarg(int) whence; - } */ *uap = v; - struct sys_lseek_args a; - - SCARG(&a, fd) = SCARG(uap, fd); - SCARG(&a, pad) = 0; - SCARG(&a, offset) = SCARG(uap, offset); - SCARG(&a, whence) = SCARG(uap, whence); - - return sys_lseek(p, &a, retval); -} + tsleep(p, PUSER|PCATCH, "uslpthrd", ticks); /* XXX */ -/* - * OSF/1 defines _POSIX_SAVED_IDS, which means that our normal - * setuid() won't work. - * - * Instead, by P1003.1b-1993, setuid() is supposed to work like: - * If the process has appropriate [super-user] priviledges, the - * setuid() function sets the real user ID, effective user - * ID, and the saved set-user-ID to uid. - * If the process does not have appropriate priviledges, but uid - * is equal to the real user ID or the saved set-user-ID, the - * setuid() function sets the effective user ID to uid; the - * real user ID and saved set-user-ID remain unchanged by - * this function call. - */ -int -osf1_sys_setuid(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_setuid_args /* { - syscallargs(uid_t) uid; - } */ *uap = v; - register struct pcred *pc = p->p_cred; - uid_t uid = SCARG(uap, uid); - int error; - - if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0 && - uid != pc->p_ruid && uid != pc->p_svuid) - return (error); + if (SCARG(uap, slept) != NULL) { + s = splclock(); + timersub(&time, &tv, &endtv); + splx(s); + if (endtv.tv_sec < 0 || endtv.tv_usec < 0) + endtv.tv_sec = endtv.tv_usec = 0; - pc->pc_ucred = crcopy(pc->pc_ucred); - pc->pc_ucred->cr_uid = uid; - if (error == 0) { - (void)chgproccnt(pc->p_ruid, -1); - (void)chgproccnt(uid, 1); - pc->p_ruid = uid; - pc->p_svuid = uid; + endotv.tv_sec = endtv.tv_sec; + endotv.tv_usec = endtv.tv_usec; + error = copyout(&endotv, SCARG(uap, slept), sizeof endotv); } - p->p_flag |= P_SUGID; - return (0); + return (error); } -/* - * OSF/1 defines _POSIX_SAVED_IDS, which means that our normal - * setgid() won't work. - * - * If you change "uid" to "gid" in the discussion, above, about - * setuid(), you'll get a correct description of setgid(). - */ int -osf1_sys_setgid(p, v, retval) +osf1_sys_wait4(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct osf1_sys_setgid_args /* { - syscallargs(gid_t) gid; - } */ *uap = v; - register struct pcred *pc = p->p_cred; - gid_t gid = SCARG(uap, gid); + struct osf1_sys_wait4_args *uap = v; + struct sys_wait4_args a; + struct osf1_rusage osf1_rusage; + struct rusage netbsd_rusage; + unsigned long leftovers; + caddr_t sg; int error; - if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0 && - gid != pc->p_rgid && gid != pc->p_svgid) - return (error); - - pc->pc_ucred = crcopy(pc->pc_ucred); - pc->pc_ucred->cr_gid = gid; - if (error == 0) { - pc->p_rgid = gid; - pc->p_svgid = gid; - } - p->p_flag |= P_SUGID; - return (0); -} - -/* - * The structures end up being the same... but we can't be sure that - * the other word of our iov_len is zero! - */ -struct osf1_iovec { - char *iov_base; - int iov_len; -}; + SCARG(&a, pid) = SCARG(uap, pid); + SCARG(&a, status) = SCARG(uap, status); -int -osf1_sys_readv(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_readv_args /* { - syscallarg(int) fd; - syscallarg(struct osf1_iovec *) iovp; - syscallarg(u_int) iovcnt; - } */ *uap = v; - struct sys_readv_args /* { - syscallarg(int) fd; - syscallarg(struct iovec *) iovp; - syscallarg(u_int) iovcnt; - } */ a; - struct emul *e = p->p_emul; - struct osf1_iovec *oio; - struct iovec *nio; - int error, i; - - if (SCARG(uap, iovcnt) > (STACKGAPLEN / sizeof (struct iovec))) + /* translate options */ + SCARG(&a, options) = emul_flags_translate(osf1_wait_options_xtab, + SCARG(uap, options), &leftovers); + if (leftovers != 0) return (EINVAL); - oio = (struct osf1_iovec *) - malloc(SCARG(uap, iovcnt)*sizeof (struct osf1_iovec), - M_TEMP, M_WAITOK); - nio = (struct iovec *)malloc(SCARG(uap, iovcnt)*sizeof (struct iovec), - M_TEMP, M_WAITOK); - - error = 0; - if ((error = copyin(SCARG(uap, iovp), oio, - SCARG(uap, iovcnt) * sizeof (struct osf1_iovec))) != 0) - goto punt; - for (i = 0; i < SCARG(uap, iovcnt); i++) { - nio[i].iov_base = oio[i].iov_base; - nio[i].iov_len = oio[i].iov_len; + if (SCARG(uap, rusage) == NULL) + SCARG(&a, rusage) = NULL; + else { + sg = stackgap_init(p->p_emul); + SCARG(&a, rusage) = stackgap_alloc(&sg, sizeof netbsd_rusage); } - SCARG(&a, fd) = SCARG(uap, fd); - SCARG(&a, iovp) = (struct iovec *)STACKGAPBASE; - SCARG(&a, iovcnt) = SCARG(uap, iovcnt); - - if ((error = copyout(nio, (caddr_t)SCARG(&a, iovp), - SCARG(uap, iovcnt) * sizeof (struct iovec))) != 0) - goto punt; - error = sys_readv(p, &a, retval); - -punt: - free(oio, M_TEMP); - free(nio, M_TEMP); - return (error); -} - -int -osf1_sys_writev(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_writev_args /* { - syscallarg(int) fd; - syscallarg(struct osf1_iovec *) iovp; - syscallarg(u_int) iovcnt; - } */ *uap = v; - struct sys_writev_args /* { - syscallarg(int) fd; - syscallarg(struct iovec *) iovp; - syscallarg(u_int) iovcnt; - } */ a; - struct emul *e = p->p_emul; - struct osf1_iovec *oio; - struct iovec *nio; - int error, i; - - if (SCARG(uap, iovcnt) > (STACKGAPLEN / sizeof (struct iovec))) - return (EINVAL); - - oio = (struct osf1_iovec *) - malloc(SCARG(uap, iovcnt)*sizeof (struct osf1_iovec), - M_TEMP, M_WAITOK); - nio = (struct iovec *)malloc(SCARG(uap, iovcnt)*sizeof (struct iovec), - M_TEMP, M_WAITOK); - - error = 0; - if ((error = copyin(SCARG(uap, iovp), oio, - SCARG(uap, iovcnt) * sizeof (struct osf1_iovec))) != 0) - goto punt; - for (i = 0; i < SCARG(uap, iovcnt); i++) { - nio[i].iov_base = oio[i].iov_base; - nio[i].iov_len = oio[i].iov_len; + error = sys_wait4(p, &a, retval); + + if (error == 0 && SCARG(&a, rusage) != NULL) { + error = copyin((caddr_t)SCARG(&a, rusage), + (caddr_t)&netbsd_rusage, sizeof netbsd_rusage); + if (error == 0) { + osf1_cvt_rusage_from_native(&netbsd_rusage, + &osf1_rusage); + error = copyout((caddr_t)&osf1_rusage, + (caddr_t)SCARG(uap, rusage), sizeof osf1_rusage); + } } - SCARG(&a, fd) = SCARG(uap, fd); - SCARG(&a, iovp) = (struct iovec *)STACKGAPBASE; - SCARG(&a, iovcnt) = SCARG(uap, iovcnt); - - if ((error = copyout(nio, (caddr_t)SCARG(&a, iovp), - SCARG(uap, iovcnt) * sizeof (struct iovec))) != 0) - goto punt; - error = sys_writev(p, &a, retval); - -punt: - free(oio, M_TEMP); - free(nio, M_TEMP); return (error); } - -/* More of the stupid off_t padding! */ -int -osf1_sys_truncate(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_truncate_args /* { - syscallarg(char *) path; - syscallarg(off_t) length; - } */ *uap = v; - struct sys_truncate_args a; - - SCARG(&a, path) = SCARG(uap, path); - SCARG(&a, pad) = 0; - SCARG(&a, length) = SCARG(uap, length); - - return sys_truncate(p, &a, retval); -} - -int -osf1_sys_ftruncate(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_ftruncate_args /* { - syscallarg(int) fd; - syscallarg(off_t) length; - } */ *uap = v; - struct sys_ftruncate_args a; - - SCARG(&a, fd) = SCARG(uap, fd); - SCARG(&a, pad) = 0; - SCARG(&a, length) = SCARG(uap, length); - - return sys_ftruncate(p, &a, retval); -} - -int -osf1_sys_getsid(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_getsid_args /* { - syscallarg(pid_t) pid; - } */ *uap = v; - struct proc *t; - - if (SCARG(uap, pid) == 0) - t = p; - else if ((t = pfind(SCARG(uap, pid))) == NULL) - return (ESRCH); - - *retval = t->p_session->s_leader->p_pid; - return (0); -} - -int -osf1_sys_getrusage(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - - /* XXX */ - return EINVAL; -} - -int -osf1_sys_madvise(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - - /* XXX */ - return EINVAL; -} - -int -osf1_sys_execve(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_execve_args *uap = v; -#if 0 - caddr_t sg = stackgap_init(p->p_emul); - - OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); -#endif - - return (sys_execve(p, (struct sys_execve_args *)&uap, retval)); -} diff --git a/sys/compat/osf1/osf1_mmap.c b/sys/compat/osf1/osf1_mmap.c new file mode 100644 index 00000000000..8db88e47986 --- /dev/null +++ b/sys/compat/osf1/osf1_mmap.c @@ -0,0 +1,282 @@ +/* $OpenBSD: osf1_mmap.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_mmap.c,v 1.5 2000/04/11 05:26:27 chs Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/proc.h> +#include <sys/mman.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <vm/vm.h> /* XXX see mmap emulation */ + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_cvt.h> + +int +osf1_sys_madvise(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_madvise_args *uap = v; + struct sys_madvise_args a; + int error; + + SCARG(&a, addr) = SCARG(uap, addr); + SCARG(&a, len) = SCARG(uap, len); + + error = 0; + switch (SCARG(uap, behav)) { + case OSF1_MADV_NORMAL: + SCARG(&a, behav) = MADV_NORMAL; + break; + + case OSF1_MADV_RANDOM: + SCARG(&a, behav) = MADV_RANDOM; + break; + + case OSF1_MADV_SEQUENTIAL: + SCARG(&a, behav) = MADV_SEQUENTIAL; + break; + + case OSF1_MADV_WILLNEED: + SCARG(&a, behav) = MADV_WILLNEED; + break; + + case OSF1_MADV_DONTNEED_COMPAT: + SCARG(&a, behav) = MADV_DONTNEED; + break; +#if 0 + case OSF1_MADV_SPACEAVAIL: + SCARG(&a, behav) = MADV_SPACEAVAIL; + break; +#endif + case OSF1_MADV_DONTNEED: + /* + * XXX not supported. In Digital UNIX, this flushes all + * XXX data in the region and replaces it with ZFOD pages. + */ + error = EINVAL; + break; + + default: + error = EINVAL; + break; + } + + if (error == 0) { + error = sys_madvise(p, &a, retval); + + /* + * NetBSD madvise() currently always returns ENOSYS. + * Digital UNIX says that non-operational requests (i.e. + * valid, but unimplemented 'behav') will return success. + */ + if (error == ENOSYS) + error = 0; + } + return (error); +} + +int +osf1_sys_mmap(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ +#if defined(UVM) + struct osf1_sys_mmap_args *uap = v; + struct sys_mmap_args a; + unsigned long leftovers; + + SCARG(&a, addr) = SCARG(uap, addr); + SCARG(&a, len) = SCARG(uap, len); + SCARG(&a, fd) = SCARG(uap, fd); + SCARG(&a, pad) = 0; + SCARG(&a, pos) = SCARG(uap, pos); + + /* translate prot */ + SCARG(&a, prot) = emul_flags_translate(osf1_mmap_prot_xtab, + SCARG(uap, prot), &leftovers); + if (leftovers != 0) + return (EINVAL); + + /* translate flags */ + SCARG(&a, flags) = emul_flags_translate(osf1_mmap_flags_xtab, + SCARG(uap, flags), &leftovers); + if (leftovers != 0) + return (EINVAL); + + /* + * XXX The following code is evil. + * + * The OSF/1 mmap() function attempts to map non-fixed entries + * near the address that the user specified. Therefore, for + * non-fixed entires we try to find space in the address space + * starting at that address. If the user specified zero, we + * start looking at at least NBPG, so that programs can't + * accidentally live through deferencing NULL. + * + * The need for this kludgery is increased by the fact that + * the loader data segment is mapped at + * (end of user address space) - 1G, MAXDSIZ is 1G, and + * the VM system tries allocate non-fixed mappings _AFTER_ + * (start of data) + MAXDSIZ. With the loader, of course, + * that means that it'll start trying at + * (end of user address space), and will never succeed! + * + * Notes: + * + * * Though we find space here, if something else (e.g. a second + * thread) were mucking with the address space the mapping + * we found might be used by another mmap(), and this call + * would clobber that region. + * + * * In general, tricks like this only work for MAP_ANON mappings, + * because of sharing/cache issues. That's not a problem on + * the Alpha, and though it's not good style to abuse that fact, + * there's little choice. + * + * * In order for this to be done right, the VM system should + * really try to use the requested 'addr' passed in to mmap() + * as a hint, even if non-fixed. If it's passed as zero, + * _maybe_ then try (start of data) + MAXDSIZ, or maybe + * provide a better way to avoid the data region altogether. + */ + if ((SCARG(&a, flags) & MAP_FIXED) == 0) { + vaddr_t addr = round_page((vaddr_t)SCARG(&a, addr)); + vsize_t size = round_page((vsize_t)SCARG(&a, len)); + int fixed = 0; + + vm_map_lock(&p->p_vmspace->vm_map); + + /* if non-NULL address given, start looking there */ + /* XXX - UVM */ + if (addr != 0 && vm_map_findspace(&p->p_vmspace->vm_map, + addr, size, &addr, NULL, 0, 0) != NULL) { + fixed = 1; + goto done; + } + + /* didn't find anything. take it again from the top. */ + if (uvm_map_findspace(&p->p_vmspace->vm_map, NBPG, size, &addr, + NULL, 0, 0) != NULL) { + fixed = 1; + goto done; + } + +done: + vm_map_unlock(&p->p_vmspace->vm_map); + if (fixed) { + SCARG(&a, flags) |= MAP_FIXED; + SCARG(&a, addr) = (void *)addr; + } + } + + return sys_mmap(p, &a, retval); +#else + struct osf1_sys_mmap_args /* { + syscallarg(caddr_t) addr; + syscallarg(size_t) len; + syscallarg(int) prot; + syscallarg(int) flags; + syscallarg(int) fd; + syscallarg(off_t) pos; + } */ *uap = v; + struct sys_mmap_args /* { + syscallarg(caddr_t) addr; + syscallarg(size_t) len; + syscallarg(int) prot; + syscallarg(int) flags; + syscallarg(int) fd; + syscallarg(long) pad; + syscallarg(off_t) pos; + } */ a; + + SCARG(&a, addr) = SCARG(uap, addr); + SCARG(&a, len) = SCARG(uap, len); + SCARG(&a, prot) = SCARG(uap, prot); + SCARG(&a, fd) = SCARG(uap, fd); + SCARG(&a, pad) = 0; + SCARG(&a, pos) = SCARG(uap, pos); + + SCARG(&a, flags) = 0; + if (SCARG(uap, flags) & OSF1_MAP_SHARED) + SCARG(&a, flags) |= MAP_SHARED; + if (SCARG(uap, flags) & OSF1_MAP_PRIVATE) + SCARG(&a, flags) |= MAP_PRIVATE; + switch (SCARG(uap, flags) & OSF1_MAP_TYPE) { + case OSF1_MAP_ANON: + SCARG(&a, flags) |= MAP_ANON; + break; + case OSF1_MAP_FILE: + SCARG(&a, flags) |= MAP_FILE; + break; + default: + return (EINVAL); + } + if (SCARG(uap, flags) & OSF1_MAP_FIXED) + SCARG(&a, flags) |= MAP_FIXED; + if (SCARG(uap, flags) & OSF1_MAP_HASSEMAPHORE) + SCARG(&a, flags) |= MAP_HASSEMAPHORE; + if (SCARG(uap, flags) & OSF1_MAP_INHERIT) + SCARG(&a, flags) |= MAP_INHERIT; + if (SCARG(uap, flags) & OSF1_MAP_UNALIGNED) + return (EINVAL); + + return sys_mmap(p, &a, retval); +#endif +} + +int +osf1_sys_mprotect(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_mprotect_args *uap = v; + struct sys_mprotect_args a; + unsigned long leftovers; + + SCARG(&a, addr) = SCARG(uap, addr); + SCARG(&a, len) = SCARG(uap, len); + + /* translate prot */ + SCARG(&a, prot) = emul_flags_translate(osf1_mmap_prot_xtab, + SCARG(uap, prot), &leftovers); + if (leftovers != 0) + return (EINVAL); + + return sys_mprotect(p, &a, retval); +} diff --git a/sys/compat/osf1/osf1_mount.c b/sys/compat/osf1/osf1_mount.c index a591c6014ab..2872db884eb 100644 --- a/sys/compat/osf1/osf1_mount.c +++ b/sys/compat/osf1/osf1_mount.c @@ -1,5 +1,35 @@ -/* $OpenBSD: osf1_mount.c,v 1.4 1996/10/30 16:37:20 niklas Exp $ */ -/* $NetBSD: osf1_mount.c,v 1.6 1996/02/17 23:08:36 jtk Exp $ */ +/* $OpenBSD: osf1_mount.c,v 1.5 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_mount.c,v 1.14 1999/05/05 01:51:34 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -33,38 +63,29 @@ #include <sys/namei.h> #include <sys/proc.h> #include <sys/file.h> +#include <sys/filedesc.h> #include <sys/kernel.h> #include <sys/mount.h> #include <sys/vnode.h> #include <sys/syscallargs.h> +#include <compat/osf1/osf1.h> #include <compat/osf1/osf1_syscallargs.h> #include <compat/osf1/osf1_util.h> +#include <compat/osf1/osf1_cvt.h> #include <net/if.h> #include <netinet/in.h> +#include <nfs/rpcv2.h> #include <nfs/nfsproto.h> +#include <nfs/nfs.h> +#include <nfs/nfsmount.h> -#include <machine/vmparam.h> +#include <ufs/ufs/quota.h> +#include <ufs/ufs/ufsmount.h> -/* File system type numbers. */ -#define OSF1_MOUNT_NONE 0 -#define OSF1_MOUNT_UFS 1 -#define OSF1_MOUNT_NFS 2 -#define OSF1_MOUNT_MFS 3 -#define OSF1_MOUNT_PC 4 -#define OSF1_MOUNT_S5FS 5 -#define OSF1_MOUNT_CDFS 6 -#define OSF1_MOUNT_DFS 7 -#define OSF1_MOUNT_EFS 8 -#define OSF1_MOUNT_PROCFS 9 -#define OSF1_MOUNT_MSFS 10 -#define OSF1_MOUNT_FFM 11 -#define OSF1_MOUNT_FDFS 12 -#define OSF1_MOUNT_ADDON 13 -#define OSF1_MOUNT_NFSV3 14 -#define OSF1_MOUNT_MAXTYPE 15 +#include <machine/vmparam.h> #define OSF1_MNT_WAIT 0x1 #define OSF1_MNT_NOWAIT 0x2 @@ -77,154 +98,11 @@ #define OSF1_MOUNT_FLAGS 0xffffffff /* XXX */ #define OSF1_UNMOUNT_FLAGS (OSF1_MNT_FORCE|OSF1_MNT_NOFORCE) -struct osf1_statfs { - int16_t f_type; /* 0 */ - int16_t f_flags; /* 2 */ - int32_t f_fsize; /* 4 */ - int32_t f_bsize; /* 8 */ - int32_t f_blocks; /* 12 */ - int32_t f_bfree; /* 16 */ - int32_t f_bavail; /* 20 */ - int32_t f_files; /* 24 */ - int32_t f_ffree; /* 28 */ - int64_t f_fsid; /* 32 */ - int32_t f_spare[9]; /* 40 (36 bytes) */ - char f_mntonname[90]; /* 76 (90 bytes) */ - char f_mntfromname[90]; /* 166 (90 bytes) */ - char f_xxx[80]; /* 256 (80 bytes) XXX */ -}; - -/* Arguments to mount() for various FS types. */ -#ifdef notyet /* XXX */ -struct osf1_ufs_args { - char *fspec; - int32_t exflags; - u_int32_t exroot; -}; - -struct osf1_cdfs_args { - char *fspec; - int32_t exflags; - u_int32_t exroot; - int32_t flags; -}; -#endif - -struct osf1_mfs_args { - char *name; - caddr_t base; - u_int size; -}; - -struct osf1_nfs_args { - struct sockaddr_in *addr; - caddr_t fh; - int32_t flags; - int32_t wsize; - int32_t rsize; - int32_t timeo; - int32_t retrans; - char *hostname; - int32_t acregmin; - int32_t acregmax; - int32_t acdirmin; - int32_t acdirmax; - char *netname; - void *pathconf; -}; - -#define OSF1_NFSMNT_SOFT 0x00001 -#define OSF1_NFSMNT_WSIZE 0x00002 -#define OSF1_NFSMNT_RSIZE 0x00004 -#define OSF1_NFSMNT_TIMEO 0x00008 -#define OSF1_NFSMNT_RETRANS 0x00010 -#define OSF1_NFSMNT_HOSTNAME 0x00020 -#define OSF1_NFSMNT_INT 0x00040 -#define OSF1_NFSMNT_NOCONN 0x00080 -#define OSF1_NFSMNT_NOAC 0x00100 /* ??? */ -#define OSF1_NFSMNT_ACREGMIN 0x00200 /* ??? */ -#define OSF1_NFSMNT_ACREGMAX 0x00400 /* ??? */ -#define OSF1_NFSMNT_ACDIRMIN 0x00800 /* ??? */ -#define OSF1_NFSMNT_ACDIRMAX 0x01000 /* ??? */ -#define OSF1_NFSMNT_NOCTO 0x02000 /* ??? */ -#define OSF1_NFSMNT_POSIX 0x04000 /* ??? */ -#define OSF1_NFSMNT_AUTO 0x08000 /* ??? */ - -#define OSF1_NFSMNT_FLAGS \ - (OSF1_NFSMNT_SOFT|OSF1_NFSMNT_WSIZE|OSF1_NFSMNT_RSIZE| \ - OSF1_NFSMNT_TIMEO|OSF1_NFSMNT_RETRANS|OSF1_NFSMNT_HOSTNAME| \ - OSF1_NFSMNT_INT|OSF1_NFSMNT_NOCONN) - -void bsd2osf_statfs __P((struct statfs *, struct osf1_statfs *)); -int osf1_mount_mfs __P((struct proc *, struct osf1_sys_mount_args *, - struct sys_mount_args *)); -int osf1_mount_nfs __P((struct proc *, struct osf1_sys_mount_args *, - struct sys_mount_args *)); - -void -bsd2osf_statfs(bsfs, osfs) - struct statfs *bsfs; - struct osf1_statfs *osfs; -{ - - bzero(osfs, sizeof (struct osf1_statfs)); - if (!strncmp(MOUNT_FFS, bsfs->f_fstypename, MFSNAMELEN)) - osfs->f_type = OSF1_MOUNT_UFS; - else if (!strncmp(MOUNT_NFS, bsfs->f_fstypename, MFSNAMELEN)) - osfs->f_type = OSF1_MOUNT_NFS; - else if (!strncmp(MOUNT_MFS, bsfs->f_fstypename, MFSNAMELEN)) - osfs->f_type = OSF1_MOUNT_MFS; - else - /* uh oh... XXX = PC, CDFS, PROCFS, etc. */ - osfs->f_type = OSF1_MOUNT_ADDON; - osfs->f_flags = bsfs->f_flags; /* XXX translate */ - osfs->f_fsize = bsfs->f_bsize; - osfs->f_bsize = bsfs->f_iosize; - osfs->f_blocks = bsfs->f_blocks; - osfs->f_bfree = bsfs->f_bfree; - osfs->f_bavail = bsfs->f_bavail; - osfs->f_files = bsfs->f_files; - osfs->f_ffree = bsfs->f_ffree; - bcopy(&bsfs->f_fsid, &osfs->f_fsid, - max(sizeof bsfs->f_fsid, sizeof osfs->f_fsid)); - /* osfs->f_spare zeroed above */ - bcopy(bsfs->f_mntonname, osfs->f_mntonname, - max(sizeof bsfs->f_mntonname, sizeof osfs->f_mntonname)); - bcopy(bsfs->f_mntfromname, osfs->f_mntfromname, - max(sizeof bsfs->f_mntfromname, sizeof osfs->f_mntfromname)); - /* XXX osfs->f_xxx should be filled in... */ -} - -int -osf1_sys_statfs(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_statfs_args /* { - syscallarg(char *) path; - syscallarg(struct osf1_statfs *) buf; - syscallarg(int) len; - } */ *uap = v; - struct mount *mp; - struct statfs *sp; - struct osf1_statfs osfs; - int error; - struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); - if ((error = namei(&nd)) != 0) - return (error); - mp = nd.ni_vp->v_mount; - sp = &mp->mnt_stat; - vrele(nd.ni_vp); - if ((error = VFS_STATFS(mp, sp, p)) != 0) - return (error); - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - bsd2osf_statfs(sp, &osfs); - return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs, - SCARG(uap, len))); -} +static int osf1_mount_mfs __P((struct proc *, + struct osf1_sys_mount_args *, struct sys_mount_args *)); +static int osf1_mount_nfs __P((struct proc *, + struct osf1_sys_mount_args *, struct sys_mount_args *)); int osf1_sys_fstatfs(p, v, retval) @@ -232,27 +110,26 @@ osf1_sys_fstatfs(p, v, retval) void *v; register_t *retval; { - struct osf1_sys_fstatfs_args /* { - syscallarg(int) fd; - syscallarg(struct osf1_statfs *) buf; - syscallarg(int) len; - } */ *uap = v; + struct osf1_sys_fstatfs_args *uap = v; struct file *fp; struct mount *mp; struct statfs *sp; struct osf1_statfs osfs; int error; - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + /* getvnode() will use the descriptor for us */ + if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp))) return (error); mp = ((struct vnode *)fp->f_data)->v_mount; sp = &mp->mnt_stat; - if ((error = VFS_STATFS(mp, sp, p)) != 0) - return (error); + if ((error = VFS_STATFS(mp, sp, p))) + goto out; sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - bsd2osf_statfs(sp, &osfs); - return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs, + osf1_cvt_statfs_from_native(sp, &osfs); + error = copyout(&osfs, SCARG(uap, buf), min(sizeof osfs, SCARG(uap, len))); + out: + return (error); } int @@ -261,11 +138,7 @@ osf1_sys_getfsstat(p, v, retval) void *v; register_t *retval; { - register struct osf1_sys_getfsstat_args /* { - syscallarg(struct osf1_statfs *) buf; - syscallarg(long) bufsize; - syscallarg(int) flags; - } */ *uap = v; + struct osf1_sys_getfsstat_args *uap = v; struct mount *mp, *nmp; struct statfs *sp; struct osf1_statfs osfs; @@ -280,8 +153,7 @@ osf1_sys_getfsstat(p, v, retval) for (count = 0, mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { nmp = mp->mnt_list.cqe_next; - if (osf_sfsp && count < maxcount && - ((mp->mnt_flag & MNT_MLOCK) == 0)) { + if (osf_sfsp && count < maxcount) { sp = &mp->mnt_stat; /* * If OSF1_MNT_NOWAIT is specified, do not refresh the @@ -293,9 +165,9 @@ osf1_sys_getfsstat(p, v, retval) (error = VFS_STATFS(mp, sp, p))) continue; sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - bsd2osf_statfs(sp, &osfs); + osf1_cvt_statfs_from_native(sp, &osfs); if ((error = copyout(&osfs, osf_sfsp, - sizeof (struct osf1_statfs))) != 0) + sizeof (struct osf1_statfs)))) return (error); osf_sfsp += sizeof (struct osf1_statfs); } @@ -309,41 +181,12 @@ osf1_sys_getfsstat(p, v, retval) } int -osf1_sys_unmount(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_unmount_args /* { - syscallarg(char *) path; - syscallarg(int) flags; - } */ *uap = v; - struct sys_unmount_args a; - - SCARG(&a, path) = SCARG(uap, path); - - if (SCARG(uap, flags) & ~OSF1_UNMOUNT_FLAGS) - return (EINVAL); - SCARG(&a, flags) = 0; - if ((SCARG(uap, flags) & OSF1_MNT_FORCE) && - (SCARG(uap, flags) & OSF1_MNT_NOFORCE) == 0) - SCARG(&a, flags) |= MNT_FORCE; - - return sys_unmount(p, &a, retval); -} - -int osf1_sys_mount(p, v, retval) struct proc *p; void *v; register_t *retval; { - struct osf1_sys_mount_args /* { - syscallarg(int) type; - syscallarg(char *) path; - syscallarg(int) flags; - syscallarg(caddr_t) data; - } */ *uap = v; + struct osf1_sys_mount_args *uap = v; struct sys_mount_args a; int error; @@ -354,37 +197,16 @@ osf1_sys_mount(p, v, retval) SCARG(&a, flags) = SCARG(uap, flags); /* XXX - xlate */ switch (SCARG(uap, type)) { - case OSF1_MOUNT_UFS: /* XXX */ - return (EINVAL); - break; - - case OSF1_MOUNT_NFS: /* XXX */ - if ((error = osf1_mount_nfs(p, uap, &a)) != 0) + case OSF1_MOUNT_NFS: + if ((error = osf1_mount_nfs(p, uap, &a))) return error; break; - case OSF1_MOUNT_MFS: /* XXX */ - if ((error = osf1_mount_mfs(p, uap, &a)) != 0) + case OSF1_MOUNT_MFS: + if ((error = osf1_mount_mfs(p, uap, &a))) return error; break; - case OSF1_MOUNT_CDFS: /* XXX */ - return (EINVAL); - break; - - case OSF1_MOUNT_PROCFS: /* XXX */ - return (EINVAL); - break; - - case OSF1_MOUNT_NONE: - case OSF1_MOUNT_PC: - case OSF1_MOUNT_S5FS: - case OSF1_MOUNT_DFS: - case OSF1_MOUNT_EFS: - case OSF1_MOUNT_MSFS: - case OSF1_MOUNT_FFM: - case OSF1_MOUNT_FDFS: - case OSF1_MOUNT_ADDON: default: return (EINVAL); } @@ -393,99 +215,144 @@ osf1_sys_mount(p, v, retval) } int +osf1_sys_statfs(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_statfs_args *uap = v; + struct mount *mp; + struct statfs *sp; + struct osf1_statfs osfs; + int error; + struct nameidata nd; + + NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + if ((error = namei(&nd))) + return (error); + mp = nd.ni_vp->v_mount; + sp = &mp->mnt_stat; + vrele(nd.ni_vp); + if ((error = VFS_STATFS(mp, sp, p))) + return (error); + sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; + osf1_cvt_statfs_from_native(sp, &osfs); + return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs, + SCARG(uap, len))); +} + +int +osf1_sys_unmount(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_unmount_args *uap = v; + struct sys_unmount_args a; + + SCARG(&a, path) = SCARG(uap, path); + + if (SCARG(uap, flags) & ~OSF1_UNMOUNT_FLAGS) + return (EINVAL); + SCARG(&a, flags) = 0; + if ((SCARG(uap, flags) & OSF1_MNT_FORCE) && + (SCARG(uap, flags) & OSF1_MNT_NOFORCE) == 0) + SCARG(&a, flags) |= MNT_FORCE; + + return sys_unmount(p, &a, retval); +} + +static int osf1_mount_mfs(p, osf_argp, bsd_argp) struct proc *p; struct osf1_sys_mount_args *osf_argp; struct sys_mount_args *bsd_argp; { - struct emul *e = p->p_emul; struct osf1_mfs_args osf_ma; struct mfs_args bsd_ma; - caddr_t cp; - int error; + caddr_t sg = stackgap_init(p->p_emul); + int error, len; + static const char mfs_name[] = MOUNT_MFS; - error = copyin(SCARG(osf_argp, data), &osf_ma, sizeof osf_ma); - if (error) + if ((error = copyin(SCARG(osf_argp, data), &osf_ma, sizeof osf_ma))) return error; - bzero(&bsd_ma, sizeof bsd_ma); + memset(&bsd_ma, 0, sizeof bsd_ma); bsd_ma.fspec = osf_ma.name; /* XXX export args */ bsd_ma.base = osf_ma.base; bsd_ma.size = osf_ma.size; - cp = STACKGAPBASE; - SCARG(bsd_argp, data) = cp; - if ((error = copyout(&bsd_ma, cp, sizeof bsd_ma)) != 0) + SCARG(bsd_argp, data) = stackgap_alloc(&sg, sizeof bsd_ma); + if ((error = copyout(&bsd_ma, SCARG(bsd_argp, data), sizeof bsd_ma))) return error; - cp += ALIGN(sizeof bsd_ma); - SCARG(bsd_argp, type) = cp; - if ((error = copyout(MOUNT_MFS, cp, strlen(MOUNT_MFS) + 1)) != 0) + len = strlen(mfs_name) + 1; + SCARG(bsd_argp, type) = stackgap_alloc(&sg, len); + if ((error = copyout(mfs_name, (void *)SCARG(bsd_argp, type), len))) return error; return 0; } -int +static int osf1_mount_nfs(p, osf_argp, bsd_argp) struct proc *p; struct osf1_sys_mount_args *osf_argp; struct sys_mount_args *bsd_argp; { - struct emul *e = p->p_emul; struct osf1_nfs_args osf_na; struct nfs_args bsd_na; - caddr_t cp; - int error; + caddr_t sg = stackgap_init(p->p_emul); + int error, len; + static const char nfs_name[] = MOUNT_NFS; + unsigned long leftovers; - error = copyin(SCARG(osf_argp, data), &osf_na, sizeof osf_na); - if (error) + if ((error = copyin(SCARG(osf_argp, data), &osf_na, sizeof osf_na))) return error; - bzero(&bsd_na, sizeof bsd_na); - bsd_na.version = 2; + memset(&bsd_na, 0, sizeof bsd_na); bsd_na.addr = (struct sockaddr *)osf_na.addr; bsd_na.addrlen = sizeof (struct sockaddr_in); - bsd_na.sotype = SOCK_DGRAM; - bsd_na.proto = 0; - bsd_na.fh = (char *)osf_na.fh; - - if (osf_na.flags & ~OSF1_NFSMNT_FLAGS) - return EINVAL; - if (osf_na.flags & OSF1_NFSMNT_SOFT) - bsd_na.flags |= NFSMNT_SOFT; - if (osf_na.flags & OSF1_NFSMNT_WSIZE) { - bsd_na.wsize = osf_na.wsize; - bsd_na.flags |= NFSMNT_WSIZE; + bsd_na.fh = osf_na.fh; + + /* translate flags */ + bsd_na.flags = emul_flags_translate(osf1_nfs_mount_flags_xtab, + osf_na.flags, &leftovers); + if (leftovers & OSF1_NFSMNT_HOSTNAME) { + leftovers &= ~OSF1_NFSMNT_HOSTNAME; + bsd_na.hostname = osf_na.hostname; + } else { + /* XXX FILL IN HOST NAME WITH IPADDR? */ } - if (osf_na.flags & OSF1_NFSMNT_RSIZE) { - bsd_na.rsize = osf_na.rsize; - bsd_na.flags |= NFSMNT_RSIZE; + if (leftovers & OSF1_NFSMNT_TCP) { + leftovers &= ~OSF1_NFSMNT_TCP; + bsd_na.sotype = SOCK_DGRAM; + bsd_na.proto = 0; + } else { + bsd_na.sotype = SOCK_STREAM; + bsd_na.proto = 0; } - if (osf_na.flags & OSF1_NFSMNT_TIMEO) { + if (leftovers != 0) + return (EINVAL); + + /* copy structure elements based on flags */ + if (bsd_na.flags & NFSMNT_WSIZE) + bsd_na.wsize = osf_na.wsize; + if (bsd_na.flags & NFSMNT_RSIZE) + bsd_na.rsize = osf_na.rsize; + if (bsd_na.flags & NFSMNT_TIMEO) bsd_na.timeo = osf_na.timeo; - bsd_na.flags |= NFSMNT_TIMEO; - } - if (osf_na.flags & OSF1_NFSMNT_RETRANS) { + if (bsd_na.flags & NFSMNT_RETRANS) bsd_na.retrans = osf_na.retrans; - bsd_na.flags |= NFSMNT_RETRANS; - } - if (osf_na.flags & OSF1_NFSMNT_HOSTNAME) - bsd_na.hostname = osf_na.hostname; - if (osf_na.flags & OSF1_NFSMNT_INT) - bsd_na.flags |= NFSMNT_INT; - if (osf_na.flags & OSF1_NFSMNT_NOCONN) - bsd_na.flags |= NFSMNT_NOCONN; - - cp = STACKGAPBASE; - SCARG(bsd_argp, data) = cp; - if ((error = copyout(&bsd_na, cp, sizeof bsd_na)) != 0) + + SCARG(bsd_argp, data) = stackgap_alloc(&sg, sizeof bsd_na); + if ((error = copyout(&bsd_na, SCARG(bsd_argp, data), sizeof bsd_na))) return error; - cp += ALIGN(sizeof bsd_na); - SCARG(bsd_argp, type) = cp; - if ((error = copyout(MOUNT_NFS, cp, strlen(MOUNT_NFS) + 1)) != 0) + len = strlen(nfs_name) + 1; + SCARG(bsd_argp, type) = stackgap_alloc(&sg, len); + if ((error = copyout(MOUNT_NFS, (void *)SCARG(bsd_argp, type), len))) return error; return 0; diff --git a/sys/compat/osf1/osf1_prot.c b/sys/compat/osf1/osf1_prot.c new file mode 100644 index 00000000000..9385ab48f24 --- /dev/null +++ b/sys/compat/osf1/osf1_prot.c @@ -0,0 +1,142 @@ +/* $OpenBSD: osf1_prot.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_prot.c,v 1.2 1999/05/05 01:51:35 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/proc.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_cvt.h> + +/* + * OSF/1 defines _POSIX_SAVED_IDS, which means that our normal + * setgid() won't work. + * + * If you change "uid" to "gid" in the discussion, below, about + * setuid(), you'll get a correct description of setgid(). + */ +int +osf1_sys_setgid(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_setgid_args *uap = v; + struct pcred *pc = p->p_cred; + gid_t gid = SCARG(uap, gid); + int error; + + if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0 && + gid != pc->p_rgid && gid != pc->p_svgid) + return (error); + + pc->pc_ucred = crcopy(pc->pc_ucred); + pc->pc_ucred->cr_gid = gid; + if (error == 0) { + pc->p_rgid = gid; + pc->p_svgid = gid; + } + p->p_flag |= P_SUGID; + return (0); +} + +/* + * OSF/1 defines _POSIX_SAVED_IDS, which means that our normal + * setuid() won't work. + * + * Instead, by P1003.1b-1993, setuid() is supposed to work like: + * If the process has appropriate [super-user] privileges, the + * setuid() function sets the real user ID, effective user + * ID, and the saved set-user-ID to uid. + * If the process does not have appropriate privileges, but uid + * is equal to the real user ID or the saved set-user-ID, the + * setuid() function sets the effective user ID to uid; the + * real user ID and saved set-user-ID remain unchanged by + * this function call. + */ +int +osf1_sys_setuid(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_setuid_args *uap = v; + struct pcred *pc = p->p_cred; + uid_t uid = SCARG(uap, uid); + int error; + + if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0 && + uid != pc->p_ruid && uid != pc->p_svuid) + return (error); + + pc->pc_ucred = crcopy(pc->pc_ucred); + pc->pc_ucred->cr_uid = uid; + if (error == 0) { + (void)chgproccnt(pc->p_ruid, -1); + (void)chgproccnt(uid, 1); + pc->p_ruid = uid; + pc->p_svuid = uid; + } + p->p_flag |= P_SUGID; + return (0); +} diff --git a/sys/compat/osf1/osf1_resource.c b/sys/compat/osf1/osf1_resource.c new file mode 100644 index 00000000000..7285af7ee50 --- /dev/null +++ b/sys/compat/osf1/osf1_resource.c @@ -0,0 +1,171 @@ +/* $OpenBSD: osf1_resource.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_resource.c,v 1.1 1999/05/01 05:41:56 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/proc.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <sys/resource.h> +#include <sys/resourcevar.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_cvt.h> + +int +osf1_sys_getrlimit(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_getrlimit_args *uap = v; + struct sys_getrlimit_args a; + + switch (SCARG(uap, which)) { + case OSF1_RLIMIT_CPU: + SCARG(&a, which) = RLIMIT_CPU; + break; + case OSF1_RLIMIT_FSIZE: + SCARG(&a, which) = RLIMIT_FSIZE; + break; + case OSF1_RLIMIT_DATA: + SCARG(&a, which) = RLIMIT_DATA; + break; + case OSF1_RLIMIT_STACK: + SCARG(&a, which) = RLIMIT_STACK; + break; + case OSF1_RLIMIT_CORE: + SCARG(&a, which) = RLIMIT_CORE; + break; + case OSF1_RLIMIT_RSS: + SCARG(&a, which) = RLIMIT_RSS; + break; + case OSF1_RLIMIT_NOFILE: + SCARG(&a, which) = RLIMIT_NOFILE; + break; + case OSF1_RLIMIT_AS: /* unhandled */ + default: + return (EINVAL); + } + + /* XXX should translate */ + SCARG(&a, rlp) = SCARG(uap, rlp); + + return sys_getrlimit(p, &a, retval); +} + +int +osf1_sys_getrusage(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_getrusage_args *uap = v; + struct sys_getrusage_args a; + struct osf1_rusage osf1_rusage; + struct rusage netbsd_rusage; + caddr_t sg; + int error; + + switch (SCARG(uap, who)) { + case OSF1_RUSAGE_SELF: + SCARG(&a, who) = RUSAGE_SELF; + break; + + case OSF1_RUSAGE_CHILDREN: + SCARG(&a, who) = RUSAGE_CHILDREN; + break; + + case OSF1_RUSAGE_THREAD: /* XXX not supported */ + default: + return (EINVAL); + } + + sg = stackgap_init(p->p_emul); + SCARG(&a, rusage) = stackgap_alloc(&sg, sizeof netbsd_rusage); + + error = sys_getrusage(p, &a, retval); + if (error == 0) + error = copyin((caddr_t)SCARG(&a, rusage), + (caddr_t)&netbsd_rusage, sizeof netbsd_rusage); + if (error == 0) { + osf1_cvt_rusage_from_native(&netbsd_rusage, &osf1_rusage); + error = copyout((caddr_t)&osf1_rusage, + (caddr_t)SCARG(uap, rusage), sizeof osf1_rusage); + } + + return (error); +} + +int +osf1_sys_setrlimit(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_setrlimit_args *uap = v; + struct sys_setrlimit_args a; + + switch (SCARG(uap, which)) { + case OSF1_RLIMIT_CPU: + SCARG(&a, which) = RLIMIT_CPU; + break; + case OSF1_RLIMIT_FSIZE: + SCARG(&a, which) = RLIMIT_FSIZE; + break; + case OSF1_RLIMIT_DATA: + SCARG(&a, which) = RLIMIT_DATA; + break; + case OSF1_RLIMIT_STACK: + SCARG(&a, which) = RLIMIT_STACK; + break; + case OSF1_RLIMIT_CORE: + SCARG(&a, which) = RLIMIT_CORE; + break; + case OSF1_RLIMIT_RSS: + SCARG(&a, which) = RLIMIT_RSS; + break; + case OSF1_RLIMIT_NOFILE: + SCARG(&a, which) = RLIMIT_NOFILE; + break; + case OSF1_RLIMIT_AS: /* unhandled */ + default: + return (EINVAL); + } + + /* XXX should translate */ + SCARG(&a, rlp) = SCARG(uap, rlp); + + return sys_setrlimit(p, &a, retval); +} diff --git a/sys/compat/osf1/osf1_signal.c b/sys/compat/osf1/osf1_signal.c index 5e5b9e1a7f9..40165280f70 100644 --- a/sys/compat/osf1/osf1_signal.c +++ b/sys/compat/osf1/osf1_signal.c @@ -1,4 +1,35 @@ -/* $OpenBSD: osf1_signal.c,v 1.8 1998/12/23 16:23:47 millert Exp $ */ +/* $OpenBSD: osf1_signal.c,v 1.9 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_signal.c,v 1.15 1999/05/05 00:57:43 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ #include <sys/param.h> #include <sys/systm.h> @@ -14,213 +45,27 @@ #include <sys/syscallargs.h> +#include <compat/osf1/osf1.h> #include <compat/osf1/osf1_signal.h> #include <compat/osf1/osf1_syscallargs.h> #include <compat/osf1/osf1_util.h> +#include <compat/osf1/osf1_cvt.h> -static void bsd_to_osf1_sigaction __P((const struct sigaction *bsa, - struct osf1_sigaction *osa)); -static void osf1_to_bsd_sigaction __P((const struct osf1_sigaction *osa, - struct sigaction *bsa)); - -#define sigemptyset(s) bzero((s), sizeof(*(s))) -#define sigismember(s, n) (*(s) & sigmask(n)) -#define sigaddset(s, n) (*(s) |= sigmask(n)) - -#define osf1_sigmask(n) (1 << ((n) - 1)) -#define osf1_sigemptyset(s) bzero((s), sizeof(*(s))) -#define osf1_sigismember(s, n) (*(s) & sigmask(n)) -#define osf1_sigaddset(s, n) (*(s) |= sigmask(n)) - -int bsd_to_osf1_sig[] = { - 0, - OSF1_SIGHUP, - OSF1_SIGINT, - OSF1_SIGQUIT, - OSF1_SIGILL, - OSF1_SIGTRAP, - OSF1_SIGABRT, - OSF1_SIGEMT, - OSF1_SIGFPE, - OSF1_SIGKILL, - OSF1_SIGBUS, - OSF1_SIGSEGV, - OSF1_SIGSYS, - OSF1_SIGPIPE, - OSF1_SIGALRM, - OSF1_SIGTERM, - OSF1_SIGURG, - OSF1_SIGSTOP, - OSF1_SIGTSTP, - OSF1_SIGCONT, - OSF1_SIGCHLD, - OSF1_SIGTTIN, - OSF1_SIGTTOU, - OSF1_SIGIO, - OSF1_SIGXCPU, - OSF1_SIGXFSZ, - OSF1_SIGVTALRM, - OSF1_SIGPROF, - OSF1_SIGWINCH, - OSF1_SIGINFO, - OSF1_SIGUSR1, - OSF1_SIGUSR2, -}; - -int osf1_to_bsd_sig[] = { - 0, - SIGHUP, - SIGINT, - SIGQUIT, - SIGILL, - SIGTRAP, - SIGABRT, - SIGEMT, - SIGFPE, - SIGKILL, - SIGBUS, - SIGSEGV, - SIGSYS, - SIGPIPE, - SIGALRM, - SIGTERM, - SIGURG, - SIGSTOP, - SIGTSTP, - SIGCONT, - SIGCHLD, - SIGTTIN, - SIGTTOU, - SIGIO, - SIGXCPU, - SIGXFSZ, - SIGVTALRM, - SIGPROF, - SIGWINCH, - SIGINFO, - SIGUSR1, - SIGUSR2, -}; - -void -osf1_to_bsd_sigset(oss, bss) - const osf1_sigset_t *oss; - sigset_t *bss; -{ - int i, newsig; - - sigemptyset(bss); - for (i = 1; i < OSF1_NSIG; i++) { - if (osf1_sigismember(oss, i)) { - newsig = osf1_to_bsd_sig[i]; - if (newsig) - sigaddset(bss, newsig); - } - } -} - - -void -bsd_to_osf1_sigset(bss, oss) - const sigset_t *bss; - osf1_sigset_t *oss; -{ - int i, newsig; - - osf1_sigemptyset(oss); - for (i = 1; i < NSIG; i++) { - if (sigismember(bss, i)) { - newsig = bsd_to_osf1_sig[i]; - if (newsig) - osf1_sigaddset(oss, newsig); - } - } -} - -/* - * XXX: Only a subset of the flags is currently implemented. - */ -void -osf1_to_bsd_sigaction(osa, bsa) - const struct osf1_sigaction *osa; - struct sigaction *bsa; -{ - - bsa->sa_handler = osa->sa__handler; - osf1_to_bsd_sigset(&osa->sa_mask, &bsa->sa_mask); - bsa->sa_flags = 0; - if ((osa->sa_flags & OSF1_SA_ONSTACK) != 0) - bsa->sa_flags |= SA_ONSTACK; - if ((osa->sa_flags & OSF1_SA_RESTART) != 0) - bsa->sa_flags |= SA_RESTART; - if ((osa->sa_flags & OSF1_SA_RESETHAND) != 0) - bsa->sa_flags |= SA_RESETHAND; - if ((osa->sa_flags & OSF1_SA_NOCLDSTOP) != 0) - bsa->sa_flags |= SA_NOCLDSTOP; - if ((osa->sa_flags & OSF1_SA_NOCLDWAIT) != 0) - bsa->sa_flags |= SA_NOCLDWAIT; - if ((osa->sa_flags & OSF1_SA_NODEFER) != 0) - bsa->sa_flags |= SA_NODEFER; - if ((osa->sa_flags & OSF1_SA_SIGINFO) != 0) - bsa->sa_flags |= SA_SIGINFO; -} - -void -bsd_to_osf1_sigaction(bsa, osa) - const struct sigaction *bsa; - struct osf1_sigaction *osa; -{ - - osa->sa__handler = bsa->sa_handler; - bsd_to_osf1_sigset(&bsa->sa_mask, &osa->sa_mask); - osa->sa_flags = 0; - if ((bsa->sa_flags & SA_ONSTACK) != 0) - osa->sa_flags |= OSF1_SA_ONSTACK; - if ((bsa->sa_flags & SA_RESTART) != 0) - osa->sa_flags |= OSF1_SA_RESTART; - if ((bsa->sa_flags & SA_NOCLDSTOP) != 0) - osa->sa_flags |= OSF1_SA_NOCLDSTOP; - if ((bsa->sa_flags & SA_NOCLDWAIT) != 0) - osa->sa_flags |= OSF1_SA_NOCLDWAIT; - if ((bsa->sa_flags & SA_NODEFER) != 0) - osa->sa_flags |= OSF1_SA_NODEFER; - if ((bsa->sa_flags & SA_RESETHAND) != 0) - osa->sa_flags |= OSF1_SA_RESETHAND; - if ((bsa->sa_flags & SA_SIGINFO) != 0) - osa->sa_flags |= OSF1_SA_SIGINFO; -} - -void -osf1_to_bsd_sigaltstack(oss, bss) - const struct osf1_sigaltstack *oss; - struct sigaltstack *bss; -{ - - bss->ss_sp = oss->ss_sp; - bss->ss_size = oss->ss_size; - bss->ss_flags = 0; - - if ((oss->ss_flags & OSF1_SS_DISABLE) != 0) - bss->ss_flags |= SS_DISABLE; - if ((oss->ss_flags & OSF1_SS_ONSTACK) != 0) - bss->ss_flags |= SS_ONSTACK; -} - -void -bsd_to_osf1_sigaltstack(bss, oss) - const struct sigaltstack *bss; - struct osf1_sigaltstack *oss; +#if 0 +int +osf1_sys_kill(p, v, retval) + struct proc *p; + void *v; + register_t *retval; { + struct osf1_sys_kill_args *uap = v; + struct sys_kill_args ka; - oss->ss_sp = bss->ss_sp; - oss->ss_size = bss->ss_size; - oss->ss_flags = 0; - - if ((bss->ss_flags & SS_DISABLE) != 0) - oss->ss_flags |= OSF1_SS_DISABLE; - if ((bss->ss_flags & SS_ONSTACK) != 0) - oss->ss_flags |= OSF1_SS_ONSTACK; + SCARG(&ka, pid) = SCARG(uap, pid); + SCARG(&ka, signum) = osf1_signal_xlist[SCARG(uap, signum)]; + return sys_kill(p, &ka, retval); } +#endif int osf1_sys_sigaction(p, v, retval) @@ -228,20 +73,13 @@ osf1_sys_sigaction(p, v, retval) void *v; register_t *retval; { - struct osf1_sys_sigaction_args /* { - syscallarg(int) signum; - syscallarg(struct osf1_sigaction *) nsa; - syscallarg(struct osf1_sigaction *) osa; - } */ *uap = v; + struct osf1_sys_sigaction_args *uap = v; struct osf1_sigaction *nosa, *oosa, tmposa; struct sigaction *nbsa, *obsa, tmpbsa; struct sys_sigaction_args sa; caddr_t sg; int error; - if (SCARG(uap, signum) < 0 || SCARG(uap, signum) >= OSF1_NSIG) - return (EINVAL); - sg = stackgap_init(p->p_emul); nosa = SCARG(uap, nsa); oosa = SCARG(uap, osa); @@ -255,23 +93,24 @@ osf1_sys_sigaction(p, v, retval) nbsa = stackgap_alloc(&sg, sizeof(struct sigaction)); if ((error = copyin(nosa, &tmposa, sizeof(tmposa))) != 0) return error; - osf1_to_bsd_sigaction(&tmposa, &tmpbsa); + osf1_cvt_sigaction_to_native(&tmposa, &tmpbsa); if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0) return error; } else nbsa = NULL; - SCARG(&sa, signum) = osf1_to_bsd_sig[SCARG(uap, signum)]; + SCARG(&sa, signum) = osf1_signal_xlist[SCARG(uap, signum)]; SCARG(&sa, nsa) = nbsa; SCARG(&sa, osa) = obsa; + /* XXX */ if ((error = sys_sigaction(p, &sa, retval)) != 0) return error; if (oosa != NULL) { if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0) return error; - bsd_to_osf1_sigaction(&tmpbsa, &tmposa); + osf1_cvt_sigaction_from_native(&tmpbsa, &tmposa); if ((error = copyout(&tmposa, oosa, sizeof(tmposa))) != 0) return error; } @@ -281,14 +120,11 @@ osf1_sys_sigaction(p, v, retval) int osf1_sys_sigaltstack(p, v, retval) - register struct proc *p; + struct proc *p; void *v; register_t *retval; { - struct osf1_sys_sigaltstack_args /* { - syscallarg(struct osf1_sigaltstack *) nss; - syscallarg(struct osf1_sigaltstack *) oss; - } */ *uap = v; + struct osf1_sys_sigaltstack_args *uap = v; struct osf1_sigaltstack *noss, *ooss, tmposs; struct sigaltstack *nbss, *obss, tmpbss; struct sys_sigaltstack_args sa; @@ -308,7 +144,8 @@ osf1_sys_sigaltstack(p, v, retval) nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack)); if ((error = copyin(noss, &tmposs, sizeof(tmposs))) != 0) return error; - osf1_to_bsd_sigaltstack(&tmposs, &tmpbss); + if ((error = osf1_cvt_sigaltstack_to_native(&tmposs, &tmpbss)) != 0) + return error; if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0) return error; } else @@ -317,13 +154,14 @@ osf1_sys_sigaltstack(p, v, retval) SCARG(&sa, nss) = nbss; SCARG(&sa, oss) = obss; + /* XXX */ if ((error = sys_sigaltstack(p, &sa, retval)) != 0) return error; if (obss != NULL) { if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0) return error; - bsd_to_osf1_sigaltstack(&tmpbss, &tmposs); + osf1_cvt_sigaltstack_from_native(&tmpbss, &tmposs); if ((error = copyout(&tmposs, ooss, sizeof(tmposs))) != 0) return error; } @@ -334,24 +172,21 @@ osf1_sys_sigaltstack(p, v, retval) #if 0 int osf1_sys_signal(p, v, retval) - register struct proc *p; + struct proc *p; void *v; register_t *retval; { - struct osf1_sys_signal_args /* { - syscallarg(int) signum; - syscallarg(osf1_sig_t) handler; - } */ *uap = v; - int signum, error; + struct osf1_sys_signal_args *uap = v; + int signum = osf1_signal_xlist[OSF1_SIGNO(SCARG(uap, signum))]; + int error; caddr_t sg = stackgap_init(p->p_emul); - if (SCARG(uap, signum) < 0 || SCARG(uap, signum) >= OSF1_NSIG) + if (signum <= 0 || signum >= OSF1_NSIG) { if (OSF1_SIGCALL(SCARG(uap, signum)) == OSF1_SIGNAL_MASK || OSF1_SIGCALL(SCARG(uap, signum)) == OSF1_SIGDEFER_MASK) *retval = (int)OSF1_SIG_ERR; return EINVAL; } - int signum = osf1_to_bsd_sig[signum]; switch (OSF1_SIGCALL(SCARG(uap, signum))) { case OSF1_SIGDEFER_MASK: @@ -455,23 +290,35 @@ osf1_sys_signal(p, v, retval) } int +osf1_sys_sigpending(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_sigpending_args *uap = v; + sigset_t bss; + osf1_sigset_t oss; + + bss = p->p_siglist & p->p_sigmask; + osf1_cvt_sigset_from_native(&bss, &oss); + + return copyout(&oss, SCARG(uap, mask), sizeof(oss)); +} + +int osf1_sys_sigprocmask(p, v, retval) - register struct proc *p; + struct proc *p; void *v; register_t *retval; { - struct osf1_sys_sigprocmask_args /* { - syscallarg(int) how; - syscallarg(osf1_sigset_t *) set; - syscallarg(osf1_sigset_t *) oset; - } */ *uap = v; + struct osf1_sys_sigprocmask_args *uap = v; osf1_sigset_t oss; sigset_t bss; int error = 0; if (SCARG(uap, oset) != NULL) { /* Fix the return value first if needed */ - bsd_to_osf1_sigset(&p->p_sigmask, &oss); + osf1_cvt_sigset_from_native(&p->p_sigmask, &oss); if ((error = copyout(&oss, SCARG(uap, oset), sizeof(oss))) != 0) return error; } @@ -483,7 +330,7 @@ osf1_sys_sigprocmask(p, v, retval) if ((error = copyin(SCARG(uap, set), &oss, sizeof(oss))) != 0) return error; - osf1_to_bsd_sigset(&oss, &bss); + osf1_cvt_sigset_to_native(&oss, &bss); (void) splhigh(); @@ -511,32 +358,12 @@ osf1_sys_sigprocmask(p, v, retval) } int -osf1_sys_sigpending(p, v, retval) - register struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_sigpending_args /* { - syscallarg(osf1_sigset_t *) mask; - } */ *uap = v; - sigset_t bss; - osf1_sigset_t oss; - - bss = p->p_siglist & p->p_sigmask; - bsd_to_osf1_sigset(&bss, &oss); - - return copyout(&oss, SCARG(uap, mask), sizeof(oss)); -} - -int osf1_sys_sigsuspend(p, v, retval) - register struct proc *p; + struct proc *p; void *v; register_t *retval; { - struct osf1_sys_sigsuspend_args /* { - syscallarg(osf1_sigset_t *) ss; - } */ *uap = v; + struct osf1_sys_sigsuspend_args *uap = v; osf1_sigset_t oss; sigset_t bss; struct sys_sigsuspend_args sa; @@ -545,28 +372,9 @@ osf1_sys_sigsuspend(p, v, retval) if ((error = copyin(SCARG(uap, ss), &oss, sizeof(oss))) != 0) return error; - osf1_to_bsd_sigset(&oss, &bss); + osf1_cvt_sigset_to_native(&oss, &bss); SCARG(&sa, mask) = bss; return sys_sigsuspend(p, &sa, retval); } - -int -osf1_sys_kill(p, v, retval) - register struct proc *p; - void *v; - register_t *retval; -{ - struct osf1_sys_kill_args /* { - syscallarg(int) pid; - syscallarg(int) signum; - } */ *uap = v; - struct sys_kill_args ka; - - if (SCARG(uap, signum) < 0 || SCARG(uap, signum) >= OSF1_NSIG) - return (EINVAL); - SCARG(&ka, pid) = SCARG(uap, pid); - SCARG(&ka, signum) = osf1_to_bsd_sig[SCARG(uap, signum)]; - return sys_kill(p, &ka, retval); -} #endif diff --git a/sys/compat/osf1/osf1_signal.h b/sys/compat/osf1/osf1_signal.h index 08183d59579..a224df51cb6 100644 --- a/sys/compat/osf1/osf1_signal.h +++ b/sys/compat/osf1/osf1_signal.h @@ -1,4 +1,7 @@ -/* $OpenBSD: osf1_signal.h,v 1.3 1998/02/17 01:48:08 millert Exp $ */ +/* $OpenBSD: osf1_signal.h,v 1.4 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_signal.h,v 1.5 1999/05/01 02:57:11 cgd Exp $ */ + +/* XXX OUT OF DATE, some of the non-signal number bits here don't belong */ #ifndef _OSF1_SIGNAL_H #define _OSF1_SIGNAL_H @@ -45,38 +48,4 @@ #define OSF1_SIG_UNBLOCK 2 #define OSF1_SIG_SETMASK 3 -typedef u_long osf1_sigset_t; -typedef void (*osf1_handler_t) __P((int)); - -struct osf1_sigaction { - osf1_handler_t sa__handler; - osf1_sigset_t sa_mask; - int sa_flags; -}; - -struct osf1_sigaltstack { - caddr_t ss_sp; - int ss_flags; - size_t ss_size; -}; - -/* sa_flags */ -#define OSF1_SA_ONSTACK 0x00000001 -#define OSF1_SA_RESTART 0x00000002 -#define OSF1_SA_NOCLDSTOP 0x00000004 -#define OSF1_SA_NODEFER 0x00000008 -#define OSF1_SA_RESETHAND 0x00000010 -#define OSF1_SA_NOCLDWAIT 0x00000020 -#define OSF1_SA_SIGINFO 0x00000040 - -/* ss_flags */ -#define OSF1_SS_ONSTACK 0x00000001 -#define OSF1_SS_DISABLE 0x00000002 - -extern int osf1_to_bsd_sig[]; -void bsd_to_osf1_sigaltstack __P((const struct sigaltstack *, struct osf1_sigaltstack *)); -void bsd_to_osf1_sigset __P((const sigset_t *, osf1_sigset_t *)); -void osf1_to_bsd_sigaltstack __P((const struct osf1_sigaltstack *, struct sigaltstack *)); -void osf1_to_bsd_sigset __P((const osf1_sigset_t *, sigset_t *)); - #endif /* !_OSF1_SIGNAL_H */ diff --git a/sys/compat/osf1/osf1_socket.c b/sys/compat/osf1/osf1_socket.c new file mode 100644 index 00000000000..846ee8090ed --- /dev/null +++ b/sys/compat/osf1/osf1_socket.c @@ -0,0 +1,229 @@ +/* $OpenBSD: osf1_socket.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_socket.c,v 1.4 1999/05/10 01:58:37 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <sys/socketvar.h> +#include <sys/exec.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_util.h> +#include <compat/osf1/osf1_cvt.h> + +int +osf1_sys_recvmsg_xopen(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + + /* XXX */ + return (EINVAL); +} + +int +osf1_sys_sendmsg_xopen(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_sendmsg_xopen_args *uap = v; + struct sys_sendmsg_args a; + struct osf1_msghdr_xopen osf_msghdr; + struct osf1_iovec_xopen osf_iovec, *osf_iovec_ptr; + struct msghdr bsd_msghdr; + struct iovec bsd_iovec, *bsd_iovec_ptr; + unsigned long leftovers; + caddr_t sg; + unsigned int i; + int error; + + sg = stackgap_init(p->p_emul); + + SCARG(&a, s) = SCARG(uap, s); + + /* + * translate msghdr structure + */ + if ((error = copyin(SCARG(uap, msg), &osf_msghdr, + sizeof osf_msghdr)) != 0) + return (error); + + error = osf1_cvt_msghdr_xopen_to_native(&osf_msghdr, &bsd_msghdr); + if (error != 0) + return (error); + + if (STACKGAPLEN < (bsd_msghdr.msg_iovlen * sizeof (struct iovec) + + sizeof (struct msghdr))) +{ +printf("sendmsg space\n"); + return (EINVAL); +} + + SCARG(&a, msg) = stackgap_alloc(&sg, sizeof bsd_msghdr); + bsd_msghdr.msg_iov = stackgap_alloc(&sg, + bsd_msghdr.msg_iovlen * sizeof (struct iovec)); + + if ((error = copyout(&bsd_msghdr, (caddr_t)SCARG(&a, msg), + sizeof bsd_msghdr)) != 0) + return (error); + + osf_iovec_ptr = osf_msghdr.msg_iov; + bsd_iovec_ptr = bsd_msghdr.msg_iov; + for (i = 0; i < bsd_msghdr.msg_iovlen; i++) { + if ((error = copyin(&osf_iovec_ptr[i], &osf_iovec, + sizeof osf_iovec)) != 0) + return (error); + + bsd_iovec.iov_base = osf_iovec.iov_base; + bsd_iovec.iov_len = osf_iovec.iov_len; + + if ((error = copyout(&bsd_iovec, &bsd_iovec_ptr[i], + sizeof bsd_iovec)) != 0) + return (error); + } + + /* + * translate flags + */ + SCARG(&a, flags) = emul_flags_translate(osf1_sendrecv_msg_flags_xtab, + SCARG(uap, flags), &leftovers); + if (leftovers != 0) +{ +printf("sendmsg flags leftover: 0x%lx\n", leftovers); + return (EINVAL); +} + + return sys_sendmsg(p, &a, retval); +} + +int +osf1_sys_sendto(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_sendto_args *uap = v; + struct sys_sendto_args a; + unsigned long leftovers; + + SCARG(&a, s) = SCARG(uap, s); + SCARG(&a, buf) = SCARG(uap, buf); + SCARG(&a, len) = SCARG(uap, len); + SCARG(&a, to) = SCARG(uap, to); + SCARG(&a, tolen) = SCARG(uap, tolen); + + /* translate flags */ + SCARG(&a, flags) = emul_flags_translate(osf1_sendrecv_msg_flags_xtab, + SCARG(uap, flags), &leftovers); + if (leftovers != 0) + return (EINVAL); + + return sys_sendto(p, &a, retval); +} + +int +osf1_sys_socket(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_socket_args *uap = v; + struct sys_socket_args a; + + /* XXX TRANSLATE */ + + if (SCARG(uap, domain) > AF_LINK) + return (EINVAL); /* XXX After AF_LINK, divergence. */ + + SCARG(&a, domain) = SCARG(uap, domain); + SCARG(&a, type) = SCARG(uap, type); + SCARG(&a, protocol) = SCARG(uap, protocol); + + return sys_socket(p, &a, retval); +} + +int +osf1_sys_socketpair(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_socketpair_args *uap = v; + struct sys_socketpair_args a; + + /* XXX TRANSLATE */ + + if (SCARG(uap, domain) > AF_LINK) + return (EINVAL); /* XXX After AF_LINK, divergence. */ + + SCARG(&a, domain) = SCARG(uap, domain); + SCARG(&a, type) = SCARG(uap, type); + SCARG(&a, protocol) = SCARG(uap, protocol); + SCARG(&a, rsv) = SCARG(uap, rsv); + + return sys_socketpair(p, &a, retval); +} diff --git a/sys/compat/osf1/osf1_sysv_ipc.c b/sys/compat/osf1/osf1_sysv_ipc.c new file mode 100644 index 00000000000..ae9debabb48 --- /dev/null +++ b/sys/compat/osf1/osf1_sysv_ipc.c @@ -0,0 +1,88 @@ +/* $OpenBSD: osf1_sysv_ipc.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_sysv_ipc.c,v 1.1 1999/05/04 04:59:21 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_cvt.h> + +int +osf1_sys_shmat(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + + /* XXX */ + return (ENOSYS); +} + +int +osf1_sys_shmctl(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + + /* XXX */ + return (ENOSYS); +} + +int +osf1_sys_shmdt(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + + /* XXX */ + return (ENOSYS); +} + +int +osf1_sys_shmget(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + + /* XXX */ + return (ENOSYS); +} diff --git a/sys/compat/osf1/osf1_time.c b/sys/compat/osf1/osf1_time.c new file mode 100644 index 00000000000..813e4f2d8fd --- /dev/null +++ b/sys/compat/osf1/osf1_time.c @@ -0,0 +1,238 @@ +/* $NetBSD: osf1_time.c,v 1.1 1999/05/01 05:25:37 cgd Exp $ */ + +/* + * Copyright (c) 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou + * for the NetBSD Project. + * 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. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> + +#include <compat/osf1/osf1.h> +#include <compat/osf1/osf1_syscallargs.h> +#include <compat/osf1/osf1_cvt.h> + +int +osf1_sys_gettimeofday(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_gettimeofday_args *uap = v; + struct sys_gettimeofday_args a; + struct osf1_timeval otv; + struct osf1_timezone otz; + struct timeval tv; + struct timezone tz; + int error; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + if (SCARG(uap, tp) == NULL) + SCARG(&a, tp) = NULL; + else + SCARG(&a, tp) = stackgap_alloc(&sg, sizeof tv); + if (SCARG(uap, tzp) == NULL) + SCARG(&a, tzp) = NULL; + else + SCARG(&a, tzp) = stackgap_alloc(&sg, sizeof tz); + + error = sys_gettimeofday(p, &a, retval); + + if (error == 0 && SCARG(uap, tp) != NULL) { + error = copyin((caddr_t)SCARG(&a, tp), + (caddr_t)&tv, sizeof tv); + if (error == 0) { + memset(&otv, 0, sizeof otv); + otv.tv_sec = tv.tv_sec; + otv.tv_usec = tv.tv_usec; + + error = copyout((caddr_t)&otv, + (caddr_t)SCARG(uap, tp), sizeof otv); + } + } + if (error == 0 && SCARG(uap, tzp) != NULL) { + error = copyin((caddr_t)SCARG(&a, tzp), + (caddr_t)&tz, sizeof tz); + if (error == 0) { + memset(&otz, 0, sizeof otz); + otz.tz_minuteswest = tz.tz_minuteswest; + otz.tz_dsttime = tz.tz_dsttime; + + error = copyout((caddr_t)&otz, + (caddr_t)SCARG(uap, tzp), sizeof otz); + } + } + return (error); +} + +int +osf1_sys_setitimer(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_setitimer_args *uap = v; + struct sys_setitimer_args a; + struct osf1_itimerval o_itv, o_oitv; + struct itimerval b_itv, b_oitv; + caddr_t sg; + int error; + + switch (SCARG(uap, which)) { + case OSF1_ITIMER_REAL: + SCARG(&a, which) = ITIMER_REAL; + break; + + case OSF1_ITIMER_VIRTUAL: + SCARG(&a, which) = ITIMER_VIRTUAL; + break; + + case OSF1_ITIMER_PROF: + SCARG(&a, which) = ITIMER_PROF; + break; + + default: + return (EINVAL); + } + + sg = stackgap_init(p->p_emul); + + SCARG(&a, itv) = stackgap_alloc(&sg, sizeof b_itv); + + /* get the OSF/1 itimerval argument */ + error = copyin((caddr_t)SCARG(uap, itv), (caddr_t)&o_itv, + sizeof o_itv); + if (error == 0) { + + /* fill in and copy out the NetBSD timeval */ + memset(&b_itv, 0, sizeof b_itv); + b_itv.it_interval.tv_sec = o_itv.it_interval.tv_sec; + b_itv.it_interval.tv_usec = o_itv.it_interval.tv_usec; + b_itv.it_value.tv_sec = o_itv.it_value.tv_sec; + b_itv.it_value.tv_usec = o_itv.it_value.tv_usec; + + error = copyout((caddr_t)&b_itv, + (caddr_t)SCARG(&a, itv), sizeof b_itv); + } + + if (SCARG(uap, oitv) == NULL) + SCARG(&a, oitv) = NULL; + else + SCARG(&a, oitv) = stackgap_alloc(&sg, sizeof b_oitv); + + if (error == 0) + error = sys_setitimer(p, &a, retval); + + if (error == 0 && SCARG(uap, oitv) != NULL) { + /* get the NetBSD itimerval return value */ + error = copyin((caddr_t)SCARG(&a, oitv), (caddr_t)&b_oitv, + sizeof b_oitv); + if (error == 0) { + + /* fill in and copy out the NetBSD timeval */ + memset(&o_oitv, 0, sizeof o_oitv); + o_oitv.it_interval.tv_sec = b_oitv.it_interval.tv_sec; + o_oitv.it_interval.tv_usec = b_oitv.it_interval.tv_usec; + o_oitv.it_value.tv_sec = b_oitv.it_value.tv_sec; + o_oitv.it_value.tv_usec = b_oitv.it_value.tv_usec; + + error = copyout((caddr_t)&o_oitv, + (caddr_t)SCARG(uap, oitv), sizeof o_oitv); + } + } + + return (error); +} + +int +osf1_sys_settimeofday(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct osf1_sys_settimeofday_args *uap = v; + struct sys_settimeofday_args a; + struct osf1_timeval otv; + struct osf1_timezone otz; + struct timeval tv; + struct timezone tz; + int error; + caddr_t sg; + + sg = stackgap_init(p->p_emul); + if (SCARG(uap, tv) == NULL) + SCARG(&a, tv) = NULL; + else { + SCARG(&a, tv) = stackgap_alloc(&sg, sizeof tv); + + /* get the OSF/1 timeval argument */ + error = copyin((caddr_t)SCARG(uap, tv), + (caddr_t)&otv, sizeof otv); + if (error == 0) { + + /* fill in and copy out the NetBSD timeval */ + memset(&tv, 0, sizeof tv); + tv.tv_sec = otv.tv_sec; + tv.tv_usec = otv.tv_usec; + + error = copyout((caddr_t)&tv, + (caddr_t)SCARG(&a, tv), sizeof tv); + } + } + + if (SCARG(uap, tzp) == NULL) + SCARG(&a, tzp) = NULL; + else { + SCARG(&a, tzp) = stackgap_alloc(&sg, sizeof tz); + + /* get the OSF/1 timeval argument */ + error = copyin((caddr_t)SCARG(uap, tzp), + (caddr_t)&otz, sizeof otz); + if (error == 0) { + + /* fill in and copy out the NetBSD timezone */ + memset(&tz, 0, sizeof tz); + tz.tz_minuteswest = otz.tz_minuteswest; + tz.tz_dsttime = otz.tz_dsttime; + + error = copyout((caddr_t)&tz, + (caddr_t)SCARG(&a, tzp), sizeof tz); + } + } + + if (error == 0) + error = sys_settimeofday(p, &a, retval); + + return (error); +} diff --git a/sys/compat/osf1/osf1_util.h b/sys/compat/osf1/osf1_util.h index 87cc309774d..1470b8b7a25 100644 --- a/sys/compat/osf1/osf1_util.h +++ b/sys/compat/osf1/osf1_util.h @@ -1,3 +1,17 @@ -/* $OpenBSD: osf1_util.h,v 1.2 1996/08/02 20:35:29 niklas Exp $ */ +/* $OpenBSD: osf1_util.h,v 1.3 2000/08/04 15:47:55 ericj Exp $ */ +/* $NetBSD: osf1_util.h,v 1.4 1999/04/23 05:55:13 cgd Exp $ */ + +#ifndef _COMPAT_OSF1_OSF1_UTIL_H_ +#define _COMPAT_OSF1_OSF1_UTIL_H_ #include <compat/common/compat_util.h> + +extern const char osf1_emul_path[]; + +#define OSF1_CHECK_ALT_EXIST(p, sgp, path) \ + CHECK_ALT_EXIST(p, sgp, osf1_emul_path, path) + +#define OSF1_CHECK_ALT_CREAT(p, sgp, path) \ + CHECK_ALT_CREAT(p, sgp, osf1_emul_path, path) + +#endif /* _COMPAT_OSF1_OSF1_UTIL_H_ */ diff --git a/sys/compat/osf1/syscalls.conf b/sys/compat/osf1/syscalls.conf index aa6d4a59c92..51dfa388f60 100644 --- a/sys/compat/osf1/syscalls.conf +++ b/sys/compat/osf1/syscalls.conf @@ -1,5 +1,5 @@ -# $OpenBSD: syscalls.conf,v 1.2 1996/08/02 20:35:30 niklas Exp $ -# $NetBSD: syscalls.conf,v 1.1 1995/02/13 21:39:08 cgd Exp $ +# $OpenBSD: syscalls.conf,v 1.3 2000/08/04 15:47:55 ericj Exp $ +# $NetBSD: syscalls.conf,v 1.1 1994/08/21 19:27:06 cgd Exp $ sysnames="osf1_syscalls.c" sysnumhdr="osf1_syscall.h" diff --git a/sys/compat/osf1/syscalls.master b/sys/compat/osf1/syscalls.master index 3b10ea400bb..c91e636465b 100644 --- a/sys/compat/osf1/syscalls.master +++ b/sys/compat/osf1/syscalls.master @@ -1,9 +1,9 @@ -; $OpenBSD: syscalls.master,v 1.7 2000/07/21 19:26:39 ericj Exp $ -; $NetBSD: syscalls.master,v 1.2 1995/10/07 06:27:28 mycroft Exp $ + $OpenBSD: syscalls.master,v 1.8 2000/08/04 15:47:55 ericj Exp $ +; $NetBSD: syscalls.master,v 1.29 1999/05/10 03:33:04 cgd Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 -; OpenBSD COMPAT_OSF1 system call name/number "master" file. +; NetBSD COMPAT_OSF1 system call name/number "master" file. ; (See syscalls.conf to see what it is processed into.) ; ; Fields: number type [type-dependent ...] @@ -30,7 +30,7 @@ ; [comment] ; ; #ifdef's, etc. may be included, and are copied to the output files. -; #include's are copied to the syscall switch definition file only. +; #include's are copied to the syscall names and switch definition files only. #include <sys/param.h> #include <sys/systm.h> @@ -39,46 +39,52 @@ #include <sys/poll.h> #include <sys/syscallargs.h> +#include <compat/osf1/osf1.h> #include <compat/osf1/osf1_syscallargs.h> 0 NOARGS { int sys_nosys(void); } syscall 1 NOARGS { int sys_exit(int rval); } 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); } +4 NOARGS { int sys_write(int fd, const char *buf, \ + u_int nbyte); } 5 UNIMPL old open 6 NOARGS { int sys_close(int fd); } -7 NOARGS { int sys_wait4(int pid, int *status, int options, \ - struct rusage *rusage); } +7 STD { int osf1_sys_wait4(int pid, int *status, \ + int options, struct osf1_rusage *rusage); } 8 UNIMPL old creat -9 NOARGS { int sys_link(char *path, char *link); } -10 NOARGS { int sys_unlink(char *path); } +9 NOARGS { int sys_link(const char *path, const char *link); } +10 NOARGS { int sys_unlink(const char *path); } 11 UNIMPL execv -12 NOARGS { int sys_chdir(char *path); } +12 NOARGS { int sys_chdir(const char *path); } 13 NOARGS { int sys_fchdir(int fd); } -14 STD { int osf1_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); } +14 STD { int osf1_sys_mknod(char *path, int mode, \ + int dev); } +15 NOARGS { int sys_chmod(const char *path, int mode); } +16 NOARGS { int sys_chown(const char *path, int uid, \ + int gid); } 17 NOARGS { int sys_obreak(char *nsize); } 18 STD { int osf1_sys_getfsstat(struct osf1_statfs *buf, \ long bufsize, int flags); } 19 STD { off_t osf1_sys_lseek(int fd, off_t offset, \ int whence); } 20 NOARGS { pid_t sys_getpid(void); } -21 STD { int osf1_sys_mount(int type, char *path, int flags, \ - caddr_t data); } -22 STD { int osf1_sys_unmount(char *path, int flags); } +21 STD { int osf1_sys_mount(int type, const char *path, \ + int flags, caddr_t data); } +22 STD { int osf1_sys_unmount(const char *path, int flags); } 23 STD { int osf1_sys_setuid(uid_t uid); } 24 NOARGS { uid_t sys_getuid(void); } 25 UNIMPL exec_with_loader 26 UNIMPL ptrace -27 UNIMPL recvmsg -28 UNIMPL sendmsg +27 STD { int osf1_sys_recvmsg_xopen(int s, \ + struct osf1_msghdr_xopen *msg, int flags); } +28 STD { int osf1_sys_sendmsg_xopen(int s, \ + const struct osf1_msghdr_xopen *msg, int flags); } 29 UNIMPL recvfrom 30 UNIMPL accept 31 UNIMPL getpeername 32 UNIMPL getsockname -33 NOARGS { int sys_access(char *path, int flags); } +33 STD { int osf1_sys_access(char *path, int flags); } 34 UNIMPL chflags 35 UNIMPL fchflags 36 NOARGS { int sys_sync(void); } @@ -87,33 +93,41 @@ 39 NOARGS { int sys_setpgid(int pid, int pgid); } 40 UNIMPL old lstat 41 NOARGS { int sys_dup(u_int fd); } -42 NOARGS { int sys_opipe(void); } -43 UNIMPL set_program_attributes +42 NOARGS { int sys_pipe(void); } +43 STD { int osf1_sys_set_program_attributes( \ + caddr_t taddr, unsigned long tsize, \ + caddr_t daddr, unsigned long dsize); } 44 UNIMPL profil -45 STD { int osf1_sys_open(char *path, int flags, int mode); } +45 STD { int osf1_sys_open(char *path, int flags, \ + int mode); } 46 OBSOL sigaction 47 NOARGS { gid_t sys_getgid(void); } +; XXX 48 NOARGS { int sys_sigprocmask(int how, sigset_t mask); } 49 NOARGS { int sys_getlogin(char *namebuf, u_int namelen); } -50 NOARGS { int sys_setlogin(char *namebuf); } -51 NOARGS { int sys_acct(char *path); } +50 NOARGS { int sys_setlogin(const char *namebuf); } +51 NOARGS { int sys_acct(const char *path); } 52 UNIMPL sigpending -53 UNIMPL +53 STD { int osf1_sys_classcntl(int opcode, int arg1, \ + int arg2, int arg3); } 54 STD { int osf1_sys_ioctl(int fd, int com, caddr_t data); } 55 STD { int osf1_sys_reboot(int opt); } -56 NOARGS { int sys_revoke(char *path); } -57 NOARGS { int sys_symlink(char *path, char *link); } -58 NOARGS { int sys_readlink(char *path, char *buf, int count); } -59 STD { int osf1_sys_execve(char *path, char **argp, \ - char **envp); } +56 NOARGS { int sys_revoke(const char *path); } +57 NOARGS { int sys_symlink(const char *path, \ + const char *link); } +58 NOARGS { int sys_readlink(const char *path, char *buf, \ + int count); } +59 STD { int osf1_sys_execve(char *path, \ + char * const *argp, char * const *envp); } 60 NOARGS { int sys_umask(int newmask); } -61 NOARGS { int sys_chroot(char *path); } +61 NOARGS { int sys_chroot(const char *path); } 62 UNIMPL old fstat 63 NOARGS { int sys_getpgrp(void); } 64 NOARGS { int compat_43_sys_getpagesize(void); } 65 UNIMPL mremap 66 NOARGS { int sys_vfork(void); } -67 STD { int osf1_sys_stat(char *path, struct osf1_stat *ub); } +67 STD { int osf1_sys_stat(char *path, \ + struct osf1_stat *ub); } 68 STD { int osf1_sys_lstat(char *path, \ struct osf1_stat *ub); } 69 UNIMPL sbrk @@ -122,9 +136,10 @@ int prot, int flags, int fd, off_t pos); } 72 UNIMPL ovadvise 73 NOARGS { int sys_munmap(caddr_t addr, size_t len); } -74 UNIMPL mprotect -; XXX -75 STD { int osf1_sys_madvise(void); } +74 STD { int osf1_sys_mprotect(void *addr, size_t len, \ + int prot); } +75 STD { int osf1_sys_madvise(void *addr, size_t len, \ + int behav); } 76 UNIMPL old vhangup 77 UNIMPL kmodcall 78 UNIMPL mincore @@ -133,23 +148,25 @@ 81 UNIMPL old getpgrp ; OSF/1 setpgrp(); identical in function to setpgid(). XXX 82 NOARGS { int sys_setpgid(int pid, int pgid); } setpgrp -83 NOARGS { int sys_setitimer(u_int which, \ - struct itimerval *itv, struct itimerval *oitv); } +83 STD { int osf1_sys_setitimer(u_int which, \ + struct osf1_itimerval *itv, \ + struct osf1_itimerval *oitv); } 84 UNIMPL old wait 85 UNIMPL table 86 UNIMPL getitimer 87 NOARGS { int compat_43_sys_gethostname(char *hostname, \ u_int len); } -88 NOARGS { int compat_43_sys_sethostname(char *hostname, \ +88 NOARGS { int compat_43_sys_sethostname(const char *hostname, \ u_int len); } 89 NOARGS { int compat_43_sys_getdtablesize(void); } 90 NOARGS { int sys_dup2(u_int from, u_int to); } 91 STD { int osf1_sys_fstat(int fd, void *sb); } 92 STD { int osf1_sys_fcntl(int fd, int cmd, void *arg); } -93 NOARGS { int sys_select(u_int nd, fd_set *in, fd_set *ou, \ - fd_set *ex, struct timeval *tv); } -94 STD { int osf1_sys_poll(struct pollfd *fds, \ - unsigned int nfds, int timeout); } +93 STD { int osf1_sys_select(u_int nd, fd_set *in, \ + fd_set *ou, fd_set *ex, struct osf1_timeval *tv); } +; maybe XXX +94 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \ + int timeout); } 95 NOARGS { int sys_fsync(int fd); } 96 NOARGS { int sys_setpriority(int which, int who, int prio); } 97 STD { int osf1_sys_socket(int domain, int type, \ @@ -165,7 +182,7 @@ 103 NOARGS { int sys_sigreturn(struct sigcontext *sigcntxp); } 104 NOARGS { int sys_bind(int s, caddr_t name, int namelen); } 105 NOARGS { int sys_setsockopt(int s, int level, int name, \ - caddr_t val, int valsize); } + caddr_t val, int valsize); } 106 NOARGS { int sys_listen(int s, int backlog); } 107 UNIMPL plock 108 UNIMPL old sigvec @@ -176,20 +193,21 @@ struct sigstack *oss); } 113 UNIMPL old recvmsg 114 UNIMPL old sendmsg -115 UNIMPL vtrace -116 NOARGS { int sys_gettimeofday(struct timeval *tp, \ - struct timezone *tzp); } +115 OBSOL vtrace +116 STD { int osf1_sys_gettimeofday(struct osf1_timeval *tp, \ + struct osf1_timezone *tzp); } +117 STD { int osf1_sys_getrusage(int who, \ + struct osf1_rusage *rusage); } ; XXX -117 STD { int osf1_sys_getrusage(void); } 118 NOARGS { int sys_getsockopt(int s, int level, int name, \ - caddr_t val, int *avalsize); } + caddr_t val, int *avalsize); } 119 UNIMPL -120 STD { int osf1_sys_readv(int fd, struct osf1_iovec *iovp, \ - u_int iovcnt); } -121 STD { int osf1_sys_writev(int fd, struct osf1_iovec *iovp, \ - u_int iovcnt); } -122 NOARGS { int sys_settimeofday(struct timeval *tv, \ - struct timezone *tzp); } +120 STD { int osf1_sys_readv(int fd, \ + struct osf1_iovec *iovp, u_int iovcnt); } +121 STD { int osf1_sys_writev(int fd, \ + struct osf1_iovec *iovp, u_int iovcnt); } +122 STD { int osf1_sys_settimeofday(struct osf1_timeval *tv, \ + struct osf1_timezone *tzp); } 123 NOARGS { int sys_fchown(int fd, int uid, int gid); } 124 NOARGS { int sys_fchmod(int fd, int mode); } 125 NOARGS { int compat_43_sys_recvfrom(int s, caddr_t buf, \ @@ -197,54 +215,63 @@ int *fromlenaddr); } 126 UNIMPL setreuid 127 UNIMPL setregid -128 NOARGS { int sys_rename(char *from, char *to); } -129 STD { int osf1_sys_truncate(char *path, off_t length); } +128 NOARGS { int sys_rename(const char *from, \ + const char *to); } +129 STD { int osf1_sys_truncate(char *path, \ + off_t length); } 130 STD { int osf1_sys_ftruncate(int fd, off_t length); } 131 UNIMPL flock 132 STD { int osf1_sys_setgid(gid_t gid); } -133 STD { int osf1_sys_sendto(int s, const void *buf, \ - size_t len, int flags, const struct sockaddr *to, \ - int tolen); } +133 STD { int osf1_sys_sendto(int s, caddr_t buf, size_t len, \ + int flags, struct sockaddr *to, int tolen); } 134 NOARGS { int sys_shutdown(int s, int how); } -135 UNIMPL socketpair -136 NOARGS { int sys_mkdir(char *path, int mode); } -137 NOARGS { int sys_rmdir(char *path); } -138 NOARGS { int sys_utimes(char *path, struct timeval *tptr); } +135 STD { int osf1_sys_socketpair(int domain, int type, \ + int protocol, int *rsv); } +136 NOARGS { int sys_mkdir(const char *path, int mode); } +137 NOARGS { int sys_rmdir(const char *path); } +138 STD { int osf1_sys_utimes(char *path, \ + const struct osf1_timeval *tptr); } 139 OBSOL 4.2 sigreturn 140 UNIMPL adjtime -141 UNIMPL old getpeername +141 NOARGS { int compat_43_sys_getpeername(int fdes, \ + caddr_t asa, int *alen); } 142 NOARGS { int32_t compat_43_sys_gethostid(void); } 143 NOARGS { int compat_43_sys_sethostid(int32_t hostid); } +; XXX 144 STD { int osf1_sys_getrlimit(u_int which, \ struct rlimit *rlp); } +; XXX 145 STD { int osf1_sys_setrlimit(u_int which, \ struct rlimit *rlp); } 146 UNIMPL old killpg 147 NOARGS { int sys_setsid(void); } 148 UNIMPL quotactl 149 NOARGS { int compat_43_sys_quota(void); } -150 UNIMPL old getsockname -151 UNIMPL -152 UNIMPL -153 UNIMPL -154 UNIMPL -155 UNIMPL +150 NOARGS { int compat_43_sys_getsockname(int fdec, \ + caddr_t asa, int *alen); } +151 UNIMPL pread +152 UNIMPL pwrite +153 UNIMPL pid_block +154 UNIMPL pid_unblock +155 UNIMPL signal_urti 156 STD { int osf1_sys_sigaction(int signum, \ struct osf1_sigaction *nsa, \ struct osf1_sigaction *osa); } -157 UNIMPL +157 UNIMPL sigwaitprim 158 UNIMPL nfssvc 159 NOARGS { int compat_43_sys_getdirentries(int fd, char *buf, \ u_int count, long *basep); } -160 STD { int osf1_sys_statfs(char *path, \ +160 STD { int osf1_sys_statfs(const char *path, \ struct osf1_statfs *buf, int len); } -161 STD { int osf1_sys_fstatfs(int fd, \ +161 STD { int osf1_sys_fstatfs(int fd, \ struct osf1_statfs *buf, int len); } 162 UNIMPL 163 UNIMPL async_daemon 164 UNIMPL getfh -165 UNIMPL getdomainname -166 UNIMPL setdomainname +165 NOARGS { int compat_09_sys_getdomainname(char *domainname, \ + int len); } +166 NOARGS { int compat_09_sys_setdomainname(char *domainname, \ + int len); } 167 UNIMPL 168 UNIMPL 169 UNIMPL exportfs @@ -285,12 +312,16 @@ 204 UNIMPL semctl 205 UNIMPL semget 206 UNIMPL semop -207 UNIMPL uname -208 NOARGS { int sys_lchown(char *path, int uid, int gid); } -209 UNIMPL shmat -210 UNIMPL shmctl -211 UNIMPL shmdt -212 UNIMPL shmget +207 STD { int osf1_sys_uname(struct osf1_uname *name); } +208 NOARGS { int sys_lchown(const char *path, int uid, \ + int gid); } +209 STD { void *osf1_sys_shmat(int shmid, \ + const void *shmaddr, int shmflg); } +210 STD { int osf1_sys_shmctl(int shmid, int cmd, \ + struct osf1_shmid_ds *buf); } +211 STD { int osf1_sys_shmdt(const void *shmaddr); } +212 STD { int osf1_sys_shmget(osf1_key_t key, size_t size, \ + int flags); } 213 UNIMPL mvalid 214 UNIMPL getaddressconf 215 UNIMPL msleep @@ -312,33 +343,36 @@ 231 UNIMPL 232 UNIMPL 233 UNIMPL getpgid -234 STD { pid_t osf1_sys_getsid(pid_t pid); } -235 STD { int osf1_sys_sigaltstack(struct osf1_sigaltstack *nss, \ +234 NOARGS { pid_t sys_getsid(pid_t pid); } +235 STD { int osf1_sys_sigaltstack( \ + struct osf1_sigaltstack *nss, \ struct osf1_sigaltstack *oss); } 236 UNIMPL waitid 237 UNIMPL priocntlset 238 UNIMPL sigsendset -239 UNIMPL +239 UNIMPL set_speculative 240 UNIMPL msfs_syscall -241 UNIMPL sysinfo +241 STD { int osf1_sys_sysinfo(int cmd, char *buf, long len); } 242 UNIMPL uadmin 243 UNIMPL fuser -244 UNIMPL -245 UNIMPL -246 UNIMPL -247 UNIMPL -248 UNIMPL +244 UNIMPL proplist_syscall +245 UNIMPL ntp_adjtime +246 UNIMPL ntp_gettime +247 STD { long osf1_sys_pathconf(char *path, int name); } +248 STD { long osf1_sys_fpathconf(int fd, int name); } 249 UNIMPL 250 UNIMPL uswitch -251 STD { int osf1_sys_usleep_thread(struct timeval *sleep, \ - struct timeval *slept); } +251 STD { int osf1_sys_usleep_thread( \ + struct osf1_timeval *sleep, \ + struct osf1_timeval *slept); } 252 UNIMPL audcntl 253 UNIMPL audgen 254 UNIMPL sysfs -255 UNIMPL +255 UNIMPL subsys_info 256 UNIMPL getsysinfo 257 STD { int osf1_sys_setsysinfo(u_long op, caddr_t buffer, \ u_long nbytes, caddr_t arg, u_long flag); } 258 UNIMPL afs_syscall 259 UNIMPL swapctl 260 UNIMPL memcntl +261 UNIMPL fdatasync |