mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-22 09:43:47 +00:00
Emulator KLD for SysVR4 executables grabbed from NetBSD.
See http://www.freebsd.org/~newton/freebsd-svr4 for limitations, capabilities, history and TO-DO list.
This commit is contained in:
parent
bd56b99ac3
commit
f22dd58acc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43412
13
sys/compat/svr4/Makefile
Normal file
13
sys/compat/svr4/Makefile
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Makefile for syscall tables
|
||||||
|
#
|
||||||
|
# $Id: Makefile,v 1.3 1997/03/29 11:17:26 peter Exp $
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo "make svr4_sysent.c only"
|
||||||
|
|
||||||
|
svr4_sysent.c svr4_syscall.h svr4_proto.h: ../kern/makesyscalls.sh \
|
||||||
|
syscalls.master syscalls.conf
|
||||||
|
-mv -f svr4_sysent.c svr4_sysent.c.bak
|
||||||
|
-mv -f svr4_syscall.h svr4_syscall.h.bak
|
||||||
|
-mv -f svr4_proto.h svr4_proto.h.bak
|
||||||
|
sh ../kern/makesyscalls.sh syscalls.master syscalls.conf
|
237
sys/compat/svr4/imgact_svr4.c
Normal file
237
sys/compat/svr4/imgact_svr4.c
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994-1996 Søren Schmidt
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Based heavily on /sys/kern/imgact_aout.c which is:
|
||||||
|
* Copyright (c) 1993, David Greenman
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* in this position and unchanged.
|
||||||
|
* 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. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software withough 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/resourcevar.h>
|
||||||
|
#include <sys/exec.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/imgact.h>
|
||||||
|
#include <sys/imgact_aout.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/lock.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <vm/vm_kern.h>
|
||||||
|
#include <vm/vm_param.h>
|
||||||
|
#include <vm/pmap.h>
|
||||||
|
#include <vm/vm_map.h>
|
||||||
|
#include <vm/vm_prot.h>
|
||||||
|
#include <vm/vm_extern.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
|
||||||
|
static int exec_svr4_imgact __P((struct image_params *iparams));
|
||||||
|
|
||||||
|
static int
|
||||||
|
exec_svr4_imgact(imgp)
|
||||||
|
struct image_params *imgp;
|
||||||
|
{
|
||||||
|
const struct exec *a_out = (const struct exec *) imgp->image_header;
|
||||||
|
struct vmspace *vmspace;
|
||||||
|
vm_offset_t vmaddr;
|
||||||
|
unsigned long virtual_offset, file_offset;
|
||||||
|
vm_offset_t buffer;
|
||||||
|
unsigned long bss_size;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (((a_out->a_magic >> 16) & 0xff) != 0x64)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set file/virtual offset based on a.out variant.
|
||||||
|
*/
|
||||||
|
switch ((int)(a_out->a_magic & 0xffff)) {
|
||||||
|
case 0413:
|
||||||
|
virtual_offset = 0;
|
||||||
|
file_offset = 1024;
|
||||||
|
break;
|
||||||
|
case 0314:
|
||||||
|
virtual_offset = 4096;
|
||||||
|
file_offset = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
bss_size = round_page(a_out->a_bss);
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: text: %08x, data: %08x, bss: %08x\n", a_out->a_text, a_out->a_data, bss_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check various fields in header for validity/bounds.
|
||||||
|
*/
|
||||||
|
if (a_out->a_entry < virtual_offset ||
|
||||||
|
a_out->a_entry >= virtual_offset + a_out->a_text ||
|
||||||
|
a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
/* text + data can't exceed file size */
|
||||||
|
if (a_out->a_data + a_out->a_text > imgp->attr->va_size)
|
||||||
|
return (EFAULT);
|
||||||
|
/*
|
||||||
|
* text/data/bss must not exceed limits
|
||||||
|
*/
|
||||||
|
if (a_out->a_text > MAXTSIZ ||
|
||||||
|
a_out->a_data + bss_size > imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur)
|
||||||
|
return (ENOMEM);
|
||||||
|
|
||||||
|
/* copy in arguments and/or environment from old process */
|
||||||
|
error = exec_extract_strings(imgp);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy old process VM and create a new one (with a new stack)
|
||||||
|
*/
|
||||||
|
exec_new_vmspace(imgp);
|
||||||
|
vmspace = imgp->proc->p_vmspace;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if file_offset page aligned,.
|
||||||
|
* Currently we cannot handle misalinged file offsets,
|
||||||
|
* and so we read in the entire image (what a waste).
|
||||||
|
*/
|
||||||
|
if (file_offset & PAGE_MASK) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: Non page aligned binary %d\n", file_offset);
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Map text+data+bss read/write/execute
|
||||||
|
*/
|
||||||
|
vmaddr = virtual_offset;
|
||||||
|
error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr,
|
||||||
|
a_out->a_text + a_out->a_data + bss_size, FALSE,
|
||||||
|
VM_PROT_ALL, VM_PROT_ALL, 0);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = vm_mmap(kernel_map, &buffer,
|
||||||
|
round_page(a_out->a_text + a_out->a_data + file_offset),
|
||||||
|
VM_PROT_READ, VM_PROT_READ, 0,
|
||||||
|
(caddr_t) imgp->vp, trunc_page(file_offset));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = copyout((caddr_t)(buffer + file_offset), (caddr_t)vmaddr,
|
||||||
|
a_out->a_text + a_out->a_data);
|
||||||
|
|
||||||
|
vm_map_remove(kernel_map, buffer,
|
||||||
|
buffer + round_page(a_out->a_text + a_out->a_data + file_offset));
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* remove write enable on the 'text' part
|
||||||
|
*/
|
||||||
|
error = vm_map_protect(&vmspace->vm_map,
|
||||||
|
vmaddr,
|
||||||
|
vmaddr + a_out->a_text,
|
||||||
|
VM_PROT_EXECUTE|VM_PROT_READ,
|
||||||
|
TRUE);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: Page aligned binary %d\n", file_offset);
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Map text+data read/execute
|
||||||
|
*/
|
||||||
|
vmaddr = virtual_offset;
|
||||||
|
error = vm_mmap(&vmspace->vm_map, &vmaddr,
|
||||||
|
a_out->a_text + a_out->a_data,
|
||||||
|
VM_PROT_READ | VM_PROT_EXECUTE,
|
||||||
|
VM_PROT_ALL,
|
||||||
|
MAP_PRIVATE | MAP_FIXED,
|
||||||
|
(caddr_t)imgp->vp, file_offset);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: startaddr=%08x, length=%08x\n", vmaddr, a_out->a_text + a_out->a_data);
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* allow read/write of data
|
||||||
|
*/
|
||||||
|
error = vm_map_protect(&vmspace->vm_map,
|
||||||
|
vmaddr + a_out->a_text,
|
||||||
|
vmaddr + a_out->a_text + a_out->a_data,
|
||||||
|
VM_PROT_ALL,
|
||||||
|
FALSE);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate anon demand-zeroed area for uninitialized data
|
||||||
|
*/
|
||||||
|
if (bss_size != 0) {
|
||||||
|
vmaddr = virtual_offset + a_out->a_text + a_out->a_data;
|
||||||
|
error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr,
|
||||||
|
bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: bssaddr=%08x, length=%08x\n", vmaddr, bss_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Indicate that this file should not be modified */
|
||||||
|
imgp->vp->v_flag |= VTEXT;
|
||||||
|
}
|
||||||
|
/* Fill in process VM information */
|
||||||
|
vmspace->vm_tsize = round_page(a_out->a_text) >> PAGE_SHIFT;
|
||||||
|
vmspace->vm_dsize = round_page(a_out->a_data + bss_size) >> PAGE_SHIFT;
|
||||||
|
vmspace->vm_taddr = (caddr_t)virtual_offset;
|
||||||
|
vmspace->vm_daddr = (caddr_t)virtual_offset + a_out->a_text;
|
||||||
|
|
||||||
|
/* Fill in image_params */
|
||||||
|
imgp->interpreted = 0;
|
||||||
|
imgp->entry_addr = a_out->a_entry;
|
||||||
|
|
||||||
|
imgp->proc->p_sysent = &svr4_sysvec;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tell kern_execve.c about it, with a little help from the linker.
|
||||||
|
* Since `const' objects end up in the text segment, TEXT_SET is the
|
||||||
|
* correct directive to use. Do not staticize; used by Linux LKM.
|
||||||
|
*/
|
||||||
|
const struct execsw svr4_execsw = { exec_svr4_imgact, "svr4 ELF" };
|
||||||
|
TEXT_SET(execsw_set, svr4_execsw);
|
||||||
|
|
38
sys/compat/svr4/svr4.h
Normal file
38
sys/compat/svr4/svr4.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* 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. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(_SVR4_H)
|
||||||
|
#define _SVR4_H
|
||||||
|
|
||||||
|
extern struct sysentvec svr4_sysvec;
|
||||||
|
|
||||||
|
#define memset(x,y,z) bzero(x,z)
|
||||||
|
|
||||||
|
#define COMPAT_SVR4_SOLARIS2
|
||||||
|
#define KTRACE
|
||||||
|
|
||||||
|
#endif
|
44
sys/compat/svr4/svr4_acl.h
Normal file
44
sys/compat/svr4/svr4_acl.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1996 Christos Zoulas.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#ifndef _SVR4_ACL_H_
|
||||||
|
#define _SVR4_ACL_H_
|
||||||
|
|
||||||
|
typedef struct svr4_aclent {
|
||||||
|
int a_type;
|
||||||
|
svr4_uid_t a_id;
|
||||||
|
svr4_o_mode_t a_perm;
|
||||||
|
} svr4_aclent_t;
|
||||||
|
|
||||||
|
#define SVR4_SYS_GETACL 1
|
||||||
|
#define SVR4_SYS_SETACL 2
|
||||||
|
#define SVR4_SYS_GETACLCNT 3
|
||||||
|
|
||||||
|
#endif /* !_SVR4_ACL_H_ */
|
51
sys/compat/svr4/svr4_dirent.h
Normal file
51
sys/compat/svr4/svr4_dirent.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_DIRENT_H_
|
||||||
|
#define _SVR4_DIRENT_H_
|
||||||
|
|
||||||
|
#define SVR4_MAXNAMLEN 512
|
||||||
|
|
||||||
|
struct svr4_dirent {
|
||||||
|
svr4_ino_t d_ino;
|
||||||
|
svr4_off_t d_off;
|
||||||
|
u_short d_reclen;
|
||||||
|
char d_name[SVR4_MAXNAMLEN + 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_dirent64 {
|
||||||
|
svr4_ino64_t d_ino;
|
||||||
|
svr4_off64_t d_off;
|
||||||
|
u_short d_reclen;
|
||||||
|
char d_name[SVR4_MAXNAMLEN + 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp)
|
||||||
|
#define SVR4_RECLEN(de,namlen) ALIGN((SVR4_NAMEOFF(de) + (namlen) + 1))
|
||||||
|
|
||||||
|
#endif /* !_SVR4_DIRENT_H_ */
|
170
sys/compat/svr4/svr4_errno.h
Normal file
170
sys/compat/svr4/svr4_errno.h
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_ERRNO_H_
|
||||||
|
#define _SVR4_ERRNO_H_
|
||||||
|
|
||||||
|
#define SVR4_EPERM 1
|
||||||
|
#define SVR4_ENOENT 2
|
||||||
|
#define SVR4_ESRCH 3
|
||||||
|
#define SVR4_EINTR 4
|
||||||
|
#define SVR4_EIO 5
|
||||||
|
#define SVR4_ENXIO 6
|
||||||
|
#define SVR4_E2BIG 7
|
||||||
|
#define SVR4_ENOEXEC 8
|
||||||
|
#define SVR4_EBADF 9
|
||||||
|
#define SVR4_ECHILD 10
|
||||||
|
#define SVR4_EAGAIN 11
|
||||||
|
#define SVR4_ENOMEM 12
|
||||||
|
#define SVR4_EACCES 13
|
||||||
|
#define SVR4_EFAULT 14
|
||||||
|
#define SVR4_ENOTBLK 15
|
||||||
|
#define SVR4_EBUSY 16
|
||||||
|
#define SVR4_EEXIST 17
|
||||||
|
#define SVR4_EXDEV 18
|
||||||
|
#define SVR4_ENODEV 19
|
||||||
|
#define SVR4_ENOTDIR 20
|
||||||
|
#define SVR4_EISDIR 21
|
||||||
|
#define SVR4_EINVAL 22
|
||||||
|
#define SVR4_ENFILE 23
|
||||||
|
#define SVR4_EMFILE 24
|
||||||
|
#define SVR4_ENOTTY 25
|
||||||
|
#define SVR4_ETXTBSY 26
|
||||||
|
#define SVR4_EFBIG 27
|
||||||
|
#define SVR4_ENOSPC 28
|
||||||
|
#define SVR4_ESPIPE 29
|
||||||
|
#define SVR4_EROFS 30
|
||||||
|
#define SVR4_EMLINK 31
|
||||||
|
#define SVR4_EPIPE 32
|
||||||
|
#define SVR4_EDOM 33
|
||||||
|
#define SVR4_ERANGE 34
|
||||||
|
#define SVR4_ENOMSG 35
|
||||||
|
#define SVR4_EIDRM 36
|
||||||
|
#define SVR4_ECHRNG 37
|
||||||
|
#define SVR4_EL2NSYNC 38
|
||||||
|
#define SVR4_EL3HLT 39
|
||||||
|
#define SVR4_EL3RST 40
|
||||||
|
#define SVR4_ELNRNG 41
|
||||||
|
#define SVR4_EUNATCH 42
|
||||||
|
#define SVR4_ENOCSI 43
|
||||||
|
#define SVR4_EL2HLT 44
|
||||||
|
#define SVR4_EDEADLK 45
|
||||||
|
#define SVR4_ENOLCK 46
|
||||||
|
#define SVR4_EBADE 50
|
||||||
|
#define SVR4_EBADR 51
|
||||||
|
#define SVR4_EXFULL 52
|
||||||
|
#define SVR4_ENOANO 53
|
||||||
|
#define SVR4_EBADRQC 54
|
||||||
|
#define SVR4_EBADSLT 55
|
||||||
|
#define SVR4_EDEADLOCK 56
|
||||||
|
#define SVR4_EBFONT 57
|
||||||
|
#define SVR4_ENOSTR 60
|
||||||
|
#define SVR4_ENODATA 61
|
||||||
|
#define SVR4_ETIME 62
|
||||||
|
#define SVR4_ENOSR 63
|
||||||
|
#define SVR4_ENONET 64
|
||||||
|
#define SVR4_ENOPKG 65
|
||||||
|
#define SVR4_EREMOTE 66
|
||||||
|
#define SVR4_ENOLINK 67
|
||||||
|
#define SVR4_EADV 68
|
||||||
|
#define SVR4_ESRMNT 69
|
||||||
|
#define SVR4_ECOMM 70
|
||||||
|
#define SVR4_EPROTO 71
|
||||||
|
#define SVR4_EMULTIHOP 74
|
||||||
|
#define SVR4_EBADMSG 77
|
||||||
|
#define SVR4_ENAMETOOLONG 78
|
||||||
|
#define SVR4_EOVERFLOW 79
|
||||||
|
#define SVR4_ENOTUNIQ 80
|
||||||
|
#define SVR4_EBADFD 81
|
||||||
|
#define SVR4_EREMCHG 82
|
||||||
|
#define SVR4_ELIBACC 83
|
||||||
|
#define SVR4_ELIBBAD 84
|
||||||
|
#define SVR4_ELIBSCN 85
|
||||||
|
#define SVR4_ELIBMAX 86
|
||||||
|
#define SVR4_ELIBEXEC 87
|
||||||
|
#define SVR4_EILSEQ 88
|
||||||
|
#define SVR4_ENOSYS 89
|
||||||
|
#define SVR4_ELOOP 90
|
||||||
|
#define SVR4_ERESTART 91
|
||||||
|
#define SVR4_ESTRPIPE 92
|
||||||
|
#define SVR4_ENOTEMPTY 93
|
||||||
|
#define SVR4_EUSERS 94
|
||||||
|
#define SVR4_ENOTSOCK 95
|
||||||
|
#define SVR4_EDESTADDRREQ 96
|
||||||
|
#define SVR4_EMSGSIZE 97
|
||||||
|
#define SVR4_EPROTOTYPE 98
|
||||||
|
#define SVR4_ENOPROTOOPT 99
|
||||||
|
#define SVR4_EPROTONOSUPPORT 120
|
||||||
|
#define SVR4_ESOCKTNOSUPPORT 121
|
||||||
|
#define SVR4_EOPNOTSUPP 122
|
||||||
|
#define SVR4_EPFNOSUPPORT 123
|
||||||
|
#define SVR4_EAFNOSUPPORT 124
|
||||||
|
#define SVR4_EADDRINUSE 125
|
||||||
|
#define SVR4_EADDRNOTAVAIL 126
|
||||||
|
#define SVR4_ENETDOWN 127
|
||||||
|
#define SVR4_ENETUNREACH 128
|
||||||
|
#define SVR4_ENETRESET 129
|
||||||
|
#define SVR4_ECONNABORTED 130
|
||||||
|
#define SVR4_ECONNRESET 131
|
||||||
|
#define SVR4_ENOBUFS 132
|
||||||
|
#define SVR4_EISCONN 133
|
||||||
|
#define SVR4_ENOTCONN 134
|
||||||
|
#define SVR4_EUCLEAN 135
|
||||||
|
#define SVR4_ENOTNAM 137
|
||||||
|
#define SVR4_ENAVAIL 138
|
||||||
|
#define SVR4_EISNAM 139
|
||||||
|
#define SVR4_EREMOTEIO 140
|
||||||
|
#define SVR4_EINIT 141
|
||||||
|
#define SVR4_EREMDEV 142
|
||||||
|
#define SVR4_ESHUTDOWN 143
|
||||||
|
#define SVR4_ETOOMANYREFS 144
|
||||||
|
#define SVR4_ETIMEDOUT 145
|
||||||
|
#define SVR4_ECONNREFUSED 146
|
||||||
|
#define SVR4_EHOSTDOWN 147
|
||||||
|
#define SVR4_EHOSTUNREACH 148
|
||||||
|
#define SVR4_EWOULDBLOCK SVR4_EAGAIN
|
||||||
|
#define SVR4_EALREADY 149
|
||||||
|
#define SVR4_EINPROGRESS 150
|
||||||
|
#define SVR4_ESTALE 151
|
||||||
|
#define SVR4_EIORESID 500
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These ones are not translated...
|
||||||
|
*/
|
||||||
|
#define SVR4_EPROCLIM SVR4_ENOSYS
|
||||||
|
#define SVR4_EDQUOT SVR4_ENOSYS
|
||||||
|
#define SVR4_EBADRPC SVR4_ENOSYS
|
||||||
|
#define SVR4_ERPCMISMATCH SVR4_ENOSYS
|
||||||
|
#define SVR4_EPROGUNAVAIL SVR4_ENOSYS
|
||||||
|
#define SVR4_EPROGMISMATCH SVR4_ENOSYS
|
||||||
|
#define SVR4_EPROCUNAVAIL SVR4_ENOSYS
|
||||||
|
#define SVR4_EFTYPE SVR4_ENOSYS
|
||||||
|
#define SVR4_EAUTH SVR4_ENOSYS
|
||||||
|
#define SVR4_ENEEDAUTH SVR4_ENOSYS
|
||||||
|
|
||||||
|
#endif /* !_SVR4_ERRNO_H_ */
|
68
sys/compat/svr4/svr4_exec.h
Normal file
68
sys/compat/svr4/svr4_exec.h
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_EXEC_H_
|
||||||
|
#define _SVR4_EXEC_H_
|
||||||
|
|
||||||
|
#ifdef SVR4_COMPAT_SOLARIS2
|
||||||
|
# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 12 / sizeof(char *))
|
||||||
|
#else
|
||||||
|
# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 8 / sizeof(char *))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Don't think we need all this NetBSD stuff */
|
||||||
|
/*
|
||||||
|
* The following is horrible; there must be a better way. I need to
|
||||||
|
* play with brk(2) a bit more.
|
||||||
|
*/
|
||||||
|
#ifdef i386
|
||||||
|
/*
|
||||||
|
* I cannot load the interpreter after the data segment because brk(2)
|
||||||
|
* breaks. I have to load it somewhere before. Programs start at
|
||||||
|
* 0x08000000 so I load the interpreter far before.
|
||||||
|
*/
|
||||||
|
#define SVR4_INTERP_ADDR 0x01000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef sparc
|
||||||
|
/*
|
||||||
|
* Here programs load at 0x00010000, so I load the interpreter far after
|
||||||
|
* the end of the data segment.
|
||||||
|
*/
|
||||||
|
#define SVR4_INTERP_ADDR 0x10000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SVR4_INTERP_ADDR
|
||||||
|
# define SVR4_INTERP_ADDR 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*void svr4_setregs __P((struct proc *, struct exec_package *, u_long));*/
|
||||||
|
|
||||||
|
#endif /* !_SVR4_EXEC_H_ */
|
721
sys/compat/svr4/svr4_fcntl.c
Normal file
721
sys/compat/svr4/svr4_fcntl.c
Normal file
|
@ -0,0 +1,721 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994, 1997 Christos Zoulas.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#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/ioctl.h>*/
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_fcntl.h>
|
||||||
|
|
||||||
|
static int svr4_to_bsd_flags __P((int));
|
||||||
|
static u_long svr4_to_bsd_cmd __P((u_long));
|
||||||
|
static int fd_revoke __P((struct proc *, int));
|
||||||
|
static int fd_truncate __P((struct proc *, int, struct flock *));
|
||||||
|
static int bsd_to_svr4_flags __P((int));
|
||||||
|
static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *));
|
||||||
|
static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *));
|
||||||
|
static void bsd_to_svr4_flock64 __P((struct flock *, struct svr4_flock64 *));
|
||||||
|
static void svr4_to_bsd_flock64 __P((struct svr4_flock64 *, struct flock *));
|
||||||
|
|
||||||
|
static u_long
|
||||||
|
svr4_to_bsd_cmd(cmd)
|
||||||
|
u_long cmd;
|
||||||
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_F_DUPFD:
|
||||||
|
return F_DUPFD;
|
||||||
|
case SVR4_F_GETFD:
|
||||||
|
return F_GETFD;
|
||||||
|
case SVR4_F_SETFD:
|
||||||
|
return F_SETFD;
|
||||||
|
case SVR4_F_GETFL:
|
||||||
|
return F_GETFL;
|
||||||
|
case SVR4_F_SETFL:
|
||||||
|
return F_SETFL;
|
||||||
|
case SVR4_F_GETLK:
|
||||||
|
return F_GETLK;
|
||||||
|
case SVR4_F_SETLK:
|
||||||
|
return F_SETLK;
|
||||||
|
case SVR4_F_SETLKW:
|
||||||
|
return F_SETLKW;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_to_bsd_flags(l)
|
||||||
|
int l;
|
||||||
|
{
|
||||||
|
int r = 0;
|
||||||
|
r |= (l & SVR4_O_RDONLY) ? O_RDONLY : 0;
|
||||||
|
r |= (l & SVR4_O_WRONLY) ? O_WRONLY : 0;
|
||||||
|
r |= (l & SVR4_O_RDWR) ? O_RDWR : 0;
|
||||||
|
r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0;
|
||||||
|
r |= (l & SVR4_O_APPEND) ? O_APPEND : 0;
|
||||||
|
r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0;
|
||||||
|
r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0;
|
||||||
|
r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0;
|
||||||
|
r |= (l & SVR4_O_CREAT) ? O_CREAT : 0;
|
||||||
|
r |= (l & SVR4_O_TRUNC) ? O_TRUNC : 0;
|
||||||
|
r |= (l & SVR4_O_EXCL) ? O_EXCL : 0;
|
||||||
|
r |= (l & SVR4_O_NOCTTY) ? O_NOCTTY : 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bsd_to_svr4_flags(l)
|
||||||
|
int l;
|
||||||
|
{
|
||||||
|
int r = 0;
|
||||||
|
r |= (l & O_RDONLY) ? SVR4_O_RDONLY : 0;
|
||||||
|
r |= (l & O_WRONLY) ? SVR4_O_WRONLY : 0;
|
||||||
|
r |= (l & O_RDWR) ? SVR4_O_RDWR : 0;
|
||||||
|
r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0;
|
||||||
|
r |= (l & O_APPEND) ? SVR4_O_APPEND : 0;
|
||||||
|
r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0;
|
||||||
|
r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0;
|
||||||
|
r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0;
|
||||||
|
r |= (l & O_CREAT) ? SVR4_O_CREAT : 0;
|
||||||
|
r |= (l & O_TRUNC) ? SVR4_O_TRUNC : 0;
|
||||||
|
r |= (l & O_EXCL) ? SVR4_O_EXCL : 0;
|
||||||
|
r |= (l & O_NOCTTY) ? SVR4_O_NOCTTY : 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_flock(iflp, oflp)
|
||||||
|
struct flock *iflp;
|
||||||
|
struct svr4_flock *oflp;
|
||||||
|
{
|
||||||
|
switch (iflp->l_type) {
|
||||||
|
case F_RDLCK:
|
||||||
|
oflp->l_type = SVR4_F_RDLCK;
|
||||||
|
break;
|
||||||
|
case F_WRLCK:
|
||||||
|
oflp->l_type = SVR4_F_WRLCK;
|
||||||
|
break;
|
||||||
|
case F_UNLCK:
|
||||||
|
oflp->l_type = SVR4_F_UNLCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oflp->l_type = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oflp->l_whence = (short) iflp->l_whence;
|
||||||
|
oflp->l_start = (svr4_off_t) iflp->l_start;
|
||||||
|
oflp->l_len = (svr4_off_t) iflp->l_len;
|
||||||
|
oflp->l_sysid = 0;
|
||||||
|
oflp->l_pid = (svr4_pid_t) iflp->l_pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_flock(iflp, oflp)
|
||||||
|
struct svr4_flock *iflp;
|
||||||
|
struct flock *oflp;
|
||||||
|
{
|
||||||
|
switch (iflp->l_type) {
|
||||||
|
case SVR4_F_RDLCK:
|
||||||
|
oflp->l_type = F_RDLCK;
|
||||||
|
break;
|
||||||
|
case SVR4_F_WRLCK:
|
||||||
|
oflp->l_type = F_WRLCK;
|
||||||
|
break;
|
||||||
|
case SVR4_F_UNLCK:
|
||||||
|
oflp->l_type = F_UNLCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oflp->l_type = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oflp->l_whence = iflp->l_whence;
|
||||||
|
oflp->l_start = (off_t) iflp->l_start;
|
||||||
|
oflp->l_len = (off_t) iflp->l_len;
|
||||||
|
oflp->l_pid = (pid_t) iflp->l_pid;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_flock64(iflp, oflp)
|
||||||
|
struct flock *iflp;
|
||||||
|
struct svr4_flock64 *oflp;
|
||||||
|
{
|
||||||
|
switch (iflp->l_type) {
|
||||||
|
case F_RDLCK:
|
||||||
|
oflp->l_type = SVR4_F_RDLCK;
|
||||||
|
break;
|
||||||
|
case F_WRLCK:
|
||||||
|
oflp->l_type = SVR4_F_WRLCK;
|
||||||
|
break;
|
||||||
|
case F_UNLCK:
|
||||||
|
oflp->l_type = SVR4_F_UNLCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oflp->l_type = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oflp->l_whence = (short) iflp->l_whence;
|
||||||
|
oflp->l_start = (svr4_off64_t) iflp->l_start;
|
||||||
|
oflp->l_len = (svr4_off64_t) iflp->l_len;
|
||||||
|
oflp->l_sysid = 0;
|
||||||
|
oflp->l_pid = (svr4_pid_t) iflp->l_pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_flock64(iflp, oflp)
|
||||||
|
struct svr4_flock64 *iflp;
|
||||||
|
struct flock *oflp;
|
||||||
|
{
|
||||||
|
switch (iflp->l_type) {
|
||||||
|
case SVR4_F_RDLCK:
|
||||||
|
oflp->l_type = F_RDLCK;
|
||||||
|
break;
|
||||||
|
case SVR4_F_WRLCK:
|
||||||
|
oflp->l_type = F_WRLCK;
|
||||||
|
break;
|
||||||
|
case SVR4_F_UNLCK:
|
||||||
|
oflp->l_type = F_UNLCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oflp->l_type = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oflp->l_whence = iflp->l_whence;
|
||||||
|
oflp->l_start = (off_t) iflp->l_start;
|
||||||
|
oflp->l_len = (off_t) iflp->l_len;
|
||||||
|
oflp->l_pid = (pid_t) iflp->l_pid;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
fd_revoke(p, fd)
|
||||||
|
struct proc *p;
|
||||||
|
int fd;
|
||||||
|
{
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
struct file *fp;
|
||||||
|
struct vnode *vp;
|
||||||
|
struct vattr vattr;
|
||||||
|
int error, *retval;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
|
||||||
|
return EBADF;
|
||||||
|
|
||||||
|
switch (fp->f_type) {
|
||||||
|
case DTYPE_VNODE:
|
||||||
|
vp = (struct vnode *) fp->f_data;
|
||||||
|
|
||||||
|
case DTYPE_SOCKET:
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
default:
|
||||||
|
panic("svr4_fcntl(F_REVOKE)");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
||||||
|
error = EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (p->p_ucred->cr_uid != vattr.va_uid &&
|
||||||
|
(error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (vp->v_usecount > 1 || (vp->v_flag & VALIASED))
|
||||||
|
VOP_REVOKE(vp, REVOKEALL);
|
||||||
|
out:
|
||||||
|
vrele(vp);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
fd_truncate(p, fd, flp)
|
||||||
|
struct proc *p;
|
||||||
|
int fd;
|
||||||
|
struct flock *flp;
|
||||||
|
{
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
struct file *fp;
|
||||||
|
off_t start, length;
|
||||||
|
struct vnode *vp;
|
||||||
|
struct vattr vattr;
|
||||||
|
int error, *retval;
|
||||||
|
struct ftruncate_args ft;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We only support truncating the file.
|
||||||
|
*/
|
||||||
|
if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
|
||||||
|
return EBADF;
|
||||||
|
|
||||||
|
vp = (struct vnode *)fp->f_data;
|
||||||
|
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO)
|
||||||
|
return ESPIPE;
|
||||||
|
|
||||||
|
if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
length = vattr.va_size;
|
||||||
|
|
||||||
|
switch (flp->l_whence) {
|
||||||
|
case SEEK_CUR:
|
||||||
|
start = fp->f_offset + flp->l_start;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SEEK_END:
|
||||||
|
start = flp->l_start + length;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SEEK_SET:
|
||||||
|
start = flp->l_start;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start + flp->l_len < length) {
|
||||||
|
/* We don't support free'ing in the middle of the file */
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCARG(&ft, fd) = fd;
|
||||||
|
SCARG(&ft, length) = start;
|
||||||
|
|
||||||
|
return ftruncate(p, &ft);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_open(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_open_args *uap;
|
||||||
|
{
|
||||||
|
int error, retval;
|
||||||
|
struct open_args cup;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
(&cup)->path = uap->path;
|
||||||
|
(&cup)->flags = svr4_to_bsd_flags(uap->flags);
|
||||||
|
(&cup)->mode = uap->mode;
|
||||||
|
error = open(p, &cup);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
/* uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path,
|
||||||
|
uap->flags, uap->mode, error);*/
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = p->p_retval[0];
|
||||||
|
|
||||||
|
if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) &&
|
||||||
|
!(p->p_flag & P_CONTROLT)) {
|
||||||
|
#if defined(NOTYET)
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
struct file *fp = fdp->fd_ofiles[retval];
|
||||||
|
|
||||||
|
/* ignore any error, just give it a try */
|
||||||
|
if (fp->f_type == DTYPE_VNODE)
|
||||||
|
(fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, (caddr_t) 0, p);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_open64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_open64_args *uap;
|
||||||
|
{
|
||||||
|
return svr4_sys_open(p, (struct svr4_sys_open_args *)uap);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_creat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_creat_args *uap;
|
||||||
|
{
|
||||||
|
struct open_args cup;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, mode) = SCARG(uap, mode);
|
||||||
|
SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC;
|
||||||
|
|
||||||
|
return open(p, &cup);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_creat64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_creat64_args *uap;
|
||||||
|
{
|
||||||
|
return svr4_sys_creat(p, (struct svr4_sys_creat_args *)uap);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_llseek(p, v)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_llseek_args *v;
|
||||||
|
{
|
||||||
|
struct svr4_sys_llseek_args *uap = v;
|
||||||
|
struct lseek_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, fd) = SCARG(uap, fd);
|
||||||
|
|
||||||
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
|
SCARG(&ap, offset) = (((long long) SCARG(uap, offset1)) << 32) |
|
||||||
|
SCARG(uap, offset2);
|
||||||
|
#else
|
||||||
|
SCARG(&ap, offset) = (((long long) SCARG(uap, offset2)) << 32) |
|
||||||
|
SCARG(uap, offset1);
|
||||||
|
#endif
|
||||||
|
SCARG(&ap, whence) = SCARG(uap, whence);
|
||||||
|
|
||||||
|
return lseek(p, &ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_access(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_access_args *uap;
|
||||||
|
{
|
||||||
|
struct access_args cup;
|
||||||
|
int *retval;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, flags) = SCARG(uap, flags);
|
||||||
|
|
||||||
|
return access(p, &cup);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int
|
||||||
|
svr4_sys_pread(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_pread_args *uap;
|
||||||
|
{
|
||||||
|
struct pread_args pra;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just translate the args structure and call the NetBSD
|
||||||
|
* pread(2) system call (offset type is 64-bit in NetBSD).
|
||||||
|
*/
|
||||||
|
SCARG(&pra, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&pra, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&pra, nbyte) = SCARG(uap, nbyte);
|
||||||
|
SCARG(&pra, offset) = SCARG(uap, off);
|
||||||
|
|
||||||
|
return pread(p, &pra);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int
|
||||||
|
svr4_sys_pread64(p, v, retval)
|
||||||
|
register struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
|
||||||
|
struct svr4_sys_pread64_args *uap = v;
|
||||||
|
struct sys_pread_args pra;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just translate the args structure and call the NetBSD
|
||||||
|
* pread(2) system call (offset type is 64-bit in NetBSD).
|
||||||
|
*/
|
||||||
|
SCARG(&pra, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&pra, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&pra, nbyte) = SCARG(uap, nbyte);
|
||||||
|
SCARG(&pra, offset) = SCARG(uap, off);
|
||||||
|
|
||||||
|
return (sys_pread(p, &pra, retval));
|
||||||
|
}
|
||||||
|
#endif /* NOTYET */
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int
|
||||||
|
svr4_sys_pwrite(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_pwrite_args *uap;
|
||||||
|
{
|
||||||
|
struct pwrite_args pwa;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just translate the args structure and call the NetBSD
|
||||||
|
* pwrite(2) system call (offset type is 64-bit in NetBSD).
|
||||||
|
*/
|
||||||
|
SCARG(&pwa, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&pwa, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
|
||||||
|
SCARG(&pwa, offset) = SCARG(uap, off);
|
||||||
|
|
||||||
|
return pwrite(p, &pwa);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int
|
||||||
|
svr4_sys_pwrite64(p, v, retval)
|
||||||
|
register struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_pwrite64_args *uap = v;
|
||||||
|
struct sys_pwrite_args pwa;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just translate the args structure and call the NetBSD
|
||||||
|
* pwrite(2) system call (offset type is 64-bit in NetBSD).
|
||||||
|
*/
|
||||||
|
SCARG(&pwa, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&pwa, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
|
||||||
|
SCARG(&pwa, offset) = SCARG(uap, off);
|
||||||
|
|
||||||
|
return (sys_pwrite(p, &pwa, retval));
|
||||||
|
}
|
||||||
|
#endif /* NOTYET */
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fcntl(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fcntl_args *uap;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
struct fcntl_args fa;
|
||||||
|
int *retval;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(&fa, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd));
|
||||||
|
|
||||||
|
switch (SCARG(&fa, cmd)) {
|
||||||
|
case F_DUPFD:
|
||||||
|
case F_GETFD:
|
||||||
|
case F_SETFD:
|
||||||
|
SCARG(&fa, arg) = (long) SCARG(uap, arg);
|
||||||
|
return fcntl(p, &fa);
|
||||||
|
|
||||||
|
case F_GETFL:
|
||||||
|
SCARG(&fa, arg) = (long) SCARG(uap, arg);
|
||||||
|
error = fcntl(p, &fa);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
*retval = bsd_to_svr4_flags(*retval);
|
||||||
|
return error;
|
||||||
|
|
||||||
|
case F_SETFL:
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* we must save the O_ASYNC flag, as that is
|
||||||
|
* handled by ioctl(_, I_SETSIG, _) emulation.
|
||||||
|
*/
|
||||||
|
long cmd;
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
DPRINTF(("Setting flags 0x%x\n", SCARG(uap, arg)));
|
||||||
|
cmd = SCARG(&fa, cmd); /* save it for a while */
|
||||||
|
|
||||||
|
SCARG(&fa, cmd) = F_GETFL;
|
||||||
|
if ((error = fcntl(p, &fa)) != 0)
|
||||||
|
return error;
|
||||||
|
flags = *retval;
|
||||||
|
flags &= O_ASYNC;
|
||||||
|
flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg));
|
||||||
|
SCARG(&fa, cmd) = cmd;
|
||||||
|
SCARG(&fa, arg) = (long) flags;
|
||||||
|
return fcntl(p, &fa);
|
||||||
|
}
|
||||||
|
|
||||||
|
case F_GETLK:
|
||||||
|
case F_SETLK:
|
||||||
|
case F_SETLKW:
|
||||||
|
{
|
||||||
|
struct svr4_flock ifl;
|
||||||
|
struct flock *flp, fl;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
flp = stackgap_alloc(&sg, sizeof(struct flock));
|
||||||
|
SCARG(&fa, arg) = (long) flp;
|
||||||
|
|
||||||
|
error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_to_bsd_flock(&ifl, &fl);
|
||||||
|
|
||||||
|
error = copyout(&fl, flp, sizeof fl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = fcntl(p, &fa);
|
||||||
|
if (error || SCARG(&fa, cmd) != F_GETLK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = copyin(flp, &fl, sizeof fl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_flock(&fl, &ifl);
|
||||||
|
|
||||||
|
return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
|
||||||
|
}
|
||||||
|
case -1:
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_F_DUP2FD:
|
||||||
|
{
|
||||||
|
struct dup2_args du;
|
||||||
|
|
||||||
|
SCARG(&du, from) = SCARG(uap, fd);
|
||||||
|
SCARG(&du, to) = (int)SCARG(uap, arg);
|
||||||
|
error = dup2(p, &du);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
*retval = SCARG(&du, to);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_F_FREESP:
|
||||||
|
{
|
||||||
|
struct svr4_flock ifl;
|
||||||
|
struct flock fl;
|
||||||
|
|
||||||
|
error = copyin(SCARG(uap, arg), &ifl,
|
||||||
|
sizeof ifl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_flock(&ifl, &fl);
|
||||||
|
return fd_truncate(p, SCARG(uap, fd), &fl);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_F_GETLK64:
|
||||||
|
case SVR4_F_SETLK64:
|
||||||
|
case SVR4_F_SETLKW64:
|
||||||
|
{
|
||||||
|
struct svr4_flock64 ifl;
|
||||||
|
struct flock *flp, fl;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
flp = stackgap_alloc(&sg, sizeof(struct flock));
|
||||||
|
SCARG(&fa, arg) = (long) flp;
|
||||||
|
|
||||||
|
error = copyin(SCARG(uap, arg), &ifl,
|
||||||
|
sizeof ifl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_to_bsd_flock64(&ifl, &fl);
|
||||||
|
|
||||||
|
error = copyout(&fl, flp, sizeof fl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = fcntl(p, &fa);
|
||||||
|
if (error || SCARG(&fa, cmd) != F_GETLK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = copyin(flp, &fl, sizeof fl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_flock64(&fl, &ifl);
|
||||||
|
|
||||||
|
return copyout(&ifl, SCARG(uap, arg),
|
||||||
|
sizeof ifl);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_F_FREESP64:
|
||||||
|
{
|
||||||
|
struct svr4_flock64 ifl;
|
||||||
|
struct flock fl;
|
||||||
|
|
||||||
|
error = copyin(SCARG(uap, arg), &ifl,
|
||||||
|
sizeof ifl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_flock64(&ifl, &fl);
|
||||||
|
return fd_truncate(p, SCARG(uap, fd), &fl);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_F_REVOKE:
|
||||||
|
return fd_revoke(p, SCARG(uap, fd));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
}
|
132
sys/compat/svr4/svr4_fcntl.h
Normal file
132
sys/compat/svr4/svr4_fcntl.h
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_FCNTL_H_
|
||||||
|
#define _SVR4_FCNTL_H_
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
|
||||||
|
#define SVR4_O_RDONLY 0x0000
|
||||||
|
#define SVR4_O_WRONLY 0x0001
|
||||||
|
#define SVR4_O_RDWR 0x0002
|
||||||
|
#define SVR4_O_ACCMODE 0x0003
|
||||||
|
#define SVR4_O_NDELAY 0x0004
|
||||||
|
#define SVR4_O_APPEND 0x0008
|
||||||
|
#define SVR4_O_SYNC 0x0010
|
||||||
|
#define SVR4_O_NONBLOCK 0x0080
|
||||||
|
#define SVR4_O_CREAT 0x0100
|
||||||
|
#define SVR4_O_TRUNC 0x0200
|
||||||
|
#define SVR4_O_EXCL 0x0400
|
||||||
|
#define SVR4_O_NOCTTY 0x0800
|
||||||
|
#define SVR4_O_PRIV 0x1000
|
||||||
|
|
||||||
|
|
||||||
|
#define SVR4_FD_CLOEXEC 1
|
||||||
|
|
||||||
|
#define SVR4_F_DUPFD 0
|
||||||
|
#define SVR4_F_GETFD 1
|
||||||
|
#define SVR4_F_SETFD 2
|
||||||
|
#define SVR4_F_GETFL 3
|
||||||
|
#define SVR4_F_SETFL 4
|
||||||
|
#define SVR4_F_GETLK_SVR3 5
|
||||||
|
#define SVR4_F_SETLK 6
|
||||||
|
#define SVR4_F_SETLKW 7
|
||||||
|
#define SVR4_F_CHKFL 8
|
||||||
|
#define SVR4_F_DUP2FD 9
|
||||||
|
#define SVR4_F_ALLOCSP 10
|
||||||
|
#define SVR4_F_FREESP 11
|
||||||
|
|
||||||
|
#define SVR4_F_ISSTREAM 13
|
||||||
|
#define SVR4_F_GETLK 14
|
||||||
|
#define SVR4_F_PRIV 15
|
||||||
|
#define SVR4_F_NPRIV 16
|
||||||
|
#define SVR4_F_QUOTACTL 17
|
||||||
|
#define SVR4_F_BLOCKS 18
|
||||||
|
#define SVR4_F_BLKSIZE 19
|
||||||
|
#define SVR4_F_RSETLK 20
|
||||||
|
#define SVR4_F_RGETLK 21
|
||||||
|
#define SVR4_F_RSETLKW 22
|
||||||
|
#define SVR4_F_GETOWN 23
|
||||||
|
#define SVR4_F_SETOWN 24
|
||||||
|
#define SVR4_F_REVOKE 25
|
||||||
|
#define SVR4_F_HASREMOTELOCKS 26
|
||||||
|
#define SVR4_F_FREESP64 27
|
||||||
|
|
||||||
|
#define SVR4_F_GETLK64 33
|
||||||
|
#define SVR4_F_SETLK64 34
|
||||||
|
#define SVR4_F_SETLKW64 35
|
||||||
|
|
||||||
|
#define SVR4_F_SHARE 40
|
||||||
|
#define SVR4_F_UNSHARE 41
|
||||||
|
|
||||||
|
#define SVR4_F_CHSIZE_XENIX 0x6000
|
||||||
|
#define SVR4_F_RDCHK_XENIX 0x6001
|
||||||
|
#define SVR4_F_LK_UNLCK_XENIX 0x6300
|
||||||
|
#define SVR4_F_LK_LOCK_XENIX 0x7200
|
||||||
|
#define SVR4_F_LK_NBLCK_XENIX 0x6200
|
||||||
|
#define SVR4_F_LK_RLCK_XENIX 0x7100
|
||||||
|
#define SVR4_F_LK_NBRLCK_XENIX 0x6100
|
||||||
|
|
||||||
|
#define SVR4_LK_CMDTYPE(x) (((x) >> 12) & 0x7)
|
||||||
|
#define SVR4_LK_LCKTYPE(x) (((x) >> 8) & 0x7)
|
||||||
|
|
||||||
|
#define SVR4_F_RDLCK 1
|
||||||
|
#define SVR4_F_WRLCK 2
|
||||||
|
#define SVR4_F_UNLCK 3
|
||||||
|
|
||||||
|
struct svr4_flock_svr3 {
|
||||||
|
short l_type;
|
||||||
|
short l_whence;
|
||||||
|
svr4_off_t l_start;
|
||||||
|
svr4_off_t l_len;
|
||||||
|
short l_sysid;
|
||||||
|
svr4_o_pid_t l_pid;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct svr4_flock {
|
||||||
|
short l_type;
|
||||||
|
short l_whence;
|
||||||
|
svr4_off_t l_start;
|
||||||
|
svr4_off_t l_len;
|
||||||
|
long l_sysid;
|
||||||
|
svr4_pid_t l_pid;
|
||||||
|
long pad[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_flock64 {
|
||||||
|
short l_type;
|
||||||
|
short l_whence;
|
||||||
|
svr4_off64_t l_start;
|
||||||
|
svr4_off64_t l_len;
|
||||||
|
long l_sysid;
|
||||||
|
svr4_pid_t l_pid;
|
||||||
|
long pad[4];
|
||||||
|
};
|
||||||
|
#endif /* !_SVR4_FCNTL_H_ */
|
245
sys/compat/svr4/svr4_filio.c
Normal file
245
sys/compat/svr4/svr4_filio.c
Normal file
|
@ -0,0 +1,245 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filio.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/tty.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/socketvar.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_ioctl.h>
|
||||||
|
#include <svr4/svr4_filio.h>
|
||||||
|
|
||||||
|
/*#define GROTTY_READ_HACK*/
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_poll(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_poll_args *uap;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
struct poll_args pa;
|
||||||
|
struct pollfd *pfd;
|
||||||
|
int idx = 0, cerr;
|
||||||
|
u_long siz;
|
||||||
|
|
||||||
|
SCARG(&pa, fds) = SCARG(uap, fds);
|
||||||
|
SCARG(&pa, nfds) = SCARG(uap, nfds);
|
||||||
|
SCARG(&pa, timeout) = SCARG(uap, timeout);
|
||||||
|
|
||||||
|
siz = SCARG(uap, nfds) * sizeof(struct pollfd);
|
||||||
|
pfd = (struct pollfd *)malloc(siz, M_TEMP, M_WAITOK);
|
||||||
|
|
||||||
|
error = poll(p, (struct poll_args *)uap);
|
||||||
|
|
||||||
|
if ((cerr = copyin(SCARG(uap, fds), pfd, siz)) != 0) {
|
||||||
|
error = cerr;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx = 0; idx < SCARG(uap, nfds); idx++) {
|
||||||
|
/* POLLWRNORM already equals POLLOUT, so we don't worry about that */
|
||||||
|
if (pfd[idx].revents & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI))
|
||||||
|
pfd[idx].revents |= (POLLIN | POLLRDBAND | POLLRDNORM | POLLPRI);
|
||||||
|
if (pfd[idx].revents & (POLLOUT | POLLWRNORM | POLLWRBAND))
|
||||||
|
pfd[idx].revents |= (POLLOUT | POLLWRNORM | POLLWRBAND);
|
||||||
|
pfd[idx].revents &= POLLSTANDARD; /* don't want to surprise SysV */
|
||||||
|
|
||||||
|
DPRINTF(("pollfd[%d]->fd = %d\n", idx, pfd[idx].fd));
|
||||||
|
DPRINTF(("pollfd[%d]->events = %x\n", idx, pfd[idx].events));
|
||||||
|
DPRINTF(("pollfd[%d]->revents = %x\n", idx, pfd[idx].revents));
|
||||||
|
}
|
||||||
|
DPRINTF(("poll(%x, %x, %d) = %d\n", SCARG(uap, fds), SCARG(uap, nfds),
|
||||||
|
SCARG(uap, timeout), p->p_retval[0]));
|
||||||
|
if ((cerr = copyout(pfd, SCARG(uap, fds), siz)) != 0) {
|
||||||
|
error = cerr;
|
||||||
|
goto done; /* yeah, I know it's the next line, but this way I won't
|
||||||
|
forget to update it if I add more code */
|
||||||
|
}
|
||||||
|
done:
|
||||||
|
free(pfd, M_TEMP);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(READ_TEST)
|
||||||
|
int
|
||||||
|
svr4_sys_read(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_read_args *uap;
|
||||||
|
{
|
||||||
|
struct read_args ra;
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
struct file *fp;
|
||||||
|
struct socket *so = NULL;
|
||||||
|
int so_state;
|
||||||
|
sigset_t sigmask;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
SCARG(&ra, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&ra, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&ra, nbyte) = SCARG(uap, nbyte);
|
||||||
|
|
||||||
|
if ((fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) {
|
||||||
|
DPRINTF(("Something fishy with the user-supplied file descriptor...\n"));
|
||||||
|
return EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fp->f_type == DTYPE_SOCKET) {
|
||||||
|
so = (struct socket *)fp->f_data;
|
||||||
|
DPRINTF(("fd %d is a socket\n", SCARG(uap, fd)));
|
||||||
|
if (so->so_state & SS_ASYNC) {
|
||||||
|
DPRINTF(("fd %d is an ASYNC socket!\n", SCARG(uap, fd)));
|
||||||
|
}
|
||||||
|
DPRINTF(("Here are its flags: 0x%x\n", so->so_state));
|
||||||
|
#if defined(GROTTY_READ_HACK)
|
||||||
|
so_state = so->so_state;
|
||||||
|
so->so_state &= ~SS_NBIO;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = read(p, &ra);
|
||||||
|
|
||||||
|
DPRINTF(("svr4_read(%d, 0x%0x, %d) = %d\n",
|
||||||
|
SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv));
|
||||||
|
if (rv == EAGAIN) {
|
||||||
|
DPRINTF(("sigmask = 0x%x\n", p->p_sigmask));
|
||||||
|
DPRINTF(("sigignore = 0x%x\n", p->p_sigignore));
|
||||||
|
DPRINTF(("sigcaught = 0x%x\n", p->p_sigcatch));
|
||||||
|
DPRINTF(("siglist = 0x%x\n", p->p_siglist));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(GROTTY_READ_HACK)
|
||||||
|
if (so) { /* We've already checked to see if this is a socket */
|
||||||
|
so->so_state = so_state;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(rv);
|
||||||
|
}
|
||||||
|
#endif /* READ_TEST */
|
||||||
|
|
||||||
|
#if defined(BOGUS)
|
||||||
|
int
|
||||||
|
svr4_sys_write(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_write_args *uap;
|
||||||
|
{
|
||||||
|
struct write_args wa;
|
||||||
|
struct filedesc *fdp;
|
||||||
|
struct file *fp;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
SCARG(&wa, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&wa, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&wa, nbyte) = SCARG(uap, nbyte);
|
||||||
|
|
||||||
|
rv = write(p, &wa);
|
||||||
|
|
||||||
|
DPRINTF(("svr4_write(%d, 0x%0x, %d) = %d\n",
|
||||||
|
SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv));
|
||||||
|
|
||||||
|
return(rv);
|
||||||
|
}
|
||||||
|
#endif /* BOGUS */
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_fil_ioctl(fp, p, retval, fd, cmd, data)
|
||||||
|
struct file *fp;
|
||||||
|
struct proc *p;
|
||||||
|
register_t *retval;
|
||||||
|
int fd;
|
||||||
|
u_long cmd;
|
||||||
|
caddr_t data;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
int num;
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
|
||||||
|
fp->f_ops->fo_ioctl;
|
||||||
|
|
||||||
|
*retval = 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_FIOCLEX:
|
||||||
|
fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SVR4_FIONCLEX:
|
||||||
|
fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SVR4_FIOGETOWN:
|
||||||
|
case SVR4_FIOSETOWN:
|
||||||
|
case SVR4_FIOASYNC:
|
||||||
|
case SVR4_FIONBIO:
|
||||||
|
case SVR4_FIONREAD:
|
||||||
|
if ((error = copyin(data, &num, sizeof(num))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_FIOGETOWN: cmd = FIOGETOWN; break;
|
||||||
|
case SVR4_FIOSETOWN: cmd = FIOSETOWN; break;
|
||||||
|
case SVR4_FIOASYNC: cmd = FIOASYNC; break;
|
||||||
|
case SVR4_FIONBIO: cmd = FIONBIO; break;
|
||||||
|
case SVR4_FIONREAD: cmd = FIONREAD; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SVR4_DEBUG
|
||||||
|
if (cmd == FIOASYNC) DPRINTF(("FIOASYNC\n"));
|
||||||
|
#endif
|
||||||
|
error = (*ctl)(fp, cmd, (caddr_t) &num, p);
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return copyout(&num, data, sizeof(num));
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Unknown svr4 filio %lx\n", cmd));
|
||||||
|
return 0; /* ENOSYS really */
|
||||||
|
}
|
||||||
|
}
|
43
sys/compat/svr4/svr4_filio.h
Normal file
43
sys/compat/svr4/svr4_filio.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_FILIO_H_
|
||||||
|
#define _SVR4_FILIO_H_
|
||||||
|
|
||||||
|
#define SVR4_FIOC ('f' << 8)
|
||||||
|
|
||||||
|
#define SVR4_FIOCLEX SVR4_IO('f', 1)
|
||||||
|
#define SVR4_FIONCLEX SVR4_IO('f', 2)
|
||||||
|
|
||||||
|
#define SVR4_FIOGETOWN SVR4_IOR('f', 123, int)
|
||||||
|
#define SVR4_FIOSETOWN SVR4_IOW('f', 124, int)
|
||||||
|
#define SVR4_FIOASYNC SVR4_IOW('f', 125, int)
|
||||||
|
#define SVR4_FIONBIO SVR4_IOW('f', 126, int)
|
||||||
|
#define SVR4_FIONREAD SVR4_IOR('f', 127, int)
|
||||||
|
|
||||||
|
#endif /* !_SVR4_FILIO_H_ */
|
96
sys/compat/svr4/svr4_fuser.h
Normal file
96
sys/compat/svr4/svr4_fuser.h
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Derived from:
|
||||||
|
* $NetBSD: svr4_fuser.h,v 1.4 1998/09/04 19:54:38 christos Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Original Copyright:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Christos Zoulas.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions of this code have been derived from code contributed to the
|
||||||
|
* FreeBSD Project by Mark Newton.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mark Newton
|
||||||
|
* 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. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_FUSER_H_
|
||||||
|
#define _SVR4_FUSER_H_
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
|
||||||
|
struct svr4_f_user {
|
||||||
|
svr4_pid_t fu_pid;
|
||||||
|
int fu_flags;
|
||||||
|
uid_t fu_uid;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define SVR4_F_FILE_ONLY 1
|
||||||
|
#define SVR4_F_CONTAINED 2
|
||||||
|
|
||||||
|
#define SVR4_F_CDIR 0x01
|
||||||
|
#define SVR4_F_RDIR 0x02
|
||||||
|
#define SVR4_F_TEXT 0x04
|
||||||
|
#define SVR4_F_MAP 0x08
|
||||||
|
#define SVR4_F_OPEN 0x10
|
||||||
|
#define SVR4_F_TRACE 0x20
|
||||||
|
#define SVR4_F_TTY 0x40
|
||||||
|
|
||||||
|
#endif /* !_SVR4_FUSER_H_ */
|
85
sys/compat/svr4/svr4_hrt.h
Normal file
85
sys/compat/svr4/svr4_hrt.h
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_HRT_H_
|
||||||
|
#define _SVR4_HRT_H_
|
||||||
|
|
||||||
|
#define SVR4_HRT_CNTL 0
|
||||||
|
#define SVR4_HRT_CNTL_RES 0
|
||||||
|
#define SVR4_HRT_CNTL_TOFD 1
|
||||||
|
#define SVR4_HRT_CNTL_START 2
|
||||||
|
#define SVR4_HRT_CNTL_GET 3
|
||||||
|
|
||||||
|
#define SVR4_HRT_ALRM 1
|
||||||
|
#define SVR4_HRT_ALRM_DO 4
|
||||||
|
#define SVR4_HRT_ALRM_REP 5
|
||||||
|
#define SVR4_HRT_ALRM_TOD 6
|
||||||
|
#define SVR4_HRT_ALRM_FUTREP 7
|
||||||
|
#define SVR4_HRT_ALRM_TODREP 8
|
||||||
|
#define SVR4_HRT_ALRM_PEND 9
|
||||||
|
|
||||||
|
#define SVR4_HRT_SLP 2
|
||||||
|
#define SVR4_HRT_SLP_INT 10
|
||||||
|
#define SVR4_HRT_SLP_TOD 11
|
||||||
|
|
||||||
|
#define SVR4_HRT_BSD 12
|
||||||
|
#define SVR4_HRT_BSD_PEND 13
|
||||||
|
#define SVR4_HRT_BSD_REP1 14
|
||||||
|
#define SVR4_HRT_BSD_REP2 15
|
||||||
|
#define SVR4_HRT_BSD_CANCEL 16
|
||||||
|
|
||||||
|
#define SVR4_HRT_CAN 3
|
||||||
|
|
||||||
|
#define SVR4_HRT_SEC 1
|
||||||
|
#define SVR4_HRT_MSEC 1000
|
||||||
|
#define SVR4_HRT_USEC 1000000
|
||||||
|
#define SVR4_HRT_NSEC 1000000000
|
||||||
|
|
||||||
|
#define SVR4_HRT_TRUNC 0
|
||||||
|
#define SVR4_HRT_RND 1
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u_long i_word1;
|
||||||
|
u_long i_word2;
|
||||||
|
int i_clock;
|
||||||
|
} svr4_hrt_interval_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u_long h_sec;
|
||||||
|
long h_rem;
|
||||||
|
u_long h_res;
|
||||||
|
} svr4_hrt_time_t;
|
||||||
|
|
||||||
|
#define SVR4_HRT_DONE 1
|
||||||
|
#define SVR4_HRT_ERROR 2
|
||||||
|
|
||||||
|
#define SVR4_HRT_CLK_STD 1
|
||||||
|
#define SVR4_HRT_CLK_USERVIRT 2
|
||||||
|
#define SVR4_HRT_CLK_PROCVIRT 4
|
||||||
|
|
||||||
|
#endif /* !_SVR4_HRT_H_ */
|
167
sys/compat/svr4/svr4_ioctl.c
Normal file
167
sys/compat/svr4/svr4_ioctl.c
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/tty.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/socketvar.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_stropts.h>
|
||||||
|
#include <svr4/svr4_ioctl.h>
|
||||||
|
#include <svr4/svr4_termios.h>
|
||||||
|
#include <svr4/svr4_ttold.h>
|
||||||
|
#include <svr4/svr4_filio.h>
|
||||||
|
#include <svr4/svr4_sockio.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
static void svr4_decode_cmd __P((u_long, char *, char *, int *, int *));
|
||||||
|
/*
|
||||||
|
* Decode an ioctl command symbolically
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
svr4_decode_cmd(cmd, dir, c, num, argsiz)
|
||||||
|
u_long cmd;
|
||||||
|
char *dir, *c;
|
||||||
|
int *num, *argsiz;
|
||||||
|
{
|
||||||
|
if (cmd & SVR4_IOC_VOID)
|
||||||
|
*dir++ = 'V';
|
||||||
|
if (cmd & SVR4_IOC_IN)
|
||||||
|
*dir++ = 'R';
|
||||||
|
if (cmd & SVR4_IOC_OUT)
|
||||||
|
*dir++ = 'W';
|
||||||
|
*dir = '\0';
|
||||||
|
if (cmd & SVR4_IOC_INOUT)
|
||||||
|
*argsiz = (cmd >> 16) & 0xff;
|
||||||
|
else
|
||||||
|
*argsiz = -1;
|
||||||
|
|
||||||
|
*c = (cmd >> 8) & 0xff;
|
||||||
|
*num = cmd & 0xff;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_ioctl(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_ioctl_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
struct file *fp;
|
||||||
|
struct filedesc *fdp;
|
||||||
|
u_long cmd;
|
||||||
|
int (*fun) __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
char dir[4];
|
||||||
|
char c;
|
||||||
|
int num;
|
||||||
|
int argsiz;
|
||||||
|
|
||||||
|
svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz);
|
||||||
|
|
||||||
|
DPRINTF(("svr4_ioctl[%x](%d, _IO%s(%c, %d, %d), %p);\n", SCARG(uap, com), SCARG(uap, fd),
|
||||||
|
dir, c, num, argsiz, SCARG(uap, data)));
|
||||||
|
#endif
|
||||||
|
retval = p->p_retval;
|
||||||
|
fdp = p->p_fd;
|
||||||
|
cmd = SCARG(uap, com);
|
||||||
|
|
||||||
|
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
|
||||||
|
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
|
||||||
|
return EBADF;
|
||||||
|
|
||||||
|
if ((fp->f_flag & (FREAD | FWRITE)) == 0)
|
||||||
|
return EBADF;
|
||||||
|
|
||||||
|
#if defined(DEBUG_SVR4)
|
||||||
|
if (fp->f_type == DTYPE_SOCKET) {
|
||||||
|
struct socket *so = fp->f_data;
|
||||||
|
DPRINTF(("<<< IN: so_state = 0x%x\n", so->so_state));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (cmd & 0xff00) {
|
||||||
|
case SVR4_tIOC:
|
||||||
|
DPRINTF(("ttold\n"));
|
||||||
|
fun = svr4_ttold_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_TIOC:
|
||||||
|
DPRINTF(("term\n"));
|
||||||
|
fun = svr4_term_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_STR:
|
||||||
|
DPRINTF(("stream\n"));
|
||||||
|
fun = svr4_stream_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_FIOC:
|
||||||
|
DPRINTF(("file\n"));
|
||||||
|
fun = svr4_fil_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SIOC:
|
||||||
|
DPRINTF(("socket\n"));
|
||||||
|
fun = svr4_sock_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_XIOC:
|
||||||
|
/* We do not support those */
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Unimplemented ioctl %lx\n", cmd));
|
||||||
|
return 0; /* XXX: really ENOSYS */
|
||||||
|
}
|
||||||
|
#if defined(DEBUG_SVR4)
|
||||||
|
if (fp->f_type == DTYPE_SOCKET) {
|
||||||
|
struct socket *so = fp->f_data;
|
||||||
|
DPRINTF((">>> OUT: so_state = 0x%x\n", so->so_state));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return (*fun)(fp, p, retval, SCARG(uap, fd), cmd, SCARG(uap, data));
|
||||||
|
}
|
60
sys/compat/svr4/svr4_ioctl.h
Normal file
60
sys/compat/svr4/svr4_ioctl.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_IOCTL_H_
|
||||||
|
#define _SVR4_IOCTL_H_
|
||||||
|
|
||||||
|
#define SVR4_IOC_VOID 0x20000000
|
||||||
|
#define SVR4_IOC_OUT 0x40000000
|
||||||
|
#define SVR4_IOC_IN 0x80000000
|
||||||
|
#define SVR4_IOC_INOUT (SVR4_IOC_IN|SVR4_IOC_OUT)
|
||||||
|
|
||||||
|
#define SVR4_IOC(inout,group,num,len) \
|
||||||
|
(inout | ((len & 0xff) << 16) | ((group) << 8) | (num))
|
||||||
|
|
||||||
|
#define SVR4_XIOC ('X' << 8)
|
||||||
|
|
||||||
|
#define SVR4_IO(g,n) SVR4_IOC(SVR4_IOC_VOID, (g), (n), 0)
|
||||||
|
#define SVR4_IOR(g,n,t) SVR4_IOC(SVR4_IOC_OUT, (g), (n), sizeof(t))
|
||||||
|
#define SVR4_IOW(g,n,t) SVR4_IOC(SVR4_IOC_IN, (g), (n), sizeof(t))
|
||||||
|
#define SVR4_IOWR(g,n,t) SVR4_IOC(SVR4_IOC_INOUT,(g), (n), sizeof(t))
|
||||||
|
|
||||||
|
int svr4_stream_ti_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_stream_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_term_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_ttold_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_fil_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_sock_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
|
||||||
|
#endif /* !_SVR4_IOCTL_H_ */
|
831
sys/compat/svr4/svr4_ipc.c
Normal file
831
sys/compat/svr4/svr4_ipc.c
Normal file
|
@ -0,0 +1,831 @@
|
||||||
|
/*
|
||||||
|
* Derived from:
|
||||||
|
* $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Original copyright:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Christos Zoulas.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions of this code have been derived from software contributed
|
||||||
|
* to the FreeBSD Project by Mark Newton.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mark Newton
|
||||||
|
* 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. 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.
|
||||||
|
*
|
||||||
|
* XXX- This code is presently a no-op on FreeBSD (and isn't compiled due
|
||||||
|
* to preprocessor conditionals). A nice project for a kernel hacking
|
||||||
|
* novice might be to MakeItGo, but I have more important fish to fry
|
||||||
|
* at present.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/msg.h>
|
||||||
|
#include <sys/sem.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_ipc.h>
|
||||||
|
|
||||||
|
#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
|
||||||
|
static void svr4_to_bsd_ipc_perm __P((const struct svr4_ipc_perm *,
|
||||||
|
struct ipc_perm *));
|
||||||
|
static void bsd_to_svr4_ipc_perm __P((const struct ipc_perm *,
|
||||||
|
struct svr4_ipc_perm *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVSEM
|
||||||
|
static void bsd_to_svr4_semid_ds __P((const struct semid_ds *,
|
||||||
|
struct svr4_semid_ds *));
|
||||||
|
static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *,
|
||||||
|
struct semid_ds *));
|
||||||
|
static int svr4_setsemun __P((caddr_t *sgp, union semun **argp,
|
||||||
|
union semun *usp));
|
||||||
|
static int svr4_semop __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_semget __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_semctl __P((struct proc *, void *, register_t *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVMSG
|
||||||
|
static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *,
|
||||||
|
struct svr4_msqid_ds *));
|
||||||
|
static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *,
|
||||||
|
struct msqid_ds *));
|
||||||
|
static int svr4_msgsnd __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_msgrcv __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_msgget __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_msgctl __P((struct proc *, void *, register_t *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVSHM
|
||||||
|
static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *,
|
||||||
|
struct svr4_shmid_ds *));
|
||||||
|
static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *,
|
||||||
|
struct shmid_ds *));
|
||||||
|
static int svr4_shmat __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_shmdt __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_shmget __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_shmctl __P((struct proc *, void *, register_t *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_ipc_perm(spp, bpp)
|
||||||
|
const struct svr4_ipc_perm *spp;
|
||||||
|
struct ipc_perm *bpp;
|
||||||
|
{
|
||||||
|
bpp->key = spp->key;
|
||||||
|
bpp->uid = spp->uid;
|
||||||
|
bpp->gid = spp->gid;
|
||||||
|
bpp->cuid = spp->cuid;
|
||||||
|
bpp->cgid = spp->cgid;
|
||||||
|
bpp->mode = spp->mode;
|
||||||
|
bpp->seq = spp->seq;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_ipc_perm(bpp, spp)
|
||||||
|
const struct ipc_perm *bpp;
|
||||||
|
struct svr4_ipc_perm *spp;
|
||||||
|
{
|
||||||
|
spp->key = bpp->key;
|
||||||
|
spp->uid = bpp->uid;
|
||||||
|
spp->gid = bpp->gid;
|
||||||
|
spp->cuid = bpp->cuid;
|
||||||
|
spp->cgid = bpp->cgid;
|
||||||
|
spp->mode = bpp->mode;
|
||||||
|
spp->seq = bpp->seq;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVSEM
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_semid_ds(bds, sds)
|
||||||
|
const struct semid_ds *bds;
|
||||||
|
struct svr4_semid_ds *sds;
|
||||||
|
{
|
||||||
|
bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
|
||||||
|
sds->sem_base = (struct svr4_sem *) bds->sem_base;
|
||||||
|
sds->sem_nsems = bds->sem_nsems;
|
||||||
|
sds->sem_otime = bds->sem_otime;
|
||||||
|
sds->sem_pad1 = bds->sem_pad1;
|
||||||
|
sds->sem_ctime = bds->sem_ctime;
|
||||||
|
sds->sem_pad2 = bds->sem_pad2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_semid_ds(sds, bds)
|
||||||
|
const struct svr4_semid_ds *sds;
|
||||||
|
struct semid_ds *bds;
|
||||||
|
{
|
||||||
|
svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
|
||||||
|
bds->sem_base = (struct sem *) bds->sem_base;
|
||||||
|
bds->sem_nsems = sds->sem_nsems;
|
||||||
|
bds->sem_otime = sds->sem_otime;
|
||||||
|
bds->sem_pad1 = sds->sem_pad1;
|
||||||
|
bds->sem_ctime = sds->sem_ctime;
|
||||||
|
bds->sem_pad2 = sds->sem_pad2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_setsemun(sgp, argp, usp)
|
||||||
|
caddr_t *sgp;
|
||||||
|
union semun **argp;
|
||||||
|
union semun *usp;
|
||||||
|
{
|
||||||
|
*argp = stackgap_alloc(sgp, sizeof(union semun));
|
||||||
|
return copyout((caddr_t)usp, *argp, sizeof(union semun));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_semctl_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) semid;
|
||||||
|
syscallarg(int) semnum;
|
||||||
|
syscallarg(int) cmd;
|
||||||
|
syscallarg(union semun) arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_semctl(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
struct svr4_sys_semctl_args *uap = v;
|
||||||
|
struct sys___semctl_args ap;
|
||||||
|
struct svr4_semid_ds ss;
|
||||||
|
struct semid_ds bs, *bsp;
|
||||||
|
caddr_t sg = stackgap_init(p->p_emul);
|
||||||
|
|
||||||
|
SCARG(&ap, semid) = SCARG(uap, semid);
|
||||||
|
SCARG(&ap, semnum) = SCARG(uap, semnum);
|
||||||
|
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_SEM_GETZCNT:
|
||||||
|
case SVR4_SEM_GETNCNT:
|
||||||
|
case SVR4_SEM_GETPID:
|
||||||
|
case SVR4_SEM_GETVAL:
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_SEM_GETZCNT:
|
||||||
|
SCARG(&ap, cmd) = GETZCNT;
|
||||||
|
break;
|
||||||
|
case SVR4_SEM_GETNCNT:
|
||||||
|
SCARG(&ap, cmd) = GETNCNT;
|
||||||
|
break;
|
||||||
|
case SVR4_SEM_GETPID:
|
||||||
|
SCARG(&ap, cmd) = GETPID;
|
||||||
|
break;
|
||||||
|
case SVR4_SEM_GETVAL:
|
||||||
|
SCARG(&ap, cmd) = GETVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_SEM_SETVAL:
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
SCARG(&ap, cmd) = SETVAL;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_SEM_GETALL:
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
SCARG(&ap, cmd) = GETVAL;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_SEM_SETALL:
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
SCARG(&ap, cmd) = SETVAL;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_IPC_STAT:
|
||||||
|
SCARG(&ap, cmd) = IPC_STAT;
|
||||||
|
bsp = stackgap_alloc(&sg, sizeof(bs));
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg),
|
||||||
|
(union semun *)&bsp);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
if ((error = sys___semctl(p, &ap, retval)) != 0)
|
||||||
|
return error;
|
||||||
|
error = copyin((caddr_t)bsp, (caddr_t)&bs, sizeof(bs));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_semid_ds(&bs, &ss);
|
||||||
|
return copyout(&ss, SCARG(uap, arg).buf, sizeof(ss));
|
||||||
|
|
||||||
|
case SVR4_IPC_SET:
|
||||||
|
SCARG(&ap, cmd) = IPC_SET;
|
||||||
|
bsp = stackgap_alloc(&sg, sizeof(bs));
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg),
|
||||||
|
(union semun *)&bsp);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
error = copyin(SCARG(uap, arg).buf, (caddr_t) &ss, sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_semid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, bsp, sizeof(bs));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
SCARG(&ap, cmd) = IPC_RMID;
|
||||||
|
bsp = stackgap_alloc(&sg, sizeof(bs));
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg),
|
||||||
|
(union semun *)&bsp);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
error = copyin(SCARG(uap, arg).buf, &ss, sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_semid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, bsp, sizeof(bs));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_semget_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(svr4_key_t) key;
|
||||||
|
syscallarg(int) nsems;
|
||||||
|
syscallarg(int) semflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_semget(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_semget_args *uap = v;
|
||||||
|
struct sys_semget_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, key) = SCARG(uap, key);
|
||||||
|
SCARG(&ap, nsems) = SCARG(uap, nsems);
|
||||||
|
SCARG(&ap, semflg) = SCARG(uap, semflg);
|
||||||
|
|
||||||
|
return sys_semget(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_semop_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) semid;
|
||||||
|
syscallarg(struct svr4_sembuf *) sops;
|
||||||
|
syscallarg(u_int) nsops;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_semop(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_semop_args *uap = v;
|
||||||
|
struct sys_semop_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, semid) = SCARG(uap, semid);
|
||||||
|
/* These are the same */
|
||||||
|
SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops);
|
||||||
|
SCARG(&ap, nsops) = SCARG(uap, nsops);
|
||||||
|
|
||||||
|
return sys_semop(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_semsys(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_semsys_args *uap = v;
|
||||||
|
|
||||||
|
DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what)));
|
||||||
|
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case SVR4_semctl:
|
||||||
|
return svr4_semctl(p, v, retval);
|
||||||
|
case SVR4_semget:
|
||||||
|
return svr4_semget(p, v, retval);
|
||||||
|
case SVR4_semop:
|
||||||
|
return svr4_semop(p, v, retval);
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVMSG
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_msqid_ds(bds, sds)
|
||||||
|
const struct msqid_ds *bds;
|
||||||
|
struct svr4_msqid_ds *sds;
|
||||||
|
{
|
||||||
|
bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
|
||||||
|
sds->msg_first = (struct svr4_msg *) bds->msg_first;
|
||||||
|
sds->msg_last = (struct svr4_msg *) bds->msg_last;
|
||||||
|
sds->msg_cbytes = bds->msg_cbytes;
|
||||||
|
sds->msg_qnum = bds->msg_qnum;
|
||||||
|
sds->msg_qbytes = bds->msg_qbytes;
|
||||||
|
sds->msg_lspid = bds->msg_lspid;
|
||||||
|
sds->msg_lrpid = bds->msg_lrpid;
|
||||||
|
sds->msg_stime = bds->msg_stime;
|
||||||
|
sds->msg_pad1 = bds->msg_pad1;
|
||||||
|
sds->msg_rtime = bds->msg_rtime;
|
||||||
|
sds->msg_pad2 = bds->msg_pad2;
|
||||||
|
sds->msg_ctime = bds->msg_ctime;
|
||||||
|
sds->msg_pad3 = bds->msg_pad3;
|
||||||
|
|
||||||
|
/* use the padding for the rest of the fields */
|
||||||
|
{
|
||||||
|
const short *pad = (const short *) bds->msg_pad4;
|
||||||
|
sds->msg_cv = pad[0];
|
||||||
|
sds->msg_qnum_cv = pad[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_msqid_ds(sds, bds)
|
||||||
|
const struct svr4_msqid_ds *sds;
|
||||||
|
struct msqid_ds *bds;
|
||||||
|
{
|
||||||
|
svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
|
||||||
|
bds->msg_first = (struct msg *) sds->msg_first;
|
||||||
|
bds->msg_last = (struct msg *) sds->msg_last;
|
||||||
|
bds->msg_cbytes = sds->msg_cbytes;
|
||||||
|
bds->msg_qnum = sds->msg_qnum;
|
||||||
|
bds->msg_qbytes = sds->msg_qbytes;
|
||||||
|
bds->msg_lspid = sds->msg_lspid;
|
||||||
|
bds->msg_lrpid = sds->msg_lrpid;
|
||||||
|
bds->msg_stime = sds->msg_stime;
|
||||||
|
bds->msg_pad1 = sds->msg_pad1;
|
||||||
|
bds->msg_rtime = sds->msg_rtime;
|
||||||
|
bds->msg_pad2 = sds->msg_pad2;
|
||||||
|
bds->msg_ctime = sds->msg_ctime;
|
||||||
|
bds->msg_pad3 = sds->msg_pad3;
|
||||||
|
|
||||||
|
/* use the padding for the rest of the fields */
|
||||||
|
{
|
||||||
|
short *pad = (short *) bds->msg_pad4;
|
||||||
|
pad[0] = sds->msg_cv;
|
||||||
|
pad[1] = sds->msg_qnum_cv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_msgsnd_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) msqid;
|
||||||
|
syscallarg(void *) msgp;
|
||||||
|
syscallarg(size_t) msgsz;
|
||||||
|
syscallarg(int) msgflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_msgsnd(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_msgsnd_args *uap = v;
|
||||||
|
struct sys_msgsnd_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
||||||
|
SCARG(&ap, msgp) = SCARG(uap, msgp);
|
||||||
|
SCARG(&ap, msgsz) = SCARG(uap, msgsz);
|
||||||
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
||||||
|
|
||||||
|
return sys_msgsnd(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_msgrcv_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) msqid;
|
||||||
|
syscallarg(void *) msgp;
|
||||||
|
syscallarg(size_t) msgsz;
|
||||||
|
syscallarg(long) msgtyp;
|
||||||
|
syscallarg(int) msgflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_msgrcv(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_msgrcv_args *uap = v;
|
||||||
|
struct sys_msgrcv_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
||||||
|
SCARG(&ap, msgp) = SCARG(uap, msgp);
|
||||||
|
SCARG(&ap, msgsz) = SCARG(uap, msgsz);
|
||||||
|
SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
|
||||||
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
||||||
|
|
||||||
|
return sys_msgrcv(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_msgget_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(svr4_key_t) key;
|
||||||
|
syscallarg(int) msgflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_msgget(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_msgget_args *uap = v;
|
||||||
|
struct sys_msgget_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, key) = SCARG(uap, key);
|
||||||
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
||||||
|
|
||||||
|
return sys_msgget(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_msgctl_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) msqid;
|
||||||
|
syscallarg(int) cmd;
|
||||||
|
syscallarg(struct svr4_msqid_ds *) buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_msgctl(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
struct svr4_sys_msgctl_args *uap = v;
|
||||||
|
struct sys_msgctl_args ap;
|
||||||
|
struct svr4_msqid_ds ss;
|
||||||
|
struct msqid_ds bs;
|
||||||
|
caddr_t sg = stackgap_init(p->p_emul);
|
||||||
|
|
||||||
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
||||||
|
SCARG(&ap, cmd) = SCARG(uap, cmd);
|
||||||
|
SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs));
|
||||||
|
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_IPC_STAT:
|
||||||
|
SCARG(&ap, cmd) = IPC_STAT;
|
||||||
|
if ((error = sys_msgctl(p, &ap, retval)) != 0)
|
||||||
|
return error;
|
||||||
|
error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_msqid_ds(&bs, &ss);
|
||||||
|
return copyout(&ss, SCARG(uap, buf), sizeof ss);
|
||||||
|
|
||||||
|
case SVR4_IPC_SET:
|
||||||
|
SCARG(&ap, cmd) = IPC_SET;
|
||||||
|
error = copyin(SCARG(uap, buf), &ss, sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_msqid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return sys_msgctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
SCARG(&ap, cmd) = IPC_RMID;
|
||||||
|
error = copyin(SCARG(uap, buf), &ss, sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_msqid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return sys_msgctl(p, &ap, retval);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_msgsys(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_msgsys_args *uap = v;
|
||||||
|
|
||||||
|
DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what)));
|
||||||
|
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case SVR4_msgsnd:
|
||||||
|
return svr4_msgsnd(p, v, retval);
|
||||||
|
case SVR4_msgrcv:
|
||||||
|
return svr4_msgrcv(p, v, retval);
|
||||||
|
case SVR4_msgget:
|
||||||
|
return svr4_msgget(p, v, retval);
|
||||||
|
case SVR4_msgctl:
|
||||||
|
return svr4_msgctl(p, v, retval);
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVSHM
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_shmid_ds(bds, sds)
|
||||||
|
const struct shmid_ds *bds;
|
||||||
|
struct svr4_shmid_ds *sds;
|
||||||
|
{
|
||||||
|
bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm);
|
||||||
|
sds->shm_segsz = bds->shm_segsz;
|
||||||
|
sds->shm_lkcnt = 0;
|
||||||
|
sds->shm_lpid = bds->shm_lpid;
|
||||||
|
sds->shm_cpid = bds->shm_cpid;
|
||||||
|
sds->shm_amp = bds->shm_internal;
|
||||||
|
sds->shm_nattch = bds->shm_nattch;
|
||||||
|
sds->shm_cnattch = 0;
|
||||||
|
sds->shm_atime = bds->shm_atime;
|
||||||
|
sds->shm_pad1 = 0;
|
||||||
|
sds->shm_dtime = bds->shm_dtime;
|
||||||
|
sds->shm_pad2 = 0;
|
||||||
|
sds->shm_ctime = bds->shm_ctime;
|
||||||
|
sds->shm_pad3 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_shmid_ds(sds, bds)
|
||||||
|
const struct svr4_shmid_ds *sds;
|
||||||
|
struct shmid_ds *bds;
|
||||||
|
{
|
||||||
|
svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
|
||||||
|
bds->shm_segsz = sds->shm_segsz;
|
||||||
|
bds->shm_lpid = sds->shm_lpid;
|
||||||
|
bds->shm_cpid = sds->shm_cpid;
|
||||||
|
bds->shm_internal = sds->shm_amp;
|
||||||
|
bds->shm_nattch = sds->shm_nattch;
|
||||||
|
bds->shm_atime = sds->shm_atime;
|
||||||
|
bds->shm_dtime = sds->shm_dtime;
|
||||||
|
bds->shm_ctime = sds->shm_ctime;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_shmat_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) shmid;
|
||||||
|
syscallarg(void *) shmaddr;
|
||||||
|
syscallarg(int) shmflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_shmat(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmat_args *uap = v;
|
||||||
|
struct sys_shmat_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, shmid) = SCARG(uap, shmid);
|
||||||
|
SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
|
||||||
|
SCARG(&ap, shmflg) = SCARG(uap, shmflg);
|
||||||
|
|
||||||
|
return sys_shmat(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_shmdt_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(void *) shmaddr;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_shmdt(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmdt_args *uap = v;
|
||||||
|
struct sys_shmdt_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
|
||||||
|
|
||||||
|
return sys_shmdt(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_shmget_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(key_t) key;
|
||||||
|
syscallarg(int) size;
|
||||||
|
syscallarg(int) shmflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_shmget(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmget_args *uap = v;
|
||||||
|
struct sys_shmget_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, key) = SCARG(uap, key);
|
||||||
|
SCARG(&ap, size) = SCARG(uap, size);
|
||||||
|
SCARG(&ap, shmflg) = SCARG(uap, shmflg);
|
||||||
|
|
||||||
|
return sys_shmget(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_shmctl_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) shmid;
|
||||||
|
syscallarg(int) cmd;
|
||||||
|
syscallarg(struct svr4_shmid_ds *) buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_shmctl(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmctl_args *uap = v;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init(p->p_emul);
|
||||||
|
struct sys_shmctl_args ap;
|
||||||
|
struct shmid_ds bs;
|
||||||
|
struct svr4_shmid_ds ss;
|
||||||
|
|
||||||
|
SCARG(&ap, shmid) = SCARG(uap, shmid);
|
||||||
|
|
||||||
|
if (SCARG(uap, buf) != NULL) {
|
||||||
|
SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof (struct shmid_ds));
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_IPC_SET:
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
case SVR4_SHM_LOCK:
|
||||||
|
case SVR4_SHM_UNLOCK:
|
||||||
|
error = copyin(SCARG(uap, buf), (caddr_t) &ss,
|
||||||
|
sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_shmid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SCARG(&ap, buf) = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_IPC_STAT:
|
||||||
|
SCARG(&ap, cmd) = IPC_STAT;
|
||||||
|
if ((error = sys_shmctl(p, &ap, retval)) != 0)
|
||||||
|
return error;
|
||||||
|
if (SCARG(uap, buf) == NULL)
|
||||||
|
return 0;
|
||||||
|
error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_shmid_ds(&bs, &ss);
|
||||||
|
return copyout(&ss, SCARG(uap, buf), sizeof ss);
|
||||||
|
|
||||||
|
case SVR4_IPC_SET:
|
||||||
|
SCARG(&ap, cmd) = IPC_SET;
|
||||||
|
return sys_shmctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
case SVR4_SHM_LOCK:
|
||||||
|
case SVR4_SHM_UNLOCK:
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
SCARG(&ap, cmd) = IPC_RMID;
|
||||||
|
break;
|
||||||
|
case SVR4_SHM_LOCK:
|
||||||
|
SCARG(&ap, cmd) = SHM_LOCK;
|
||||||
|
break;
|
||||||
|
case SVR4_SHM_UNLOCK:
|
||||||
|
SCARG(&ap, cmd) = SHM_UNLOCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
return sys_shmctl(p, &ap, retval);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_shmsys(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmsys_args *uap = v;
|
||||||
|
|
||||||
|
DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what)));
|
||||||
|
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case SVR4_shmat:
|
||||||
|
return svr4_shmat(p, v, retval);
|
||||||
|
case SVR4_shmdt:
|
||||||
|
return svr4_shmdt(p, v, retval);
|
||||||
|
case SVR4_shmget:
|
||||||
|
return svr4_shmget(p, v, retval);
|
||||||
|
case SVR4_shmctl:
|
||||||
|
return svr4_shmctl(p, v, retval);
|
||||||
|
default:
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* SYSVSHM */
|
174
sys/compat/svr4/svr4_ipc.h
Normal file
174
sys/compat/svr4/svr4_ipc.h
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1995 Christos Zoulas. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_IPC_H_
|
||||||
|
#define _SVR4_IPC_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* General IPC
|
||||||
|
*/
|
||||||
|
#define SVR4_IPC_RMID 10
|
||||||
|
#define SVR4_IPC_SET 11
|
||||||
|
#define SVR4_IPC_STAT 12
|
||||||
|
|
||||||
|
struct svr4_ipc_perm {
|
||||||
|
svr4_uid_t uid;
|
||||||
|
svr4_gid_t gid;
|
||||||
|
svr4_uid_t cuid;
|
||||||
|
svr4_gid_t cgid;
|
||||||
|
svr4_mode_t mode;
|
||||||
|
u_long seq;
|
||||||
|
svr4_key_t key;
|
||||||
|
long pad[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Message queues
|
||||||
|
*/
|
||||||
|
#define SVR4_msgget 0
|
||||||
|
#define SVR4_msgctl 1
|
||||||
|
#define SVR4_msgrcv 2
|
||||||
|
#define SVR4_msgsnd 3
|
||||||
|
|
||||||
|
struct svr4_msg {
|
||||||
|
struct svr4_msg *msg_next;
|
||||||
|
long msg_type;
|
||||||
|
u_short msg_ts;
|
||||||
|
short msg_spot;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_msqid_ds {
|
||||||
|
struct svr4_ipc_perm msg_perm;
|
||||||
|
struct svr4_msg *msg_first;
|
||||||
|
struct svr4_msg *msg_last;
|
||||||
|
u_long msg_cbytes;
|
||||||
|
u_long msg_qnum;
|
||||||
|
u_long msg_qbytes;
|
||||||
|
svr4_pid_t msg_lspid;
|
||||||
|
svr4_pid_t msg_lrpid;
|
||||||
|
svr4_time_t msg_stime;
|
||||||
|
long msg_pad1;
|
||||||
|
svr4_time_t msg_rtime;
|
||||||
|
long msg_pad2;
|
||||||
|
svr4_time_t msg_ctime;
|
||||||
|
long msg_pad3;
|
||||||
|
short msg_cv;
|
||||||
|
short msg_qnum_cv;
|
||||||
|
long msg_pad4[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_msgbuf {
|
||||||
|
long mtype; /* message type */
|
||||||
|
char mtext[1]; /* message text */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_msginfo {
|
||||||
|
int msgmap;
|
||||||
|
int msgmax;
|
||||||
|
int msgmnb;
|
||||||
|
int msgmni;
|
||||||
|
int msgssz;
|
||||||
|
int msgtql;
|
||||||
|
u_short msgseg;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shared memory
|
||||||
|
*/
|
||||||
|
#define SVR4_shmat 0
|
||||||
|
#define SVR4_shmctl 1
|
||||||
|
#define SVR4_shmdt 2
|
||||||
|
#define SVR4_shmget 3
|
||||||
|
|
||||||
|
/* shmctl() operations */
|
||||||
|
#define SVR4_SHM_LOCK 3
|
||||||
|
#define SVR4_SHM_UNLOCK 4
|
||||||
|
|
||||||
|
struct svr4_shmid_ds {
|
||||||
|
struct svr4_ipc_perm shm_perm;
|
||||||
|
int shm_segsz;
|
||||||
|
void *shm_amp;
|
||||||
|
u_short shm_lkcnt;
|
||||||
|
svr4_pid_t shm_lpid;
|
||||||
|
svr4_pid_t shm_cpid;
|
||||||
|
u_long shm_nattch;
|
||||||
|
u_long shm_cnattch;
|
||||||
|
svr4_time_t shm_atime;
|
||||||
|
long shm_pad1;
|
||||||
|
svr4_time_t shm_dtime;
|
||||||
|
long shm_pad2;
|
||||||
|
svr4_time_t shm_ctime;
|
||||||
|
long shm_pad3;
|
||||||
|
long shm_pad4[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Semaphores
|
||||||
|
*/
|
||||||
|
#define SVR4_semctl 0
|
||||||
|
#define SVR4_semget 1
|
||||||
|
#define SVR4_semop 2
|
||||||
|
|
||||||
|
/* semctl() operations */
|
||||||
|
#define SVR4_SEM_GETNCNT 3
|
||||||
|
#define SVR4_SEM_GETPID 4
|
||||||
|
#define SVR4_SEM_GETVAL 5
|
||||||
|
#define SVR4_SEM_GETALL 6
|
||||||
|
#define SVR4_SEM_GETZCNT 7
|
||||||
|
#define SVR4_SEM_SETVAL 8
|
||||||
|
#define SVR4_SEM_SETALL 9
|
||||||
|
|
||||||
|
struct svr4_sem {
|
||||||
|
u_short semval;
|
||||||
|
svr4_pid_t sempid;
|
||||||
|
u_short semncnt;
|
||||||
|
u_short semzcnt;
|
||||||
|
u_short semncnt_cv;
|
||||||
|
u_short semzcnt_cv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_semid_ds {
|
||||||
|
struct svr4_ipc_perm sem_perm;
|
||||||
|
struct svr4_sem *sem_base;
|
||||||
|
u_short sem_nsems;
|
||||||
|
svr4_time_t sem_otime;
|
||||||
|
long sem_pad1;
|
||||||
|
svr4_time_t sem_ctime;
|
||||||
|
long sem_pad2;
|
||||||
|
long sem_pad3[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_sembuf {
|
||||||
|
u_short sem_num;
|
||||||
|
short sem_op;
|
||||||
|
short sem_flg;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _SVR4_IPC_H */
|
1629
sys/compat/svr4/svr4_misc.c
Normal file
1629
sys/compat/svr4/svr4_misc.c
Normal file
File diff suppressed because it is too large
Load diff
45
sys/compat/svr4/svr4_mman.h
Normal file
45
sys/compat/svr4/svr4_mman.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1997 Todd Vierling
|
||||||
|
* 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. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_MMAN_H_
|
||||||
|
#define _SVR4_MMAN_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Commands and flags passed to memcntl().
|
||||||
|
* Most of them are the same as <sys/mman.h>, but we need the MC_
|
||||||
|
* memcntl command definitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SVR4_MC_SYNC 1
|
||||||
|
#define SVR4_MC_LOCK 2
|
||||||
|
#define SVR4_MC_UNLOCK 3
|
||||||
|
#define SVR4_MC_ADVISE 4
|
||||||
|
#define SVR4_MC_LOCKAS 5
|
||||||
|
#define SVR4_MC_UNLOCKAS 6
|
||||||
|
|
||||||
|
#endif /* !_SVR4_MMAN_H */
|
472
sys/compat/svr4/svr4_proto.h
Normal file
472
sys/compat/svr4/svr4_proto.h
Normal file
|
@ -0,0 +1,472 @@
|
||||||
|
/*
|
||||||
|
* System call prototypes.
|
||||||
|
*
|
||||||
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
|
* created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SYSPROTO_H_
|
||||||
|
#define _SVR4_SYSPROTO_H_
|
||||||
|
|
||||||
|
#include <sys/signal.h>
|
||||||
|
|
||||||
|
struct proc;
|
||||||
|
|
||||||
|
#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
|
||||||
|
0 : sizeof(register_t) - sizeof(t))
|
||||||
|
|
||||||
|
struct svr4_sys_open_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_wait_args {
|
||||||
|
int * status; char status_[PAD_(int *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_creat_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_execv_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
char ** argp; char argp_[PAD_(char **)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_time_args {
|
||||||
|
time_t * t; char t_[PAD_(time_t *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_mknod_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
int dev; char dev_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_break_args {
|
||||||
|
caddr_t nsize; char nsize_[PAD_(caddr_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_stat_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_stat * ub; char ub_[PAD_(struct svr4_stat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_alarm_args {
|
||||||
|
unsigned sec; char sec_[PAD_(unsigned)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fstat_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_stat * sb; char sb_[PAD_(struct svr4_stat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_pause_args {
|
||||||
|
register_t dummy;
|
||||||
|
};
|
||||||
|
struct svr4_sys_utime_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_utimbuf * ubuf; char ubuf_[PAD_(struct svr4_utimbuf *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_access_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_nice_args {
|
||||||
|
int prio; char prio_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_kill_args {
|
||||||
|
int pid; char pid_[PAD_(int)];
|
||||||
|
int signum; char signum_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_pgrpsys_args {
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
int pid; char pid_[PAD_(int)];
|
||||||
|
int pgid; char pgid_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_times_args {
|
||||||
|
struct tms * tp; char tp_[PAD_(struct tms *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_signal_args {
|
||||||
|
int signum; char signum_[PAD_(int)];
|
||||||
|
svr4_sig_t handler; char handler_[PAD_(svr4_sig_t)];
|
||||||
|
};
|
||||||
|
#if defined(NOTYET)
|
||||||
|
struct svr4_sys_msgsys_args {
|
||||||
|
int what; char what_[PAD_(int)];
|
||||||
|
int a2; char a2_[PAD_(int)];
|
||||||
|
int a3; char a3_[PAD_(int)];
|
||||||
|
int a4; char a4_[PAD_(int)];
|
||||||
|
int a5; char a5_[PAD_(int)];
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
struct svr4_sys_sysarch_args {
|
||||||
|
int op; char op_[PAD_(int)];
|
||||||
|
void * a1; char a1_[PAD_(void *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_ioctl_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
u_long com; char com_[PAD_(u_long)];
|
||||||
|
caddr_t data; char data_[PAD_(caddr_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_utssys_args {
|
||||||
|
void * a1; char a1_[PAD_(void *)];
|
||||||
|
void * a2; char a2_[PAD_(void *)];
|
||||||
|
int sel; char sel_[PAD_(int)];
|
||||||
|
void * a3; char a3_[PAD_(void *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_execve_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
char ** argp; char argp_[PAD_(char **)];
|
||||||
|
char ** envp; char envp_[PAD_(char **)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fcntl_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
char * arg; char arg_[PAD_(char *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_ulimit_args {
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
long newlimit; char newlimit_[PAD_(long)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getdents_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
char * buf; char buf_[PAD_(char *)];
|
||||||
|
int nbytes; char nbytes_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getmsg_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_strbuf * ctl; char ctl_[PAD_(struct svr4_strbuf *)];
|
||||||
|
struct svr4_strbuf * dat; char dat_[PAD_(struct svr4_strbuf *)];
|
||||||
|
int * flags; char flags_[PAD_(int *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_putmsg_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_strbuf * ctl; char ctl_[PAD_(struct svr4_strbuf *)];
|
||||||
|
struct svr4_strbuf * dat; char dat_[PAD_(struct svr4_strbuf *)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_poll_args {
|
||||||
|
struct pollfd * fds; char fds_[PAD_(struct pollfd *)];
|
||||||
|
unsigned int nfds; char nfds_[PAD_(unsigned int)];
|
||||||
|
int timeout; char timeout_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_lstat_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_stat * ub; char ub_[PAD_(struct svr4_stat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigprocmask_args {
|
||||||
|
int how; char how_[PAD_(int)];
|
||||||
|
svr4_sigset_t * set; char set_[PAD_(svr4_sigset_t *)];
|
||||||
|
svr4_sigset_t * oset; char oset_[PAD_(svr4_sigset_t *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigsuspend_args {
|
||||||
|
svr4_sigset_t * ss; char ss_[PAD_(svr4_sigset_t *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigaltstack_args {
|
||||||
|
struct svr4_sigaltstack * nss; char nss_[PAD_(struct svr4_sigaltstack *)];
|
||||||
|
struct svr4_sigaltstack * oss; char oss_[PAD_(struct svr4_sigaltstack *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigaction_args {
|
||||||
|
int signum; char signum_[PAD_(int)];
|
||||||
|
struct svr4_sigaction * nsa; char nsa_[PAD_(struct svr4_sigaction *)];
|
||||||
|
struct svr4_sigaction * osa; char osa_[PAD_(struct svr4_sigaction *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigpending_args {
|
||||||
|
int what; char what_[PAD_(int)];
|
||||||
|
svr4_sigset_t * mask; char mask_[PAD_(svr4_sigset_t *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_context_args {
|
||||||
|
int func; char func_[PAD_(int)];
|
||||||
|
struct svr4_ucontext * uc; char uc_[PAD_(struct svr4_ucontext *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_statvfs_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_statvfs * fs; char fs_[PAD_(struct svr4_statvfs *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fstatvfs_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_statvfs * fs; char fs_[PAD_(struct svr4_statvfs *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_waitsys_args {
|
||||||
|
int grp; char grp_[PAD_(int)];
|
||||||
|
int id; char id_[PAD_(int)];
|
||||||
|
union svr4_siginfo * info; char info_[PAD_(union svr4_siginfo *)];
|
||||||
|
int options; char options_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_hrtsys_args {
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
int fun; char fun_[PAD_(int)];
|
||||||
|
int sub; char sub_[PAD_(int)];
|
||||||
|
void * rv1; char rv1_[PAD_(void *)];
|
||||||
|
void * rv2; char rv2_[PAD_(void *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_pathconf_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int name; char name_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_mmap_args {
|
||||||
|
caddr_t addr; char addr_[PAD_(caddr_t)];
|
||||||
|
svr4_size_t len; char len_[PAD_(svr4_size_t)];
|
||||||
|
int prot; char prot_[PAD_(int)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
svr4_off_t pos; char pos_[PAD_(svr4_off_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fpathconf_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
int name; char name_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_xstat_args {
|
||||||
|
int two; char two_[PAD_(int)];
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_xstat * ub; char ub_[PAD_(struct svr4_xstat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_lxstat_args {
|
||||||
|
int two; char two_[PAD_(int)];
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_xstat * ub; char ub_[PAD_(struct svr4_xstat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fxstat_args {
|
||||||
|
int two; char two_[PAD_(int)];
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_xstat * sb; char sb_[PAD_(struct svr4_xstat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_xmknod_args {
|
||||||
|
int two; char two_[PAD_(int)];
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
svr4_mode_t mode; char mode_[PAD_(svr4_mode_t)];
|
||||||
|
svr4_dev_t dev; char dev_[PAD_(svr4_dev_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_setrlimit_args {
|
||||||
|
int which; char which_[PAD_(int)];
|
||||||
|
const struct svr4_rlimit * rlp; char rlp_[PAD_(const struct svr4_rlimit *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getrlimit_args {
|
||||||
|
int which; char which_[PAD_(int)];
|
||||||
|
struct svr4_rlimit * rlp; char rlp_[PAD_(struct svr4_rlimit *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_memcntl_args {
|
||||||
|
void * addr; char addr_[PAD_(void *)];
|
||||||
|
svr4_size_t len; char len_[PAD_(svr4_size_t)];
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
void * arg; char arg_[PAD_(void *)];
|
||||||
|
int attr; char attr_[PAD_(int)];
|
||||||
|
int mask; char mask_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_uname_args {
|
||||||
|
struct svr4_utsname * name; char name_[PAD_(struct svr4_utsname *)];
|
||||||
|
int dummy; char dummy_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sysconfig_args {
|
||||||
|
int name; char name_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_systeminfo_args {
|
||||||
|
int what; char what_[PAD_(int)];
|
||||||
|
char * buf; char buf_[PAD_(char *)];
|
||||||
|
long len; char len_[PAD_(long)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fchroot_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_utimes_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct timeval * tptr; char tptr_[PAD_(struct timeval *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_vhangup_args {
|
||||||
|
register_t dummy;
|
||||||
|
};
|
||||||
|
struct svr4_sys_gettimeofday_args {
|
||||||
|
struct timeval * tp; char tp_[PAD_(struct timeval *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_llseek_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
long offset1; char offset1_[PAD_(long)];
|
||||||
|
long offset2; char offset2_[PAD_(long)];
|
||||||
|
int whence; char whence_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_acl_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
int num; char num_[PAD_(int)];
|
||||||
|
struct svr4_aclent * buf; char buf_[PAD_(struct svr4_aclent *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_auditsys_args {
|
||||||
|
int code; char code_[PAD_(int)];
|
||||||
|
int a1; char a1_[PAD_(int)];
|
||||||
|
int a2; char a2_[PAD_(int)];
|
||||||
|
int a3; char a3_[PAD_(int)];
|
||||||
|
int a4; char a4_[PAD_(int)];
|
||||||
|
int a5; char a5_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_facl_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
int num; char num_[PAD_(int)];
|
||||||
|
struct svr4_aclent * buf; char buf_[PAD_(struct svr4_aclent *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_resolvepath_args {
|
||||||
|
const char * path; char path_[PAD_(const char *)];
|
||||||
|
char * buf; char buf_[PAD_(char *)];
|
||||||
|
size_t bufsiz; char bufsiz_[PAD_(size_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getdents64_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_dirent64 * dp; char dp_[PAD_(struct svr4_dirent64 *)];
|
||||||
|
int nbytes; char nbytes_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_mmap64_args {
|
||||||
|
void * addr; char addr_[PAD_(void *)];
|
||||||
|
svr4_size_t len; char len_[PAD_(svr4_size_t)];
|
||||||
|
int prot; char prot_[PAD_(int)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
svr4_off64_t pos; char pos_[PAD_(svr4_off64_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_stat64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_lstat64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fstat64_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_statvfs64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_statvfs64 * fs; char fs_[PAD_(struct svr4_statvfs64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fstatvfs64_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_statvfs64 * fs; char fs_[PAD_(struct svr4_statvfs64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_setrlimit64_args {
|
||||||
|
int which; char which_[PAD_(int)];
|
||||||
|
const struct svr4_rlimit64 * rlp; char rlp_[PAD_(const struct svr4_rlimit64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getrlimit64_args {
|
||||||
|
int which; char which_[PAD_(int)];
|
||||||
|
struct svr4_rlimit64 * rlp; char rlp_[PAD_(struct svr4_rlimit64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_creat64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_open64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_socket_args {
|
||||||
|
int domain; char domain_[PAD_(int)];
|
||||||
|
int type; char type_[PAD_(int)];
|
||||||
|
int protocol; char protocol_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_recv_args {
|
||||||
|
int s; char s_[PAD_(int)];
|
||||||
|
caddr_t buf; char buf_[PAD_(caddr_t)];
|
||||||
|
int len; char len_[PAD_(int)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_send_args {
|
||||||
|
int s; char s_[PAD_(int)];
|
||||||
|
caddr_t buf; char buf_[PAD_(caddr_t)];
|
||||||
|
int len; char len_[PAD_(int)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sendto_args {
|
||||||
|
int s; char s_[PAD_(int)];
|
||||||
|
const void * buf; char buf_[PAD_(const void *)];
|
||||||
|
size_t len; char len_[PAD_(size_t)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
const struct sockaddr * to; char to_[PAD_(const struct sockaddr *)];
|
||||||
|
int tolen; char tolen_[PAD_(int)];
|
||||||
|
};
|
||||||
|
int svr4_sys_open __P((struct proc *, struct svr4_sys_open_args *));
|
||||||
|
int svr4_sys_wait __P((struct proc *, struct svr4_sys_wait_args *));
|
||||||
|
int svr4_sys_creat __P((struct proc *, struct svr4_sys_creat_args *));
|
||||||
|
int svr4_sys_execv __P((struct proc *, struct svr4_sys_execv_args *));
|
||||||
|
int svr4_sys_time __P((struct proc *, struct svr4_sys_time_args *));
|
||||||
|
int svr4_sys_mknod __P((struct proc *, struct svr4_sys_mknod_args *));
|
||||||
|
int svr4_sys_break __P((struct proc *, struct svr4_sys_break_args *));
|
||||||
|
int svr4_sys_stat __P((struct proc *, struct svr4_sys_stat_args *));
|
||||||
|
int svr4_sys_alarm __P((struct proc *, struct svr4_sys_alarm_args *));
|
||||||
|
int svr4_sys_fstat __P((struct proc *, struct svr4_sys_fstat_args *));
|
||||||
|
int svr4_sys_pause __P((struct proc *, struct svr4_sys_pause_args *));
|
||||||
|
int svr4_sys_utime __P((struct proc *, struct svr4_sys_utime_args *));
|
||||||
|
int svr4_sys_access __P((struct proc *, struct svr4_sys_access_args *));
|
||||||
|
int svr4_sys_nice __P((struct proc *, struct svr4_sys_nice_args *));
|
||||||
|
int svr4_sys_kill __P((struct proc *, struct svr4_sys_kill_args *));
|
||||||
|
int svr4_sys_pgrpsys __P((struct proc *, struct svr4_sys_pgrpsys_args *));
|
||||||
|
int svr4_sys_times __P((struct proc *, struct svr4_sys_times_args *));
|
||||||
|
int svr4_sys_signal __P((struct proc *, struct svr4_sys_signal_args *));
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int svr4_sys_msgsys __P((struct proc *, struct svr4_sys_msgsys_args *));
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
int svr4_sys_sysarch __P((struct proc *, struct svr4_sys_sysarch_args *));
|
||||||
|
int svr4_sys_ioctl __P((struct proc *, struct svr4_sys_ioctl_args *));
|
||||||
|
int svr4_sys_utssys __P((struct proc *, struct svr4_sys_utssys_args *));
|
||||||
|
int svr4_sys_execve __P((struct proc *, struct svr4_sys_execve_args *));
|
||||||
|
int svr4_sys_fcntl __P((struct proc *, struct svr4_sys_fcntl_args *));
|
||||||
|
int svr4_sys_ulimit __P((struct proc *, struct svr4_sys_ulimit_args *));
|
||||||
|
int svr4_sys_getdents __P((struct proc *, struct svr4_sys_getdents_args *));
|
||||||
|
int svr4_sys_getmsg __P((struct proc *, struct svr4_sys_getmsg_args *));
|
||||||
|
int svr4_sys_putmsg __P((struct proc *, struct svr4_sys_putmsg_args *));
|
||||||
|
int svr4_sys_poll __P((struct proc *, struct svr4_sys_poll_args *));
|
||||||
|
int svr4_sys_lstat __P((struct proc *, struct svr4_sys_lstat_args *));
|
||||||
|
int svr4_sys_sigprocmask __P((struct proc *, struct svr4_sys_sigprocmask_args *));
|
||||||
|
int svr4_sys_sigsuspend __P((struct proc *, struct svr4_sys_sigsuspend_args *));
|
||||||
|
int svr4_sys_sigaltstack __P((struct proc *, struct svr4_sys_sigaltstack_args *));
|
||||||
|
int svr4_sys_sigaction __P((struct proc *, struct svr4_sys_sigaction_args *));
|
||||||
|
int svr4_sys_sigpending __P((struct proc *, struct svr4_sys_sigpending_args *));
|
||||||
|
int svr4_sys_context __P((struct proc *, struct svr4_sys_context_args *));
|
||||||
|
int svr4_sys_statvfs __P((struct proc *, struct svr4_sys_statvfs_args *));
|
||||||
|
int svr4_sys_fstatvfs __P((struct proc *, struct svr4_sys_fstatvfs_args *));
|
||||||
|
int svr4_sys_waitsys __P((struct proc *, struct svr4_sys_waitsys_args *));
|
||||||
|
int svr4_sys_hrtsys __P((struct proc *, struct svr4_sys_hrtsys_args *));
|
||||||
|
int svr4_sys_pathconf __P((struct proc *, struct svr4_sys_pathconf_args *));
|
||||||
|
int svr4_sys_mmap __P((struct proc *, struct svr4_sys_mmap_args *));
|
||||||
|
int svr4_sys_fpathconf __P((struct proc *, struct svr4_sys_fpathconf_args *));
|
||||||
|
int svr4_sys_xstat __P((struct proc *, struct svr4_sys_xstat_args *));
|
||||||
|
int svr4_sys_lxstat __P((struct proc *, struct svr4_sys_lxstat_args *));
|
||||||
|
int svr4_sys_fxstat __P((struct proc *, struct svr4_sys_fxstat_args *));
|
||||||
|
int svr4_sys_xmknod __P((struct proc *, struct svr4_sys_xmknod_args *));
|
||||||
|
int svr4_sys_setrlimit __P((struct proc *, struct svr4_sys_setrlimit_args *));
|
||||||
|
int svr4_sys_getrlimit __P((struct proc *, struct svr4_sys_getrlimit_args *));
|
||||||
|
int svr4_sys_memcntl __P((struct proc *, struct svr4_sys_memcntl_args *));
|
||||||
|
int svr4_sys_uname __P((struct proc *, struct svr4_sys_uname_args *));
|
||||||
|
int svr4_sys_sysconfig __P((struct proc *, struct svr4_sys_sysconfig_args *));
|
||||||
|
int svr4_sys_systeminfo __P((struct proc *, struct svr4_sys_systeminfo_args *));
|
||||||
|
int svr4_sys_fchroot __P((struct proc *, struct svr4_sys_fchroot_args *));
|
||||||
|
int svr4_sys_utimes __P((struct proc *, struct svr4_sys_utimes_args *));
|
||||||
|
int svr4_sys_vhangup __P((struct proc *, struct svr4_sys_vhangup_args *));
|
||||||
|
int svr4_sys_gettimeofday __P((struct proc *, struct svr4_sys_gettimeofday_args *));
|
||||||
|
int svr4_sys_llseek __P((struct proc *, struct svr4_sys_llseek_args *));
|
||||||
|
int svr4_sys_acl __P((struct proc *, struct svr4_sys_acl_args *));
|
||||||
|
int svr4_sys_auditsys __P((struct proc *, struct svr4_sys_auditsys_args *));
|
||||||
|
int svr4_sys_facl __P((struct proc *, struct svr4_sys_facl_args *));
|
||||||
|
int svr4_sys_resolvepath __P((struct proc *, struct svr4_sys_resolvepath_args *));
|
||||||
|
int svr4_sys_getdents64 __P((struct proc *, struct svr4_sys_getdents64_args *));
|
||||||
|
int svr4_sys_mmap64 __P((struct proc *, struct svr4_sys_mmap64_args *));
|
||||||
|
int svr4_sys_stat64 __P((struct proc *, struct svr4_sys_stat64_args *));
|
||||||
|
int svr4_sys_lstat64 __P((struct proc *, struct svr4_sys_lstat64_args *));
|
||||||
|
int svr4_sys_fstat64 __P((struct proc *, struct svr4_sys_fstat64_args *));
|
||||||
|
int svr4_sys_statvfs64 __P((struct proc *, struct svr4_sys_statvfs64_args *));
|
||||||
|
int svr4_sys_fstatvfs64 __P((struct proc *, struct svr4_sys_fstatvfs64_args *));
|
||||||
|
int svr4_sys_setrlimit64 __P((struct proc *, struct svr4_sys_setrlimit64_args *));
|
||||||
|
int svr4_sys_getrlimit64 __P((struct proc *, struct svr4_sys_getrlimit64_args *));
|
||||||
|
int svr4_sys_creat64 __P((struct proc *, struct svr4_sys_creat64_args *));
|
||||||
|
int svr4_sys_open64 __P((struct proc *, struct svr4_sys_open64_args *));
|
||||||
|
int svr4_sys_socket __P((struct proc *, struct svr4_sys_socket_args *));
|
||||||
|
int svr4_sys_recv __P((struct proc *, struct svr4_sys_recv_args *));
|
||||||
|
int svr4_sys_send __P((struct proc *, struct svr4_sys_send_args *));
|
||||||
|
int svr4_sys_sendto __P((struct proc *, struct svr4_sys_sendto_args *));
|
||||||
|
|
||||||
|
#ifdef COMPAT_43
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* COMPAT_43 */
|
||||||
|
|
||||||
|
#undef PAD_
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SYSPROTO_H_ */
|
311
sys/compat/svr4/svr4_resource.c
Normal file
311
sys/compat/svr4/svr4_resource.c
Normal file
|
@ -0,0 +1,311 @@
|
||||||
|
/* Derived from:
|
||||||
|
* $NetBSD: svr4_resource.c,v 1.3 1998/12/13 18:00:52 christos Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Original copyright:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Christos Zoulas.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions of this software have been derived from software contributed
|
||||||
|
* to the FreeBSD Project by Mark Newton.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mark Newton
|
||||||
|
* 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. 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/file.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/resourcevar.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_resource.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
|
||||||
|
static __inline int svr4_to_native_rl __P((int));
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
svr4_to_native_rl(rl)
|
||||||
|
int rl;
|
||||||
|
{
|
||||||
|
switch (rl) {
|
||||||
|
case SVR4_RLIMIT_CPU:
|
||||||
|
return RLIMIT_CPU;
|
||||||
|
case SVR4_RLIMIT_FSIZE:
|
||||||
|
return RLIMIT_FSIZE;
|
||||||
|
case SVR4_RLIMIT_DATA:
|
||||||
|
return RLIMIT_DATA;
|
||||||
|
case SVR4_RLIMIT_STACK:
|
||||||
|
return RLIMIT_STACK;
|
||||||
|
case SVR4_RLIMIT_CORE:
|
||||||
|
return RLIMIT_CORE;
|
||||||
|
case SVR4_RLIMIT_NOFILE:
|
||||||
|
return RLIMIT_NOFILE;
|
||||||
|
case SVR4_RLIMIT_VMEM:
|
||||||
|
return RLIMIT_RSS;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the resource limit fits within the BSD range and it is not
|
||||||
|
* one of the magic SVR4 limit values
|
||||||
|
*/
|
||||||
|
#define OKLIMIT(l) (((int32_t)(l)) >= 0 && ((int32_t)(l)) < 0x7fffffff && \
|
||||||
|
((svr4_rlim_t)(l)) != SVR4_RLIM_INFINITY && \
|
||||||
|
((svr4_rlim_t)(l)) != SVR4_RLIM_SAVED_CUR && \
|
||||||
|
((svr4_rlim_t)(l)) != SVR4_RLIM_SAVED_MAX)
|
||||||
|
|
||||||
|
#define OKLIMIT64(l) (((rlim_t)(l)) >= 0 && ((rlim_t)(l)) < RLIM_INFINITY && \
|
||||||
|
((svr4_rlim64_t)(l)) != SVR4_RLIM64_INFINITY && \
|
||||||
|
((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_CUR && \
|
||||||
|
((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_MAX)
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_getrlimit(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_getrlimit_args *uap;
|
||||||
|
{
|
||||||
|
int rl = svr4_to_native_rl(SCARG(uap, which));
|
||||||
|
struct rlimit blim;
|
||||||
|
struct svr4_rlimit slim;
|
||||||
|
|
||||||
|
if (rl == -1)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
blim = p->p_rlimit[rl];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our infinity, is their maxfiles.
|
||||||
|
*/
|
||||||
|
if (rl == RLIMIT_NOFILE && blim.rlim_max == RLIM_INFINITY)
|
||||||
|
blim.rlim_max = maxfiles;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the limit can be be represented, it is returned.
|
||||||
|
* Otherwise, if rlim_cur == rlim_max, return RLIM_SAVED_MAX
|
||||||
|
* else return RLIM_SAVED_CUR
|
||||||
|
*/
|
||||||
|
if (blim.rlim_max == RLIM_INFINITY)
|
||||||
|
slim.rlim_max = SVR4_RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT(blim.rlim_max))
|
||||||
|
slim.rlim_max = (svr4_rlim_t) blim.rlim_max;
|
||||||
|
else
|
||||||
|
slim.rlim_max = SVR4_RLIM_SAVED_MAX;
|
||||||
|
|
||||||
|
if (blim.rlim_cur == RLIM_INFINITY)
|
||||||
|
slim.rlim_cur = SVR4_RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT(blim.rlim_cur))
|
||||||
|
slim.rlim_cur = (svr4_rlim_t) blim.rlim_cur;
|
||||||
|
else if (blim.rlim_max == blim.rlim_cur)
|
||||||
|
slim.rlim_cur = SVR4_RLIM_SAVED_MAX;
|
||||||
|
else
|
||||||
|
slim.rlim_cur = SVR4_RLIM_SAVED_CUR;
|
||||||
|
|
||||||
|
return copyout(&slim, SCARG(uap, rlp), sizeof(*SCARG(uap, rlp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_setrlimit(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_setrlimit_args *uap;
|
||||||
|
{
|
||||||
|
int rl = svr4_to_native_rl(SCARG(uap, which));
|
||||||
|
struct rlimit blim, *limp;
|
||||||
|
struct svr4_rlimit slim;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (rl == -1)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
limp = &p->p_rlimit[rl];
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, rlp), &slim, sizeof(slim))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if the limit is SVR4_RLIM_INFINITY, then we set it to our
|
||||||
|
* unlimited.
|
||||||
|
* We should also: If it is SVR4_RLIM_SAVED_MAX, we should set the
|
||||||
|
* new limit to the corresponding saved hard limit, and if
|
||||||
|
* it is equal to SVR4_RLIM_SAVED_CUR, we should set it to the
|
||||||
|
* corresponding saved soft limit.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if (slim.rlim_max == SVR4_RLIM_INFINITY)
|
||||||
|
blim.rlim_max = RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT(slim.rlim_max))
|
||||||
|
blim.rlim_max = (rlim_t) slim.rlim_max;
|
||||||
|
else if (slim.rlim_max == SVR4_RLIM_SAVED_MAX)
|
||||||
|
blim.rlim_max = limp->rlim_max;
|
||||||
|
else if (slim.rlim_max == SVR4_RLIM_SAVED_CUR)
|
||||||
|
blim.rlim_max = limp->rlim_cur;
|
||||||
|
|
||||||
|
if (slim.rlim_cur == SVR4_RLIM_INFINITY)
|
||||||
|
blim.rlim_cur = RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT(slim.rlim_cur))
|
||||||
|
blim.rlim_cur = (rlim_t) slim.rlim_cur;
|
||||||
|
else if (slim.rlim_cur == SVR4_RLIM_SAVED_MAX)
|
||||||
|
blim.rlim_cur = limp->rlim_max;
|
||||||
|
else if (slim.rlim_cur == SVR4_RLIM_SAVED_CUR)
|
||||||
|
blim.rlim_cur = limp->rlim_cur;
|
||||||
|
|
||||||
|
return dosetrlimit(p, rl, &blim);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_getrlimit64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_getrlimit64_args *uap;
|
||||||
|
{
|
||||||
|
int rl = svr4_to_native_rl(SCARG(uap, which));
|
||||||
|
struct rlimit blim;
|
||||||
|
struct svr4_rlimit64 slim;
|
||||||
|
|
||||||
|
if (rl == -1)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
blim = p->p_rlimit[rl];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our infinity, is their maxfiles.
|
||||||
|
*/
|
||||||
|
if (rl == RLIMIT_NOFILE && blim.rlim_max == RLIM_INFINITY)
|
||||||
|
blim.rlim_max = maxfiles;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the limit can be be represented, it is returned.
|
||||||
|
* Otherwise, if rlim_cur == rlim_max, return SVR4_RLIM_SAVED_MAX
|
||||||
|
* else return SVR4_RLIM_SAVED_CUR
|
||||||
|
*/
|
||||||
|
if (blim.rlim_max == RLIM_INFINITY)
|
||||||
|
slim.rlim_max = SVR4_RLIM64_INFINITY;
|
||||||
|
else if (OKLIMIT64(blim.rlim_max))
|
||||||
|
slim.rlim_max = (svr4_rlim64_t) blim.rlim_max;
|
||||||
|
else
|
||||||
|
slim.rlim_max = SVR4_RLIM64_SAVED_MAX;
|
||||||
|
|
||||||
|
if (blim.rlim_cur == RLIM_INFINITY)
|
||||||
|
slim.rlim_cur = SVR4_RLIM64_INFINITY;
|
||||||
|
else if (OKLIMIT64(blim.rlim_cur))
|
||||||
|
slim.rlim_cur = (svr4_rlim64_t) blim.rlim_cur;
|
||||||
|
else if (blim.rlim_max == blim.rlim_cur)
|
||||||
|
slim.rlim_cur = SVR4_RLIM64_SAVED_MAX;
|
||||||
|
else
|
||||||
|
slim.rlim_cur = SVR4_RLIM64_SAVED_CUR;
|
||||||
|
|
||||||
|
return copyout(&slim, SCARG(uap, rlp), sizeof(*SCARG(uap, rlp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_setrlimit64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_setrlimit64_args *uap;
|
||||||
|
{
|
||||||
|
int rl = svr4_to_native_rl(SCARG(uap, which));
|
||||||
|
struct rlimit blim, *limp;
|
||||||
|
struct svr4_rlimit64 slim;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (rl == -1)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
limp = &p->p_rlimit[rl];
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, rlp), &slim, sizeof(slim))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if the limit is SVR4_RLIM64_INFINITY, then we set it to our
|
||||||
|
* unlimited.
|
||||||
|
* We should also: If it is SVR4_RLIM64_SAVED_MAX, we should set the
|
||||||
|
* new limit to the corresponding saved hard limit, and if
|
||||||
|
* it is equal to SVR4_RLIM64_SAVED_CUR, we should set it to the
|
||||||
|
* corresponding saved soft limit.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if (slim.rlim_max == SVR4_RLIM64_INFINITY)
|
||||||
|
blim.rlim_max = RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT64(slim.rlim_max))
|
||||||
|
blim.rlim_max = (rlim_t) slim.rlim_max;
|
||||||
|
else if (slim.rlim_max == SVR4_RLIM64_SAVED_MAX)
|
||||||
|
blim.rlim_max = limp->rlim_max;
|
||||||
|
else if (slim.rlim_max == SVR4_RLIM64_SAVED_CUR)
|
||||||
|
blim.rlim_max = limp->rlim_cur;
|
||||||
|
|
||||||
|
if (slim.rlim_cur == SVR4_RLIM64_INFINITY)
|
||||||
|
blim.rlim_cur = RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT64(slim.rlim_cur))
|
||||||
|
blim.rlim_cur = (rlim_t) slim.rlim_cur;
|
||||||
|
else if (slim.rlim_cur == SVR4_RLIM64_SAVED_MAX)
|
||||||
|
blim.rlim_cur = limp->rlim_max;
|
||||||
|
else if (slim.rlim_cur == SVR4_RLIM64_SAVED_CUR)
|
||||||
|
blim.rlim_cur = limp->rlim_cur;
|
||||||
|
|
||||||
|
return dosetrlimit(p, rl, &blim);
|
||||||
|
}
|
107
sys/compat/svr4/svr4_resource.h
Normal file
107
sys/compat/svr4/svr4_resource.h
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
/* Derived from:
|
||||||
|
* $NetBSD: svr4_resource.h,v 1.1 1998/11/28 21:53:02 christos Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Original copyright:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Christos Zoulas.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions of this code derived from software contributed to the
|
||||||
|
* FreeBSD Project by Mark Newton.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mark Newton
|
||||||
|
* 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. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_RESOURCE_H_
|
||||||
|
#define _SVR4_RESOURCE_H_
|
||||||
|
|
||||||
|
#define SVR4_RLIMIT_CPU 0
|
||||||
|
#define SVR4_RLIMIT_FSIZE 1
|
||||||
|
#define SVR4_RLIMIT_DATA 2
|
||||||
|
#define SVR4_RLIMIT_STACK 3
|
||||||
|
#define SVR4_RLIMIT_CORE 4
|
||||||
|
#define SVR4_RLIMIT_NOFILE 5
|
||||||
|
#define SVR4_RLIMIT_VMEM 6
|
||||||
|
#define SVR4_RLIMIT_AS SVR4_RLIMIT_VMEM
|
||||||
|
#define SVR4_RLIM_NLIMITS 7
|
||||||
|
|
||||||
|
typedef u_int32_t svr4_rlim_t;
|
||||||
|
|
||||||
|
#define SVR4_RLIM_SAVED_CUR 0x7ffffffd
|
||||||
|
#define SVR4_RLIM_SAVED_MAX 0x7ffffffe
|
||||||
|
#define SVR4_RLIM_INFINITY 0x7fffffff
|
||||||
|
|
||||||
|
struct svr4_rlimit {
|
||||||
|
svr4_rlim_t rlim_cur;
|
||||||
|
svr4_rlim_t rlim_max;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef u_int64_t svr4_rlim64_t;
|
||||||
|
|
||||||
|
#define SVR4_RLIM64_SAVED_CUR ((svr4_rlim64_t) -1)
|
||||||
|
#define SVR4_RLIM64_SAVED_MAX ((svr4_rlim64_t) -2)
|
||||||
|
#define SVR4_RLIM64_INFINITY ((svr4_rlim64_t) -3)
|
||||||
|
|
||||||
|
struct svr4_rlimit64 {
|
||||||
|
svr4_rlim64_t rlim_cur;
|
||||||
|
svr4_rlim64_t rlim_max;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_SVR4_RESOURCE_H_ */
|
109
sys/compat/svr4/svr4_siginfo.h
Normal file
109
sys/compat/svr4/svr4_siginfo.h
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SIGINFO_H_
|
||||||
|
#define _SVR4_SIGINFO_H_
|
||||||
|
|
||||||
|
#define SVR4_ILL_ILLOPC 1
|
||||||
|
#define SVR4_ILL_ILLOPN 2
|
||||||
|
#define SVR4_ILL_ILLADR 3
|
||||||
|
#define SVR4_ILL_ILLTRP 4
|
||||||
|
#define SVR4_ILL_PRVOPC 5
|
||||||
|
#define SVR4_ILL_PRVREG 6
|
||||||
|
#define SVR4_ILL_COPROC 7
|
||||||
|
#define SVR4_ILL_BADSTK 8
|
||||||
|
|
||||||
|
#define SVR4_FPE_INTDIV 1
|
||||||
|
#define SVR4_FPE_INTOVF 2
|
||||||
|
#define SVR4_FPE_FLTDIV 3
|
||||||
|
#define SVR4_FPE_FLTOVF 4
|
||||||
|
#define SVR4_FPE_FLTUND 5
|
||||||
|
#define SVR4_FPE_FLTRES 6
|
||||||
|
#define SVR4_FPE_FLTINV 7
|
||||||
|
#define SVR4_FPE_FLTSUB 8
|
||||||
|
|
||||||
|
#define SVR4_SEGV_MAPERR 1
|
||||||
|
#define SVR4_SEGV_ACCERR 2
|
||||||
|
|
||||||
|
#define SVR4_BUS_ADRALN 1
|
||||||
|
#define SVR4_BUS_ADRERR 2
|
||||||
|
#define SVR4_BUS_OBJERR 3
|
||||||
|
|
||||||
|
#define SVR4_TRAP_BRKPT 1
|
||||||
|
#define SVR4_TRAP_TRACE 2
|
||||||
|
|
||||||
|
#define SVR4_POLL_IN 1
|
||||||
|
#define SVR4_POLL_OUT 2
|
||||||
|
#define SVR4_POLL_MSG 3
|
||||||
|
#define SVR4_POLL_ERR 4
|
||||||
|
#define SVR4_POLL_PRI 5
|
||||||
|
|
||||||
|
#define SVR4_CLD_EXITED 1
|
||||||
|
#define SVR4_CLD_KILLED 2
|
||||||
|
#define SVR4_CLD_DUMPED 3
|
||||||
|
#define SVR4_CLD_TRAPPED 4
|
||||||
|
#define SVR4_CLD_STOPPED 5
|
||||||
|
#define SVR4_CLD_CONTINUED 6
|
||||||
|
|
||||||
|
#define SVR4_EMT_TAGOVF 1
|
||||||
|
|
||||||
|
typedef union svr4_siginfo {
|
||||||
|
char si_pad[128]; /* Total size; for future expansion */
|
||||||
|
struct {
|
||||||
|
int _signo;
|
||||||
|
int _code;
|
||||||
|
int _errno;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
svr4_pid_t _pid;
|
||||||
|
svr4_clock_t _utime;
|
||||||
|
int _status;
|
||||||
|
svr4_clock_t _stime;
|
||||||
|
} _child;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
caddr_t _addr;
|
||||||
|
int _trap;
|
||||||
|
} _fault;
|
||||||
|
} _reason;
|
||||||
|
} _info;
|
||||||
|
} svr4_siginfo_t;
|
||||||
|
|
||||||
|
#define si_signo _info._signo
|
||||||
|
#define si_code _info._code
|
||||||
|
#define si_errno _info._errno
|
||||||
|
|
||||||
|
#define si_pid _info._reason._child._pid
|
||||||
|
#define si_stime _info._reason._child._stime
|
||||||
|
#define si_status _info._reason._child._status
|
||||||
|
#define si_utime _info._reason._child._utime
|
||||||
|
|
||||||
|
#define si_addr _info._reason._fault._addr
|
||||||
|
#define si_trap _info._reason._fault._trap
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SIGINFO_H_ */
|
623
sys/compat/svr4/svr4_signal.c
Normal file
623
sys/compat/svr4/svr4_signal.c
Normal file
|
@ -0,0 +1,623 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/filedesc.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_ucontext.h>
|
||||||
|
|
||||||
|
#define sigemptyset(s) memset((s), 0, sizeof(*(s)))
|
||||||
|
#define sigismember(s, n) (*(s) & sigmask(n))
|
||||||
|
#define sigaddset(s, n) (*(s) |= sigmask(n))
|
||||||
|
|
||||||
|
#define svr4_sigmask(n) (1 << (((n) - 1) & 31))
|
||||||
|
#define svr4_sigword(n) (((n) - 1) >> 5)
|
||||||
|
#define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s)))
|
||||||
|
#define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n))
|
||||||
|
#define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n))
|
||||||
|
|
||||||
|
static __inline void svr4_sigfillset __P((svr4_sigset_t *));
|
||||||
|
void svr4_to_bsd_sigaction __P((const struct svr4_sigaction *,
|
||||||
|
struct sigaction *));
|
||||||
|
void bsd_to_svr4_sigaction __P((const struct sigaction *,
|
||||||
|
struct svr4_sigaction *));
|
||||||
|
|
||||||
|
int bsd_to_svr4_sig[] = {
|
||||||
|
0,
|
||||||
|
SVR4_SIGHUP,
|
||||||
|
SVR4_SIGINT,
|
||||||
|
SVR4_SIGQUIT,
|
||||||
|
SVR4_SIGILL,
|
||||||
|
SVR4_SIGTRAP,
|
||||||
|
SVR4_SIGABRT,
|
||||||
|
SVR4_SIGEMT,
|
||||||
|
SVR4_SIGFPE,
|
||||||
|
SVR4_SIGKILL,
|
||||||
|
SVR4_SIGBUS,
|
||||||
|
SVR4_SIGSEGV,
|
||||||
|
SVR4_SIGSYS,
|
||||||
|
SVR4_SIGPIPE,
|
||||||
|
SVR4_SIGALRM,
|
||||||
|
SVR4_SIGTERM,
|
||||||
|
SVR4_SIGURG,
|
||||||
|
SVR4_SIGSTOP,
|
||||||
|
SVR4_SIGTSTP,
|
||||||
|
SVR4_SIGCONT,
|
||||||
|
SVR4_SIGCHLD,
|
||||||
|
SVR4_SIGTTIN,
|
||||||
|
SVR4_SIGTTOU,
|
||||||
|
SVR4_SIGIO,
|
||||||
|
SVR4_SIGXCPU,
|
||||||
|
SVR4_SIGXFSZ,
|
||||||
|
SVR4_SIGVTALRM,
|
||||||
|
SVR4_SIGPROF,
|
||||||
|
SVR4_SIGWINCH,
|
||||||
|
0, /* SIGINFO */
|
||||||
|
SVR4_SIGUSR1,
|
||||||
|
SVR4_SIGUSR2,
|
||||||
|
};
|
||||||
|
|
||||||
|
int svr4_to_bsd_sig[] = {
|
||||||
|
0,
|
||||||
|
SIGHUP,
|
||||||
|
SIGINT,
|
||||||
|
SIGQUIT,
|
||||||
|
SIGILL,
|
||||||
|
SIGTRAP,
|
||||||
|
SIGABRT,
|
||||||
|
SIGEMT,
|
||||||
|
SIGFPE,
|
||||||
|
SIGKILL,
|
||||||
|
SIGBUS,
|
||||||
|
SIGSEGV,
|
||||||
|
SIGSYS,
|
||||||
|
SIGPIPE,
|
||||||
|
SIGALRM,
|
||||||
|
SIGTERM,
|
||||||
|
SIGUSR1,
|
||||||
|
SIGUSR2,
|
||||||
|
SIGCHLD,
|
||||||
|
0, /* XXX NetBSD uses SIGPWR here, but we don't seem to have one */
|
||||||
|
SIGWINCH,
|
||||||
|
SIGURG,
|
||||||
|
SIGIO,
|
||||||
|
SIGSTOP,
|
||||||
|
SIGTSTP,
|
||||||
|
SIGCONT,
|
||||||
|
SIGTTIN,
|
||||||
|
SIGTTOU,
|
||||||
|
SIGVTALRM,
|
||||||
|
SIGPROF,
|
||||||
|
SIGXCPU,
|
||||||
|
SIGXFSZ,
|
||||||
|
};
|
||||||
|
|
||||||
|
static __inline void
|
||||||
|
svr4_sigfillset(s)
|
||||||
|
svr4_sigset_t *s;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
svr4_sigemptyset(s);
|
||||||
|
for (i = 1; i < SVR4_NSIG; i++)
|
||||||
|
svr4_sigaddset(s, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
svr4_to_bsd_sigset(sss, bss)
|
||||||
|
const svr4_sigset_t *sss;
|
||||||
|
sigset_t *bss;
|
||||||
|
{
|
||||||
|
int i, newsig;
|
||||||
|
|
||||||
|
sigemptyset(bss);
|
||||||
|
for (i = 1; i < SVR4_NSIG; i++) {
|
||||||
|
if (svr4_sigismember(sss, i)) {
|
||||||
|
newsig = svr4_to_bsd_sig[i];
|
||||||
|
if (newsig)
|
||||||
|
sigaddset(bss, newsig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
bsd_to_svr4_sigset(bss, sss)
|
||||||
|
const sigset_t *bss;
|
||||||
|
svr4_sigset_t *sss;
|
||||||
|
{
|
||||||
|
int i, newsig;
|
||||||
|
|
||||||
|
svr4_sigemptyset(sss);
|
||||||
|
for (i = 1; i < NSIG; i++) {
|
||||||
|
if (sigismember(bss, i)) {
|
||||||
|
newsig = bsd_to_svr4_sig[i];
|
||||||
|
if (newsig)
|
||||||
|
svr4_sigaddset(sss, newsig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: Only a subset of the flags is currently implemented.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
svr4_to_bsd_sigaction(ssa, bsa)
|
||||||
|
const struct svr4_sigaction *ssa;
|
||||||
|
struct sigaction *bsa;
|
||||||
|
{
|
||||||
|
|
||||||
|
bsa->sa_handler = (sig_t) ssa->sa_handler;
|
||||||
|
svr4_to_bsd_sigset(&ssa->sa_mask, &bsa->sa_mask);
|
||||||
|
bsa->sa_flags = 0;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_ONSTACK) != 0)
|
||||||
|
bsa->sa_flags |= SA_ONSTACK;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_RESETHAND) != 0)
|
||||||
|
bsa->sa_flags |= SA_RESETHAND;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_RESTART) != 0)
|
||||||
|
bsa->sa_flags |= SA_RESTART;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_SIGINFO) != 0)
|
||||||
|
DPRINTF(("svr4_to_bsd_sigaction: SA_SIGINFO ignored\n"));
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_NOCLDSTOP) != 0)
|
||||||
|
bsa->sa_flags |= SA_NOCLDSTOP;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_NODEFER) != 0)
|
||||||
|
bsa->sa_flags |= SA_NODEFER;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_NOCLDWAIT) != 0)
|
||||||
|
bsa->sa_flags |= SA_NOCLDWAIT;
|
||||||
|
if ((ssa->sa_flags & ~SVR4_SA_ALLBITS) != 0)
|
||||||
|
DPRINTF(("svr4_to_bsd_sigaction: extra bits ignored\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bsd_to_svr4_sigaction(bsa, ssa)
|
||||||
|
const struct sigaction *bsa;
|
||||||
|
struct svr4_sigaction *ssa;
|
||||||
|
{
|
||||||
|
|
||||||
|
ssa->sa_handler = (svr4_sig_t) bsa->sa_handler;
|
||||||
|
bsd_to_svr4_sigset(&bsa->sa_mask, &ssa->sa_mask);
|
||||||
|
ssa->sa_flags = 0;
|
||||||
|
if ((bsa->sa_flags & SA_ONSTACK) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_ONSTACK;
|
||||||
|
if ((bsa->sa_flags & SA_RESETHAND) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_RESETHAND;
|
||||||
|
if ((bsa->sa_flags & SA_RESTART) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_RESTART;
|
||||||
|
if ((bsa->sa_flags & SA_NODEFER) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_NODEFER;
|
||||||
|
if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_NOCLDSTOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
svr4_to_bsd_sigaltstack(sss, bss)
|
||||||
|
const struct svr4_sigaltstack *sss;
|
||||||
|
struct sigaltstack *bss;
|
||||||
|
{
|
||||||
|
|
||||||
|
bss->ss_sp = sss->ss_sp;
|
||||||
|
bss->ss_size = sss->ss_size;
|
||||||
|
bss->ss_flags = 0;
|
||||||
|
if ((sss->ss_flags & SVR4_SS_DISABLE) != 0)
|
||||||
|
bss->ss_flags |= SS_DISABLE;
|
||||||
|
if ((sss->ss_flags & SVR4_SS_ONSTACK) != 0)
|
||||||
|
bss->ss_flags |= SS_ONSTACK;
|
||||||
|
if ((sss->ss_flags & ~SVR4_SS_ALLBITS) != 0)
|
||||||
|
/*XXX*/ uprintf("svr4_to_bsd_sigaltstack: extra bits ignored\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bsd_to_svr4_sigaltstack(bss, sss)
|
||||||
|
const struct sigaltstack *bss;
|
||||||
|
struct svr4_sigaltstack *sss;
|
||||||
|
{
|
||||||
|
|
||||||
|
sss->ss_sp = bss->ss_sp;
|
||||||
|
sss->ss_size = bss->ss_size;
|
||||||
|
sss->ss_flags = 0;
|
||||||
|
if ((bss->ss_flags & SS_DISABLE) != 0)
|
||||||
|
sss->ss_flags |= SVR4_SS_DISABLE;
|
||||||
|
if ((bss->ss_flags & SS_ONSTACK) != 0)
|
||||||
|
sss->ss_flags |= SVR4_SS_ONSTACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigaction(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_sigaction_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_sigaction *nisa, *oisa, tmpisa;
|
||||||
|
struct sigaction *nbsa, *obsa, tmpbsa;
|
||||||
|
struct sigaction_args sa;
|
||||||
|
caddr_t sg;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
sg = stackgap_init();
|
||||||
|
nisa = SCARG(uap, nsa);
|
||||||
|
oisa = SCARG(uap, osa);
|
||||||
|
|
||||||
|
if (oisa != NULL)
|
||||||
|
obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
else
|
||||||
|
obsa = NULL;
|
||||||
|
|
||||||
|
if (nisa != NULL) {
|
||||||
|
nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
if ((error = copyin(nisa, &tmpisa, sizeof(tmpisa))) != 0)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_sigaction(&tmpisa, &tmpbsa);
|
||||||
|
if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
|
||||||
|
return error;
|
||||||
|
} else
|
||||||
|
nbsa = NULL;
|
||||||
|
|
||||||
|
SCARG(&sa, signum) = svr4_to_bsd_sig[SCARG(uap, signum)];
|
||||||
|
SCARG(&sa, nsa) = nbsa;
|
||||||
|
SCARG(&sa, osa) = obsa;
|
||||||
|
|
||||||
|
if ((error = sigaction(p, &sa)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (oisa != NULL) {
|
||||||
|
if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_sigaction(&tmpbsa, &tmpisa);
|
||||||
|
if ((error = copyout(&tmpisa, oisa, sizeof(tmpisa))) != 0)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigaltstack(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_sigaltstack_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_sigaltstack *nsss, *osss, tmpsss;
|
||||||
|
struct sigaltstack *nbss, *obss, tmpbss;
|
||||||
|
struct sigaltstack_args sa;
|
||||||
|
caddr_t sg;
|
||||||
|
int error, *retval;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
sg = stackgap_init();
|
||||||
|
nsss = SCARG(uap, nss);
|
||||||
|
osss = SCARG(uap, oss);
|
||||||
|
|
||||||
|
if (osss != NULL)
|
||||||
|
obss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
|
||||||
|
else
|
||||||
|
obss = NULL;
|
||||||
|
|
||||||
|
if (nsss != NULL) {
|
||||||
|
nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
|
||||||
|
if ((error = copyin(nsss, &tmpsss, sizeof(tmpsss))) != 0)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_sigaltstack(&tmpsss, &tmpbss);
|
||||||
|
if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0)
|
||||||
|
return error;
|
||||||
|
} else
|
||||||
|
nbss = NULL;
|
||||||
|
|
||||||
|
SCARG(&sa, nss) = nbss;
|
||||||
|
SCARG(&sa, oss) = obss;
|
||||||
|
|
||||||
|
if ((error = sigaltstack(p, &sa)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (obss != NULL) {
|
||||||
|
if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_sigaltstack(&tmpbss, &tmpsss);
|
||||||
|
if ((error = copyout(&tmpsss, osss, sizeof(tmpsss))) != 0)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stolen from the ibcs2 one
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
svr4_sys_signal(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_signal_args *uap;
|
||||||
|
{
|
||||||
|
int signum = svr4_to_bsd_sig[SVR4_SIGNO(SCARG(uap, signum))];
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
if (signum <= 0 || signum >= SVR4_NSIG)
|
||||||
|
return (EINVAL);
|
||||||
|
|
||||||
|
switch (SVR4_SIGCALL(SCARG(uap, signum))) {
|
||||||
|
case SVR4_SIGDEFER_MASK:
|
||||||
|
if (SCARG(uap, handler) == SVR4_SIG_HOLD)
|
||||||
|
goto sighold;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
|
case SVR4_SIGNAL_MASK:
|
||||||
|
{
|
||||||
|
struct sigaction_args sa_args;
|
||||||
|
struct sigaction *nbsa, *obsa, sa;
|
||||||
|
|
||||||
|
nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
SCARG(&sa_args, signum) = signum;
|
||||||
|
SCARG(&sa_args, nsa) = nbsa;
|
||||||
|
SCARG(&sa_args, osa) = obsa;
|
||||||
|
|
||||||
|
sa.sa_handler = (sig_t) SCARG(uap, handler);
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_flags = 0;
|
||||||
|
|
||||||
|
if (signum != SIGALRM)
|
||||||
|
sa.sa_flags = SA_RESTART;
|
||||||
|
|
||||||
|
if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
|
||||||
|
return error;
|
||||||
|
if ((error = sigaction(p, &sa_args)) != 0) {
|
||||||
|
DPRINTF(("signal: sigaction failed: %d\n",
|
||||||
|
error));
|
||||||
|
*retval = (int)SVR4_SIG_ERR;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
|
||||||
|
return error;
|
||||||
|
*retval = (int)sa.sa_handler;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIGHOLD_MASK:
|
||||||
|
sighold:
|
||||||
|
{
|
||||||
|
struct sigprocmask_args sa;
|
||||||
|
|
||||||
|
SCARG(&sa, how) = SIG_BLOCK;
|
||||||
|
SCARG(&sa, mask) = sigmask(signum);
|
||||||
|
return sigprocmask(p, &sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIGRELSE_MASK:
|
||||||
|
{
|
||||||
|
struct sigprocmask_args sa;
|
||||||
|
|
||||||
|
SCARG(&sa, how) = SIG_UNBLOCK;
|
||||||
|
SCARG(&sa, mask) = sigmask(signum);
|
||||||
|
return sigprocmask(p, &sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIGIGNORE_MASK:
|
||||||
|
{
|
||||||
|
struct sigaction_args sa_args;
|
||||||
|
struct sigaction *bsa, sa;
|
||||||
|
|
||||||
|
bsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
SCARG(&sa_args, signum) = signum;
|
||||||
|
SCARG(&sa_args, nsa) = bsa;
|
||||||
|
SCARG(&sa_args, osa) = NULL;
|
||||||
|
|
||||||
|
sa.sa_handler = SIG_IGN;
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_flags = 0;
|
||||||
|
if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
|
||||||
|
return error;
|
||||||
|
if ((error = sigaction(p, &sa_args)) != 0) {
|
||||||
|
DPRINTF(("sigignore: sigaction failed\n"));
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIGPAUSE_MASK:
|
||||||
|
{
|
||||||
|
struct sigsuspend_args sa;
|
||||||
|
|
||||||
|
SCARG(&sa, mask) = p->p_sigmask & ~sigmask(signum);
|
||||||
|
return sigsuspend(p, &sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return (ENOSYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigprocmask(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_sigprocmask_args *uap;
|
||||||
|
{
|
||||||
|
svr4_sigset_t sss;
|
||||||
|
sigset_t bss;
|
||||||
|
int error = 0, *retval;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
if (SCARG(uap, oset) != NULL) {
|
||||||
|
/* Fix the return value first if needed */
|
||||||
|
bsd_to_svr4_sigset(&p->p_sigmask, &sss);
|
||||||
|
if ((error = copyout(&sss, SCARG(uap, oset), sizeof(sss))) != 0)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SCARG(uap, set) == NULL)
|
||||||
|
/* Just examine */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, set), &sss, sizeof(sss))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_to_bsd_sigset(&sss, &bss);
|
||||||
|
|
||||||
|
(void) splhigh();
|
||||||
|
|
||||||
|
switch (SCARG(uap, how)) {
|
||||||
|
case SVR4_SIG_BLOCK:
|
||||||
|
p->p_sigmask |= bss & ~sigcantmask;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SIG_UNBLOCK:
|
||||||
|
p->p_sigmask &= ~bss;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SIG_SETMASK:
|
||||||
|
p->p_sigmask = bss & ~sigcantmask;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
error = EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) spl0();
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigpending(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_sigpending_args *uap;
|
||||||
|
{
|
||||||
|
sigset_t bss;
|
||||||
|
int *retval;
|
||||||
|
svr4_sigset_t sss;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case 1: /* sigpending */
|
||||||
|
if (SCARG(uap, mask) == NULL)
|
||||||
|
return 0;
|
||||||
|
bss = p->p_siglist & p->p_sigmask;
|
||||||
|
bsd_to_svr4_sigset(&bss, &sss);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: /* sigfillset */
|
||||||
|
svr4_sigfillset(&sss);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return copyout(&sss, SCARG(uap, mask), sizeof(sss));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigsuspend(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_sigsuspend_args *uap;
|
||||||
|
{
|
||||||
|
svr4_sigset_t sss;
|
||||||
|
sigset_t bss;
|
||||||
|
struct sigsuspend_args sa;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, ss), &sss, sizeof(sss))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_to_bsd_sigset(&sss, &bss);
|
||||||
|
|
||||||
|
SCARG(&sa, mask) = bss;
|
||||||
|
return sigsuspend(p, &sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_kill(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_kill_args *uap;
|
||||||
|
{
|
||||||
|
struct kill_args ka;
|
||||||
|
|
||||||
|
SCARG(&ka, pid) = SCARG(uap, pid);
|
||||||
|
SCARG(&ka, signum) = svr4_to_bsd_sig[SCARG(uap, signum)];
|
||||||
|
return kill(p, &ka);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_context(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_context_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_ucontext uc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
switch (uap->func) {
|
||||||
|
case 0:
|
||||||
|
DPRINTF(("getcontext(%p)\n", uap->uc));
|
||||||
|
svr4_getcontext(p, &uc, p->p_sigmask,
|
||||||
|
p->p_sigacts->ps_sigstk.ss_flags & SS_ONSTACK);
|
||||||
|
return copyout(&uc, uap->uc, sizeof(uc));
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
DPRINTF(("setcontext(%p)\n", uap->uc));
|
||||||
|
if ((error = copyin(uap->uc, &uc, sizeof(uc))) != 0)
|
||||||
|
return error;
|
||||||
|
DPRINTF(("uc_flags = %x\n", uc.uc_flags));
|
||||||
|
DPRINTF(("uc_sigmask = %x\n", uc.uc_sigmask));
|
||||||
|
|
||||||
|
return svr4_setcontext(p, &uc);
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("context(%d, %p)\n", uap->func,
|
||||||
|
uap->uc));
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_pause(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_pause_args *uap;
|
||||||
|
{
|
||||||
|
struct sigsuspend_args bsa;
|
||||||
|
|
||||||
|
SCARG(&bsa, mask) = p->p_sigmask;
|
||||||
|
return sigsuspend(p, &bsa);
|
||||||
|
}
|
130
sys/compat/svr4/svr4_signal.h
Normal file
130
sys/compat/svr4/svr4_signal.h
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SIGNAL_H_
|
||||||
|
#define _SVR4_SIGNAL_H_
|
||||||
|
|
||||||
|
#include <i386/svr4/svr4_machdep.h>
|
||||||
|
#include <svr4/svr4_siginfo.h>
|
||||||
|
|
||||||
|
#define SVR4_SIGHUP 1
|
||||||
|
#define SVR4_SIGINT 2
|
||||||
|
#define SVR4_SIGQUIT 3
|
||||||
|
#define SVR4_SIGILL 4
|
||||||
|
#define SVR4_SIGTRAP 5
|
||||||
|
#define SVR4_SIGIOT 6
|
||||||
|
#define SVR4_SIGABRT 6
|
||||||
|
#define SVR4_SIGEMT 7
|
||||||
|
#define SVR4_SIGFPE 8
|
||||||
|
#define SVR4_SIGKILL 9
|
||||||
|
#define SVR4_SIGBUS 10
|
||||||
|
#define SVR4_SIGSEGV 11
|
||||||
|
#define SVR4_SIGSYS 12
|
||||||
|
#define SVR4_SIGPIPE 13
|
||||||
|
#define SVR4_SIGALRM 14
|
||||||
|
#define SVR4_SIGTERM 15
|
||||||
|
#define SVR4_SIGUSR1 16
|
||||||
|
#define SVR4_SIGUSR2 17
|
||||||
|
#define SVR4_SIGCLD 18
|
||||||
|
#define SVR4_SIGCHLD 18
|
||||||
|
#define SVR4_SIGPWR 19
|
||||||
|
#define SVR4_SIGWINCH 20
|
||||||
|
#define SVR4_SIGURG 21
|
||||||
|
#define SVR4_SIGPOLL 22
|
||||||
|
#define SVR4_SIGIO 22
|
||||||
|
#define SVR4_SIGSTOP 23
|
||||||
|
#define SVR4_SIGTSTP 24
|
||||||
|
#define SVR4_SIGCONT 25
|
||||||
|
#define SVR4_SIGTTIN 26
|
||||||
|
#define SVR4_SIGTTOU 27
|
||||||
|
#define SVR4_SIGVTALRM 28
|
||||||
|
#define SVR4_SIGPROF 29
|
||||||
|
#define SVR4_SIGXCPU 30
|
||||||
|
#define SVR4_SIGXFSZ 31
|
||||||
|
#define SVR4_NSIG 32
|
||||||
|
|
||||||
|
#define SVR4_SIGNO_MASK 0x00FF
|
||||||
|
#define SVR4_SIGNAL_MASK 0x0000
|
||||||
|
#define SVR4_SIGDEFER_MASK 0x0100
|
||||||
|
#define SVR4_SIGHOLD_MASK 0x0200
|
||||||
|
#define SVR4_SIGRELSE_MASK 0x0400
|
||||||
|
#define SVR4_SIGIGNORE_MASK 0x0800
|
||||||
|
#define SVR4_SIGPAUSE_MASK 0x1000
|
||||||
|
|
||||||
|
typedef void (*svr4_sig_t) __P((int, svr4_siginfo_t *, void *));
|
||||||
|
#define SVR4_SIG_DFL (svr4_sig_t) 0
|
||||||
|
#define SVR4_SIG_ERR (svr4_sig_t) -1
|
||||||
|
#define SVR4_SIG_IGN (svr4_sig_t) 1
|
||||||
|
#define SVR4_SIG_HOLD (svr4_sig_t) 2
|
||||||
|
|
||||||
|
#define SVR4_SIGNO(a) ((a) & SVR4_SIGNO_MASK)
|
||||||
|
#define SVR4_SIGCALL(a) ((a) & ~SVR4_SIGNO_MASK)
|
||||||
|
|
||||||
|
#define SVR4_SIG_BLOCK 1
|
||||||
|
#define SVR4_SIG_UNBLOCK 2
|
||||||
|
#define SVR4_SIG_SETMASK 3
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u_long bits[4];
|
||||||
|
} svr4_sigset_t;
|
||||||
|
|
||||||
|
struct svr4_sigaction {
|
||||||
|
int sa_flags;
|
||||||
|
svr4_sig_t sa_handler;
|
||||||
|
svr4_sigset_t sa_mask;
|
||||||
|
int sa_reserved[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_sigaltstack {
|
||||||
|
char *ss_sp;
|
||||||
|
int ss_size;
|
||||||
|
int ss_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* sa_flags */
|
||||||
|
#define SVR4_SA_ONSTACK 0x00000001
|
||||||
|
#define SVR4_SA_RESETHAND 0x00000002
|
||||||
|
#define SVR4_SA_RESTART 0x00000004
|
||||||
|
#define SVR4_SA_SIGINFO 0x00000008
|
||||||
|
#define SVR4_SA_NODEFER 0x00000010
|
||||||
|
#define SVR4_SA_NOCLDWAIT 0x00010000 /* No zombies */
|
||||||
|
#define SVR4_SA_NOCLDSTOP 0x00020000 /* No jcl */
|
||||||
|
#define SVR4_SA_ALLBITS 0x0003001f
|
||||||
|
|
||||||
|
/* ss_flags */
|
||||||
|
#define SVR4_SS_ONSTACK 0x00000001
|
||||||
|
#define SVR4_SS_DISABLE 0x00000002
|
||||||
|
#define SVR4_SS_ALLBITS 0x00000003
|
||||||
|
|
||||||
|
void bsd_to_svr4_sigaltstack __P((const struct sigaltstack *, struct svr4_sigaltstack *));
|
||||||
|
void bsd_to_svr4_sigset __P((const sigset_t *, svr4_sigset_t *));
|
||||||
|
void svr4_to_bsd_sigaltstack __P((const struct svr4_sigaltstack *, struct sigaltstack *));
|
||||||
|
void svr4_to_bsd_sigset __P((const svr4_sigset_t *, sigset_t *));
|
||||||
|
void svr4_sendsig(sig_t, int, int, u_long);
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SIGNAL_H_ */
|
204
sys/compat/svr4/svr4_socket.c
Normal file
204
sys/compat/svr4/svr4_socket.c
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1996 Christos Zoulas.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In SVR4 unix domain sockets are referenced sometimes
|
||||||
|
* (in putmsg(2) for example) as a [device, inode] pair instead of a pathname.
|
||||||
|
* Since there is no iname() routine in the kernel, and we need access to
|
||||||
|
* a mapping from inode to pathname, we keep our own table. This is a simple
|
||||||
|
* linked list that contains the pathname, the [device, inode] pair, the
|
||||||
|
* file corresponding to that socket and the process. When the
|
||||||
|
* socket gets closed we remove the item from the list. The list gets loaded
|
||||||
|
* every time a stat(2) call finds a socket.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/queue.h>
|
||||||
|
#include <sys/mbuf.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/socketvar.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_socket.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_sockmod.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
|
||||||
|
struct svr4_sockcache_entry {
|
||||||
|
struct proc *p; /* Process for the socket */
|
||||||
|
void *cookie; /* Internal cookie used for matching */
|
||||||
|
struct sockaddr_un sock;/* Pathname for the socket */
|
||||||
|
dev_t dev; /* Device where the socket lives on */
|
||||||
|
ino_t ino; /* Inode where the socket lives on */
|
||||||
|
TAILQ_ENTRY(svr4_sockcache_entry) entries;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern TAILQ_HEAD(svr4_sockcache_head, svr4_sockcache_entry) svr4_head;
|
||||||
|
extern int svr4_str_initialized;
|
||||||
|
|
||||||
|
struct sockaddr_un *
|
||||||
|
svr4_find_socket(p, fp, dev, ino)
|
||||||
|
struct proc *p;
|
||||||
|
struct file *fp;
|
||||||
|
dev_t dev;
|
||||||
|
ino_t ino;
|
||||||
|
{
|
||||||
|
struct svr4_sockcache_entry *e;
|
||||||
|
void *cookie = ((struct socket *) fp->f_data)->so_emuldata;
|
||||||
|
|
||||||
|
if (!svr4_str_initialized) {
|
||||||
|
DPRINTF(("svr4_find_socket: uninitialized [%p,%d,%d]\n",
|
||||||
|
p, dev, ino));
|
||||||
|
TAILQ_INIT(&svr4_head);
|
||||||
|
svr4_str_initialized = 1;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", p, dev, ino));
|
||||||
|
for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next)
|
||||||
|
if (e->p == p && e->dev == dev && e->ino == ino) {
|
||||||
|
#ifdef DIAGNOSTIC
|
||||||
|
if (e->cookie != NULL && e->cookie != cookie)
|
||||||
|
panic("svr4 socket cookie mismatch");
|
||||||
|
#endif
|
||||||
|
e->cookie = cookie;
|
||||||
|
DPRINTF(("%s\n", e->sock.sun_path));
|
||||||
|
return &e->sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINTF(("not found\n"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
svr4_delete_socket(p, fp)
|
||||||
|
struct proc *p;
|
||||||
|
struct file *fp;
|
||||||
|
{
|
||||||
|
struct svr4_sockcache_entry *e;
|
||||||
|
void *cookie = ((struct socket *) fp->f_data)->so_emuldata;
|
||||||
|
|
||||||
|
if (!svr4_str_initialized) {
|
||||||
|
TAILQ_INIT(&svr4_head);
|
||||||
|
svr4_str_initialized = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next)
|
||||||
|
if (e->p == p && e->cookie == cookie) {
|
||||||
|
TAILQ_REMOVE(&svr4_head, e, entries);
|
||||||
|
DPRINTF(("svr4_delete_socket: %s [%p,%d,%d]\n",
|
||||||
|
e->sock.sun_path, p, e->dev, e->ino));
|
||||||
|
free(e, M_TEMP);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_add_socket(p, path, st)
|
||||||
|
struct proc *p;
|
||||||
|
const char *path;
|
||||||
|
struct stat *st;
|
||||||
|
{
|
||||||
|
struct svr4_sockcache_entry *e;
|
||||||
|
int len, error;
|
||||||
|
|
||||||
|
if (!svr4_str_initialized) {
|
||||||
|
TAILQ_INIT(&svr4_head);
|
||||||
|
svr4_str_initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = malloc(sizeof(*e), M_TEMP, M_WAITOK);
|
||||||
|
e->cookie = NULL;
|
||||||
|
e->dev = st->st_dev;
|
||||||
|
e->ino = st->st_ino;
|
||||||
|
e->p = p;
|
||||||
|
|
||||||
|
if ((error = copyinstr(path, e->sock.sun_path,
|
||||||
|
sizeof(e->sock.sun_path), &len)) != 0) {
|
||||||
|
DPRINTF(("svr4_add_socket: copyinstr failed %d\n", error));
|
||||||
|
free(e, M_TEMP);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
e->sock.sun_family = AF_LOCAL;
|
||||||
|
e->sock.sun_len = len;
|
||||||
|
|
||||||
|
TAILQ_INSERT_HEAD(&svr4_head, e, entries);
|
||||||
|
DPRINTF(("svr4_add_socket: %s [%p,%d,%d]\n", e->sock.sun_path,
|
||||||
|
p, e->dev, e->ino));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_socket(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_socket_args *uap;
|
||||||
|
{
|
||||||
|
switch (SCARG(uap, type)) {
|
||||||
|
case SVR4_SOCK_DGRAM:
|
||||||
|
SCARG(uap, type) = SOCK_DGRAM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SOCK_STREAM:
|
||||||
|
SCARG(uap, type) = SOCK_STREAM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SOCK_RAW:
|
||||||
|
SCARG(uap, type) = SOCK_RAW;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SOCK_RDM:
|
||||||
|
SCARG(uap, type) = SOCK_RDM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SOCK_SEQPACKET:
|
||||||
|
SCARG(uap, type) = SOCK_SEQPACKET;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
return socket(p, (struct socket_args *)uap);
|
||||||
|
}
|
53
sys/compat/svr4/svr4_socket.h
Normal file
53
sys/compat/svr4/svr4_socket.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1996 Christos Zoulas.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SOCKET_H_
|
||||||
|
#define _SVR4_SOCKET_H_
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
struct sockaddr_un;
|
||||||
|
struct proc;
|
||||||
|
struct file;
|
||||||
|
|
||||||
|
struct svr4_sockaddr_in {
|
||||||
|
u_char sin_family;
|
||||||
|
u_short sin_port;
|
||||||
|
struct in_addr sin_addr;
|
||||||
|
u_char sin_zero[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr_un *svr4_find_socket __P((struct proc *, struct file *,
|
||||||
|
dev_t, ino_t));
|
||||||
|
void svr4_delete_socket __P((struct proc *, struct file *));
|
||||||
|
int svr4_add_socket __P((struct proc *, const char *, struct stat *));
|
||||||
|
|
||||||
|
#endif /* _SVR4_SOCKET_H_ */
|
174
sys/compat/svr4/svr4_sockio.c
Normal file
174
sys/compat/svr4/svr4_sockio.c
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1995 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/tty.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_stropts.h>
|
||||||
|
#include <svr4/svr4_ioctl.h>
|
||||||
|
#include <svr4/svr4_sockio.h>
|
||||||
|
|
||||||
|
static int bsd_to_svr4_flags __P((int));
|
||||||
|
|
||||||
|
#define bsd_to_svr4_flag(a) \
|
||||||
|
if (bf & __CONCAT(I,a)) sf |= __CONCAT(SVR4_I,a)
|
||||||
|
|
||||||
|
static int
|
||||||
|
bsd_to_svr4_flags(bf)
|
||||||
|
int bf;
|
||||||
|
{
|
||||||
|
int sf = 0;
|
||||||
|
bsd_to_svr4_flag(FF_UP);
|
||||||
|
bsd_to_svr4_flag(FF_BROADCAST);
|
||||||
|
bsd_to_svr4_flag(FF_DEBUG);
|
||||||
|
bsd_to_svr4_flag(FF_LOOPBACK);
|
||||||
|
bsd_to_svr4_flag(FF_POINTOPOINT);
|
||||||
|
#if defined(IFF_NOTRAILERS)
|
||||||
|
bsd_to_svr4_flag(FF_NOTRAILERS);
|
||||||
|
#endif
|
||||||
|
bsd_to_svr4_flag(FF_RUNNING);
|
||||||
|
bsd_to_svr4_flag(FF_NOARP);
|
||||||
|
bsd_to_svr4_flag(FF_PROMISC);
|
||||||
|
bsd_to_svr4_flag(FF_ALLMULTI);
|
||||||
|
bsd_to_svr4_flag(FF_MULTICAST);
|
||||||
|
return sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sock_ioctl(fp, p, retval, fd, cmd, data)
|
||||||
|
struct file *fp;
|
||||||
|
struct proc *p;
|
||||||
|
register_t *retval;
|
||||||
|
int fd;
|
||||||
|
u_long cmd;
|
||||||
|
caddr_t data;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
|
||||||
|
fp->f_ops->fo_ioctl;
|
||||||
|
|
||||||
|
*retval = 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_SIOCGIFNUM:
|
||||||
|
{
|
||||||
|
struct ifnet *ifp;
|
||||||
|
struct ifaddr *ifa;
|
||||||
|
int ifnum = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This does not return the number of physical
|
||||||
|
* interfaces (if_index), but the number of interfaces
|
||||||
|
* + addresses like ifconf() does, because this number
|
||||||
|
* is used by code that will call SVR4_SIOCGIFCONF to
|
||||||
|
* find the space needed for SVR4_SIOCGIFCONF. So we
|
||||||
|
* count the number of ifreq entries that the next
|
||||||
|
* SVR4_SIOCGIFCONF will return. Maybe a more correct
|
||||||
|
* fix is to make SVR4_SIOCGIFCONF return only one
|
||||||
|
* entry per physical interface?
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (ifp = ifnet.tqh_first;
|
||||||
|
ifp != 0; ifp = ifp->if_link.tqe_next)
|
||||||
|
if ((ifa = ifp->if_addrhead.tqh_first) == NULL)
|
||||||
|
ifnum++;
|
||||||
|
else
|
||||||
|
for (;ifa != NULL;
|
||||||
|
ifa = ifa->ifa_link.tqe_next)
|
||||||
|
ifnum++;
|
||||||
|
|
||||||
|
|
||||||
|
DPRINTF(("SIOCGIFNUM %d\n", ifnum));
|
||||||
|
return copyout(&ifnum, data, sizeof(ifnum));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIOCGIFFLAGS:
|
||||||
|
{
|
||||||
|
struct ifreq br;
|
||||||
|
struct svr4_ifreq sr;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &sr, sizeof(sr))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
(void) strncpy(br.ifr_name, "de0", /*sr.svr4_ifr_name,*/
|
||||||
|
sizeof(br.ifr_name));
|
||||||
|
if ((error = (*ctl)(fp, SIOCGIFFLAGS,
|
||||||
|
(caddr_t) &br, p)) != 0) {
|
||||||
|
DPRINTF(("SIOCGIFFLAGS (%s) %s: error %d\n",
|
||||||
|
br.ifr_name, sr.svr4_ifr_name, error));
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
sr.svr4_ifr_flags = bsd_to_svr4_flags(br.ifr_flags);
|
||||||
|
DPRINTF(("SIOCGIFFLAGS %s = %x\n",
|
||||||
|
sr.svr4_ifr_name, sr.svr4_ifr_flags));
|
||||||
|
return copyout(&sr, data, sizeof(sr));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIOCGIFCONF:
|
||||||
|
{
|
||||||
|
struct svr4_ifconf sc;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &sc, sizeof(sc))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
DPRINTF(("ifreq %d svr4_ifreq %d ifc_len %d\n",
|
||||||
|
sizeof(struct ifreq), sizeof(struct svr4_ifreq),
|
||||||
|
sc.svr4_ifc_len));
|
||||||
|
|
||||||
|
if ((error = (*ctl)(fp, OSIOCGIFCONF,
|
||||||
|
(caddr_t) &sc, p)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
DPRINTF(("SIOCGIFCONF\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Unknown svr4 sockio %lx\n", cmd));
|
||||||
|
return 0; /* ENOSYS really */
|
||||||
|
}
|
||||||
|
}
|
91
sys/compat/svr4/svr4_sockio.h
Normal file
91
sys/compat/svr4/svr4_sockio.h
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1995 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SOCKIO_H_
|
||||||
|
#define _SVR4_SOCKIO_H_
|
||||||
|
|
||||||
|
#define SVR4_IFF_UP 0x0001
|
||||||
|
#define SVR4_IFF_BROADCAST 0x0002
|
||||||
|
#define SVR4_IFF_DEBUG 0x0004
|
||||||
|
#define SVR4_IFF_LOOPBACK 0x0008
|
||||||
|
#define SVR4_IFF_POINTOPOINT 0x0010
|
||||||
|
#define SVR4_IFF_NOTRAILERS 0x0020
|
||||||
|
#define SVR4_IFF_RUNNING 0x0040
|
||||||
|
#define SVR4_IFF_NOARP 0x0080
|
||||||
|
#define SVR4_IFF_PROMISC 0x0100
|
||||||
|
#define SVR4_IFF_ALLMULTI 0x0200
|
||||||
|
#define SVR4_IFF_INTELLIGENT 0x0400
|
||||||
|
#define SVR4_IFF_MULTICAST 0x0800
|
||||||
|
#define SVR4_IFF_MULTI_BCAST 0x1000
|
||||||
|
#define SVR4_IFF_UNNUMBERED 0x2000
|
||||||
|
#define SVR4_IFF_PRIVATE 0x8000
|
||||||
|
|
||||||
|
struct svr4_ifreq {
|
||||||
|
#define SVR4_IFNAMSIZ 16
|
||||||
|
char svr4_ifr_name[SVR4_IFNAMSIZ];
|
||||||
|
union {
|
||||||
|
struct osockaddr ifru_addr;
|
||||||
|
struct osockaddr ifru_dstaddr;
|
||||||
|
struct osockaddr ifru_broadaddr;
|
||||||
|
short ifru_flags;
|
||||||
|
int ifru_metric;
|
||||||
|
char ifru_data;
|
||||||
|
char ifru_enaddr[6];
|
||||||
|
int if_muxid[2];
|
||||||
|
|
||||||
|
} ifr_ifru;
|
||||||
|
|
||||||
|
#define svr4_ifr_addr ifr_ifru.ifru_addr
|
||||||
|
#define svr4_ifr_dstaddr ifr_ifru.ifru_dstaddr
|
||||||
|
#define svr4_ifr_broadaddr ifr_ifru.ifru_broadaddr
|
||||||
|
#define svr4_ifr_flags ifr_ifru.ifru_flags
|
||||||
|
#define svr4_ifr_metric ifr_ifru.ifru_metric
|
||||||
|
#define svr4_ifr_data ifr_ifru.ifru_data
|
||||||
|
#define svr4_ifr_enaddr ifr_ifru.ifru_enaddr
|
||||||
|
#define svr4_ifr_muxid ifr_ifru.ifru_muxid
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_ifconf {
|
||||||
|
int svr4_ifc_len;
|
||||||
|
union {
|
||||||
|
caddr_t ifcu_buf;
|
||||||
|
struct svr4_ifreq *ifcu_req;
|
||||||
|
} ifc_ifcu;
|
||||||
|
|
||||||
|
#define svr4_ifc_buf ifc_ifcu.ifcu_buf
|
||||||
|
#define svr4_ifc_req ifc_ifcu.ifcu_req
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_SIOC ('i' << 8)
|
||||||
|
|
||||||
|
#define SVR4_SIOCGIFFLAGS SVR4_IOWR('i', 17, struct svr4_ifreq)
|
||||||
|
#define SVR4_SIOCGIFCONF SVR4_IOWR('i', 20, struct svr4_ifconf)
|
||||||
|
#define SVR4_SIOCGIFNUM SVR4_IOR('i', 87, int)
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SOCKIO_H_ */
|
81
sys/compat/svr4/svr4_sockmod.h
Normal file
81
sys/compat/svr4/svr4_sockmod.h
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SOCKMOD_H_
|
||||||
|
#define _SVR4_SOCKMOD_H_
|
||||||
|
|
||||||
|
#define SVR4_SIMOD ('I' << 8)
|
||||||
|
|
||||||
|
#define SVR4_SI_OGETUDATA (SVR4_SIMOD|101)
|
||||||
|
#define SVR4_SI_SHUTDOWN (SVR4_SIMOD|102)
|
||||||
|
#define SVR4_SI_LISTEN (SVR4_SIMOD|103)
|
||||||
|
#define SVR4_SI_SETMYNAME (SVR4_SIMOD|104)
|
||||||
|
#define SVR4_SI_SETPEERNAME (SVR4_SIMOD|105)
|
||||||
|
#define SVR4_SI_GETINTRANSIT (SVR4_SIMOD|106)
|
||||||
|
#define SVR4_SI_TCL_LINK (SVR4_SIMOD|107)
|
||||||
|
#define SVR4_SI_TCL_UNLINK (SVR4_SIMOD|108)
|
||||||
|
#define SVR4_SI_SOCKPARAMS (SVR4_SIMOD|109)
|
||||||
|
#define SVR4_SI_GETUDATA (SVR4_SIMOD|110)
|
||||||
|
|
||||||
|
|
||||||
|
#define SVR4_SOCK_DGRAM 1
|
||||||
|
#define SVR4_SOCK_STREAM 2
|
||||||
|
#define SVR4_SOCK_STREAM_ORD 3
|
||||||
|
#define SVR4_SOCK_RAW 4
|
||||||
|
#define SVR4_SOCK_RDM 5
|
||||||
|
#define SVR4_SOCK_SEQPACKET 6
|
||||||
|
|
||||||
|
struct svr4_si_sockparms {
|
||||||
|
int family;
|
||||||
|
int type;
|
||||||
|
int protocol;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_si_oudata {
|
||||||
|
int tidusize;
|
||||||
|
int addrsize;
|
||||||
|
int optsize;
|
||||||
|
int etsdusize;
|
||||||
|
int servtype;
|
||||||
|
int so_state;
|
||||||
|
int so_options;
|
||||||
|
int tsdusize;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_si_udata {
|
||||||
|
int tidusize;
|
||||||
|
int addrsize;
|
||||||
|
int optsize;
|
||||||
|
int etsdusize;
|
||||||
|
int servtype;
|
||||||
|
int so_state;
|
||||||
|
int so_options;
|
||||||
|
int tsdusize;
|
||||||
|
struct svr4_si_sockparms sockparms;
|
||||||
|
};
|
||||||
|
#endif /* !_SVR4_SOCKMOD_H_ */
|
803
sys/compat/svr4/svr4_stat.c
Normal file
803
sys/compat/svr4/svr4_stat.c
Normal file
|
@ -0,0 +1,803 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/stat.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/ucred.h>
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_stat.h>
|
||||||
|
#include <svr4/svr4_ustat.h>
|
||||||
|
#include <svr4/svr4_utsname.h>
|
||||||
|
#include <svr4/svr4_systeminfo.h>
|
||||||
|
#include <svr4/svr4_socket.h>
|
||||||
|
#include <svr4/svr4_time.h>
|
||||||
|
#if defined(NOTYET)
|
||||||
|
#include "svr4_fuser.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef sparc
|
||||||
|
/*
|
||||||
|
* Solaris-2.4 on the sparc has the old stat call using the new
|
||||||
|
* stat data structure...
|
||||||
|
*/
|
||||||
|
# define SVR4_NO_OSTAT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct svr4_ustat_args {
|
||||||
|
svr4_dev_t dev;
|
||||||
|
struct svr4_ustat * name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *));
|
||||||
|
static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *));
|
||||||
|
int svr4_ustat __P((struct proc *, struct svr4_ustat_args *));
|
||||||
|
static int svr4_to_bsd_pathconf __P((int));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SVR4 uses named pipes as named sockets, so we tell programs
|
||||||
|
* that sockets are named pipes with mode 0
|
||||||
|
*/
|
||||||
|
#define BSD_TO_SVR4_MODE(mode) (S_ISSOCK(mode) ? S_IFIFO : (mode))
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SVR4_NO_OSTAT
|
||||||
|
static void bsd_to_svr4_stat __P((struct stat *, struct svr4_stat *));
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_stat(st, st4)
|
||||||
|
struct stat *st;
|
||||||
|
struct svr4_stat *st4;
|
||||||
|
{
|
||||||
|
memset(st4, 0, sizeof(*st4));
|
||||||
|
st4->st_dev = bsd_to_svr4_odev_t(st->st_dev);
|
||||||
|
st4->st_ino = st->st_ino;
|
||||||
|
st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
|
||||||
|
st4->st_nlink = st->st_nlink;
|
||||||
|
st4->st_uid = st->st_uid;
|
||||||
|
st4->st_gid = st->st_gid;
|
||||||
|
st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
|
||||||
|
st4->st_size = st->st_size;
|
||||||
|
st4->st_atim = st->st_atimespec.tv_sec;
|
||||||
|
st4->st_mtim = st->st_mtimespec.tv_sec;
|
||||||
|
st4->st_ctim = st->st_ctimespec.tv_sec;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_xstat(st, st4)
|
||||||
|
struct stat *st;
|
||||||
|
struct svr4_xstat *st4;
|
||||||
|
{
|
||||||
|
memset(st4, 0, sizeof(*st4));
|
||||||
|
st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
|
||||||
|
st4->st_ino = st->st_ino;
|
||||||
|
st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
|
||||||
|
st4->st_nlink = st->st_nlink;
|
||||||
|
st4->st_uid = st->st_uid;
|
||||||
|
st4->st_gid = st->st_gid;
|
||||||
|
st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
|
||||||
|
st4->st_size = st->st_size;
|
||||||
|
st4->st_atim = st->st_atimespec;
|
||||||
|
st4->st_mtim = st->st_mtimespec;
|
||||||
|
st4->st_ctim = st->st_ctimespec;
|
||||||
|
st4->st_blksize = st->st_blksize;
|
||||||
|
st4->st_blocks = st->st_blocks;
|
||||||
|
strcpy(st4->st_fstype, "unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_stat64(st, st4)
|
||||||
|
struct stat *st;
|
||||||
|
struct svr4_stat64 *st4;
|
||||||
|
{
|
||||||
|
memset(st4, 0, sizeof(*st4));
|
||||||
|
st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
|
||||||
|
st4->st_ino = st->st_ino;
|
||||||
|
st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
|
||||||
|
st4->st_nlink = st->st_nlink;
|
||||||
|
st4->st_uid = st->st_uid;
|
||||||
|
st4->st_gid = st->st_gid;
|
||||||
|
st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
|
||||||
|
st4->st_size = st->st_size;
|
||||||
|
st4->st_atim = st->st_atimespec;
|
||||||
|
st4->st_mtim = st->st_mtimespec;
|
||||||
|
st4->st_ctim = st->st_ctimespec;
|
||||||
|
st4->st_blksize = st->st_blksize;
|
||||||
|
st4->st_blocks = st->st_blocks;
|
||||||
|
strcpy(st4->st_fstype, "unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_stat(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_stat_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
#ifdef SVR4_NO_OSTAT
|
||||||
|
struct svr4_sys_xstat_args cup;
|
||||||
|
|
||||||
|
retval = &(p->p_retval[0]);
|
||||||
|
SCARG(&cup, two) = 2;
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub);
|
||||||
|
return svr4_sys_xstat(p, &cup, retval);
|
||||||
|
#else
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat svr4_st;
|
||||||
|
struct stat_args cup;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
|
||||||
|
if ((error = stat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat(&st, &svr4_st);
|
||||||
|
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_lstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_lstat_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat svr4_st;
|
||||||
|
struct lstat_args cup;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = lstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat(&st, &svr4_st);
|
||||||
|
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fstat_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat svr4_st;
|
||||||
|
struct fstat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
SCARG(&cup, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = fstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat(&st, &svr4_st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_xstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_xstat_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_xstat svr4_st;
|
||||||
|
struct stat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = stat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_xstat(&st, &svr4_st);
|
||||||
|
|
||||||
|
#if defined(SOCKET_NOTYET)
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_lxstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_lxstat_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_xstat svr4_st;
|
||||||
|
struct lstat_args cup;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = lstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_xstat(&st, &svr4_st);
|
||||||
|
|
||||||
|
#if defined(SOCKET_NOTYET)
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
#endif
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fxstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fxstat_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_xstat svr4_st;
|
||||||
|
struct fstat_args cup;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
SCARG(&cup, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = fstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_xstat(&st, &svr4_st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_stat64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_stat64_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat64 svr4_st;
|
||||||
|
struct stat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = stat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat64(&st, &svr4_st);
|
||||||
|
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_lstat64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_lstat64_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat64 svr4_st;
|
||||||
|
struct stat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
CHECKALTEXIST(p, &sg, (char *) SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = lstat(p, (struct lstat_args *)&cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat64(&st, &svr4_st);
|
||||||
|
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fstat64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fstat64_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat64 svr4_st;
|
||||||
|
struct fstat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(&cup, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = fstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat64(&st, &svr4_st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_ustat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_ustat_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_ustat us;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
memset(&us, 0, sizeof us);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: should set f_tfree and f_tinode at least
|
||||||
|
* How do we translate dev -> fstat? (and then to svr4_ustat)
|
||||||
|
*/
|
||||||
|
if ((error = copyout(&us, SCARG(uap, name), sizeof us)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*extern char ostype[], hostname[], osrelease[], version[], machine[];*/
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_uname(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_uname_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_utsname sut;
|
||||||
|
|
||||||
|
|
||||||
|
memset(&sut, 0, sizeof(sut));
|
||||||
|
|
||||||
|
strncpy(sut.sysname, ostype, sizeof(sut.sysname));
|
||||||
|
sut.sysname[sizeof(sut.sysname) - 1] = '\0';
|
||||||
|
|
||||||
|
strncpy(sut.nodename, hostname, sizeof(sut.nodename));
|
||||||
|
sut.nodename[sizeof(sut.nodename) - 1] = '\0';
|
||||||
|
|
||||||
|
strncpy(sut.release, osrelease, sizeof(sut.release));
|
||||||
|
sut.release[sizeof(sut.release) - 1] = '\0';
|
||||||
|
|
||||||
|
strncpy(sut.version, version, sizeof(sut.version));
|
||||||
|
sut.version[sizeof(sut.version) - 1] = '\0';
|
||||||
|
|
||||||
|
strncpy(sut.machine, machine, sizeof(sut.machine));
|
||||||
|
sut.machine[sizeof(sut.machine) - 1] = '\0';
|
||||||
|
|
||||||
|
return copyout((caddr_t) &sut, (caddr_t) SCARG(uap, name),
|
||||||
|
sizeof(struct svr4_utsname));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_systeminfo(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_systeminfo_args *uap;
|
||||||
|
{
|
||||||
|
char *str = NULL;
|
||||||
|
int error = 0, *retval = p->p_retval;
|
||||||
|
size_t len = 0;
|
||||||
|
char buf[1]; /* XXX NetBSD uses 256, but that seems like awfully
|
||||||
|
excessive kstack usage for an empty string... */
|
||||||
|
u_int rlen = SCARG(uap, len);
|
||||||
|
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case SVR4_SI_SYSNAME:
|
||||||
|
str = ostype;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_HOSTNAME:
|
||||||
|
str = hostname;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_RELEASE:
|
||||||
|
str = osrelease;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_VERSION:
|
||||||
|
str = version;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_MACHINE:
|
||||||
|
str = machine;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_ARCHITECTURE:
|
||||||
|
str = machine;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_HW_SERIAL:
|
||||||
|
str = "0";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_HW_PROVIDER:
|
||||||
|
str = ostype;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_SRPC_DOMAIN:
|
||||||
|
str = domainname;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_PLATFORM:
|
||||||
|
#ifdef __i386__
|
||||||
|
str = "i86pc";
|
||||||
|
#else
|
||||||
|
str = "unknown";
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_KERB_REALM:
|
||||||
|
str = "unsupported";
|
||||||
|
break;
|
||||||
|
#if defined(WHY_DOES_AN_EMULATOR_WANT_TO_SET_HOSTNAMES)
|
||||||
|
case SVR4_SI_SET_HOSTNAME:
|
||||||
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||||
|
return error;
|
||||||
|
name = KERN_HOSTNAME;
|
||||||
|
return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
|
||||||
|
|
||||||
|
case SVR4_SI_SET_SRPC_DOMAIN:
|
||||||
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||||
|
return error;
|
||||||
|
name = KERN_NISDOMAINNAME;
|
||||||
|
return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
|
||||||
|
#else
|
||||||
|
case SVR4_SI_SET_HOSTNAME:
|
||||||
|
case SVR4_SI_SET_SRPC_DOMAIN:
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
#endif
|
||||||
|
case SVR4_SI_SET_KERB_REALM:
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str) {
|
||||||
|
len = strlen(str) + 1;
|
||||||
|
if (len > rlen)
|
||||||
|
len = rlen;
|
||||||
|
|
||||||
|
if (SCARG(uap, buf)) {
|
||||||
|
error = copyout(str, SCARG(uap, buf), len);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
/* make sure we are NULL terminated */
|
||||||
|
buf[0] = '\0';
|
||||||
|
error = copyout(buf, &(SCARG(uap, buf)[len - 1]), 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
error = 0;
|
||||||
|
}
|
||||||
|
/* XXX NetBSD has hostname setting stuff here. Why would an emulator
|
||||||
|
want to do that? */
|
||||||
|
|
||||||
|
*retval = len;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_utssys(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_utssys_args *uap;
|
||||||
|
{
|
||||||
|
switch (SCARG(uap, sel)) {
|
||||||
|
case 0: /* uname(2) */
|
||||||
|
{
|
||||||
|
struct svr4_sys_uname_args ua;
|
||||||
|
SCARG(&ua, name) = SCARG(uap, a1);
|
||||||
|
return svr4_sys_uname(p, &ua);
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2: /* ustat(2) */
|
||||||
|
{
|
||||||
|
struct svr4_ustat_args ua;
|
||||||
|
SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2);
|
||||||
|
SCARG(&ua, name) = SCARG(uap, a1);
|
||||||
|
return svr4_ustat(p, &ua);
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3: /* fusers(2) */
|
||||||
|
return ENOSYS;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_utime(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_utime_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_utimbuf ub;
|
||||||
|
struct timeval tbuf[2];
|
||||||
|
struct utimes_args ap;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
void *ttp;
|
||||||
|
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
SCARG(&ap, path) = SCARG(uap, path);
|
||||||
|
if (SCARG(uap, ubuf) != NULL) {
|
||||||
|
if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0)
|
||||||
|
return error;
|
||||||
|
tbuf[0].tv_sec = ub.actime;
|
||||||
|
tbuf[0].tv_usec = 0;
|
||||||
|
tbuf[1].tv_sec = ub.modtime;
|
||||||
|
tbuf[1].tv_usec = 0;
|
||||||
|
ttp = stackgap_alloc(&sg, sizeof(tbuf));
|
||||||
|
error = copyout(tbuf, ttp, sizeof(tbuf));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
SCARG(&ap, tptr) = ttp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SCARG(&ap, tptr) = NULL;
|
||||||
|
return utimes(p, &ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_utimes(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_utimes_args *uap;
|
||||||
|
{
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
return utimes(p, (struct utimes_args *)uap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_to_bsd_pathconf(name)
|
||||||
|
int name;
|
||||||
|
{
|
||||||
|
switch (name) {
|
||||||
|
case SVR4_PC_LINK_MAX:
|
||||||
|
return _PC_LINK_MAX;
|
||||||
|
|
||||||
|
case SVR4_PC_MAX_CANON:
|
||||||
|
return _PC_MAX_CANON;
|
||||||
|
|
||||||
|
case SVR4_PC_MAX_INPUT:
|
||||||
|
return _PC_MAX_INPUT;
|
||||||
|
|
||||||
|
case SVR4_PC_NAME_MAX:
|
||||||
|
return _PC_NAME_MAX;
|
||||||
|
|
||||||
|
case SVR4_PC_PATH_MAX:
|
||||||
|
return _PC_PATH_MAX;
|
||||||
|
|
||||||
|
case SVR4_PC_PIPE_BUF:
|
||||||
|
return _PC_PIPE_BUF;
|
||||||
|
|
||||||
|
case SVR4_PC_NO_TRUNC:
|
||||||
|
return _PC_NO_TRUNC;
|
||||||
|
|
||||||
|
case SVR4_PC_VDISABLE:
|
||||||
|
return _PC_VDISABLE;
|
||||||
|
|
||||||
|
case SVR4_PC_CHOWN_RESTRICTED:
|
||||||
|
return _PC_CHOWN_RESTRICTED;
|
||||||
|
case SVR4_PC_SYNC_IO:
|
||||||
|
#if defined(_PC_SYNC_IO)
|
||||||
|
return _PC_SYNC_IO;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
case SVR4_PC_ASYNC_IO:
|
||||||
|
case SVR4_PC_PRIO_IO:
|
||||||
|
/* Not supported */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* Invalid */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_pathconf(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_pathconf_args *uap;
|
||||||
|
{
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
int *retval = p->p_retval;
|
||||||
|
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
|
||||||
|
|
||||||
|
switch (SCARG(uap, name)) {
|
||||||
|
case -1:
|
||||||
|
*retval = -1;
|
||||||
|
return EINVAL;
|
||||||
|
case 0:
|
||||||
|
*retval = 0;
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return pathconf(p, (struct pathconf_args *)uap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fpathconf(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fpathconf_args *uap;
|
||||||
|
{
|
||||||
|
int *retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
|
||||||
|
|
||||||
|
switch (SCARG(uap, name)) {
|
||||||
|
case -1:
|
||||||
|
*retval = -1;
|
||||||
|
return EINVAL;
|
||||||
|
case 0:
|
||||||
|
*retval = 0;
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return fpathconf(p, (struct fpathconf_args *)uap);
|
||||||
|
}
|
||||||
|
}
|
103
sys/compat/svr4/svr4_stat.h
Normal file
103
sys/compat/svr4/svr4_stat.h
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_STAT_H_
|
||||||
|
#define _SVR4_STAT_H_
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
struct svr4_stat {
|
||||||
|
svr4_o_dev_t st_dev;
|
||||||
|
svr4_o_ino_t st_ino;
|
||||||
|
svr4_o_mode_t st_mode;
|
||||||
|
svr4_o_nlink_t st_nlink;
|
||||||
|
svr4_o_uid_t st_uid;
|
||||||
|
svr4_o_gid_t st_gid;
|
||||||
|
svr4_o_dev_t st_rdev;
|
||||||
|
svr4_off_t st_size;
|
||||||
|
svr4_time_t st_atim;
|
||||||
|
svr4_time_t st_mtim;
|
||||||
|
svr4_time_t st_ctim;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_xstat {
|
||||||
|
svr4_dev_t st_dev;
|
||||||
|
long st_pad1[3];
|
||||||
|
svr4_ino_t st_ino;
|
||||||
|
svr4_mode_t st_mode;
|
||||||
|
svr4_nlink_t st_nlink;
|
||||||
|
svr4_uid_t st_uid;
|
||||||
|
svr4_gid_t st_gid;
|
||||||
|
svr4_dev_t st_rdev;
|
||||||
|
long st_pad2[2];
|
||||||
|
svr4_off_t st_size;
|
||||||
|
long st_pad3;
|
||||||
|
svr4_timestruc_t st_atim;
|
||||||
|
svr4_timestruc_t st_mtim;
|
||||||
|
svr4_timestruc_t st_ctim;
|
||||||
|
long st_blksize;
|
||||||
|
svr4_blkcnt_t st_blocks;
|
||||||
|
char st_fstype[16];
|
||||||
|
long st_pad4[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_stat64 {
|
||||||
|
svr4_dev_t st_dev;
|
||||||
|
long st_pad1[3];
|
||||||
|
svr4_ino64_t st_ino;
|
||||||
|
svr4_mode_t st_mode;
|
||||||
|
svr4_nlink_t st_nlink;
|
||||||
|
svr4_uid_t st_uid;
|
||||||
|
svr4_gid_t st_gid;
|
||||||
|
svr4_dev_t st_rdev;
|
||||||
|
long st_pad2[2];
|
||||||
|
svr4_off64_t st_size;
|
||||||
|
svr4_timestruc_t st_atim;
|
||||||
|
svr4_timestruc_t st_mtim;
|
||||||
|
svr4_timestruc_t st_ctim;
|
||||||
|
long st_blksize;
|
||||||
|
svr4_blkcnt64_t st_blocks;
|
||||||
|
char st_fstype[16];
|
||||||
|
long st_pad4[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_PC_LINK_MAX 1
|
||||||
|
#define SVR4_PC_MAX_CANON 2
|
||||||
|
#define SVR4_PC_MAX_INPUT 3
|
||||||
|
#define SVR4_PC_NAME_MAX 4
|
||||||
|
#define SVR4_PC_PATH_MAX 5
|
||||||
|
#define SVR4_PC_PIPE_BUF 6
|
||||||
|
#define SVR4_PC_NO_TRUNC 7
|
||||||
|
#define SVR4_PC_VDISABLE 8
|
||||||
|
#define SVR4_PC_CHOWN_RESTRICTED 9
|
||||||
|
#define SVR4_PC_ASYNC_IO 10
|
||||||
|
#define SVR4_PC_PRIO_IO 11
|
||||||
|
#define SVR4_PC_SYNC_IO 12
|
||||||
|
|
||||||
|
#endif /* !_SVR4_STAT_H_ */
|
70
sys/compat/svr4/svr4_statvfs.h
Normal file
70
sys/compat/svr4/svr4_statvfs.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_STATVFS_H_
|
||||||
|
#define _SVR4_STATVFS_H_
|
||||||
|
|
||||||
|
typedef struct svr4_statvfs {
|
||||||
|
u_long f_bsize;
|
||||||
|
u_long f_frsize;
|
||||||
|
svr4_fsblkcnt_t f_blocks;
|
||||||
|
svr4_fsblkcnt_t f_bfree;
|
||||||
|
svr4_fsblkcnt_t f_bavail;
|
||||||
|
svr4_fsblkcnt_t f_files;
|
||||||
|
svr4_fsblkcnt_t f_ffree;
|
||||||
|
svr4_fsblkcnt_t f_favail;
|
||||||
|
u_long f_fsid;
|
||||||
|
char f_basetype[16];
|
||||||
|
u_long f_flag;
|
||||||
|
u_long f_namemax;
|
||||||
|
char f_fstr[32];
|
||||||
|
u_long f_filler[16];
|
||||||
|
} svr4_statvfs_t;
|
||||||
|
|
||||||
|
typedef struct svr4_statvfs64 {
|
||||||
|
u_long f_bsize;
|
||||||
|
u_long f_frsize;
|
||||||
|
svr4_fsblkcnt64_t f_blocks;
|
||||||
|
svr4_fsblkcnt64_t f_bfree;
|
||||||
|
svr4_fsblkcnt64_t f_bavail;
|
||||||
|
svr4_fsblkcnt64_t f_files;
|
||||||
|
svr4_fsblkcnt64_t f_ffree;
|
||||||
|
svr4_fsblkcnt64_t f_favail;
|
||||||
|
u_long f_fsid;
|
||||||
|
char f_basetype[16];
|
||||||
|
u_long f_flag;
|
||||||
|
u_long f_namemax;
|
||||||
|
char f_fstr[32];
|
||||||
|
u_long f_filler[16];
|
||||||
|
} svr4_statvfs64_t;
|
||||||
|
|
||||||
|
#define SVR4_ST_RDONLY 0x01
|
||||||
|
#define SVR4_ST_NOSUID 0x02
|
||||||
|
#define SVR4_ST_NOTRUNC 0x04
|
||||||
|
|
||||||
|
#endif /* !_SVR4_STATVFS_H_ */
|
2264
sys/compat/svr4/svr4_stream.c
Normal file
2264
sys/compat/svr4/svr4_stream.c
Normal file
File diff suppressed because it is too large
Load diff
173
sys/compat/svr4/svr4_stropts.h
Normal file
173
sys/compat/svr4/svr4_stropts.h
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_STROPTS_H_
|
||||||
|
#define _SVR4_STROPTS_H_
|
||||||
|
|
||||||
|
|
||||||
|
struct svr4_strbuf {
|
||||||
|
int maxlen;
|
||||||
|
int len;
|
||||||
|
char *buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_STR ('S' << 8)
|
||||||
|
#define SVR4_I_NREAD (SVR4_STR| 1)
|
||||||
|
#define SVR4_I_PUSH (SVR4_STR| 2)
|
||||||
|
#define SVR4_I_POP (SVR4_STR| 3)
|
||||||
|
#define SVR4_I_LOOK (SVR4_STR| 4)
|
||||||
|
#define SVR4_I_FLUSH (SVR4_STR| 5)
|
||||||
|
#define SVR4_I_SRDOPT (SVR4_STR| 6)
|
||||||
|
#define SVR4_I_GRDOPT (SVR4_STR| 7)
|
||||||
|
#define SVR4_I_STR (SVR4_STR| 8)
|
||||||
|
#define SVR4_I_SETSIG (SVR4_STR| 9)
|
||||||
|
#define SVR4_I_GETSIG (SVR4_STR|10)
|
||||||
|
#define SVR4_I_FIND (SVR4_STR|11)
|
||||||
|
#define SVR4_I_LINK (SVR4_STR|12)
|
||||||
|
#define SVR4_I_UNLINK (SVR4_STR|13)
|
||||||
|
#define SVR4_I_ERECVFD (SVR4_STR|14)
|
||||||
|
#define SVR4_I_PEEK (SVR4_STR|15)
|
||||||
|
#define SVR4_I_FDINSERT (SVR4_STR|16)
|
||||||
|
#define SVR4_I_SENDFD (SVR4_STR|17)
|
||||||
|
#define SVR4_I_RECVFD (SVR4_STR|18)
|
||||||
|
#define SVR4_I_SWROPT (SVR4_STR|19)
|
||||||
|
#define SVR4_I_GWROPT (SVR4_STR|20)
|
||||||
|
#define SVR4_I_LIST (SVR4_STR|21)
|
||||||
|
#define SVR4_I_PLINK (SVR4_STR|22)
|
||||||
|
#define SVR4_I_PUNLINK (SVR4_STR|23)
|
||||||
|
#define SVR4_I_SETEV (SVR4_STR|24)
|
||||||
|
#define SVR4_I_GETEV (SVR4_STR|25)
|
||||||
|
#define SVR4_I_STREV (SVR4_STR|26)
|
||||||
|
#define SVR4_I_UNSTREV (SVR4_STR|27)
|
||||||
|
#define SVR4_I_FLUSHBAND (SVR4_STR|28)
|
||||||
|
#define SVR4_I_CKBAND (SVR4_STR|29)
|
||||||
|
#define SVR4_I_GETBAND (SVR4_STR|30)
|
||||||
|
#define SVR4_I_ATMARK (SVR4_STR|31)
|
||||||
|
#define SVR4_I_SETCLTIME (SVR4_STR|32)
|
||||||
|
#define SVR4_I_GETCLTIME (SVR4_STR|33)
|
||||||
|
#define SVR4_I_CANPUT (SVR4_STR|34)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following two ioctls are OS specific and
|
||||||
|
* undocumented.
|
||||||
|
*/
|
||||||
|
#define SVR4__I_BIND_RSVD (SVR4_STR|242)
|
||||||
|
#define SVR4__I_RELE_RSVD (SVR4_STR|243)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Service type definitions
|
||||||
|
*/
|
||||||
|
#define SVR4_T_COTS 1 /* Connection-orieted */
|
||||||
|
#define SVR4_T_COTS_ORD 2 /* Local connection-oriented */
|
||||||
|
#define SVR4_T_CLTS 3 /* Connectionless */
|
||||||
|
|
||||||
|
/* Struct passed for SVR4_I_STR */
|
||||||
|
struct svr4_strioctl {
|
||||||
|
u_long cmd;
|
||||||
|
int timeout;
|
||||||
|
int len;
|
||||||
|
char *buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bits for I_{G,S}ETSIG
|
||||||
|
*/
|
||||||
|
#define SVR4_S_INPUT 0x0001 /* any message on read queue no HIPRI */
|
||||||
|
#define SVR4_S_HIPRI 0x0002 /* high prio message on read queue */
|
||||||
|
#define SVR4_S_OUTPUT 0x0004 /* write queue has free space */
|
||||||
|
#define SVR4_S_MSG 0x0008 /* signal message in read queue head */
|
||||||
|
#define SVR4_S_ERROR 0x0010 /* error message in read queue head */
|
||||||
|
#define SVR4_S_HANGUP 0x0020 /* hangup message in read queue head */
|
||||||
|
#define SVR4_S_RDNORM 0x0040 /* normal message on read queue */
|
||||||
|
#define SVR4_S_WRNORM S_OUTPUT /* write queue has free space */
|
||||||
|
#define SVR4_S_RDBAND 0x0080 /* out of band message on read queue */
|
||||||
|
#define SVR4_S_WRBAND 0x0100 /* write queue has free space for oob */
|
||||||
|
#define SVR4_S_BANDURG 0x0200 /* generate SIGURG instead of SIGPOLL */
|
||||||
|
#define SVR4_S_ALLMASK 0x03ff /* all events mask */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our internal state for the stream
|
||||||
|
* For now we keep almost nothing... In the future we can keep more
|
||||||
|
* streams state.
|
||||||
|
*/
|
||||||
|
struct svr4_strm {
|
||||||
|
int s_family; /* socket family */
|
||||||
|
int s_cmd; /* last getmsg reply or putmsg request */
|
||||||
|
int s_afd; /* last accepted fd; [for fd_insert] */
|
||||||
|
int s_eventmask; /* state info from I_SETSIG et al */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following structures are determined empirically.
|
||||||
|
*/
|
||||||
|
struct svr4_strmcmd {
|
||||||
|
long cmd; /* command ? */
|
||||||
|
long len; /* Address len */
|
||||||
|
long offs; /* Address offset */
|
||||||
|
long pad[61];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_infocmd {
|
||||||
|
long cmd;
|
||||||
|
long tsdu;
|
||||||
|
long etsdu;
|
||||||
|
long cdata;
|
||||||
|
long ddata;
|
||||||
|
long addr;
|
||||||
|
long opt;
|
||||||
|
long tidu;
|
||||||
|
long serv;
|
||||||
|
long current;
|
||||||
|
long provider;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_strfdinsert {
|
||||||
|
struct svr4_strbuf ctl;
|
||||||
|
struct svr4_strbuf data;
|
||||||
|
long flags;
|
||||||
|
int fd;
|
||||||
|
int offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_netaddr_in {
|
||||||
|
u_short family;
|
||||||
|
u_short port;
|
||||||
|
u_long addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_netaddr_un {
|
||||||
|
u_short family;
|
||||||
|
char path[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_ADDROF(sc) (void *) (((char *) (sc)) + (sc)->offs)
|
||||||
|
#define SVR4_C_ADDROF(sc) (const void *) (((const char *) (sc)) + (sc)->offs)
|
||||||
|
|
||||||
|
struct svr4_strm *svr4_stream_get __P((struct file *fp));
|
||||||
|
|
||||||
|
#endif /* !_SVR4_STROPTS */
|
144
sys/compat/svr4/svr4_syscall.h
Normal file
144
sys/compat/svr4/svr4_syscall.h
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
/*
|
||||||
|
* System call numbers.
|
||||||
|
*
|
||||||
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
|
* created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SVR4_SYS_exit 1
|
||||||
|
#define SVR4_SYS_fork 2
|
||||||
|
#define SVR4_SYS_read 3
|
||||||
|
#define SVR4_SYS_write 4
|
||||||
|
#define SVR4_SYS_svr4_sys_open 5
|
||||||
|
#define SVR4_SYS_close 6
|
||||||
|
#define SVR4_SYS_svr4_sys_wait 7
|
||||||
|
#define SVR4_SYS_svr4_sys_creat 8
|
||||||
|
#define SVR4_SYS_link 9
|
||||||
|
#define SVR4_SYS_unlink 10
|
||||||
|
#define SVR4_SYS_svr4_sys_execv 11
|
||||||
|
#define SVR4_SYS_chdir 12
|
||||||
|
#define SVR4_SYS_svr4_sys_time 13
|
||||||
|
#define SVR4_SYS_svr4_sys_mknod 14
|
||||||
|
#define SVR4_SYS_chmod 15
|
||||||
|
#define SVR4_SYS_chown 16
|
||||||
|
#define SVR4_SYS_svr4_sys_break 17
|
||||||
|
#define SVR4_SYS_svr4_sys_stat 18
|
||||||
|
#define SVR4_SYS_lseek 19
|
||||||
|
#define SVR4_SYS_getpid 20
|
||||||
|
#define SVR4_SYS_setuid 23
|
||||||
|
#define SVR4_SYS_getuid 24
|
||||||
|
#define SVR4_SYS_svr4_sys_alarm 27
|
||||||
|
#define SVR4_SYS_svr4_sys_fstat 28
|
||||||
|
#define SVR4_SYS_svr4_sys_pause 29
|
||||||
|
#define SVR4_SYS_svr4_sys_utime 30
|
||||||
|
#define SVR4_SYS_svr4_sys_access 33
|
||||||
|
#define SVR4_SYS_svr4_sys_nice 34
|
||||||
|
#define SVR4_SYS_sync 36
|
||||||
|
#define SVR4_SYS_svr4_sys_kill 37
|
||||||
|
#define SVR4_SYS_svr4_sys_pgrpsys 39
|
||||||
|
#define SVR4_SYS_dup 41
|
||||||
|
#define SVR4_SYS_pipe 42
|
||||||
|
#define SVR4_SYS_svr4_sys_times 43
|
||||||
|
#define SVR4_SYS_setgid 46
|
||||||
|
#define SVR4_SYS_getgid 47
|
||||||
|
#define SVR4_SYS_svr4_sys_signal 48
|
||||||
|
#define SVR4_SYS_svr4_sys_msgsys 49
|
||||||
|
#define SVR4_SYS_svr4_sys_sysarch 50
|
||||||
|
#define SVR4_SYS_svr4_sys_ioctl 54
|
||||||
|
#define SVR4_SYS_svr4_sys_utssys 57
|
||||||
|
#define SVR4_SYS_fsync 58
|
||||||
|
#define SVR4_SYS_svr4_sys_execve 59
|
||||||
|
#define SVR4_SYS_umask 60
|
||||||
|
#define SVR4_SYS_chroot 61
|
||||||
|
#define SVR4_SYS_svr4_sys_fcntl 62
|
||||||
|
#define SVR4_SYS_svr4_sys_ulimit 63
|
||||||
|
#define SVR4_SYS_rmdir 79
|
||||||
|
#define SVR4_SYS_mkdir 80
|
||||||
|
#define SVR4_SYS_svr4_sys_getdents 81
|
||||||
|
#define SVR4_SYS_svr4_sys_getmsg 85
|
||||||
|
#define SVR4_SYS_svr4_sys_putmsg 86
|
||||||
|
#define SVR4_SYS_svr4_sys_poll 87
|
||||||
|
#define SVR4_SYS_svr4_sys_lstat 88
|
||||||
|
#define SVR4_SYS_symlink 89
|
||||||
|
#define SVR4_SYS_readlink 90
|
||||||
|
#define SVR4_SYS_getgroups 91
|
||||||
|
#define SVR4_SYS_setgroups 92
|
||||||
|
#define SVR4_SYS_fchmod 93
|
||||||
|
#define SVR4_SYS_fchown 94
|
||||||
|
#define SVR4_SYS_svr4_sys_sigprocmask 95
|
||||||
|
#define SVR4_SYS_svr4_sys_sigsuspend 96
|
||||||
|
#define SVR4_SYS_svr4_sys_sigaltstack 97
|
||||||
|
#define SVR4_SYS_svr4_sys_sigaction 98
|
||||||
|
#define SVR4_SYS_svr4_sys_sigpending 99
|
||||||
|
#define SVR4_SYS_svr4_sys_context 100
|
||||||
|
#define SVR4_SYS_svr4_sys_statvfs 103
|
||||||
|
#define SVR4_SYS_svr4_sys_fstatvfs 104
|
||||||
|
#define SVR4_SYS_svr4_sys_waitsys 107
|
||||||
|
#define SVR4_SYS_svr4_sys_hrtsys 109
|
||||||
|
#define SVR4_SYS_svr4_sys_pathconf 113
|
||||||
|
#define SVR4_SYS_svr4_sys_mmap 115
|
||||||
|
#define SVR4_SYS_mprotect 116
|
||||||
|
#define SVR4_SYS_munmap 117
|
||||||
|
#define SVR4_SYS_svr4_sys_fpathconf 118
|
||||||
|
#define SVR4_SYS_vfork 119
|
||||||
|
#define SVR4_SYS_fchdir 120
|
||||||
|
#define SVR4_SYS_readv 121
|
||||||
|
#define SVR4_SYS_writev 122
|
||||||
|
#define SVR4_SYS_svr4_sys_xstat 123
|
||||||
|
#define SVR4_SYS_svr4_sys_lxstat 124
|
||||||
|
#define SVR4_SYS_svr4_sys_fxstat 125
|
||||||
|
#define SVR4_SYS_svr4_sys_xmknod 126
|
||||||
|
#define SVR4_SYS_svr4_sys_setrlimit 128
|
||||||
|
#define SVR4_SYS_svr4_sys_getrlimit 129
|
||||||
|
#define SVR4_SYS_lchown 130
|
||||||
|
#define SVR4_SYS_svr4_sys_memcntl 131
|
||||||
|
#define SVR4_SYS_rename 134
|
||||||
|
#define SVR4_SYS_svr4_sys_uname 135
|
||||||
|
#define SVR4_SYS_setegid 136
|
||||||
|
#define SVR4_SYS_svr4_sys_sysconfig 137
|
||||||
|
#define SVR4_SYS_adjtime 138
|
||||||
|
#define SVR4_SYS_svr4_sys_systeminfo 139
|
||||||
|
#define SVR4_SYS_seteuid 141
|
||||||
|
#define SVR4_SYS_svr4_sys_fchroot 153
|
||||||
|
#define SVR4_SYS_svr4_sys_utimes 154
|
||||||
|
#define SVR4_SYS_svr4_sys_vhangup 155
|
||||||
|
#define SVR4_SYS_svr4_sys_gettimeofday 156
|
||||||
|
#define SVR4_SYS_getitimer 157
|
||||||
|
#define SVR4_SYS_setitimer 158
|
||||||
|
#define SVR4_SYS_svr4_sys_llseek 175
|
||||||
|
#define SVR4_SYS_svr4_sys_acl 185
|
||||||
|
#define SVR4_SYS_svr4_sys_auditsys 186
|
||||||
|
#define SVR4_SYS_nanosleep 199
|
||||||
|
#define SVR4_SYS_svr4_sys_facl 200
|
||||||
|
#define SVR4_SYS_setreuid 202
|
||||||
|
#define SVR4_SYS_setregid 203
|
||||||
|
#define SVR4_SYS_svr4_sys_resolvepath 209
|
||||||
|
#define SVR4_SYS_svr4_sys_getdents64 213
|
||||||
|
#define SVR4_SYS_svr4_sys_mmap64 214
|
||||||
|
#define SVR4_SYS_svr4_sys_stat64 215
|
||||||
|
#define SVR4_SYS_svr4_sys_lstat64 216
|
||||||
|
#define SVR4_SYS_svr4_sys_fstat64 217
|
||||||
|
#define SVR4_SYS_svr4_sys_statvfs64 218
|
||||||
|
#define SVR4_SYS_svr4_sys_fstatvfs64 219
|
||||||
|
#define SVR4_SYS_svr4_sys_setrlimit64 220
|
||||||
|
#define SVR4_SYS_svr4_sys_getrlimit64 221
|
||||||
|
#define SVR4_SYS_svr4_sys_creat64 224
|
||||||
|
#define SVR4_SYS_svr4_sys_open64 225
|
||||||
|
#define SVR4_SYS_svr4_sys_socket 230
|
||||||
|
#define SVR4_SYS_socketpair 231
|
||||||
|
#define SVR4_SYS_bind 232
|
||||||
|
#define SVR4_SYS_listen 233
|
||||||
|
#define SVR4_SYS_accept 234
|
||||||
|
#define SVR4_SYS_connect 235
|
||||||
|
#define SVR4_SYS_shutdown 236
|
||||||
|
#define SVR4_SYS_svr4_sys_recv 237
|
||||||
|
#define SVR4_SYS_recvfrom 238
|
||||||
|
#define SVR4_SYS_recvmsg 239
|
||||||
|
#define SVR4_SYS_svr4_sys_send 240
|
||||||
|
#define SVR4_SYS_sendmsg 241
|
||||||
|
#define SVR4_SYS_svr4_sys_sendto 242
|
||||||
|
#define SVR4_SYS_getpeername 243
|
||||||
|
#define SVR4_SYS_getsockname 244
|
||||||
|
#define SVR4_SYS_getsockopt 245
|
||||||
|
#define SVR4_SYS_setsockopt 246
|
||||||
|
#define SVR4_SYS_MAXSYSCALL 250
|
263
sys/compat/svr4/svr4_syscallnames.c
Normal file
263
sys/compat/svr4/svr4_syscallnames.c
Normal file
|
@ -0,0 +1,263 @@
|
||||||
|
/*
|
||||||
|
* System call names.
|
||||||
|
*
|
||||||
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
|
* created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *svr4_syscallnames[] = {
|
||||||
|
"#0", /* 0 = unused */
|
||||||
|
"exit", /* 1 = exit */
|
||||||
|
"fork", /* 2 = fork */
|
||||||
|
"read", /* 3 = read */
|
||||||
|
"write", /* 4 = write */
|
||||||
|
"svr4_sys_open", /* 5 = svr4_sys_open */
|
||||||
|
"close", /* 6 = close */
|
||||||
|
"svr4_sys_wait", /* 7 = svr4_sys_wait */
|
||||||
|
"svr4_sys_creat", /* 8 = svr4_sys_creat */
|
||||||
|
"link", /* 9 = link */
|
||||||
|
"unlink", /* 10 = unlink */
|
||||||
|
"svr4_sys_execv", /* 11 = svr4_sys_execv */
|
||||||
|
"chdir", /* 12 = chdir */
|
||||||
|
"svr4_sys_time", /* 13 = svr4_sys_time */
|
||||||
|
"svr4_sys_mknod", /* 14 = svr4_sys_mknod */
|
||||||
|
"chmod", /* 15 = chmod */
|
||||||
|
"chown", /* 16 = chown */
|
||||||
|
"svr4_sys_break", /* 17 = svr4_sys_break */
|
||||||
|
"svr4_sys_stat", /* 18 = svr4_sys_stat */
|
||||||
|
"lseek", /* 19 = lseek */
|
||||||
|
"getpid", /* 20 = getpid */
|
||||||
|
"#21", /* 21 = old_mount */
|
||||||
|
"#22", /* 22 = sysv_umount */
|
||||||
|
"setuid", /* 23 = setuid */
|
||||||
|
"getuid", /* 24 = getuid */
|
||||||
|
"#25", /* 25 = stime */
|
||||||
|
"#26", /* 26 = ptrace */
|
||||||
|
"svr4_sys_alarm", /* 27 = svr4_sys_alarm */
|
||||||
|
"svr4_sys_fstat", /* 28 = svr4_sys_fstat */
|
||||||
|
"svr4_sys_pause", /* 29 = svr4_sys_pause */
|
||||||
|
"svr4_sys_utime", /* 30 = svr4_sys_utime */
|
||||||
|
"#31", /* 31 = stty */
|
||||||
|
"#32", /* 32 = gtty */
|
||||||
|
"svr4_sys_access", /* 33 = svr4_sys_access */
|
||||||
|
"svr4_sys_nice", /* 34 = svr4_sys_nice */
|
||||||
|
"#35", /* 35 = statfs */
|
||||||
|
"sync", /* 36 = sync */
|
||||||
|
"svr4_sys_kill", /* 37 = svr4_sys_kill */
|
||||||
|
"#38", /* 38 = fstatfs */
|
||||||
|
"svr4_sys_pgrpsys", /* 39 = svr4_sys_pgrpsys */
|
||||||
|
"#40", /* 40 = xenix */
|
||||||
|
"dup", /* 41 = dup */
|
||||||
|
"pipe", /* 42 = pipe */
|
||||||
|
"svr4_sys_times", /* 43 = svr4_sys_times */
|
||||||
|
"#44", /* 44 = profil */
|
||||||
|
"#45", /* 45 = plock */
|
||||||
|
"setgid", /* 46 = setgid */
|
||||||
|
"getgid", /* 47 = getgid */
|
||||||
|
"svr4_sys_signal", /* 48 = svr4_sys_signal */
|
||||||
|
#if defined(NOTYET)
|
||||||
|
"svr4_sys_msgsys", /* 49 = svr4_sys_msgsys */
|
||||||
|
#else
|
||||||
|
"#49", /* 49 = msgsys */
|
||||||
|
#endif
|
||||||
|
"svr4_sys_sysarch", /* 50 = svr4_sys_sysarch */
|
||||||
|
"#51", /* 51 = acct */
|
||||||
|
"#52", /* 52 = shmsys */
|
||||||
|
"#53", /* 53 = semsys */
|
||||||
|
"svr4_sys_ioctl", /* 54 = svr4_sys_ioctl */
|
||||||
|
"#55", /* 55 = uadmin */
|
||||||
|
"#56", /* 56 = exch */
|
||||||
|
"svr4_sys_utssys", /* 57 = svr4_sys_utssys */
|
||||||
|
"fsync", /* 58 = fsync */
|
||||||
|
"svr4_sys_execve", /* 59 = svr4_sys_execve */
|
||||||
|
"umask", /* 60 = umask */
|
||||||
|
"chroot", /* 61 = chroot */
|
||||||
|
"svr4_sys_fcntl", /* 62 = svr4_sys_fcntl */
|
||||||
|
"svr4_sys_ulimit", /* 63 = svr4_sys_ulimit */
|
||||||
|
"#64", /* 64 = reserved */
|
||||||
|
"#65", /* 65 = reserved */
|
||||||
|
"#66", /* 66 = reserved */
|
||||||
|
"#67", /* 67 = reserved */
|
||||||
|
"#68", /* 68 = reserved */
|
||||||
|
"#69", /* 69 = reserved */
|
||||||
|
"#70", /* 70 = advfs */
|
||||||
|
"#71", /* 71 = unadvfs */
|
||||||
|
"#72", /* 72 = rmount */
|
||||||
|
"#73", /* 73 = rumount */
|
||||||
|
"#74", /* 74 = rfstart */
|
||||||
|
"#75", /* 75 = sigret */
|
||||||
|
"#76", /* 76 = rdebug */
|
||||||
|
"#77", /* 77 = rfstop */
|
||||||
|
"#78", /* 78 = rfsys */
|
||||||
|
"rmdir", /* 79 = rmdir */
|
||||||
|
"mkdir", /* 80 = mkdir */
|
||||||
|
"svr4_sys_getdents", /* 81 = svr4_sys_getdents */
|
||||||
|
"#82", /* 82 = libattach */
|
||||||
|
"#83", /* 83 = libdetach */
|
||||||
|
"#84", /* 84 = sysfs */
|
||||||
|
"svr4_sys_getmsg", /* 85 = svr4_sys_getmsg */
|
||||||
|
"svr4_sys_putmsg", /* 86 = svr4_sys_putmsg */
|
||||||
|
"svr4_sys_poll", /* 87 = svr4_sys_poll */
|
||||||
|
"svr4_sys_lstat", /* 88 = svr4_sys_lstat */
|
||||||
|
"symlink", /* 89 = symlink */
|
||||||
|
"readlink", /* 90 = readlink */
|
||||||
|
"getgroups", /* 91 = getgroups */
|
||||||
|
"setgroups", /* 92 = setgroups */
|
||||||
|
"fchmod", /* 93 = fchmod */
|
||||||
|
"fchown", /* 94 = fchown */
|
||||||
|
"svr4_sys_sigprocmask", /* 95 = svr4_sys_sigprocmask */
|
||||||
|
"svr4_sys_sigsuspend", /* 96 = svr4_sys_sigsuspend */
|
||||||
|
"svr4_sys_sigaltstack", /* 97 = svr4_sys_sigaltstack */
|
||||||
|
"svr4_sys_sigaction", /* 98 = svr4_sys_sigaction */
|
||||||
|
"svr4_sys_sigpending", /* 99 = svr4_sys_sigpending */
|
||||||
|
"svr4_sys_context", /* 100 = svr4_sys_context */
|
||||||
|
"#101", /* 101 = evsys */
|
||||||
|
"#102", /* 102 = evtrapret */
|
||||||
|
"svr4_sys_statvfs", /* 103 = svr4_sys_statvfs */
|
||||||
|
"svr4_sys_fstatvfs", /* 104 = svr4_sys_fstatvfs */
|
||||||
|
"#105", /* 105 = whoknows */
|
||||||
|
"#106", /* 106 = nfssvc */
|
||||||
|
"svr4_sys_waitsys", /* 107 = svr4_sys_waitsys */
|
||||||
|
"#108", /* 108 = sigsendsys */
|
||||||
|
"svr4_sys_hrtsys", /* 109 = svr4_sys_hrtsys */
|
||||||
|
"#110", /* 110 = acancel */
|
||||||
|
"#111", /* 111 = async */
|
||||||
|
"#112", /* 112 = priocntlsys */
|
||||||
|
"svr4_sys_pathconf", /* 113 = svr4_sys_pathconf */
|
||||||
|
"#114", /* 114 = mincore */
|
||||||
|
"svr4_sys_mmap", /* 115 = svr4_sys_mmap */
|
||||||
|
"mprotect", /* 116 = mprotect */
|
||||||
|
"munmap", /* 117 = munmap */
|
||||||
|
"svr4_sys_fpathconf", /* 118 = svr4_sys_fpathconf */
|
||||||
|
"vfork", /* 119 = vfork */
|
||||||
|
"fchdir", /* 120 = fchdir */
|
||||||
|
"readv", /* 121 = readv */
|
||||||
|
"writev", /* 122 = writev */
|
||||||
|
"svr4_sys_xstat", /* 123 = svr4_sys_xstat */
|
||||||
|
"svr4_sys_lxstat", /* 124 = svr4_sys_lxstat */
|
||||||
|
"svr4_sys_fxstat", /* 125 = svr4_sys_fxstat */
|
||||||
|
"svr4_sys_xmknod", /* 126 = svr4_sys_xmknod */
|
||||||
|
"#127", /* 127 = clocal */
|
||||||
|
"svr4_sys_setrlimit", /* 128 = svr4_sys_setrlimit */
|
||||||
|
"svr4_sys_getrlimit", /* 129 = svr4_sys_getrlimit */
|
||||||
|
"lchown", /* 130 = lchown */
|
||||||
|
"svr4_sys_memcntl", /* 131 = svr4_sys_memcntl */
|
||||||
|
"#132", /* 132 = getpmsg */
|
||||||
|
"#133", /* 133 = putpmsg */
|
||||||
|
"rename", /* 134 = rename */
|
||||||
|
"svr4_sys_uname", /* 135 = svr4_sys_uname */
|
||||||
|
"setegid", /* 136 = setegid */
|
||||||
|
"svr4_sys_sysconfig", /* 137 = svr4_sys_sysconfig */
|
||||||
|
"adjtime", /* 138 = adjtime */
|
||||||
|
"svr4_sys_systeminfo", /* 139 = svr4_sys_systeminfo */
|
||||||
|
"#140", /* 140 = notused */
|
||||||
|
"seteuid", /* 141 = seteuid */
|
||||||
|
"#142", /* 142 = vtrace */
|
||||||
|
"#143", /* 143 = { */
|
||||||
|
"#144", /* 144 = sigtimedwait */
|
||||||
|
"#145", /* 145 = lwp_info */
|
||||||
|
"#146", /* 146 = yield */
|
||||||
|
"#147", /* 147 = lwp_sema_wait */
|
||||||
|
"#148", /* 148 = lwp_sema_post */
|
||||||
|
"#149", /* 149 = lwp_sema_trywait */
|
||||||
|
"#150", /* 150 = notused */
|
||||||
|
"#151", /* 151 = notused */
|
||||||
|
"#152", /* 152 = modctl */
|
||||||
|
"svr4_sys_fchroot", /* 153 = svr4_sys_fchroot */
|
||||||
|
"svr4_sys_utimes", /* 154 = svr4_sys_utimes */
|
||||||
|
"svr4_sys_vhangup", /* 155 = svr4_sys_vhangup */
|
||||||
|
"svr4_sys_gettimeofday", /* 156 = svr4_sys_gettimeofday */
|
||||||
|
"getitimer", /* 157 = getitimer */
|
||||||
|
"setitimer", /* 158 = setitimer */
|
||||||
|
"#159", /* 159 = lwp_create */
|
||||||
|
"#160", /* 160 = lwp_exit */
|
||||||
|
"#161", /* 161 = lwp_suspend */
|
||||||
|
"#162", /* 162 = lwp_continue */
|
||||||
|
"#163", /* 163 = lwp_kill */
|
||||||
|
"#164", /* 164 = lwp_self */
|
||||||
|
"#165", /* 165 = lwp_getprivate */
|
||||||
|
"#166", /* 166 = lwp_setprivate */
|
||||||
|
"#167", /* 167 = lwp_wait */
|
||||||
|
"#168", /* 168 = lwp_mutex_unlock */
|
||||||
|
"#169", /* 169 = lwp_mutex_lock */
|
||||||
|
"#170", /* 170 = lwp_cond_wait */
|
||||||
|
"#171", /* 171 = lwp_cond_signal */
|
||||||
|
"#172", /* 172 = lwp_cond_broadcast */
|
||||||
|
"#173", /* 173 = { */
|
||||||
|
"#174", /* 174 = { */
|
||||||
|
"svr4_sys_llseek", /* 175 = svr4_sys_llseek */
|
||||||
|
"#176", /* 176 = inst_sync */
|
||||||
|
"#177", /* 177 = whoknows */
|
||||||
|
"#178", /* 178 = kaio */
|
||||||
|
"#179", /* 179 = whoknows */
|
||||||
|
"#180", /* 180 = whoknows */
|
||||||
|
"#181", /* 181 = whoknows */
|
||||||
|
"#182", /* 182 = whoknows */
|
||||||
|
"#183", /* 183 = whoknows */
|
||||||
|
"#184", /* 184 = tsolsys */
|
||||||
|
"svr4_sys_acl", /* 185 = svr4_sys_acl */
|
||||||
|
"svr4_sys_auditsys", /* 186 = svr4_sys_auditsys */
|
||||||
|
"#187", /* 187 = processor_bind */
|
||||||
|
"#188", /* 188 = processor_info */
|
||||||
|
"#189", /* 189 = p_online */
|
||||||
|
"#190", /* 190 = sigqueue */
|
||||||
|
"#191", /* 191 = clock_gettime */
|
||||||
|
"#192", /* 192 = clock_settime */
|
||||||
|
"#193", /* 193 = clock_getres */
|
||||||
|
"#194", /* 194 = timer_create */
|
||||||
|
"#195", /* 195 = timer_delete */
|
||||||
|
"#196", /* 196 = timer_settime */
|
||||||
|
"#197", /* 197 = timer_gettime */
|
||||||
|
"#198", /* 198 = timer_overrun */
|
||||||
|
"nanosleep", /* 199 = nanosleep */
|
||||||
|
"svr4_sys_facl", /* 200 = svr4_sys_facl */
|
||||||
|
"#201", /* 201 = door */
|
||||||
|
"setreuid", /* 202 = setreuid */
|
||||||
|
"setregid", /* 203 = setregid */
|
||||||
|
"#204", /* 204 = install_utrap */
|
||||||
|
"#205", /* 205 = signotify */
|
||||||
|
"#206", /* 206 = schedctl */
|
||||||
|
"#207", /* 207 = pset */
|
||||||
|
"#208", /* 208 = whoknows */
|
||||||
|
"svr4_sys_resolvepath", /* 209 = svr4_sys_resolvepath */
|
||||||
|
"#210", /* 210 = signotifywait */
|
||||||
|
"#211", /* 211 = lwp_sigredirect */
|
||||||
|
"#212", /* 212 = lwp_alarm */
|
||||||
|
"svr4_sys_getdents64", /* 213 = svr4_sys_getdents64 */
|
||||||
|
"svr4_sys_mmap64", /* 214 = svr4_sys_mmap64 */
|
||||||
|
"svr4_sys_stat64", /* 215 = svr4_sys_stat64 */
|
||||||
|
"svr4_sys_lstat64", /* 216 = svr4_sys_lstat64 */
|
||||||
|
"svr4_sys_fstat64", /* 217 = svr4_sys_fstat64 */
|
||||||
|
"svr4_sys_statvfs64", /* 218 = svr4_sys_statvfs64 */
|
||||||
|
"svr4_sys_fstatvfs64", /* 219 = svr4_sys_fstatvfs64 */
|
||||||
|
"svr4_sys_setrlimit64", /* 220 = svr4_sys_setrlimit64 */
|
||||||
|
"svr4_sys_getrlimit64", /* 221 = svr4_sys_getrlimit64 */
|
||||||
|
"#222", /* 222 = pread64 */
|
||||||
|
"#223", /* 223 = pwrite64 */
|
||||||
|
"svr4_sys_creat64", /* 224 = svr4_sys_creat64 */
|
||||||
|
"svr4_sys_open64", /* 225 = svr4_sys_open64 */
|
||||||
|
"#226", /* 226 = rpcsys */
|
||||||
|
"#227", /* 227 = whoknows */
|
||||||
|
"#228", /* 228 = whoknows */
|
||||||
|
"#229", /* 229 = whoknows */
|
||||||
|
"svr4_sys_socket", /* 230 = svr4_sys_socket */
|
||||||
|
"socketpair", /* 231 = socketpair */
|
||||||
|
"bind", /* 232 = bind */
|
||||||
|
"listen", /* 233 = listen */
|
||||||
|
"accept", /* 234 = accept */
|
||||||
|
"connect", /* 235 = connect */
|
||||||
|
"shutdown", /* 236 = shutdown */
|
||||||
|
"svr4_sys_recv", /* 237 = svr4_sys_recv */
|
||||||
|
"recvfrom", /* 238 = recvfrom */
|
||||||
|
"recvmsg", /* 239 = recvmsg */
|
||||||
|
"svr4_sys_send", /* 240 = svr4_sys_send */
|
||||||
|
"sendmsg", /* 241 = sendmsg */
|
||||||
|
"svr4_sys_sendto", /* 242 = svr4_sys_sendto */
|
||||||
|
"getpeername", /* 243 = getpeername */
|
||||||
|
"getsockname", /* 244 = getsockname */
|
||||||
|
"getsockopt", /* 245 = getsockopt */
|
||||||
|
"setsockopt", /* 246 = setsockopt */
|
||||||
|
"#247", /* 247 = sockconfig */
|
||||||
|
"#248", /* 248 = { */
|
||||||
|
"#249", /* 249 = { */
|
||||||
|
};
|
60
sys/compat/svr4/svr4_sysconfig.h
Normal file
60
sys/compat/svr4/svr4_sysconfig.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1995 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SYSCONFIG_H_
|
||||||
|
#define _SVR4_SYSCONFIG_H_
|
||||||
|
|
||||||
|
#define SVR4_CONFIG_UNUSED 0x01
|
||||||
|
#define SVR4_CONFIG_NGROUPS 0x02
|
||||||
|
#define SVR4_CONFIG_CHILD_MAX 0x03
|
||||||
|
#define SVR4_CONFIG_OPEN_FILES 0x04
|
||||||
|
#define SVR4_CONFIG_POSIX_VER 0x05
|
||||||
|
#define SVR4_CONFIG_PAGESIZE 0x06
|
||||||
|
#define SVR4_CONFIG_CLK_TCK 0x07
|
||||||
|
#define SVR4_CONFIG_XOPEN_VER 0x08
|
||||||
|
#define SVR4_CONFIG_UNUSED_9 0x09
|
||||||
|
#define SVR4_CONFIG_PROF_TCK 0x0a
|
||||||
|
#define SVR4_CONFIG_NPROC_CONF 0x0b
|
||||||
|
#define SVR4_CONFIG_NPROC_ONLN 0x0c
|
||||||
|
#define SVR4_CONFIG_AIO_LISTIO_MAX 0x0e
|
||||||
|
#define SVR4_CONFIG_AIO_MAX 0x0f
|
||||||
|
#define SVR4_CONFIG_AIO_PRIO_DELTA_MAX 0x10
|
||||||
|
#define SVR4_CONFIG_DELAYTIMER_MAX 0x11
|
||||||
|
#define SVR4_CONFIG_MQ_OPEN_MAX 0x12
|
||||||
|
#define SVR4_CONFIG_MQ_PRIO_MAX 0x13
|
||||||
|
#define SVR4_CONFIG_RTSIG_MAX 0x14
|
||||||
|
#define SVR4_CONFIG_SEM_NSEMS_MAX 0x15
|
||||||
|
#define SVR4_CONFIG_SEM_VALUE_MAX 0x16
|
||||||
|
#define SVR4_CONFIG_SIGQUEUE_MAX 0x17
|
||||||
|
#define SVR4_CONFIG_SIGRT_MIN 0x18
|
||||||
|
#define SVR4_CONFIG_SIGRT_MAX 0x19
|
||||||
|
#define SVR4_CONFIG_TIMER_MAX 0x20
|
||||||
|
#define SVR4_CONFIG_PHYS_PAGES 0x21
|
||||||
|
#define SVR4_CONFIG_AVPHYS_PAGES 0x22
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SYSCONFIG_H_ */
|
282
sys/compat/svr4/svr4_sysent.c
Normal file
282
sys/compat/svr4/svr4_sysent.c
Normal file
|
@ -0,0 +1,282 @@
|
||||||
|
/*
|
||||||
|
* System call switch table.
|
||||||
|
*
|
||||||
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
|
* created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filio.h>
|
||||||
|
#include <sys/sysent.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_stropts.h>
|
||||||
|
#include <svr4/svr4_socket.h>
|
||||||
|
#include <svr4/svr4_sockio.h>
|
||||||
|
#include <svr4/svr4_timod.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
|
||||||
|
/* The casts are bogus but will do for now. */
|
||||||
|
struct sysent svr4_sysent[] = {
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 0 = unused */
|
||||||
|
{ 1, (sy_call_t *)exit }, /* 1 = exit */
|
||||||
|
{ 0, (sy_call_t *)fork }, /* 2 = fork */
|
||||||
|
{ 3, (sy_call_t *)read }, /* 3 = read */
|
||||||
|
{ 3, (sy_call_t *)write }, /* 4 = write */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_open }, /* 5 = svr4_sys_open */
|
||||||
|
{ 1, (sy_call_t *)close }, /* 6 = close */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_wait }, /* 7 = svr4_sys_wait */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_creat }, /* 8 = svr4_sys_creat */
|
||||||
|
{ 2, (sy_call_t *)link }, /* 9 = link */
|
||||||
|
{ 1, (sy_call_t *)unlink }, /* 10 = unlink */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_execv }, /* 11 = svr4_sys_execv */
|
||||||
|
{ 1, (sy_call_t *)chdir }, /* 12 = chdir */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_time }, /* 13 = svr4_sys_time */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_mknod }, /* 14 = svr4_sys_mknod */
|
||||||
|
{ 2, (sy_call_t *)chmod }, /* 15 = chmod */
|
||||||
|
{ 3, (sy_call_t *)chown }, /* 16 = chown */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_break }, /* 17 = svr4_sys_break */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_stat }, /* 18 = svr4_sys_stat */
|
||||||
|
{ 3, (sy_call_t *)lseek }, /* 19 = lseek */
|
||||||
|
{ 0, (sy_call_t *)getpid }, /* 20 = getpid */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 21 = old_mount */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 22 = sysv_umount */
|
||||||
|
{ 1, (sy_call_t *)setuid }, /* 23 = setuid */
|
||||||
|
{ 0, (sy_call_t *)getuid }, /* 24 = getuid */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 25 = stime */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 26 = ptrace */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_alarm }, /* 27 = svr4_sys_alarm */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_fstat }, /* 28 = svr4_sys_fstat */
|
||||||
|
{ 0, (sy_call_t *)svr4_sys_pause }, /* 29 = svr4_sys_pause */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_utime }, /* 30 = svr4_sys_utime */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 31 = stty */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 32 = gtty */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_access }, /* 33 = svr4_sys_access */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_nice }, /* 34 = svr4_sys_nice */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 35 = statfs */
|
||||||
|
{ 0, (sy_call_t *)sync }, /* 36 = sync */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_kill }, /* 37 = svr4_sys_kill */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 38 = fstatfs */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_pgrpsys }, /* 39 = svr4_sys_pgrpsys */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 40 = xenix */
|
||||||
|
{ 1, (sy_call_t *)dup }, /* 41 = dup */
|
||||||
|
{ 0, (sy_call_t *)pipe }, /* 42 = pipe */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_times }, /* 43 = svr4_sys_times */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 44 = profil */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 45 = plock */
|
||||||
|
{ 1, (sy_call_t *)setgid }, /* 46 = setgid */
|
||||||
|
{ 0, (sy_call_t *)getgid }, /* 47 = getgid */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_signal }, /* 48 = svr4_sys_signal */
|
||||||
|
#if defined(NOTYET)
|
||||||
|
{ 5, (sy_call_t *)svr4_sys_msgsys }, /* 49 = svr4_sys_msgsys */
|
||||||
|
#else
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 49 = msgsys */
|
||||||
|
#endif
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_sysarch }, /* 50 = svr4_sys_sysarch */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 51 = acct */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 52 = shmsys */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 53 = semsys */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_ioctl }, /* 54 = svr4_sys_ioctl */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 55 = uadmin */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 56 = exch */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_utssys }, /* 57 = svr4_sys_utssys */
|
||||||
|
{ 1, (sy_call_t *)fsync }, /* 58 = fsync */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_execve }, /* 59 = svr4_sys_execve */
|
||||||
|
{ 1, (sy_call_t *)umask }, /* 60 = umask */
|
||||||
|
{ 1, (sy_call_t *)chroot }, /* 61 = chroot */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_fcntl }, /* 62 = svr4_sys_fcntl */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_ulimit }, /* 63 = svr4_sys_ulimit */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 64 = reserved */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 65 = reserved */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 66 = reserved */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 67 = reserved */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 68 = reserved */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 69 = reserved */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 70 = advfs */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 71 = unadvfs */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 72 = rmount */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 73 = rumount */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 74 = rfstart */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 75 = sigret */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 76 = rdebug */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 77 = rfstop */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 78 = rfsys */
|
||||||
|
{ 1, (sy_call_t *)rmdir }, /* 79 = rmdir */
|
||||||
|
{ 2, (sy_call_t *)mkdir }, /* 80 = mkdir */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_getdents }, /* 81 = svr4_sys_getdents */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 82 = libattach */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 83 = libdetach */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 84 = sysfs */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_getmsg }, /* 85 = svr4_sys_getmsg */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_putmsg }, /* 86 = svr4_sys_putmsg */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_poll }, /* 87 = svr4_sys_poll */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_lstat }, /* 88 = svr4_sys_lstat */
|
||||||
|
{ 2, (sy_call_t *)symlink }, /* 89 = symlink */
|
||||||
|
{ 3, (sy_call_t *)readlink }, /* 90 = readlink */
|
||||||
|
{ 2, (sy_call_t *)getgroups }, /* 91 = getgroups */
|
||||||
|
{ 2, (sy_call_t *)setgroups }, /* 92 = setgroups */
|
||||||
|
{ 2, (sy_call_t *)fchmod }, /* 93 = fchmod */
|
||||||
|
{ 3, (sy_call_t *)fchown }, /* 94 = fchown */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_sigprocmask }, /* 95 = svr4_sys_sigprocmask */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_sigsuspend }, /* 96 = svr4_sys_sigsuspend */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_sigaltstack }, /* 97 = svr4_sys_sigaltstack */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_sigaction }, /* 98 = svr4_sys_sigaction */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_sigpending }, /* 99 = svr4_sys_sigpending */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_context }, /* 100 = svr4_sys_context */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 101 = evsys */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 102 = evtrapret */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_statvfs }, /* 103 = svr4_sys_statvfs */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_fstatvfs }, /* 104 = svr4_sys_fstatvfs */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 105 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 106 = nfssvc */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_waitsys }, /* 107 = svr4_sys_waitsys */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 108 = sigsendsys */
|
||||||
|
{ 5, (sy_call_t *)svr4_sys_hrtsys }, /* 109 = svr4_sys_hrtsys */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 110 = acancel */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 111 = async */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 112 = priocntlsys */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_pathconf }, /* 113 = svr4_sys_pathconf */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 114 = mincore */
|
||||||
|
{ 6, (sy_call_t *)svr4_sys_mmap }, /* 115 = svr4_sys_mmap */
|
||||||
|
{ 3, (sy_call_t *)mprotect }, /* 116 = mprotect */
|
||||||
|
{ 2, (sy_call_t *)munmap }, /* 117 = munmap */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_fpathconf }, /* 118 = svr4_sys_fpathconf */
|
||||||
|
{ 0, (sy_call_t *)vfork }, /* 119 = vfork */
|
||||||
|
{ 1, (sy_call_t *)fchdir }, /* 120 = fchdir */
|
||||||
|
{ 3, (sy_call_t *)readv }, /* 121 = readv */
|
||||||
|
{ 3, (sy_call_t *)writev }, /* 122 = writev */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_xstat }, /* 123 = svr4_sys_xstat */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_lxstat }, /* 124 = svr4_sys_lxstat */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_fxstat }, /* 125 = svr4_sys_fxstat */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_xmknod }, /* 126 = svr4_sys_xmknod */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 127 = clocal */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_setrlimit }, /* 128 = svr4_sys_setrlimit */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_getrlimit }, /* 129 = svr4_sys_getrlimit */
|
||||||
|
{ 3, (sy_call_t *)lchown }, /* 130 = lchown */
|
||||||
|
{ 6, (sy_call_t *)svr4_sys_memcntl }, /* 131 = svr4_sys_memcntl */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 132 = getpmsg */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 133 = putpmsg */
|
||||||
|
{ 2, (sy_call_t *)rename }, /* 134 = rename */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_uname }, /* 135 = svr4_sys_uname */
|
||||||
|
{ 1, (sy_call_t *)setegid }, /* 136 = setegid */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_sysconfig }, /* 137 = svr4_sys_sysconfig */
|
||||||
|
{ 2, (sy_call_t *)adjtime }, /* 138 = adjtime */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_systeminfo }, /* 139 = svr4_sys_systeminfo */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 140 = notused */
|
||||||
|
{ 1, (sy_call_t *)seteuid }, /* 141 = seteuid */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 142 = vtrace */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 143 = { */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 144 = sigtimedwait */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 145 = lwp_info */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 146 = yield */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 147 = lwp_sema_wait */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 148 = lwp_sema_post */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 149 = lwp_sema_trywait */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 150 = notused */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 151 = notused */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 152 = modctl */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_fchroot }, /* 153 = svr4_sys_fchroot */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_utimes }, /* 154 = svr4_sys_utimes */
|
||||||
|
{ 0, (sy_call_t *)svr4_sys_vhangup }, /* 155 = svr4_sys_vhangup */
|
||||||
|
{ 1, (sy_call_t *)svr4_sys_gettimeofday }, /* 156 = svr4_sys_gettimeofday */
|
||||||
|
{ 2, (sy_call_t *)getitimer }, /* 157 = getitimer */
|
||||||
|
{ 3, (sy_call_t *)setitimer }, /* 158 = setitimer */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 159 = lwp_create */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 160 = lwp_exit */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 161 = lwp_suspend */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 162 = lwp_continue */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 163 = lwp_kill */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 164 = lwp_self */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 165 = lwp_getprivate */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 166 = lwp_setprivate */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 167 = lwp_wait */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 168 = lwp_mutex_unlock */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 169 = lwp_mutex_lock */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 170 = lwp_cond_wait */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 171 = lwp_cond_signal */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 172 = lwp_cond_broadcast */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 173 = { */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 174 = { */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_llseek }, /* 175 = svr4_sys_llseek */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 176 = inst_sync */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 177 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 178 = kaio */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 179 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 180 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 181 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 182 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 183 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 184 = tsolsys */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_acl }, /* 185 = svr4_sys_acl */
|
||||||
|
{ 6, (sy_call_t *)svr4_sys_auditsys }, /* 186 = svr4_sys_auditsys */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 187 = processor_bind */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 188 = processor_info */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 189 = p_online */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 190 = sigqueue */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 191 = clock_gettime */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 192 = clock_settime */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 193 = clock_getres */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 194 = timer_create */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 195 = timer_delete */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 196 = timer_settime */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 197 = timer_gettime */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 198 = timer_overrun */
|
||||||
|
{ 2, (sy_call_t *)nanosleep }, /* 199 = nanosleep */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_facl }, /* 200 = svr4_sys_facl */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 201 = door */
|
||||||
|
{ 2, (sy_call_t *)setreuid }, /* 202 = setreuid */
|
||||||
|
{ 2, (sy_call_t *)setregid }, /* 203 = setregid */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 204 = install_utrap */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 205 = signotify */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 206 = schedctl */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 207 = pset */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 208 = whoknows */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_resolvepath }, /* 209 = svr4_sys_resolvepath */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 210 = signotifywait */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 211 = lwp_sigredirect */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 212 = lwp_alarm */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_getdents64 }, /* 213 = svr4_sys_getdents64 */
|
||||||
|
{ 6, (sy_call_t *)svr4_sys_mmap64 }, /* 214 = svr4_sys_mmap64 */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_stat64 }, /* 215 = svr4_sys_stat64 */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_lstat64 }, /* 216 = svr4_sys_lstat64 */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_fstat64 }, /* 217 = svr4_sys_fstat64 */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_statvfs64 }, /* 218 = svr4_sys_statvfs64 */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_fstatvfs64 }, /* 219 = svr4_sys_fstatvfs64 */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_setrlimit64 }, /* 220 = svr4_sys_setrlimit64 */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_getrlimit64 }, /* 221 = svr4_sys_getrlimit64 */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 222 = pread64 */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 223 = pwrite64 */
|
||||||
|
{ 2, (sy_call_t *)svr4_sys_creat64 }, /* 224 = svr4_sys_creat64 */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_open64 }, /* 225 = svr4_sys_open64 */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 226 = rpcsys */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 227 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 228 = whoknows */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 229 = whoknows */
|
||||||
|
{ 3, (sy_call_t *)svr4_sys_socket }, /* 230 = svr4_sys_socket */
|
||||||
|
{ 4, (sy_call_t *)socketpair }, /* 231 = socketpair */
|
||||||
|
{ 3, (sy_call_t *)bind }, /* 232 = bind */
|
||||||
|
{ 2, (sy_call_t *)listen }, /* 233 = listen */
|
||||||
|
{ 3, (sy_call_t *)accept }, /* 234 = accept */
|
||||||
|
{ 3, (sy_call_t *)connect }, /* 235 = connect */
|
||||||
|
{ 2, (sy_call_t *)shutdown }, /* 236 = shutdown */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_recv }, /* 237 = svr4_sys_recv */
|
||||||
|
{ 6, (sy_call_t *)recvfrom }, /* 238 = recvfrom */
|
||||||
|
{ 3, (sy_call_t *)recvmsg }, /* 239 = recvmsg */
|
||||||
|
{ 4, (sy_call_t *)svr4_sys_send }, /* 240 = svr4_sys_send */
|
||||||
|
{ 3, (sy_call_t *)sendmsg }, /* 241 = sendmsg */
|
||||||
|
{ 6, (sy_call_t *)svr4_sys_sendto }, /* 242 = svr4_sys_sendto */
|
||||||
|
{ 3, (sy_call_t *)getpeername }, /* 243 = getpeername */
|
||||||
|
{ 3, (sy_call_t *)getsockname }, /* 244 = getsockname */
|
||||||
|
{ 5, (sy_call_t *)getsockopt }, /* 245 = getsockopt */
|
||||||
|
{ 5, (sy_call_t *)setsockopt }, /* 246 = setsockopt */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 247 = sockconfig */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 248 = { */
|
||||||
|
{ 0, (sy_call_t *)nosys }, /* 249 = { */
|
||||||
|
};
|
48
sys/compat/svr4/svr4_systeminfo.h
Normal file
48
sys/compat/svr4/svr4_systeminfo.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SYSTEMINFO_H_
|
||||||
|
#define _SVR4_SYSTEMINFO_H_
|
||||||
|
|
||||||
|
#define SVR4_SI_SYSNAME 1
|
||||||
|
#define SVR4_SI_HOSTNAME 2
|
||||||
|
#define SVR4_SI_RELEASE 3
|
||||||
|
#define SVR4_SI_VERSION 4
|
||||||
|
#define SVR4_SI_MACHINE 5
|
||||||
|
#define SVR4_SI_ARCHITECTURE 6
|
||||||
|
#define SVR4_SI_HW_SERIAL 7
|
||||||
|
#define SVR4_SI_HW_PROVIDER 8
|
||||||
|
#define SVR4_SI_SRPC_DOMAIN 9
|
||||||
|
#define SVR4_SI_SET_HOSTNAME 258
|
||||||
|
#define SVR4_SI_SET_SRPC_DOMAIN 265
|
||||||
|
#define SVR4_SI_SET_KERB_REALM 266
|
||||||
|
#define SVR4_SI_KERB_REALM 267
|
||||||
|
#define SVR4_SI_PLATFORM 513
|
||||||
|
#define SVR4_SI_ISALIST 514
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SYSTEMINFO_H_ */
|
383
sys/compat/svr4/svr4_sysvec.c
Normal file
383
sys/compat/svr4/svr4_sysvec.c
Normal file
|
@ -0,0 +1,383 @@
|
||||||
|
/* XXX we use functions that might not exist. */
|
||||||
|
#include "opt_compat.h"
|
||||||
|
|
||||||
|
#ifndef COMPAT_43
|
||||||
|
#error "Unable to compile SVR4-emulator due to missing COMPAT_43 option!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/buf.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/sysent.h>
|
||||||
|
#include <sys/imgact.h>
|
||||||
|
#include <sys/imgact_elf.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/namei.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
#include <sys/module.h>
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <vm/vm_param.h>
|
||||||
|
#include <vm/vm_prot.h>
|
||||||
|
#include <vm/vm_page.h>
|
||||||
|
#include <vm/vm_extern.h>
|
||||||
|
#include <sys/exec.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <machine/cpu.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_syscall.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_sockio.h>
|
||||||
|
#include <svr4/svr4_socket.h>
|
||||||
|
#include <svr4/svr4_errno.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_siginfo.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
|
||||||
|
extern int bsd_to_svr4_sig[];
|
||||||
|
extern int svr4_to_bsd_sig[];
|
||||||
|
|
||||||
|
int bsd_to_svr4_errno[ELAST+1] = {
|
||||||
|
0,
|
||||||
|
SVR4_EPERM,
|
||||||
|
SVR4_ENOENT,
|
||||||
|
SVR4_ESRCH,
|
||||||
|
SVR4_EINTR,
|
||||||
|
SVR4_EIO,
|
||||||
|
SVR4_ENXIO,
|
||||||
|
SVR4_E2BIG,
|
||||||
|
SVR4_ENOEXEC,
|
||||||
|
SVR4_EBADF,
|
||||||
|
SVR4_ECHILD,
|
||||||
|
SVR4_EDEADLK,
|
||||||
|
SVR4_ENOMEM,
|
||||||
|
SVR4_EACCES,
|
||||||
|
SVR4_EFAULT,
|
||||||
|
SVR4_ENOTBLK,
|
||||||
|
SVR4_EBUSY,
|
||||||
|
SVR4_EEXIST,
|
||||||
|
SVR4_EXDEV,
|
||||||
|
SVR4_ENODEV,
|
||||||
|
SVR4_ENOTDIR,
|
||||||
|
SVR4_EISDIR,
|
||||||
|
SVR4_EINVAL,
|
||||||
|
SVR4_ENFILE,
|
||||||
|
SVR4_EMFILE,
|
||||||
|
SVR4_ENOTTY,
|
||||||
|
SVR4_ETXTBSY,
|
||||||
|
SVR4_EFBIG,
|
||||||
|
SVR4_ENOSPC,
|
||||||
|
SVR4_ESPIPE,
|
||||||
|
SVR4_EROFS,
|
||||||
|
SVR4_EMLINK,
|
||||||
|
SVR4_EPIPE,
|
||||||
|
SVR4_EDOM,
|
||||||
|
SVR4_ERANGE,
|
||||||
|
SVR4_EAGAIN,
|
||||||
|
SVR4_EINPROGRESS,
|
||||||
|
SVR4_EALREADY,
|
||||||
|
SVR4_ENOTSOCK,
|
||||||
|
SVR4_EDESTADDRREQ,
|
||||||
|
SVR4_EMSGSIZE,
|
||||||
|
SVR4_EPROTOTYPE,
|
||||||
|
SVR4_ENOPROTOOPT,
|
||||||
|
SVR4_EPROTONOSUPPORT,
|
||||||
|
SVR4_ESOCKTNOSUPPORT,
|
||||||
|
SVR4_EOPNOTSUPP,
|
||||||
|
SVR4_EPFNOSUPPORT,
|
||||||
|
SVR4_EAFNOSUPPORT,
|
||||||
|
SVR4_EADDRINUSE,
|
||||||
|
SVR4_EADDRNOTAVAIL,
|
||||||
|
SVR4_ENETDOWN,
|
||||||
|
SVR4_ENETUNREACH,
|
||||||
|
SVR4_ENETRESET,
|
||||||
|
SVR4_ECONNABORTED,
|
||||||
|
SVR4_ECONNRESET,
|
||||||
|
SVR4_ENOBUFS,
|
||||||
|
SVR4_EISCONN,
|
||||||
|
SVR4_ENOTCONN,
|
||||||
|
SVR4_ESHUTDOWN,
|
||||||
|
SVR4_ETOOMANYREFS,
|
||||||
|
SVR4_ETIMEDOUT,
|
||||||
|
SVR4_ECONNREFUSED,
|
||||||
|
SVR4_ELOOP,
|
||||||
|
SVR4_ENAMETOOLONG,
|
||||||
|
SVR4_EHOSTDOWN,
|
||||||
|
SVR4_EHOSTUNREACH,
|
||||||
|
SVR4_ENOTEMPTY,
|
||||||
|
SVR4_EPROCLIM,
|
||||||
|
SVR4_EUSERS,
|
||||||
|
SVR4_EDQUOT,
|
||||||
|
SVR4_ESTALE,
|
||||||
|
SVR4_EREMOTE,
|
||||||
|
SVR4_EBADRPC,
|
||||||
|
SVR4_ERPCMISMATCH,
|
||||||
|
SVR4_EPROGUNAVAIL,
|
||||||
|
SVR4_EPROGMISMATCH,
|
||||||
|
SVR4_EPROCUNAVAIL,
|
||||||
|
SVR4_ENOLCK,
|
||||||
|
SVR4_ENOSYS,
|
||||||
|
SVR4_EFTYPE,
|
||||||
|
SVR4_EAUTH,
|
||||||
|
SVR4_ENEEDAUTH,
|
||||||
|
SVR4_EIDRM,
|
||||||
|
SVR4_ENOMSG,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int svr4_fixup(long **stack_base, struct image_params *imgp);
|
||||||
|
|
||||||
|
extern struct sysent svr4_sysent[];
|
||||||
|
#undef szsigcode
|
||||||
|
#undef sigcode
|
||||||
|
|
||||||
|
extern int svr4_szsigcode;
|
||||||
|
extern char svr4_sigcode[];
|
||||||
|
|
||||||
|
struct sysentvec svr4_sysvec = {
|
||||||
|
SVR4_SYS_MAXSYSCALL,
|
||||||
|
svr4_sysent,
|
||||||
|
0xff,
|
||||||
|
NSIG,
|
||||||
|
bsd_to_svr4_sig,
|
||||||
|
ELAST, /* ELAST */
|
||||||
|
bsd_to_svr4_errno,
|
||||||
|
0,
|
||||||
|
svr4_fixup,
|
||||||
|
svr4_sendsig,
|
||||||
|
svr4_sigcode,
|
||||||
|
&svr4_szsigcode,
|
||||||
|
0,
|
||||||
|
"SVR4"
|
||||||
|
};
|
||||||
|
|
||||||
|
Elf32_Brandinfo svr4_brand = {
|
||||||
|
"SVR4",
|
||||||
|
"/compat/svr4",
|
||||||
|
"/lib/libc.so.1",
|
||||||
|
&svr4_sysvec
|
||||||
|
};
|
||||||
|
|
||||||
|
const char svr4_emul_path[] = "/compat/svr4";
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_fixup(long **stack_base, struct image_params *imgp)
|
||||||
|
{
|
||||||
|
Elf32_Auxargs *args = (Elf32_Auxargs *)imgp->auxargs;
|
||||||
|
long *pos;
|
||||||
|
|
||||||
|
pos = *stack_base + (imgp->argc + imgp->envc + 2);
|
||||||
|
|
||||||
|
if (args->trace) {
|
||||||
|
AUXARGS_ENTRY(pos, AT_DEBUG, 1);
|
||||||
|
}
|
||||||
|
if (args->execfd != -1) {
|
||||||
|
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
||||||
|
}
|
||||||
|
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
||||||
|
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
||||||
|
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
||||||
|
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
||||||
|
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
||||||
|
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
||||||
|
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
||||||
|
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_cred->p_ruid);
|
||||||
|
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_cred->p_svuid);
|
||||||
|
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_cred->p_rgid);
|
||||||
|
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_cred->p_svgid);
|
||||||
|
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
||||||
|
|
||||||
|
free(imgp->auxargs, M_TEMP);
|
||||||
|
imgp->auxargs = NULL;
|
||||||
|
|
||||||
|
(*stack_base)--;
|
||||||
|
**stack_base = (int)imgp->argc;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Search an alternate path before passing pathname arguments on
|
||||||
|
* to system calls. Useful for keeping a seperate 'emulation tree'.
|
||||||
|
*
|
||||||
|
* If cflag is set, we check if an attempt can be made to create
|
||||||
|
* the named file, i.e. we check if the directory it should
|
||||||
|
* be in exists.
|
||||||
|
*
|
||||||
|
* Code shamelessly stolen by Mark Newton from IBCS2 emulation code.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
svr4_emul_find(p, sgp, prefix, path, pbuf, cflag)
|
||||||
|
struct proc *p;
|
||||||
|
caddr_t *sgp; /* Pointer to stackgap memory */
|
||||||
|
const char *prefix;
|
||||||
|
char *path;
|
||||||
|
char **pbuf;
|
||||||
|
int cflag;
|
||||||
|
{
|
||||||
|
struct nameidata nd;
|
||||||
|
struct nameidata ndroot;
|
||||||
|
struct vattr vat;
|
||||||
|
struct vattr vatroot;
|
||||||
|
int error;
|
||||||
|
char *ptr, *buf, *cp;
|
||||||
|
size_t sz, len;
|
||||||
|
|
||||||
|
buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
|
||||||
|
*pbuf = path;
|
||||||
|
|
||||||
|
for (ptr = buf; (*ptr = *prefix) != '\0'; ptr++, prefix++)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sz = MAXPATHLEN - (ptr - buf);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If sgp is not given then the path is already in kernel space
|
||||||
|
*/
|
||||||
|
if (sgp == NULL)
|
||||||
|
error = copystr(path, ptr, sz, &len);
|
||||||
|
else
|
||||||
|
error = copyinstr(path, ptr, sz, &len);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
free(buf, M_TEMP);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*ptr != '/') {
|
||||||
|
free(buf, M_TEMP);
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We know that there is a / somewhere in this pathname.
|
||||||
|
* Search backwards for it, to find the file's parent dir
|
||||||
|
* to see if it exists in the alternate tree. If it does,
|
||||||
|
* and we want to create a file (cflag is set). We don't
|
||||||
|
* need to worry about the root comparison in this case.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (cflag) {
|
||||||
|
for (cp = &ptr[len] - 1; *cp != '/'; cp--);
|
||||||
|
*cp = '\0';
|
||||||
|
|
||||||
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
|
||||||
|
|
||||||
|
if ((error = namei(&nd)) != 0) {
|
||||||
|
free(buf, M_TEMP);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
*cp = '/';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
|
||||||
|
|
||||||
|
if ((error = namei(&nd)) != 0) {
|
||||||
|
free(buf, M_TEMP);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We now compare the vnode of the svr4_root to the one
|
||||||
|
* vnode asked. If they resolve to be the same, then we
|
||||||
|
* ignore the match so that the real root gets used.
|
||||||
|
* This avoids the problem of traversing "../.." to find the
|
||||||
|
* root directory and never finding it, because "/" resolves
|
||||||
|
* to the emulation root directory. This is expensive :-(
|
||||||
|
*/
|
||||||
|
NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, svr4_emul_path,
|
||||||
|
p);
|
||||||
|
|
||||||
|
if ((error = namei(&ndroot)) != 0) {
|
||||||
|
/* Cannot happen! */
|
||||||
|
free(buf, M_TEMP);
|
||||||
|
vrele(nd.ni_vp);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
|
||||||
|
!= 0) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vat.va_fsid == vatroot.va_fsid &&
|
||||||
|
vat.va_fileid == vatroot.va_fileid) {
|
||||||
|
error = ENOENT;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (sgp == NULL)
|
||||||
|
*pbuf = buf;
|
||||||
|
else {
|
||||||
|
sz = &ptr[len] - buf;
|
||||||
|
*pbuf = stackgap_alloc(sgp, sz + 1);
|
||||||
|
error = copyout(buf, *pbuf, sz);
|
||||||
|
free(buf, M_TEMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
done:
|
||||||
|
vrele(nd.ni_vp);
|
||||||
|
if (!cflag)
|
||||||
|
vrele(ndroot.ni_vp);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: wrong, for the same reason described in linux_sysvec.c
|
||||||
|
*/
|
||||||
|
static int svr4_elf_modevent __P((module_t mod, int type, void *data));
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_elf_modevent(module_t mod, int type, void *data)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = 0;
|
||||||
|
|
||||||
|
switch(type) {
|
||||||
|
case MOD_LOAD:
|
||||||
|
if (elf_insert_brand_entry(&svr4_brand) < 0)
|
||||||
|
error = EINVAL;
|
||||||
|
if (error)
|
||||||
|
printf("cannot insert svr4 elf brand handler\n");
|
||||||
|
else if (bootverbose)
|
||||||
|
printf("svr4 ELF exec handler installed\n");
|
||||||
|
break;
|
||||||
|
case MOD_UNLOAD:
|
||||||
|
/* XXX There needs to be a generic function that any
|
||||||
|
* emulator can call to say, "Are any currently-running
|
||||||
|
* executables using me?" so we can fail to unload the
|
||||||
|
* module if it's in use. Locking up because you forgot
|
||||||
|
* to shut down a program prior to a kldunload isn't fun.
|
||||||
|
*/
|
||||||
|
if (elf_remove_brand_entry(&svr4_brand) < 0)
|
||||||
|
error = EINVAL;
|
||||||
|
if (error)
|
||||||
|
printf("Could not deinstall ELF interpreter entry\n");
|
||||||
|
else if (bootverbose)
|
||||||
|
printf("svr4 ELF exec handler removed\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
static moduledata_t svr4_elf_mod = {
|
||||||
|
"svr4elf",
|
||||||
|
svr4_elf_modevent,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
DECLARE_MODULE(svr4elf, svr4_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
|
619
sys/compat/svr4/svr4_termios.c
Normal file
619
sys/compat/svr4/svr4_termios.c
Normal file
|
@ -0,0 +1,619 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/tty.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_ioctl.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_stropts.h>
|
||||||
|
#include <svr4/svr4_termios.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __CONCAT3
|
||||||
|
# if __STDC__
|
||||||
|
# define __CONCAT3(a,b,c) a ## b ## c
|
||||||
|
# else
|
||||||
|
# define __CONCAT3(a,b,c) a/**/b/**/c
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static u_long bsd_to_svr4_speed __P((u_long, u_long));
|
||||||
|
static u_long svr4_to_bsd_speed __P((u_long, u_long));
|
||||||
|
static void svr4_to_bsd_termios __P((const struct svr4_termios *,
|
||||||
|
struct termios *, int));
|
||||||
|
static void bsd_to_svr4_termios __P((const struct termios *,
|
||||||
|
struct svr4_termios *));
|
||||||
|
static void svr4_termio_to_termios __P((const struct svr4_termio *,
|
||||||
|
struct svr4_termios *));
|
||||||
|
static void svr4_termios_to_termio __P((const struct svr4_termios *,
|
||||||
|
struct svr4_termio *));
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
static void print_svr4_termios __P((const struct svr4_termios *));
|
||||||
|
static void print_bsd_termios __P((const struct termios *));
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
|
||||||
|
#define undefined_char(a,b) /**/
|
||||||
|
#define undefined_flag1(f,a,b) /**/
|
||||||
|
#define undefined_flag2(f,a,b,c1,t1,c2,t2) /**/
|
||||||
|
#define undefined_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) /**/
|
||||||
|
|
||||||
|
#define svr4_to_bsd_char(a,b) \
|
||||||
|
if (new || __CONCAT3(SVR4_,a,b) < SVR4_NCC) { \
|
||||||
|
if (st->c_cc[__CONCAT3(SVR4_,a,b)] == SVR4_POSIX_VDISABLE) \
|
||||||
|
bt->c_cc[__CONCAT(a,b)] = _POSIX_VDISABLE; \
|
||||||
|
else \
|
||||||
|
bt->c_cc[__CONCAT(a,b)] = st->c_cc[__CONCAT3(SVR4_,a,b)]; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define svr4_to_bsd_flag1(f,a,b) \
|
||||||
|
if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
|
||||||
|
if (st->f & __CONCAT3(SVR4_,a,b)) \
|
||||||
|
bt->f |= __CONCAT(a,b); \
|
||||||
|
else \
|
||||||
|
bt->f &= ~__CONCAT(a,b); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define svr4_to_bsd_flag2(f,a,b,c1,t1,c2,t2) \
|
||||||
|
if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
|
||||||
|
bt->f &= ~__CONCAT(a,b); \
|
||||||
|
switch (st->f & __CONCAT3(SVR4_,a,b)) { \
|
||||||
|
case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
|
||||||
|
case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define svr4_to_bsd_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \
|
||||||
|
if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
|
||||||
|
bt->f &= ~__CONCAT(a,b); \
|
||||||
|
switch (st->f & __CONCAT3(SVR4_,a,b)) { \
|
||||||
|
case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
|
||||||
|
case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
|
||||||
|
case __CONCAT3(SVR4_,c3,t3): bt->f |= __CONCAT(c3,t3); break; \
|
||||||
|
case __CONCAT3(SVR4_,c4,t4): bt->f |= __CONCAT(c4,t4); break; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define bsd_to_svr4_char(a,b) \
|
||||||
|
if (bt->c_cc[__CONCAT(a,b)] == _POSIX_VDISABLE) \
|
||||||
|
st->c_cc[__CONCAT3(SVR4_,a,b)] = SVR4_POSIX_VDISABLE; \
|
||||||
|
else \
|
||||||
|
st->c_cc[__CONCAT3(SVR4_,a,b)] = bt->c_cc[__CONCAT(a,b)]
|
||||||
|
|
||||||
|
#define bsd_to_svr4_flag1(f,a,b) \
|
||||||
|
if (bt->f & __CONCAT(a,b)) \
|
||||||
|
st->f |= __CONCAT3(SVR4_,a,b); \
|
||||||
|
else \
|
||||||
|
st->f &= ~__CONCAT3(SVR4_,a,b)
|
||||||
|
|
||||||
|
#define bsd_to_svr4_flag2(f,a,b,c1,t1,c2,t2) \
|
||||||
|
st->f &= ~__CONCAT(a,b); \
|
||||||
|
switch (bt->f & __CONCAT(a,b)) { \
|
||||||
|
case __CONCAT(c1,t1): st->f |= __CONCAT3(SVR4_,c1,t1); break; \
|
||||||
|
case __CONCAT(c2,t2): st->f |= __CONCAT3(SVR4_,c2,t2); break; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define bsd_to_svr4_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \
|
||||||
|
st->f &= ~__CONCAT(a,b); \
|
||||||
|
switch (bt->f & __CONCAT(a,b)) { \
|
||||||
|
case __CONCAT(c1,t1): st->f |= __CONCAT3(SVR4_,c1,t1); break; \
|
||||||
|
case __CONCAT(c2,t2): st->f |= __CONCAT3(SVR4_,c2,t2); break; \
|
||||||
|
case __CONCAT(c3,t3): st->f |= __CONCAT3(SVR4_,c3,t3); break; \
|
||||||
|
case __CONCAT(c4,t4): st->f |= __CONCAT3(SVR4_,c4,t4); break; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
static void
|
||||||
|
print_svr4_termios(st)
|
||||||
|
const struct svr4_termios *st;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
DPRINTF(("SVR4\niflag=%lo oflag=%lo cflag=%lo lflag=%lo\n",
|
||||||
|
st->c_iflag, st->c_oflag, st->c_cflag, st->c_lflag));
|
||||||
|
DPRINTF(("cc: "));
|
||||||
|
for (i = 0; i < SVR4_NCCS; i++)
|
||||||
|
DPRINTF(("%o ", st->c_cc[i]));
|
||||||
|
DPRINTF(("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_bsd_termios(bt)
|
||||||
|
const struct termios *bt;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
uprintf("BSD\niflag=%o oflag=%o cflag=%o lflag=%o\n",
|
||||||
|
bt->c_iflag, bt->c_oflag, bt->c_cflag, bt->c_lflag);
|
||||||
|
uprintf("cc: ");
|
||||||
|
for (i = 0; i < NCCS; i++)
|
||||||
|
uprintf("%o ", bt->c_cc[i]);
|
||||||
|
uprintf("\n");
|
||||||
|
}
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
|
||||||
|
static u_long
|
||||||
|
bsd_to_svr4_speed(sp, mask)
|
||||||
|
u_long sp;
|
||||||
|
u_long mask;
|
||||||
|
{
|
||||||
|
switch (sp) {
|
||||||
|
#undef getval
|
||||||
|
#define getval(a,b) case __CONCAT(a,b): sp = __CONCAT3(SVR4_,a,b)
|
||||||
|
getval(B,0);
|
||||||
|
getval(B,50);
|
||||||
|
getval(B,75);
|
||||||
|
getval(B,110);
|
||||||
|
getval(B,134);
|
||||||
|
getval(B,150);
|
||||||
|
getval(B,200);
|
||||||
|
getval(B,300);
|
||||||
|
getval(B,600);
|
||||||
|
getval(B,1200);
|
||||||
|
getval(B,1800);
|
||||||
|
getval(B,2400);
|
||||||
|
getval(B,4800);
|
||||||
|
getval(B,9600);
|
||||||
|
getval(B,19200);
|
||||||
|
getval(B,38400);
|
||||||
|
getval(B,57600);
|
||||||
|
getval(B,115200);
|
||||||
|
default: sp = SVR4_B9600; /* XXX */
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((mask & 1) == 0) {
|
||||||
|
mask >>= 1;
|
||||||
|
sp <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static u_long
|
||||||
|
svr4_to_bsd_speed(sp, mask)
|
||||||
|
u_long sp;
|
||||||
|
u_long mask;
|
||||||
|
{
|
||||||
|
while ((mask & 1) == 0) {
|
||||||
|
mask >>= 1;
|
||||||
|
sp >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (sp & mask) {
|
||||||
|
#undef getval
|
||||||
|
#define getval(a,b) case __CONCAT3(SVR4_,a,b): return __CONCAT(a,b)
|
||||||
|
getval(B,0);
|
||||||
|
getval(B,50);
|
||||||
|
getval(B,75);
|
||||||
|
getval(B,110);
|
||||||
|
getval(B,134);
|
||||||
|
getval(B,150);
|
||||||
|
getval(B,200);
|
||||||
|
getval(B,300);
|
||||||
|
getval(B,600);
|
||||||
|
getval(B,1200);
|
||||||
|
getval(B,1800);
|
||||||
|
getval(B,2400);
|
||||||
|
getval(B,4800);
|
||||||
|
getval(B,9600);
|
||||||
|
getval(B,19200);
|
||||||
|
getval(B,38400);
|
||||||
|
getval(B,57600);
|
||||||
|
getval(B,115200);
|
||||||
|
default: return B9600; /* XXX */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_termios(st, bt, new)
|
||||||
|
const struct svr4_termios *st;
|
||||||
|
struct termios *bt;
|
||||||
|
int new;
|
||||||
|
{
|
||||||
|
/* control characters */
|
||||||
|
/*
|
||||||
|
* We process VMIN and VTIME first,
|
||||||
|
* because they are shared with VEOF and VEOL
|
||||||
|
*/
|
||||||
|
svr4_to_bsd_char(V,MIN);
|
||||||
|
svr4_to_bsd_char(V,TIME);
|
||||||
|
|
||||||
|
svr4_to_bsd_char(V,INTR);
|
||||||
|
svr4_to_bsd_char(V,QUIT);
|
||||||
|
svr4_to_bsd_char(V,ERASE);
|
||||||
|
svr4_to_bsd_char(V,KILL);
|
||||||
|
svr4_to_bsd_char(V,EOF);
|
||||||
|
svr4_to_bsd_char(V,EOL);
|
||||||
|
svr4_to_bsd_char(V,EOL2);
|
||||||
|
undefined_char(V,SWTCH);
|
||||||
|
svr4_to_bsd_char(V,START);
|
||||||
|
svr4_to_bsd_char(V,STOP);
|
||||||
|
svr4_to_bsd_char(V,SUSP);
|
||||||
|
svr4_to_bsd_char(V,DSUSP);
|
||||||
|
svr4_to_bsd_char(V,REPRINT);
|
||||||
|
svr4_to_bsd_char(V,DISCARD);
|
||||||
|
svr4_to_bsd_char(V,WERASE);
|
||||||
|
svr4_to_bsd_char(V,LNEXT);
|
||||||
|
|
||||||
|
/* Input modes */
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,GNBRK);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,B,RKINT);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,GNPAR);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,P,ARMRK);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,NPCK);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,STRIP);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,NLCR);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,GNCR);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,CRNL);
|
||||||
|
undefined_flag1(c_iflag,I,UCLC);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,XON);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,XANY);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,XOFF);
|
||||||
|
svr4_to_bsd_flag1(c_iflag,I,MAXBEL);
|
||||||
|
undefined_flag1(c_iflag,D,OSMODE);
|
||||||
|
|
||||||
|
/* Output modes */
|
||||||
|
svr4_to_bsd_flag1(c_oflag,O,POST);
|
||||||
|
undefined_flag1(c_oflag,O,LCUC);
|
||||||
|
svr4_to_bsd_flag1(c_oflag,O,NLCR);
|
||||||
|
undefined_flag1(c_oflag,O,CRNL);
|
||||||
|
undefined_flag1(c_oflag,O,NOCR);
|
||||||
|
undefined_flag1(c_oflag,O,NLRET);
|
||||||
|
undefined_flag1(c_oflag,O,FILL);
|
||||||
|
undefined_flag1(c_oflag,O,FDEL);
|
||||||
|
undefined_flag2(c_oflag,N,LDLY,N,L0,N,L1);
|
||||||
|
undefined_flag4(c_oflag,C,RDLY,C,R0,C,R1,C,R2,C,R3);
|
||||||
|
undefined_flag4(c_oflag,T,ABDLY,T,AB0,T,AB1,T,AB2,T,AB3);
|
||||||
|
undefined_flag2(c_oflag,B,SDLY,B,S0,B,S1);
|
||||||
|
undefined_flag2(c_oflag,V,TDLY,V,T0,V,T1);
|
||||||
|
undefined_flag2(c_oflag,F,FDLY,F,F0,F,F1);
|
||||||
|
undefined_flag1(c_oflag,P,AGEOUT);
|
||||||
|
undefined_flag1(c_oflag,W,RAP);
|
||||||
|
|
||||||
|
/* Control modes */
|
||||||
|
bt->c_ospeed = svr4_to_bsd_speed(st->c_cflag, SVR4_CBAUD);
|
||||||
|
svr4_to_bsd_flag4(c_cflag,C,SIZE,C,S5,C,S6,C,S7,C,S8)
|
||||||
|
svr4_to_bsd_flag1(c_cflag,C,STOPB);
|
||||||
|
svr4_to_bsd_flag1(c_cflag,C,READ);
|
||||||
|
svr4_to_bsd_flag1(c_cflag,P,ARENB);
|
||||||
|
svr4_to_bsd_flag1(c_cflag,P,ARODD);
|
||||||
|
svr4_to_bsd_flag1(c_cflag,H,UPCL);
|
||||||
|
svr4_to_bsd_flag1(c_cflag,C,LOCAL);
|
||||||
|
undefined_flag1(c_cflag,R,CV1EN);
|
||||||
|
undefined_flag1(c_cflag,X,MT1EN);
|
||||||
|
undefined_flag1(c_cflag,L,OBLK);
|
||||||
|
undefined_flag1(c_cflag,X,CLUDE);
|
||||||
|
bt->c_ispeed = svr4_to_bsd_speed(st->c_cflag, SVR4_CIBAUD);
|
||||||
|
undefined_flag1(c_cflag,P,AREXT);
|
||||||
|
|
||||||
|
/* line discipline modes */
|
||||||
|
svr4_to_bsd_flag1(c_lflag,I,SIG);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,I,CANON);
|
||||||
|
undefined_flag1(c_lflag,X,CASE);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,E,CHO);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,E,CHOE);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,E,CHOK);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,E,CHONL);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,N,OFLSH);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,T,OSTOP);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,E,CHOCTL);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,E,CHOPRT);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,E,CHOKE);
|
||||||
|
undefined_flag1(c_lflag,D,EFECHO);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,F,LUSHO);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,P,ENDIN);
|
||||||
|
svr4_to_bsd_flag1(c_lflag,I,EXTEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_termios(bt, st)
|
||||||
|
const struct termios *bt;
|
||||||
|
struct svr4_termios *st;
|
||||||
|
{
|
||||||
|
/* control characters */
|
||||||
|
/*
|
||||||
|
* We process VMIN and VTIME first,
|
||||||
|
* because they are shared with VEOF and VEOL
|
||||||
|
*/
|
||||||
|
bsd_to_svr4_char(V,MIN);
|
||||||
|
bsd_to_svr4_char(V,TIME);
|
||||||
|
bsd_to_svr4_char(V,INTR);
|
||||||
|
bsd_to_svr4_char(V,QUIT);
|
||||||
|
bsd_to_svr4_char(V,ERASE);
|
||||||
|
bsd_to_svr4_char(V,KILL);
|
||||||
|
bsd_to_svr4_char(V,EOF);
|
||||||
|
bsd_to_svr4_char(V,EOL);
|
||||||
|
bsd_to_svr4_char(V,EOL2);
|
||||||
|
undefined_char(V,SWTCH);
|
||||||
|
bsd_to_svr4_char(V,START);
|
||||||
|
bsd_to_svr4_char(V,STOP);
|
||||||
|
bsd_to_svr4_char(V,SUSP);
|
||||||
|
bsd_to_svr4_char(V,DSUSP);
|
||||||
|
bsd_to_svr4_char(V,REPRINT);
|
||||||
|
bsd_to_svr4_char(V,DISCARD);
|
||||||
|
bsd_to_svr4_char(V,WERASE);
|
||||||
|
bsd_to_svr4_char(V,LNEXT);
|
||||||
|
|
||||||
|
/* Input modes */
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,GNBRK);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,B,RKINT);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,GNPAR);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,P,ARMRK);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,NPCK);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,STRIP);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,NLCR);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,GNCR);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,CRNL);
|
||||||
|
undefined_flag1(c_iflag,I,UCLC);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,XON);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,XANY);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,XOFF);
|
||||||
|
bsd_to_svr4_flag1(c_iflag,I,MAXBEL);
|
||||||
|
undefined_flag1(c_iflag,D,OSMODE);
|
||||||
|
|
||||||
|
/* Output modes */
|
||||||
|
bsd_to_svr4_flag1(c_oflag,O,POST);
|
||||||
|
undefined_flag1(c_oflag,O,LCUC);
|
||||||
|
bsd_to_svr4_flag1(c_oflag,O,NLCR);
|
||||||
|
undefined_flag1(c_oflag,O,CRNL);
|
||||||
|
undefined_flag1(c_oflag,O,NOCR);
|
||||||
|
undefined_flag1(c_oflag,O,NLRET);
|
||||||
|
undefined_flag1(c_oflag,O,FILL);
|
||||||
|
undefined_flag1(c_oflag,O,FDEL);
|
||||||
|
undefined_flag2(c_oflag,N,LDLY,N,L0,N,L1);
|
||||||
|
undefined_flag4(c_oflag,C,RDLY,C,R0,C,R1,C,R2,C,R3);
|
||||||
|
undefined_flag4(c_oflag,T,ABDLY,T,AB0,T,AB1,T,AB2,T,AB3);
|
||||||
|
undefined_flag2(c_oflag,B,SDLY,B,S0,B,S1);
|
||||||
|
undefined_flag2(c_oflag,V,TDLY,V,T0,V,T1);
|
||||||
|
undefined_flag2(c_oflag,F,FDLY,F,F0,F,F1);
|
||||||
|
undefined_flag1(c_oflag,P,AGEOUT);
|
||||||
|
undefined_flag1(c_oflag,W,RAP);
|
||||||
|
|
||||||
|
/* Control modes */
|
||||||
|
st->c_cflag &= ~SVR4_CBAUD;
|
||||||
|
st->c_cflag |= bsd_to_svr4_speed(bt->c_ospeed, SVR4_CBAUD);
|
||||||
|
bsd_to_svr4_flag4(c_cflag,C,SIZE,C,S5,C,S6,C,S7,C,S8)
|
||||||
|
bsd_to_svr4_flag1(c_cflag,C,STOPB);
|
||||||
|
bsd_to_svr4_flag1(c_cflag,C,READ);
|
||||||
|
bsd_to_svr4_flag1(c_cflag,P,ARENB);
|
||||||
|
bsd_to_svr4_flag1(c_cflag,P,ARODD);
|
||||||
|
bsd_to_svr4_flag1(c_cflag,H,UPCL);
|
||||||
|
bsd_to_svr4_flag1(c_cflag,C,LOCAL);
|
||||||
|
undefined_flag1(c_cflag,R,CV1EN);
|
||||||
|
undefined_flag1(c_cflag,X,MT1EN);
|
||||||
|
undefined_flag1(c_cflag,L,OBLK);
|
||||||
|
undefined_flag1(c_cflag,X,CLUDE);
|
||||||
|
st->c_cflag &= ~SVR4_CIBAUD;
|
||||||
|
st->c_cflag |= bsd_to_svr4_speed(bt->c_ispeed, SVR4_CIBAUD);
|
||||||
|
|
||||||
|
undefined_flag1(c_oflag,P,AREXT);
|
||||||
|
|
||||||
|
/* line discipline modes */
|
||||||
|
bsd_to_svr4_flag1(c_lflag,I,SIG);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,I,CANON);
|
||||||
|
undefined_flag1(c_lflag,X,CASE);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,E,CHO);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,E,CHOE);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,E,CHOK);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,E,CHONL);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,N,OFLSH);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,T,OSTOP);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,E,CHOCTL);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,E,CHOPRT);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,E,CHOKE);
|
||||||
|
undefined_flag1(c_lflag,D,EFECHO);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,F,LUSHO);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,P,ENDIN);
|
||||||
|
bsd_to_svr4_flag1(c_lflag,I,EXTEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_termio_to_termios(t, ts)
|
||||||
|
const struct svr4_termio *t;
|
||||||
|
struct svr4_termios *ts;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
ts->c_iflag = (svr4_tcflag_t) t->c_iflag;
|
||||||
|
ts->c_oflag = (svr4_tcflag_t) t->c_oflag;
|
||||||
|
ts->c_cflag = (svr4_tcflag_t) t->c_cflag;
|
||||||
|
ts->c_lflag = (svr4_tcflag_t) t->c_lflag;
|
||||||
|
|
||||||
|
for (i = 0; i < SVR4_NCC; i++)
|
||||||
|
ts->c_cc[i] = (svr4_cc_t) t->c_cc[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_termios_to_termio(ts, t)
|
||||||
|
const struct svr4_termios *ts;
|
||||||
|
struct svr4_termio *t;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
t->c_iflag = (u_short) ts->c_iflag;
|
||||||
|
t->c_oflag = (u_short) ts->c_oflag;
|
||||||
|
t->c_cflag = (u_short) ts->c_cflag;
|
||||||
|
t->c_lflag = (u_short) ts->c_lflag;
|
||||||
|
t->c_line = 0; /* XXX */
|
||||||
|
|
||||||
|
for (i = 0; i < SVR4_NCC; i++)
|
||||||
|
t->c_cc[i] = (u_char) ts->c_cc[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_term_ioctl(fp, p, retval, fd, cmd, data)
|
||||||
|
struct file *fp;
|
||||||
|
struct proc *p;
|
||||||
|
register_t *retval;
|
||||||
|
int fd;
|
||||||
|
u_long cmd;
|
||||||
|
caddr_t data;
|
||||||
|
{
|
||||||
|
struct termios bt;
|
||||||
|
struct svr4_termios st;
|
||||||
|
struct svr4_termio t;
|
||||||
|
int error, new;
|
||||||
|
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
|
||||||
|
fp->f_ops->fo_ioctl;
|
||||||
|
|
||||||
|
*retval = 0;
|
||||||
|
|
||||||
|
DPRINTF(("TERM ioctl %x\n", cmd));
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_TCGETA:
|
||||||
|
case SVR4_TCGETS:
|
||||||
|
DPRINTF(("ioctl(TCGET%c);\n", cmd == SVR4_TCGETA ? 'A' : 'S'));
|
||||||
|
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bt, p)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
memset(&st, 0, sizeof(st));
|
||||||
|
bsd_to_svr4_termios(&bt, &st);
|
||||||
|
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
print_bsd_termios(&bt);
|
||||||
|
print_svr4_termios(&st);
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
|
||||||
|
if (cmd == SVR4_TCGETA) {
|
||||||
|
svr4_termios_to_termio(&st, &t);
|
||||||
|
return copyout(&t, data, sizeof(t));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return copyout(&st, data, sizeof(st));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TCSETA:
|
||||||
|
case SVR4_TCSETS:
|
||||||
|
case SVR4_TCSETAW:
|
||||||
|
case SVR4_TCSETSW:
|
||||||
|
case SVR4_TCSETAF:
|
||||||
|
case SVR4_TCSETSF:
|
||||||
|
DPRINTF(("TCSET{A,S,AW,SW,AF,SF}\n"));
|
||||||
|
/* get full BSD termios so we don't lose information */
|
||||||
|
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bt, p)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_TCSETS:
|
||||||
|
case SVR4_TCSETSW:
|
||||||
|
case SVR4_TCSETSF:
|
||||||
|
if ((error = copyin(data, &st, sizeof(st))) != 0)
|
||||||
|
return error;
|
||||||
|
new = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_TCSETA:
|
||||||
|
case SVR4_TCSETAW:
|
||||||
|
case SVR4_TCSETAF:
|
||||||
|
if ((error = copyin(data, &t, sizeof(t))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_termio_to_termios(&t, &st);
|
||||||
|
new = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
svr4_to_bsd_termios(&st, &bt, new);
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_TCSETA:
|
||||||
|
case SVR4_TCSETS:
|
||||||
|
DPRINTF(("ioctl(TCSET[A|S]);\n"));
|
||||||
|
cmd = TIOCSETA;
|
||||||
|
break;
|
||||||
|
case SVR4_TCSETAW:
|
||||||
|
case SVR4_TCSETSW:
|
||||||
|
DPRINTF(("ioctl(TCSET[A|S]W);\n"));
|
||||||
|
cmd = TIOCSETAW;
|
||||||
|
break;
|
||||||
|
case SVR4_TCSETAF:
|
||||||
|
case SVR4_TCSETSF:
|
||||||
|
DPRINTF(("ioctl(TCSET[A|S]F);\n"));
|
||||||
|
cmd = TIOCSETAF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
print_bsd_termios(&bt);
|
||||||
|
print_svr4_termios(&st);
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
|
||||||
|
return (*ctl)(fp, cmd, (caddr_t) &bt, p);
|
||||||
|
|
||||||
|
case SVR4_TIOCGWINSZ:
|
||||||
|
DPRINTF(("TIOCGWINSZ\n"));
|
||||||
|
{
|
||||||
|
struct svr4_winsize ws;
|
||||||
|
|
||||||
|
error = (*ctl)(fp, TIOCGWINSZ, (caddr_t) &ws, p);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return copyout(&ws, data, sizeof(ws));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCSWINSZ:
|
||||||
|
DPRINTF(("TIOCSWINSZ\n"));
|
||||||
|
{
|
||||||
|
struct svr4_winsize ws;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &ws, sizeof(ws))) != 0)
|
||||||
|
return error;
|
||||||
|
return (*ctl)(fp, TIOCSWINSZ, (caddr_t) &ws, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("teleport to STREAMS ioctls...\n"));
|
||||||
|
return svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, data);
|
||||||
|
}
|
||||||
|
}
|
222
sys/compat/svr4/svr4_termios.h
Normal file
222
sys/compat/svr4/svr4_termios.h
Normal file
|
@ -0,0 +1,222 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_TERMIOS_H_
|
||||||
|
#define _SVR4_TERMIOS_H_
|
||||||
|
|
||||||
|
#define SVR4_POSIX_VDISABLE 0
|
||||||
|
#define SVR4_NCC 8
|
||||||
|
#define SVR4_NCCS 19
|
||||||
|
|
||||||
|
typedef u_long svr4_tcflag_t;
|
||||||
|
typedef u_char svr4_cc_t;
|
||||||
|
typedef u_long svr4_speed_t;
|
||||||
|
|
||||||
|
struct svr4_termios {
|
||||||
|
svr4_tcflag_t c_iflag;
|
||||||
|
svr4_tcflag_t c_oflag;
|
||||||
|
svr4_tcflag_t c_cflag;
|
||||||
|
svr4_tcflag_t c_lflag;
|
||||||
|
svr4_cc_t c_cc[SVR4_NCCS];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_termio {
|
||||||
|
u_short c_iflag;
|
||||||
|
u_short c_oflag;
|
||||||
|
u_short c_cflag;
|
||||||
|
u_short c_lflag;
|
||||||
|
char c_line;
|
||||||
|
u_char c_cc[SVR4_NCC];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* control characters */
|
||||||
|
#define SVR4_VINTR 0
|
||||||
|
#define SVR4_VQUIT 1
|
||||||
|
#define SVR4_VERASE 2
|
||||||
|
#define SVR4_VKILL 3
|
||||||
|
#define SVR4_VEOF 4
|
||||||
|
#define SVR4_VEOL 5
|
||||||
|
#define SVR4_VEOL2 6
|
||||||
|
#define SVR4_VMIN 4
|
||||||
|
#define SVR4_VTIME 5
|
||||||
|
#define SVR4_VSWTCH 7
|
||||||
|
#define SVR4_VSTART 8
|
||||||
|
#define SVR4_VSTOP 9
|
||||||
|
#define SVR4_VSUSP 10
|
||||||
|
#define SVR4_VDSUSP 11
|
||||||
|
#define SVR4_VREPRINT 12
|
||||||
|
#define SVR4_VDISCARD 13
|
||||||
|
#define SVR4_VWERASE 14
|
||||||
|
#define SVR4_VLNEXT 15
|
||||||
|
|
||||||
|
/* Input modes */
|
||||||
|
#define SVR4_IGNBRK 00000001
|
||||||
|
#define SVR4_BRKINT 00000002
|
||||||
|
#define SVR4_IGNPAR 00000004
|
||||||
|
#define SVR4_PARMRK 00000010
|
||||||
|
#define SVR4_INPCK 00000020
|
||||||
|
#define SVR4_ISTRIP 00000040
|
||||||
|
#define SVR4_INLCR 00000100
|
||||||
|
#define SVR4_IGNCR 00000200
|
||||||
|
#define SVR4_ICRNL 00000400
|
||||||
|
#define SVR4_IUCLC 00001000
|
||||||
|
#define SVR4_IXON 00002000
|
||||||
|
#define SVR4_IXANY 00004000
|
||||||
|
#define SVR4_IXOFF 00010000
|
||||||
|
#define SVR4_IMAXBEL 00020000
|
||||||
|
#define SVR4_DOSMODE 00100000
|
||||||
|
|
||||||
|
/* Output modes */
|
||||||
|
#define SVR4_OPOST 00000001
|
||||||
|
#define SVR4_OLCUC 00000002
|
||||||
|
#define SVR4_ONLCR 00000004
|
||||||
|
#define SVR4_OCRNL 00000010
|
||||||
|
#define SVR4_ONOCR 00000020
|
||||||
|
#define SVR4_ONLRET 00000040
|
||||||
|
#define SVR4_OFILL 00000100
|
||||||
|
#define SVR4_OFDEL 00000200
|
||||||
|
#define SVR4_NLDLY 00000400
|
||||||
|
#define SVR4_NL0 00000000
|
||||||
|
#define SVR4_NL1 00000400
|
||||||
|
#define SVR4_CRDLY 00003000
|
||||||
|
#define SVR4_CR0 00000000
|
||||||
|
#define SVR4_CR1 00001000
|
||||||
|
#define SVR4_CR2 00002000
|
||||||
|
#define SVR4_CR3 00003000
|
||||||
|
#define SVR4_TABDLY 00014000
|
||||||
|
#define SVR4_TAB0 00000000
|
||||||
|
#define SVR4_TAB1 00004000
|
||||||
|
#define SVR4_TAB2 00010000
|
||||||
|
#define SVR4_TAB3 00014000
|
||||||
|
#define SVR4_XTABS 00014000
|
||||||
|
#define SVR4_BSDLY 00020000
|
||||||
|
#define SVR4_BS0 00000000
|
||||||
|
#define SVR4_BS1 00020000
|
||||||
|
#define SVR4_VTDLY 00040000
|
||||||
|
#define SVR4_VT0 00000000
|
||||||
|
#define SVR4_VT1 00040000
|
||||||
|
#define SVR4_FFDLY 00100000
|
||||||
|
#define SVR4_FF0 00000000
|
||||||
|
#define SVR4_FF1 00100000
|
||||||
|
#define SVR4_PAGEOUT 00200000
|
||||||
|
#define SVR4_WRAP 00400000
|
||||||
|
|
||||||
|
/* Control modes */
|
||||||
|
#define SVR4_CBAUD 00000017
|
||||||
|
#define SVR4_CSIZE 00000060
|
||||||
|
#define SVR4_CS5 00000000
|
||||||
|
#define SVR4_CS6 00000200
|
||||||
|
#define SVR4_CS7 00000040
|
||||||
|
#define SVR4_CS8 00000006
|
||||||
|
#define SVR4_CSTOPB 00000100
|
||||||
|
#define SVR4_CREAD 00000200
|
||||||
|
#define SVR4_PARENB 00000400
|
||||||
|
#define SVR4_PARODD 00001000
|
||||||
|
#define SVR4_HUPCL 00002000
|
||||||
|
#define SVR4_CLOCAL 00004000
|
||||||
|
#define SVR4_RCV1EN 00010000
|
||||||
|
#define SVR4_XMT1EN 00020000
|
||||||
|
#define SVR4_LOBLK 00040000
|
||||||
|
#define SVR4_XCLUDE 00100000
|
||||||
|
#define SVR4_CIBAUD 03600000
|
||||||
|
#define SVR4_PAREXT 04000000
|
||||||
|
|
||||||
|
/* line discipline modes */
|
||||||
|
#define SVR4_ISIG 00000001
|
||||||
|
#define SVR4_ICANON 00000002
|
||||||
|
#define SVR4_XCASE 00000004
|
||||||
|
#define SVR4_ECHO 00000010
|
||||||
|
#define SVR4_ECHOE 00000020
|
||||||
|
#define SVR4_ECHOK 00000040
|
||||||
|
#define SVR4_ECHONL 00000100
|
||||||
|
#define SVR4_NOFLSH 00000200
|
||||||
|
#define SVR4_TOSTOP 00000400
|
||||||
|
#define SVR4_ECHOCTL 00001000
|
||||||
|
#define SVR4_ECHOPRT 00002000
|
||||||
|
#define SVR4_ECHOKE 00004000
|
||||||
|
#define SVR4_DEFECHO 00010000
|
||||||
|
#define SVR4_FLUSHO 00020000
|
||||||
|
#define SVR4_PENDIN 00040000
|
||||||
|
#define SVR4_IEXTEN 00100000
|
||||||
|
|
||||||
|
#define SVR4_TIOC ('T' << 8)
|
||||||
|
|
||||||
|
#define SVR4_TCGETA (SVR4_TIOC| 1)
|
||||||
|
#define SVR4_TCSETA (SVR4_TIOC| 2)
|
||||||
|
#define SVR4_TCSETAW (SVR4_TIOC| 3)
|
||||||
|
#define SVR4_TCSETAF (SVR4_TIOC| 4)
|
||||||
|
#define SVR4_TCSBRK (SVR4_TIOC| 5)
|
||||||
|
#define SVR4_TCXONC (SVR4_TIOC| 6)
|
||||||
|
#define SVR4_TCFLSH (SVR4_TIOC| 7)
|
||||||
|
#define SVR4_TIOCKBON (SVR4_TIOC| 8)
|
||||||
|
#define SVR4_TIOCKBOF (SVR4_TIOC| 9)
|
||||||
|
#define SVR4_KBENABLED (SVR4_TIOC|10)
|
||||||
|
#define SVR4_TCGETS (SVR4_TIOC|13)
|
||||||
|
#define SVR4_TCSETS (SVR4_TIOC|14)
|
||||||
|
#define SVR4_TCSETSW (SVR4_TIOC|15)
|
||||||
|
#define SVR4_TCSETSF (SVR4_TIOC|16)
|
||||||
|
#define SVR4_TCDSET (SVR4_TIOC|32)
|
||||||
|
#define SVR4_RTS_TOG (SVR4_TIOC|33)
|
||||||
|
#define SVR4_TCGETSC (SVR4_TIOC|34)
|
||||||
|
#define SVR4_TCSETSC (SVR4_TIOC|35)
|
||||||
|
#define SVR4_TCMOUSE (SVR4_TIOC|36)
|
||||||
|
#define SVR4_TIOCGWINSZ (SVR4_TIOC|104)
|
||||||
|
#define SVR4_TIOCSWINSZ (SVR4_TIOC|103)
|
||||||
|
|
||||||
|
struct svr4_winsize {
|
||||||
|
u_short ws_row;
|
||||||
|
u_short ws_col;
|
||||||
|
u_short ws_xpixel;
|
||||||
|
u_short ws_ypixel;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_B0 0
|
||||||
|
#define SVR4_B50 1
|
||||||
|
#define SVR4_B75 2
|
||||||
|
#define SVR4_B110 3
|
||||||
|
#define SVR4_B134 4
|
||||||
|
#define SVR4_B150 5
|
||||||
|
#define SVR4_B200 6
|
||||||
|
#define SVR4_B300 7
|
||||||
|
#define SVR4_B600 8
|
||||||
|
#define SVR4_B1200 9
|
||||||
|
#define SVR4_B1800 10
|
||||||
|
#define SVR4_B2400 11
|
||||||
|
#define SVR4_B4800 12
|
||||||
|
#define SVR4_B9600 13
|
||||||
|
#define SVR4_B19200 14
|
||||||
|
#define SVR4_B38400 15
|
||||||
|
#define SVR4_B57600 16
|
||||||
|
#define SVR4_B76800 17
|
||||||
|
#define SVR4_B115200 18
|
||||||
|
#define SVR4_B153600 19
|
||||||
|
#define SVR4_B230400 20
|
||||||
|
#define SVR4_B307200 21
|
||||||
|
#define SVR4_B460800 22
|
||||||
|
|
||||||
|
#endif /* !_SVR4_TERMIOS_H_ */
|
39
sys/compat/svr4/svr4_time.h
Normal file
39
sys/compat/svr4/svr4_time.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_TIME_H_
|
||||||
|
#define _SVR4_TIME_H_
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
struct svr4_utimbuf {
|
||||||
|
time_t actime;
|
||||||
|
time_t modtime;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_SVR4_TIME_H_ */
|
85
sys/compat/svr4/svr4_timod.h
Normal file
85
sys/compat/svr4/svr4_timod.h
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_TIMOD_H_
|
||||||
|
#define _SVR4_TIMOD_H_
|
||||||
|
|
||||||
|
#define SVR4_TIMOD ('T' << 8)
|
||||||
|
#define SVR4_TI_GETINFO (SVR4_TIMOD|140)
|
||||||
|
#define SVR4_TI_OPTMGMT (SVR4_TIMOD|141)
|
||||||
|
#define SVR4_TI_BIND (SVR4_TIMOD|142)
|
||||||
|
#define SVR4_TI_UNBIND (SVR4_TIMOD|143)
|
||||||
|
#define SVR4_TI_GETMYNAME (SVR4_TIMOD|144)
|
||||||
|
#define SVR4_TI_GETPEERNAME (SVR4_TIMOD|145)
|
||||||
|
#define SVR4_TI_SETMYNAME (SVR4_TIMOD|146)
|
||||||
|
#define SVR4_TI_SETPEERNAME (SVR4_TIMOD|147)
|
||||||
|
#define SVR4_TI_SYNC (SVR4_TIMOD|148)
|
||||||
|
#define SVR4_TI_GETADDRS (SVR4_TIMOD|149)
|
||||||
|
|
||||||
|
#define SVR4_TI_CONNECT_REQUEST 0x00
|
||||||
|
#define SVR4_TI_CONNECT_RESPONSE 0x01
|
||||||
|
#define SVR4_TI_DISCONNECT_REQUEST 0x02
|
||||||
|
#define SVR4_TI_DATA_REQUEST 0x03
|
||||||
|
#define SVR4_TI_EXPDATA_REQUEST 0x04
|
||||||
|
#define SVR4_TI_INFO_REQUEST 0x05
|
||||||
|
#define SVR4_TI_OLD_BIND_REQUEST 0x06
|
||||||
|
#define SVR4_TI_UNBIND_REQUEST 0x07
|
||||||
|
#define SVR4_TI_SENDTO_REQUEST 0x08
|
||||||
|
#define SVR4_TI_OLD_OPTMGMT_REQUEST 0x09
|
||||||
|
#define SVR4_TI_ORDREL_REQUEST 0x0a
|
||||||
|
|
||||||
|
#define SVR4_TI_ACCEPT_REPLY 0x0b
|
||||||
|
#define SVR4_TI_CONNECT_REPLY 0x0c
|
||||||
|
#define SVR4_TI_DISCONNECT_IND 0x0d
|
||||||
|
#define SVR4_TI_DATA_IND 0x0e
|
||||||
|
#define SVR4_TI_EXPDATA_IND 0x0f
|
||||||
|
#define SVR4_TI_INFO_REPLY 0x10
|
||||||
|
#define SVR4_TI_BIND_REPLY 0x11
|
||||||
|
#define SVR4_TI_ERROR_REPLY 0x12
|
||||||
|
#define SVR4_TI_OK_REPLY 0x13
|
||||||
|
#define SVR4_TI_RECVFROM_IND 0x14
|
||||||
|
#define SVR4_TI_RECVFROM_ERROR_IND 0x15
|
||||||
|
#define SVR4_TI_OPTMGMT_REPLY 0x16
|
||||||
|
#define SVR4_TI_ORDREL_IND 0x17
|
||||||
|
|
||||||
|
#define SVR4_TI_ADDRESS_REQUEST 0x18
|
||||||
|
#define SVR4_TI_ADDRESS_REPLY 0x19
|
||||||
|
|
||||||
|
#define SVR4_TI_BIND_REQUEST 0x20
|
||||||
|
#define SVR4_TI_OPTMGMT_REQUEST 0x21
|
||||||
|
|
||||||
|
#define SVR4_TI__ACCEPT_WAIT 0x10000001
|
||||||
|
#define SVR4_TI__ACCEPT_OK 0x10000002
|
||||||
|
|
||||||
|
struct svr4_netbuf {
|
||||||
|
u_int maxlen;
|
||||||
|
u_int len;
|
||||||
|
char *buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_SVR4_TIMOD_H_ */
|
381
sys/compat/svr4/svr4_ttold.c
Normal file
381
sys/compat/svr4/svr4_ttold.c
Normal file
|
@ -0,0 +1,381 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/ioctl_compat.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/tty.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_stropts.h>
|
||||||
|
#include <svr4/svr4_ttold.h>
|
||||||
|
#include <svr4/svr4_ioctl.h>
|
||||||
|
|
||||||
|
|
||||||
|
static void svr4_tchars_to_bsd_tchars __P((const struct svr4_tchars *st,
|
||||||
|
struct tchars *bt));
|
||||||
|
static void bsd_tchars_to_svr4_tchars __P((const struct tchars *bt,
|
||||||
|
struct svr4_tchars *st));
|
||||||
|
static void svr4_sgttyb_to_bsd_sgttyb __P((const struct svr4_sgttyb *ss,
|
||||||
|
struct sgttyb *bs));
|
||||||
|
static void bsd_sgttyb_to_svr4_sgttyb __P((const struct sgttyb *bs,
|
||||||
|
struct svr4_sgttyb *ss));
|
||||||
|
static void svr4_ltchars_to_bsd_ltchars __P((const struct svr4_ltchars *sl,
|
||||||
|
struct ltchars *bl));
|
||||||
|
static void bsd_ltchars_to_svr4_ltchars __P((const struct ltchars *bl,
|
||||||
|
struct svr4_ltchars *sl));
|
||||||
|
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
static void print_svr4_sgttyb __P((const char *, struct svr4_sgttyb *));
|
||||||
|
static void print_svr4_tchars __P((const char *, struct svr4_tchars *));
|
||||||
|
static void print_svr4_ltchars __P((const char *, struct svr4_ltchars *));
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_svr4_sgttyb(str, ss)
|
||||||
|
const char *str;
|
||||||
|
struct svr4_sgttyb *ss;
|
||||||
|
{
|
||||||
|
|
||||||
|
uprintf("%s\nispeed=%o ospeed=%o ", str, ss->sg_ispeed, ss->sg_ospeed);
|
||||||
|
uprintf("erase=%o kill=%o flags=%o\n", ss->sg_erase, ss->sg_kill,
|
||||||
|
ss->sg_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_svr4_tchars(str, st)
|
||||||
|
const char *str;
|
||||||
|
struct svr4_tchars *st;
|
||||||
|
{
|
||||||
|
uprintf("%s\nintrc=%o quitc=%o ", str, st->t_intrc, st->t_quitc);
|
||||||
|
uprintf("startc=%o stopc=%o eofc=%o brkc=%o\n", st->t_startc,
|
||||||
|
st->t_stopc, st->t_eofc, st->t_brkc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_svr4_ltchars(str, sl)
|
||||||
|
const char *str;
|
||||||
|
struct svr4_ltchars *sl;
|
||||||
|
{
|
||||||
|
uprintf("%s\nsuspc=%o dsuspc=%o ", str, sl->t_suspc, sl->t_dsuspc);
|
||||||
|
uprintf("rprntc=%o flushc=%o werasc=%o lnextc=%o\n", sl->t_rprntc,
|
||||||
|
sl->t_flushc, sl->t_werasc, sl->t_lnextc);
|
||||||
|
}
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_tchars_to_bsd_tchars(st, bt)
|
||||||
|
const struct svr4_tchars *st;
|
||||||
|
struct tchars *bt;
|
||||||
|
{
|
||||||
|
bt->t_intrc = st->t_intrc;
|
||||||
|
bt->t_quitc = st->t_quitc;
|
||||||
|
bt->t_startc = st->t_startc;
|
||||||
|
bt->t_stopc = st->t_stopc;
|
||||||
|
bt->t_eofc = st->t_eofc;
|
||||||
|
bt->t_brkc = st->t_brkc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_tchars_to_svr4_tchars(bt, st)
|
||||||
|
const struct tchars *bt;
|
||||||
|
struct svr4_tchars *st;
|
||||||
|
{
|
||||||
|
st->t_intrc = bt->t_intrc;
|
||||||
|
st->t_quitc = bt->t_quitc;
|
||||||
|
st->t_startc = bt->t_startc;
|
||||||
|
st->t_stopc = bt->t_stopc;
|
||||||
|
st->t_eofc = bt->t_eofc;
|
||||||
|
st->t_brkc = bt->t_brkc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_sgttyb_to_bsd_sgttyb(ss, bs)
|
||||||
|
const struct svr4_sgttyb *ss;
|
||||||
|
struct sgttyb *bs;
|
||||||
|
{
|
||||||
|
bs->sg_ispeed = ss->sg_ispeed;
|
||||||
|
bs->sg_ospeed = ss->sg_ospeed;
|
||||||
|
bs->sg_erase = ss->sg_erase;
|
||||||
|
bs->sg_kill = ss->sg_kill;
|
||||||
|
bs->sg_flags = ss->sg_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_sgttyb_to_svr4_sgttyb(bs, ss)
|
||||||
|
const struct sgttyb *bs;
|
||||||
|
struct svr4_sgttyb *ss;
|
||||||
|
{
|
||||||
|
ss->sg_ispeed = bs->sg_ispeed;
|
||||||
|
ss->sg_ospeed = bs->sg_ospeed;
|
||||||
|
ss->sg_erase = bs->sg_erase;
|
||||||
|
ss->sg_kill = bs->sg_kill;
|
||||||
|
ss->sg_flags = bs->sg_flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_ltchars_to_bsd_ltchars(sl, bl)
|
||||||
|
const struct svr4_ltchars *sl;
|
||||||
|
struct ltchars *bl;
|
||||||
|
{
|
||||||
|
bl->t_suspc = sl->t_suspc;
|
||||||
|
bl->t_dsuspc = sl->t_dsuspc;
|
||||||
|
bl->t_rprntc = sl->t_rprntc;
|
||||||
|
bl->t_flushc = sl->t_flushc;
|
||||||
|
bl->t_werasc = sl->t_werasc;
|
||||||
|
bl->t_lnextc = sl->t_lnextc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_ltchars_to_svr4_ltchars(bl, sl)
|
||||||
|
const struct ltchars *bl;
|
||||||
|
struct svr4_ltchars *sl;
|
||||||
|
{
|
||||||
|
sl->t_suspc = bl->t_suspc;
|
||||||
|
sl->t_dsuspc = bl->t_dsuspc;
|
||||||
|
sl->t_rprntc = bl->t_rprntc;
|
||||||
|
sl->t_flushc = bl->t_flushc;
|
||||||
|
sl->t_werasc = bl->t_werasc;
|
||||||
|
sl->t_lnextc = bl->t_lnextc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
|
||||||
|
struct file *fp;
|
||||||
|
struct proc *p;
|
||||||
|
register_t *retval;
|
||||||
|
int fd;
|
||||||
|
u_long cmd;
|
||||||
|
caddr_t data;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
|
||||||
|
fp->f_ops->fo_ioctl;
|
||||||
|
|
||||||
|
*retval = 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_TIOCGPGRP:
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
if ((error = (*ctl)(fp, TIOCGPGRP,
|
||||||
|
(caddr_t) &pid, p)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
DPRINTF(("TIOCGPGRP %d\n", pid));
|
||||||
|
|
||||||
|
if ((error = copyout(&pid, data, sizeof(pid))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCSPGRP:
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &pid, sizeof(pid))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
DPRINTF(("TIOCSPGRP %d\n", pid));
|
||||||
|
|
||||||
|
return (*ctl)(fp, TIOCSPGRP, (caddr_t) &pid, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCGSID:
|
||||||
|
{
|
||||||
|
#if defined(TIOCGSID)
|
||||||
|
pid_t pid;
|
||||||
|
if ((error = (*ctl)(fp, TIOCGSID,
|
||||||
|
(caddr_t) &pid, p)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
DPRINTF(("TIOCGSID %d\n", pid));
|
||||||
|
|
||||||
|
return copyout(&pid, data, sizeof(pid));
|
||||||
|
#else
|
||||||
|
uprintf("ioctl(TIOCGSID) for pid %d unsupported\n", p->p_pid);
|
||||||
|
return EINVAL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCGETP:
|
||||||
|
{
|
||||||
|
struct sgttyb bs;
|
||||||
|
struct svr4_sgttyb ss;
|
||||||
|
|
||||||
|
error = (*ctl)(fp, TIOCGETP, (caddr_t) &bs, p);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_sgttyb_to_svr4_sgttyb(&bs, &ss);
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
print_svr4_sgttyb("SVR4_TIOCGETP", &ss);
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
return copyout(&ss, data, sizeof(ss));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCSETP:
|
||||||
|
case SVR4_TIOCSETN:
|
||||||
|
{
|
||||||
|
struct sgttyb bs;
|
||||||
|
struct svr4_sgttyb ss;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &ss, sizeof(ss))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_sgttyb_to_bsd_sgttyb(&ss, &bs);
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
print_svr4_sgttyb("SVR4_TIOCSET{P,N}", &ss);
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN;
|
||||||
|
return (*ctl)(fp, cmd, (caddr_t) &bs, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCGETC:
|
||||||
|
{
|
||||||
|
struct tchars bt;
|
||||||
|
struct svr4_tchars st;
|
||||||
|
|
||||||
|
error = (*ctl)(fp, TIOCGETC, (caddr_t) &bt, p);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_tchars_to_svr4_tchars(&bt, &st);
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
print_svr4_tchars("SVR4_TIOCGETC", &st);
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
return copyout(&st, data, sizeof(st));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCSETC:
|
||||||
|
{
|
||||||
|
struct tchars bt;
|
||||||
|
struct svr4_tchars st;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &st, sizeof(st))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_tchars_to_bsd_tchars(&st, &bt);
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
print_svr4_tchars("SVR4_TIOCSETC", &st);
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
return (*ctl)(fp, TIOCSETC, (caddr_t) &bt, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCGLTC:
|
||||||
|
{
|
||||||
|
struct ltchars bl;
|
||||||
|
struct svr4_ltchars sl;
|
||||||
|
|
||||||
|
error = (*ctl)(fp, TIOCGLTC, (caddr_t) &bl, p);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_ltchars_to_svr4_ltchars(&bl, &sl);
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
print_svr4_ltchars("SVR4_TIOCGLTC", &sl);
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
return copyout(&sl, data, sizeof(sl));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCSLTC:
|
||||||
|
{
|
||||||
|
struct ltchars bl;
|
||||||
|
struct svr4_ltchars sl;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &sl, sizeof(sl))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_ltchars_to_bsd_ltchars(&sl, &bl);
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
print_svr4_ltchars("SVR4_TIOCSLTC", &sl);
|
||||||
|
#endif /* DEBUG_SVR4 */
|
||||||
|
return (*ctl)(fp, TIOCSLTC, (caddr_t) &bl, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCLGET:
|
||||||
|
{
|
||||||
|
int flags;
|
||||||
|
if ((error = (*ctl)(fp, TIOCLGET,
|
||||||
|
(caddr_t) &flags, p)) != 0)
|
||||||
|
return error;
|
||||||
|
DPRINTF(("SVR4_TIOCLGET %o\n", flags));
|
||||||
|
return copyout(&flags, data, sizeof(flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_TIOCLSET:
|
||||||
|
case SVR4_TIOCLBIS:
|
||||||
|
case SVR4_TIOCLBIC:
|
||||||
|
{
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &flags, sizeof(flags))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_TIOCLSET:
|
||||||
|
cmd = TIOCLSET;
|
||||||
|
break;
|
||||||
|
case SVR4_TIOCLBIS:
|
||||||
|
cmd = TIOCLBIS;
|
||||||
|
break;
|
||||||
|
case SVR4_TIOCLBIC:
|
||||||
|
cmd = TIOCLBIC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINTF(("SVR4_TIOCL{SET,BIS,BIC} %o\n", flags));
|
||||||
|
return (*ctl)(fp, cmd, (caddr_t) &flags, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Unknown svr4 ttold %lx\n", cmd));
|
||||||
|
return 0; /* ENOSYS really */
|
||||||
|
}
|
||||||
|
}
|
120
sys/compat/svr4/svr4_ttold.h
Normal file
120
sys/compat/svr4/svr4_ttold.h
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_TTOLD_H_
|
||||||
|
#define _SVR4_TTOLD_H_
|
||||||
|
|
||||||
|
struct svr4_tchars {
|
||||||
|
char t_intrc;
|
||||||
|
char t_quitc;
|
||||||
|
char t_startc;
|
||||||
|
char t_stopc;
|
||||||
|
char t_eofc;
|
||||||
|
char t_brkc;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_sgttyb {
|
||||||
|
u_char sg_ispeed;
|
||||||
|
u_char sg_ospeed;
|
||||||
|
u_char sg_erase;
|
||||||
|
u_char sg_kill;
|
||||||
|
int sg_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_ltchars {
|
||||||
|
char t_suspc;
|
||||||
|
char t_dsuspc;
|
||||||
|
char t_rprntc;
|
||||||
|
char t_flushc;
|
||||||
|
char t_werasc;
|
||||||
|
char t_lnextc;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef SVR4_tIOC
|
||||||
|
#define SVR4_tIOC ('t' << 8)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SVR4_TIOCGETD (SVR4_tIOC | 0)
|
||||||
|
#define SVR4_TIOCSETD (SVR4_tIOC | 1)
|
||||||
|
#define SVR4_TIOCHPCL (SVR4_tIOC | 2)
|
||||||
|
#define SVR4_TIOCGETP (SVR4_tIOC | 8)
|
||||||
|
#define SVR4_TIOCSETP (SVR4_tIOC | 9)
|
||||||
|
#define SVR4_TIOCSETN (SVR4_tIOC | 10)
|
||||||
|
#define SVR4_TIOCEXCL (SVR4_tIOC | 13)
|
||||||
|
#define SVR4_TIOCNXCL (SVR4_tIOC | 14)
|
||||||
|
#define SVR4_TIOCFLUSH (SVR4_tIOC | 16)
|
||||||
|
#define SVR4_TIOCSETC (SVR4_tIOC | 17)
|
||||||
|
#define SVR4_TIOCGETC (SVR4_tIOC | 18)
|
||||||
|
#define SVR4_TIOCGPGRP (SVR4_tIOC | 20)
|
||||||
|
#define SVR4_TIOCSPGRP (SVR4_tIOC | 21)
|
||||||
|
#define SVR4_TIOCGSID (SVR4_tIOC | 22)
|
||||||
|
#define SVR4_TIOCSTI (SVR4_tIOC | 23)
|
||||||
|
#define SVR4_TIOCSSID (SVR4_tIOC | 24)
|
||||||
|
#define SVR4_TIOCMSET (SVR4_tIOC | 26)
|
||||||
|
#define SVR4_TIOCMBIS (SVR4_tIOC | 27)
|
||||||
|
#define SVR4_TIOCMBIC (SVR4_tIOC | 28)
|
||||||
|
#define SVR4_TIOCMGET (SVR4_tIOC | 29)
|
||||||
|
#define SVR4_TIOCREMOTE (SVR4_tIOC | 30)
|
||||||
|
#define SVR4_TIOCSIGNAL (SVR4_tIOC | 31)
|
||||||
|
|
||||||
|
#define SVR4_TIOCSTART (SVR4_tIOC | 110)
|
||||||
|
#define SVR4_TIOCSTOP (SVR4_tIOC | 111)
|
||||||
|
#define SVR4_TIOCNOTTY (SVR4_tIOC | 113)
|
||||||
|
#define SVR4_TIOCOUTQ (SVR4_tIOC | 115)
|
||||||
|
#define SVR4_TIOCGLTC (SVR4_tIOC | 116)
|
||||||
|
#define SVR4_TIOCSLTC (SVR4_tIOC | 117)
|
||||||
|
#define SVR4_TIOCCDTR (SVR4_tIOC | 120)
|
||||||
|
#define SVR4_TIOCSDTR (SVR4_tIOC | 121)
|
||||||
|
#define SVR4_TIOCCBRK (SVR4_tIOC | 122)
|
||||||
|
#define SVR4_TIOCSBRK (SVR4_tIOC | 123)
|
||||||
|
#define SVR4_TIOCLGET (SVR4_tIOC | 124)
|
||||||
|
#define SVR4_TIOCLSET (SVR4_tIOC | 125)
|
||||||
|
#define SVR4_TIOCLBIC (SVR4_tIOC | 126)
|
||||||
|
#define SVR4_TIOCLBIS (SVR4_tIOC | 127)
|
||||||
|
|
||||||
|
#define SVR4_TIOCM_LE 0001
|
||||||
|
#define SVR4_TIOCM_DTR 0002
|
||||||
|
#define SVR4_TIOCM_RTS 0004
|
||||||
|
#define SVR4_TIOCM_ST 0010
|
||||||
|
#define SVR4_TIOCM_SR 0020
|
||||||
|
#define SVR4_TIOCM_CTS 0040
|
||||||
|
#define SVR4_TIOCM_CAR 0100
|
||||||
|
#define SVR4_TIOCM_CD SVR4_TIOCM_CAR
|
||||||
|
#define SVR4_TIOCM_RNG 0200
|
||||||
|
#define SVR4_TIOCM_RI SVR4_TIOCM_RNG
|
||||||
|
#define SVR4_TIOCM_DSR 0400
|
||||||
|
|
||||||
|
#define SVR4_OTTYDISC 0
|
||||||
|
#define SVR4_NETLDISC 1
|
||||||
|
#define SVR4_NTTYDISC 2
|
||||||
|
#define SVR4_TABLDISC 3
|
||||||
|
#define SVR4_NTABLDISC 4
|
||||||
|
#define SVR4_MOUSELDISC 5
|
||||||
|
#define SVR4_KBDLDISC 6
|
||||||
|
|
||||||
|
#endif /* !_SVR4_TTOLD_H_ */
|
79
sys/compat/svr4/svr4_types.h
Normal file
79
sys/compat/svr4/svr4_types.h
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_TYPES_H_
|
||||||
|
#define _SVR4_TYPES_H_
|
||||||
|
|
||||||
|
typedef u_quad_t svr4_ino64_t;
|
||||||
|
typedef quad_t svr4_off64_t;
|
||||||
|
typedef quad_t svr4_blkcnt64_t;
|
||||||
|
typedef u_quad_t svr4_fsblkcnt64_t;
|
||||||
|
|
||||||
|
typedef long svr4_off_t;
|
||||||
|
typedef u_long svr4_dev_t;
|
||||||
|
typedef u_long svr4_ino_t;
|
||||||
|
typedef u_long svr4_mode_t;
|
||||||
|
typedef u_long svr4_nlink_t;
|
||||||
|
typedef long svr4_uid_t;
|
||||||
|
typedef long svr4_gid_t;
|
||||||
|
typedef long svr4_daddr_t;
|
||||||
|
typedef long svr4_pid_t;
|
||||||
|
typedef long svr4_time_t;
|
||||||
|
typedef long svr4_blkcnt_t;
|
||||||
|
typedef u_long svr4_fsblkcnt_t;
|
||||||
|
typedef char *svr4_caddr_t;
|
||||||
|
typedef u_int svr4_size_t;
|
||||||
|
|
||||||
|
typedef short svr4_o_dev_t;
|
||||||
|
typedef short svr4_o_pid_t;
|
||||||
|
typedef u_short svr4_o_ino_t;
|
||||||
|
typedef u_short svr4_o_mode_t;
|
||||||
|
typedef short svr4_o_nlink_t;
|
||||||
|
typedef u_short svr4_o_uid_t;
|
||||||
|
typedef u_short svr4_o_gid_t;
|
||||||
|
typedef long svr4_clock_t;
|
||||||
|
typedef int svr4_key_t;
|
||||||
|
|
||||||
|
typedef struct timespec svr4_timestruc_t;
|
||||||
|
|
||||||
|
#define svr4_omajor(x) ((int32_t)((((x) & 0x7f00) >> 8)))
|
||||||
|
#define svr4_ominor(x) ((int32_t)((((x) & 0x00ff) >> 0)))
|
||||||
|
#define svr4_omakedev(x,y) ((svr4_o_dev_t)((((x) << 8) & 0x7f00) | \
|
||||||
|
(((y) << 0) & 0x00ff)))
|
||||||
|
|
||||||
|
#define svr4_to_bsd_odev_t(d) makedev(svr4_omajor(d), svr4_ominor(d))
|
||||||
|
#define bsd_to_svr4_odev_t(d) svr4_omakedev(major(d), minor(d))
|
||||||
|
|
||||||
|
#define svr4_major(x) ((int32_t)((((x) & 0xfffc0000) >> 18)))
|
||||||
|
#define svr4_minor(x) ((int32_t)((((x) & 0x0003ffff) >> 0)))
|
||||||
|
#define svr4_makedev(x,y) ((svr4_dev_t)((((x) << 18) & 0xfffc0000) | \
|
||||||
|
(((y) << 0) & 0x0003ffff)))
|
||||||
|
#define svr4_to_bsd_dev_t(d) makedev(svr4_major(d), svr4_minor(d))
|
||||||
|
#define bsd_to_svr4_dev_t(d) svr4_makedev(major(d), minor(d))
|
||||||
|
|
||||||
|
#endif /* !_SVR4_TYPES_H_ */
|
72
sys/compat/svr4/svr4_ucontext.h
Normal file
72
sys/compat/svr4/svr4_ucontext.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_UCONTEXT_H_
|
||||||
|
#define _SVR4_UCONTEXT_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Machine context
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SVR4_UC_SIGMASK 0x01
|
||||||
|
#define SVR4_UC_STACK 0x02
|
||||||
|
|
||||||
|
#define SVR4_UC_CPU 0x04
|
||||||
|
#define SVR4_UC_FPU 0x08
|
||||||
|
#define SVR4_UC_WEITEK 0x10
|
||||||
|
|
||||||
|
#define SVR4_UC_MCONTEXT (SVR4_UC_CPU|SVR4_UC_FPU|SVR4_UC_WEITEK)
|
||||||
|
|
||||||
|
#define SVR4_UC_ALL (SVR4_UC_SIGMASK|SVR4_UC_STACK|SVR4_UC_MCONTEXT)
|
||||||
|
|
||||||
|
typedef struct svr4_ucontext {
|
||||||
|
u_long uc_flags;
|
||||||
|
/* struct svr4_ucontext *uc_link;*/
|
||||||
|
void *uc_link;
|
||||||
|
svr4_sigset_t uc_sigmask;
|
||||||
|
struct svr4_sigaltstack uc_stack;
|
||||||
|
svr4_mcontext_t uc_mcontext;
|
||||||
|
long uc_pad[5];
|
||||||
|
} svr4_ucontext_t;
|
||||||
|
|
||||||
|
#define SVR4_UC_GETREGSET 0
|
||||||
|
#define SVR4_UC_SETREGSET 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Signal frame
|
||||||
|
*/
|
||||||
|
struct svr4_sigframe {
|
||||||
|
int sf_signum;
|
||||||
|
union svr4_siginfo *sf_sip;
|
||||||
|
struct svr4_ucontext *sf_ucp;
|
||||||
|
sig_t sf_handler;
|
||||||
|
struct svr4_ucontext sf_uc;
|
||||||
|
union svr4_siginfo sf_si;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_SVR4_UCONTEXT_H_ */
|
39
sys/compat/svr4/svr4_ulimit.h
Normal file
39
sys/compat/svr4/svr4_ulimit.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_ULIMIT_H_
|
||||||
|
#define _SVR4_ULIMIT_H_
|
||||||
|
|
||||||
|
#define SVR4_GFILLIM 1
|
||||||
|
#define SVR4_SFILLIM 2
|
||||||
|
#define SVR4_GMEMLIM 3
|
||||||
|
#define SVR4_GDESLIM 4
|
||||||
|
#define SVR4_GTXTOFF 64
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !_SVR4_ULIMIT_H_ */
|
41
sys/compat/svr4/svr4_ustat.h
Normal file
41
sys/compat/svr4/svr4_ustat.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_USTAT_H_
|
||||||
|
#define _SVR4_USTAT_H_
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
|
||||||
|
struct svr4_ustat {
|
||||||
|
svr4_daddr_t f_tfree;
|
||||||
|
svr4_ino_t f_tinode;
|
||||||
|
char f_fname[6];
|
||||||
|
char f_fpack[6];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_SVR4_USTAT_H_ */
|
78
sys/compat/svr4/svr4_util.h
Normal file
78
sys/compat/svr4/svr4_util.h
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_UTIL_H_
|
||||||
|
#define _SVR4_UTIL_H_
|
||||||
|
|
||||||
|
/*#include <compat/common/compat_util.h>*/
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <vm/vm_param.h>
|
||||||
|
#include <vm/pmap.h>
|
||||||
|
#include <machine/vmparam.h>
|
||||||
|
#include <sys/exec.h>
|
||||||
|
#include <sys/sysent.h>
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
#define DPRINTF(a) uprintf a;
|
||||||
|
#else
|
||||||
|
#define DPRINTF(a)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static __inline caddr_t stackgap_init(void);
|
||||||
|
static __inline void *stackgap_alloc(caddr_t *, size_t);
|
||||||
|
|
||||||
|
static __inline caddr_t
|
||||||
|
stackgap_init()
|
||||||
|
{
|
||||||
|
#define szsigcode (*(curproc->p_sysent->sv_szsigcode))
|
||||||
|
return (caddr_t)(((caddr_t)PS_STRINGS) - szsigcode - SPARE_USRSPACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline void *
|
||||||
|
stackgap_alloc(sgp, sz)
|
||||||
|
caddr_t *sgp;
|
||||||
|
size_t sz;
|
||||||
|
{
|
||||||
|
void *p = (void *) *sgp;
|
||||||
|
*sgp += ALIGN(sz);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern const char svr4_emul_path[];
|
||||||
|
int svr4_emul_find __P((struct proc *, caddr_t *, const char *, char *,
|
||||||
|
char **, int));
|
||||||
|
|
||||||
|
#define CHECKALTEXIST(p, sgp, path) \
|
||||||
|
svr4_emul_find(p, sgp, svr4_emul_path, path, &(path), 0)
|
||||||
|
|
||||||
|
#define CHECKALTCREAT(p, sgp, path) \
|
||||||
|
svr4_emul_find(p, sgp, svr4_emul_path, path, &(path), 1)
|
||||||
|
|
||||||
|
#endif /* !_SVR4_UTIL_H_ */
|
42
sys/compat/svr4/svr4_utsname.h
Normal file
42
sys/compat/svr4/svr4_utsname.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_UTSNAME_H_
|
||||||
|
#define _SVR4_UTSNAME_H_
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
|
||||||
|
struct svr4_utsname {
|
||||||
|
char sysname[257];
|
||||||
|
char nodename[257];
|
||||||
|
char release[257];
|
||||||
|
char version[257];
|
||||||
|
char machine[257];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_SVR4_UTSNAME_H_ */
|
54
sys/compat/svr4/svr4_wait.h
Normal file
54
sys/compat/svr4/svr4_wait.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_WAIT_H_
|
||||||
|
#define _SVR4_WAIT_H_
|
||||||
|
|
||||||
|
|
||||||
|
#define SVR4_P_PID 0
|
||||||
|
#define SVR4_P_PPID 1
|
||||||
|
#define SVR4_P_PGID 2
|
||||||
|
#define SVR4_P_SID 3
|
||||||
|
#define SVR4_P_CID 4
|
||||||
|
#define SVR4_P_UID 5
|
||||||
|
#define SVR4_P_GID 6
|
||||||
|
#define SVR4_P_ALL 7
|
||||||
|
|
||||||
|
#define SVR4_WEXITED 0x01
|
||||||
|
#define SVR4_WTRAPPED 0x02
|
||||||
|
#define SVR4_WSTOPPED 0x04
|
||||||
|
#define SVR4_WCONTINUED 0x08
|
||||||
|
#define SVR4_WUNDEF1 0x10
|
||||||
|
#define SVR4_WUNDEF2 0x20
|
||||||
|
#define SVR4_WNOHANG 0x40
|
||||||
|
#define SVR4_WNOWAIT 0x80
|
||||||
|
|
||||||
|
#define SVR4_WOPTMASK (SVR4_WEXITED|SVR4_WTRAPPED|SVR4_WSTOPPED|\
|
||||||
|
SVR4_WCONTINUED|SVR4_WNOHANG|SVR4_WNOWAIT)
|
||||||
|
|
||||||
|
#endif /* !_SVR4_WAIT_H_ */
|
12
sys/compat/svr4/syscalls.conf
Normal file
12
sys/compat/svr4/syscalls.conf
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# $Id: syscalls.conf,v 1.4 1998/03/13 19:13:54 jb Exp $
|
||||||
|
sysnames="svr4_syscallnames.c"
|
||||||
|
sysproto="svr4_proto.h"
|
||||||
|
sysproto_h=_SVR4_SYSPROTO_H_
|
||||||
|
syshdr="svr4_syscall.h"
|
||||||
|
syssw="svr4_sysent.c"
|
||||||
|
sysmk="/dev/null"
|
||||||
|
syshide="/dev/null"
|
||||||
|
syscallprefix="SVR4_SYS_"
|
||||||
|
switchname="svr4_sysent"
|
||||||
|
namesname="svr4_syscallnames"
|
||||||
|
sysvec="\n"
|
373
sys/compat/svr4/syscalls.master
Normal file
373
sys/compat/svr4/syscalls.master
Normal file
|
@ -0,0 +1,373 @@
|
||||||
|
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||||
|
; System call name/number master file (or rather, slave, from SVR4).
|
||||||
|
; Processed to create svr4_sysent.c, svr4_syscalls.c and svr4_syscall.h.
|
||||||
|
|
||||||
|
; Columns: number type nargs namespc name alt{name,tag,rtyp}/comments
|
||||||
|
; number system call number, must be in order
|
||||||
|
; type one of STD, OBSOL, UNIMPL, COMPAT
|
||||||
|
; namespc one of POSIX, BSD, STD, NOHIDE (I dont care :-) -Peter
|
||||||
|
; name psuedo-prototype of syscall routine
|
||||||
|
; If one of the following alts is different, then all appear:
|
||||||
|
; altname name of system call if different
|
||||||
|
; alttag name of args struct tag if different from [o]`name'"_args"
|
||||||
|
; altrtyp return type if not int (bogus - syscalls always return int)
|
||||||
|
; for UNIMPL/OBSOL, name continues with comments
|
||||||
|
|
||||||
|
; types:
|
||||||
|
; STD always included
|
||||||
|
; COMPAT included on COMPAT #ifdef
|
||||||
|
; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h
|
||||||
|
; OBSOL obsolete, not included in system, only specifies name
|
||||||
|
; UNIMPL not implemented, placeholder only
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filio.h>
|
||||||
|
#include <sys/sysent.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_stropts.h>
|
||||||
|
#include <svr4/svr4_socket.h>
|
||||||
|
#include <svr4/svr4_sockio.h>
|
||||||
|
#include <svr4/svr4_timod.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
|
||||||
|
; #ifdef's, etc. may be included, and are copied to the output files.
|
||||||
|
|
||||||
|
0 UNIMPL SVR4 unused
|
||||||
|
1 NOPROTO POSIX { int exit(int rval); }
|
||||||
|
2 NOPROTO POSIX { int fork(void); }
|
||||||
|
3 NOPROTO POSIX { int read(int fd, char *buf, u_int nbyte); }
|
||||||
|
4 NOPROTO SVR4 { int write(int fd, char *buf, u_int nbyte); }
|
||||||
|
5 STD SVR4 { int svr4_sys_open(char *path, int flags, int mode); }
|
||||||
|
6 NOPROTO SVR4 { int close(int fd); }
|
||||||
|
7 STD SVR4 { int svr4_sys_wait(int *status); }
|
||||||
|
8 STD SVR4 { int svr4_sys_creat(char *path, int mode); }
|
||||||
|
9 NOPROTO SVR4 { int link(char *path, char *link); }
|
||||||
|
10 NOPROTO SVR4 { int unlink(char *path); }
|
||||||
|
11 STD SVR4 { int svr4_sys_execv(char *path, char **argp); }
|
||||||
|
12 NOPROTO SVR4 { int chdir(char *path); }
|
||||||
|
13 STD SVR4 { int svr4_sys_time(time_t *t); }
|
||||||
|
14 STD SVR4 { int svr4_sys_mknod(char* path, int mode, int dev); }
|
||||||
|
15 NOPROTO SVR4 { int chmod(char *path, int mode); }
|
||||||
|
16 NOPROTO SVR4 { int chown(char *path, uid_t uid, gid_t gid); }
|
||||||
|
17 STD SVR4 { int svr4_sys_break(caddr_t nsize); }
|
||||||
|
18 STD SVR4 { int svr4_sys_stat(char* path, \
|
||||||
|
struct svr4_stat* ub); }
|
||||||
|
19 NOPROTO SVR4 { int lseek(int filedes, off_t *offset, int whence); }
|
||||||
|
20 NOPROTO SVR4 { pid_t getpid(void); }
|
||||||
|
21 UNIMPL SVR4 old_mount
|
||||||
|
22 UNIMPL SVR4 sysv_umount
|
||||||
|
23 NOPROTO SVR4 { int setuid(uid_t uid); }
|
||||||
|
24 NOPROTO SVR4 { uid_t getuid(void); }
|
||||||
|
25 UNIMPL SVR4 stime
|
||||||
|
26 UNIMPL SVR4 ptrace
|
||||||
|
27 STD SVR4 { int svr4_sys_alarm(unsigned sec); }
|
||||||
|
28 STD SVR4 { int svr4_sys_fstat(int fd, struct svr4_stat *sb); }
|
||||||
|
29 STD SVR4 { int svr4_sys_pause(void); }
|
||||||
|
30 STD SVR4 { int svr4_sys_utime(char *path, \
|
||||||
|
struct svr4_utimbuf *ubuf); }
|
||||||
|
31 UNIMPL SVR4 stty
|
||||||
|
32 UNIMPL SVR4 gtty
|
||||||
|
33 STD SVR4 { int svr4_sys_access(char *path, int flags); }
|
||||||
|
34 STD SVR4 { int svr4_sys_nice(int prio); }
|
||||||
|
35 UNIMPL SVR4 statfs
|
||||||
|
36 NOPROTO SVR4 { int sync(void); }
|
||||||
|
37 STD SVR4 { int svr4_sys_kill(int pid, int signum); }
|
||||||
|
38 UNIMPL SVR4 fstatfs
|
||||||
|
39 STD SVR4 { int svr4_sys_pgrpsys(int cmd, int pid, int pgid); }
|
||||||
|
40 UNIMPL SVR4 xenix
|
||||||
|
41 NOPROTO SVR4 { int dup(u_int fd); }
|
||||||
|
42 NOPROTO SVR4 { int pipe(void); }
|
||||||
|
43 STD SVR4 { int svr4_sys_times(struct tms *tp); }
|
||||||
|
44 UNIMPL SVR4 profil
|
||||||
|
45 UNIMPL SVR4 plock
|
||||||
|
46 NOPROTO SVR4 { int setgid(gid_t gid); }
|
||||||
|
47 NOPROTO SVR4 { gid_t getgid(void); }
|
||||||
|
48 STD SVR4 { int svr4_sys_signal(int signum, \
|
||||||
|
svr4_sig_t handler); }
|
||||||
|
#if defined(NOTYET)
|
||||||
|
49 STD SVR4 { int svr4_sys_msgsys(int what, int a2, int a3, \
|
||||||
|
int a4, int a5); }
|
||||||
|
#else
|
||||||
|
49 UNIMPL SVR4 msgsys
|
||||||
|
#endif
|
||||||
|
50 STD SVR4 { int svr4_sys_sysarch(int op, void *a1); }
|
||||||
|
51 UNIMPL SVR4 acct
|
||||||
|
52 UNIMPL SVR4 shmsys
|
||||||
|
53 UNIMPL SVR4 semsys
|
||||||
|
54 STD SVR4 { int svr4_sys_ioctl(int fd, u_long com, \
|
||||||
|
caddr_t data); }
|
||||||
|
55 UNIMPL SVR4 uadmin
|
||||||
|
56 UNIMPL SVR4 exch
|
||||||
|
57 STD SVR4 { int svr4_sys_utssys(void *a1, void *a2, int sel, \
|
||||||
|
void *a3); }
|
||||||
|
58 NOPROTO SVR4 { int fsync(int fd); }
|
||||||
|
59 STD SVR4 { int svr4_sys_execve(char *path, char **argp, \
|
||||||
|
char **envp); }
|
||||||
|
60 NOPROTO SVR4 { int umask(int newmask); }
|
||||||
|
61 NOPROTO SVR4 { int chroot(char *path); }
|
||||||
|
62 STD SVR4 { int svr4_sys_fcntl(int fd, int cmd, char *arg); }
|
||||||
|
63 STD SVR4 { int svr4_sys_ulimit(int cmd, long newlimit); }
|
||||||
|
64 UNIMPL SVR4 reserved
|
||||||
|
65 UNIMPL SVR4 reserved
|
||||||
|
66 UNIMPL SVR4 reserved
|
||||||
|
67 UNIMPL SVR4 reserved
|
||||||
|
68 UNIMPL SVR4 reserved
|
||||||
|
69 UNIMPL SVR4 reserved
|
||||||
|
70 UNIMPL SVR4 advfs
|
||||||
|
71 UNIMPL SVR4 unadvfs
|
||||||
|
72 UNIMPL SVR4 rmount
|
||||||
|
73 UNIMPL SVR4 rumount
|
||||||
|
74 UNIMPL SVR4 rfstart
|
||||||
|
75 UNIMPL SVR4 sigret
|
||||||
|
76 UNIMPL SVR4 rdebug
|
||||||
|
77 UNIMPL SVR4 rfstop
|
||||||
|
78 UNIMPL SVR4 rfsys
|
||||||
|
79 NOPROTO SVR4 { int rmdir(char *path); }
|
||||||
|
80 NOPROTO SVR4 { int mkdir(char *path, int mode); }
|
||||||
|
81 STD SVR4 { int svr4_sys_getdents(int fd, char *buf, \
|
||||||
|
int nbytes); }
|
||||||
|
82 UNIMPL SVR4 libattach
|
||||||
|
83 UNIMPL SVR4 libdetach
|
||||||
|
84 UNIMPL SVR4 sysfs
|
||||||
|
85 STD SVR4 { int svr4_sys_getmsg(int fd, struct svr4_strbuf *ctl, \
|
||||||
|
struct svr4_strbuf *dat, int *flags); }
|
||||||
|
86 STD SVR4 { int svr4_sys_putmsg(int fd, struct svr4_strbuf *ctl, \
|
||||||
|
struct svr4_strbuf *dat, int flags); }
|
||||||
|
87 STD SVR4 { int svr4_sys_poll(struct pollfd *fds, unsigned int nfds, \
|
||||||
|
int timeout); }
|
||||||
|
88 STD SVR4 { int svr4_sys_lstat(char *path, \
|
||||||
|
struct svr4_stat *ub); }
|
||||||
|
89 NOPROTO SVR4 { int symlink(char *path, char *link); }
|
||||||
|
90 NOPROTO SVR4 { int readlink(char *path, char *buf, int count); }
|
||||||
|
91 NOPROTO SVR4 { int getgroups(u_int gidsetsize, gid_t *gidset); }
|
||||||
|
92 NOPROTO SVR4 { int setgroups(u_int gidsetsize, gid_t *gidset); }
|
||||||
|
93 NOPROTO SVR4 { int fchmod(int fd, int mode); }
|
||||||
|
94 NOPROTO SVR4 { int fchown(int fd, int uid, int gid); }
|
||||||
|
95 STD SVR4 { int svr4_sys_sigprocmask(int how, \
|
||||||
|
svr4_sigset_t *set, svr4_sigset_t *oset); }
|
||||||
|
96 STD SVR4 { int svr4_sys_sigsuspend(svr4_sigset_t *ss); }
|
||||||
|
97 STD SVR4 { int svr4_sys_sigaltstack( \
|
||||||
|
struct svr4_sigaltstack *nss, \
|
||||||
|
struct svr4_sigaltstack *oss); }
|
||||||
|
98 STD SVR4 { int svr4_sys_sigaction(int signum, \
|
||||||
|
struct svr4_sigaction *nsa, \
|
||||||
|
struct svr4_sigaction *osa); }
|
||||||
|
99 STD SVR4 { int svr4_sys_sigpending(int what, \
|
||||||
|
svr4_sigset_t *mask); }
|
||||||
|
100 STD SVR4 { int svr4_sys_context(int func, \
|
||||||
|
struct svr4_ucontext *uc); }
|
||||||
|
101 UNIMPL SVR4 evsys
|
||||||
|
102 UNIMPL SVR4 evtrapret
|
||||||
|
103 STD SVR4 { int svr4_sys_statvfs(char *path, \
|
||||||
|
struct svr4_statvfs *fs); }
|
||||||
|
104 STD SVR4 { int svr4_sys_fstatvfs(int fd, \
|
||||||
|
struct svr4_statvfs *fs); }
|
||||||
|
105 UNIMPL SVR4 whoknows
|
||||||
|
106 UNIMPL SVR4 nfssvc
|
||||||
|
107 STD SVR4 { int svr4_sys_waitsys(int grp, int id, \
|
||||||
|
union svr4_siginfo *info, int options); }
|
||||||
|
108 UNIMPL SVR4 sigsendsys
|
||||||
|
109 STD SVR4 { int svr4_sys_hrtsys(int cmd, int fun, int sub, \
|
||||||
|
void *rv1, void *rv2); }
|
||||||
|
110 UNIMPL SVR4 acancel
|
||||||
|
111 UNIMPL SVR4 async
|
||||||
|
112 UNIMPL SVR4 priocntlsys
|
||||||
|
113 STD SVR4 { int svr4_sys_pathconf(char *path, int name); }
|
||||||
|
114 UNIMPL SVR4 mincore
|
||||||
|
115 STD SVR4 { caddr_t svr4_sys_mmap( caddr_t addr, svr4_size_t len, \
|
||||||
|
int prot, int flags, int fd, svr4_off_t pos); }
|
||||||
|
116 NOPROTO SVR4 { int mprotect(void *addr, int len, int prot); }
|
||||||
|
117 NOPROTO SVR4 { int munmap(void *addr, int len); }
|
||||||
|
118 STD SVR4 { int svr4_sys_fpathconf(int fd, int name); }
|
||||||
|
119 NOPROTO SVR4 { int vfork(void); }
|
||||||
|
120 NOPROTO SVR4 { int fchdir(int fd); }
|
||||||
|
121 NOPROTO SVR4 { int readv(int fd, struct iovec *iovp, \
|
||||||
|
u_int iovcnt); }
|
||||||
|
122 NOPROTO SVR4 { int writev(int fd, struct iovec *iovp, \
|
||||||
|
u_int iovcnt); }
|
||||||
|
123 STD SVR4 { int svr4_sys_xstat(int two, char *path, \
|
||||||
|
struct svr4_xstat *ub); }
|
||||||
|
124 STD SVR4 { int svr4_sys_lxstat(int two, char *path, \
|
||||||
|
struct svr4_xstat *ub); }
|
||||||
|
125 STD SVR4 { int svr4_sys_fxstat(int two, int fd, \
|
||||||
|
struct svr4_xstat *sb); }
|
||||||
|
126 STD SVR4 { int svr4_sys_xmknod(int two, char *path, \
|
||||||
|
svr4_mode_t mode, svr4_dev_t dev); }
|
||||||
|
127 UNIMPL SVR4 clocal
|
||||||
|
128 STD SVR4 { int svr4_sys_setrlimit(int which, \
|
||||||
|
const struct svr4_rlimit *rlp); }
|
||||||
|
129 STD SVR4 { int svr4_sys_getrlimit(int which, \
|
||||||
|
struct svr4_rlimit *rlp); }
|
||||||
|
130 NOPROTO SVR4 { int lchown(char *path, uid_t uid, gid_t gid); }
|
||||||
|
131 STD SVR4 { int svr4_sys_memcntl(void * addr, \
|
||||||
|
svr4_size_t len, int cmd, void * arg, \
|
||||||
|
int attr, int mask); }
|
||||||
|
132 UNIMPL SVR4 getpmsg
|
||||||
|
133 UNIMPL SVR4 putpmsg
|
||||||
|
134 NOPROTO SVR4 { int rename(char *from, char *to); }
|
||||||
|
135 STD SVR4 { int svr4_sys_uname(struct svr4_utsname* name, \
|
||||||
|
int dummy); }
|
||||||
|
136 NOPROTO SVR4 { int setegid(gid_t egid); }
|
||||||
|
137 STD SVR4 { int svr4_sys_sysconfig(int name); }
|
||||||
|
138 NOPROTO SVR4 { int adjtime(struct timeval *delta, \
|
||||||
|
struct timeval *olddelta); }
|
||||||
|
139 STD SVR4 { long svr4_sys_systeminfo(int what, char *buf, \
|
||||||
|
long len); }
|
||||||
|
140 UNIMPL SVR4 notused
|
||||||
|
141 NOPROTO SVR4 { int seteuid(uid_t euid); }
|
||||||
|
142 UNIMPL SVR4 vtrace
|
||||||
|
; fork1
|
||||||
|
143 UNIMPL SVR4 { int fork(void); }
|
||||||
|
144 UNIMPL SVR4 sigtimedwait
|
||||||
|
145 UNIMPL SVR4 lwp_info
|
||||||
|
146 UNIMPL SVR4 yield
|
||||||
|
147 UNIMPL SVR4 lwp_sema_wait
|
||||||
|
148 UNIMPL SVR4 lwp_sema_post
|
||||||
|
149 UNIMPL SVR4 lwp_sema_trywait
|
||||||
|
150 UNIMPL SVR4 notused
|
||||||
|
151 UNIMPL SVR4 notused
|
||||||
|
152 UNIMPL SVR4 modctl
|
||||||
|
153 STD SVR4 { int svr4_sys_fchroot(int fd); }
|
||||||
|
154 STD SVR4 { int svr4_sys_utimes(char *path, \
|
||||||
|
struct timeval *tptr); }
|
||||||
|
155 STD SVR4 { int svr4_sys_vhangup(void); }
|
||||||
|
156 STD SVR4 { int svr4_sys_gettimeofday(struct timeval *tp); }
|
||||||
|
157 NOPROTO SVR4 { int getitimer(u_int which, struct itimerval *itv); }
|
||||||
|
158 NOPROTO SVR4 { int setitimer(u_int which, struct itimerval *itv, \
|
||||||
|
struct itimerval *oitv); }
|
||||||
|
159 UNIMPL SVR4 lwp_create
|
||||||
|
160 UNIMPL SVR4 lwp_exit
|
||||||
|
161 UNIMPL SVR4 lwp_suspend
|
||||||
|
162 UNIMPL SVR4 lwp_continue
|
||||||
|
163 UNIMPL SVR4 lwp_kill
|
||||||
|
164 UNIMPL SVR4 lwp_self
|
||||||
|
165 UNIMPL SVR4 lwp_getprivate
|
||||||
|
166 UNIMPL SVR4 lwp_setprivate
|
||||||
|
167 UNIMPL SVR4 lwp_wait
|
||||||
|
168 UNIMPL SVR4 lwp_mutex_unlock
|
||||||
|
169 UNIMPL SVR4 lwp_mutex_lock
|
||||||
|
170 UNIMPL SVR4 lwp_cond_wait
|
||||||
|
171 UNIMPL SVR4 lwp_cond_signal
|
||||||
|
172 UNIMPL SVR4 lwp_cond_broadcast
|
||||||
|
173 UNIMPL SVR4 { ssize_t svr4_sys_pread(int fd, void *buf, \
|
||||||
|
size_t nbyte, svr4_off_t off); }
|
||||||
|
174 UNIMPL SVR4 { ssize_t svr4_sys_pwrite(int fd, const void *buf, \
|
||||||
|
size_t nbyte, svr4_off_t off); }
|
||||||
|
175 STD SVR4 { svr4_off64_t svr4_sys_llseek(int fd, long offset1, \
|
||||||
|
long offset2, int whence); }
|
||||||
|
176 UNIMPL SVR4 inst_sync
|
||||||
|
177 UNIMPL SVR4 whoknows
|
||||||
|
178 UNIMPL SVR4 kaio
|
||||||
|
179 UNIMPL SVR4 whoknows
|
||||||
|
180 UNIMPL SVR4 whoknows
|
||||||
|
181 UNIMPL SVR4 whoknows
|
||||||
|
182 UNIMPL SVR4 whoknows
|
||||||
|
183 UNIMPL SVR4 whoknows
|
||||||
|
184 UNIMPL SVR4 tsolsys
|
||||||
|
185 STD SVR4 { int svr4_sys_acl(char *path, int cmd, int num, \
|
||||||
|
struct svr4_aclent *buf); }
|
||||||
|
186 STD SVR4 { int svr4_sys_auditsys(int code, int a1, int a2, \
|
||||||
|
int a3, int a4, int a5); }
|
||||||
|
187 UNIMPL SVR4 processor_bind
|
||||||
|
188 UNIMPL SVR4 processor_info
|
||||||
|
189 UNIMPL SVR4 p_online
|
||||||
|
190 UNIMPL SVR4 sigqueue
|
||||||
|
191 UNIMPL SVR4 clock_gettime
|
||||||
|
192 UNIMPL SVR4 clock_settime
|
||||||
|
193 UNIMPL SVR4 clock_getres
|
||||||
|
194 UNIMPL SVR4 timer_create
|
||||||
|
195 UNIMPL SVR4 timer_delete
|
||||||
|
196 UNIMPL SVR4 timer_settime
|
||||||
|
197 UNIMPL SVR4 timer_gettime
|
||||||
|
198 UNIMPL SVR4 timer_overrun
|
||||||
|
199 NOPROTO SVR4 { int nanosleep(const struct timespec *rqtp, \
|
||||||
|
struct timespec *rmtp); }
|
||||||
|
200 STD SVR4 { int svr4_sys_facl(int fd, int cmd, int num, \
|
||||||
|
struct svr4_aclent *buf); }
|
||||||
|
201 UNIMPL SVR4 door
|
||||||
|
202 NOPROTO SVR4 { int setreuid(int ruid, int euid); }
|
||||||
|
203 NOPROTO SVR4 { int setregid(int rgid, int egid); }
|
||||||
|
204 UNIMPL SVR4 install_utrap
|
||||||
|
205 UNIMPL SVR4 signotify
|
||||||
|
206 UNIMPL SVR4 schedctl
|
||||||
|
207 UNIMPL SVR4 pset
|
||||||
|
208 UNIMPL SVR4 whoknows
|
||||||
|
209 STD SVR4 { int svr4_sys_resolvepath(const char *path, \
|
||||||
|
char *buf, size_t bufsiz); }
|
||||||
|
210 UNIMPL SVR4 signotifywait
|
||||||
|
211 UNIMPL SVR4 lwp_sigredirect
|
||||||
|
212 UNIMPL SVR4 lwp_alarm
|
||||||
|
213 STD SVR4 { int svr4_sys_getdents64(int fd, \
|
||||||
|
struct svr4_dirent64 *dp, \
|
||||||
|
int nbytes); }
|
||||||
|
;213 UNIMPL SVR4 getdents64
|
||||||
|
214 STD SVR4 { caddr_t svr4_sys_mmap64(void *addr, \
|
||||||
|
svr4_size_t len, int prot, int flags, int fd, \
|
||||||
|
svr4_off64_t pos); }
|
||||||
|
215 STD SVR4 { int svr4_sys_stat64(char *path, \
|
||||||
|
struct svr4_stat64 *sb); }
|
||||||
|
216 STD SVR4 { int svr4_sys_lstat64(char *path, \
|
||||||
|
struct svr4_stat64 *sb); }
|
||||||
|
217 STD SVR4 { int svr4_sys_fstat64(int fd, \
|
||||||
|
struct svr4_stat64 *sb); }
|
||||||
|
218 STD SVR4 { int svr4_sys_statvfs64(char *path, \
|
||||||
|
struct svr4_statvfs64 *fs); }
|
||||||
|
219 STD SVR4 { int svr4_sys_fstatvfs64(int fd, \
|
||||||
|
struct svr4_statvfs64 *fs); }
|
||||||
|
220 STD SVR4 { int svr4_sys_setrlimit64(int which, \
|
||||||
|
const struct svr4_rlimit64 *rlp); }
|
||||||
|
221 STD SVR4 { int svr4_sys_getrlimit64(int which, \
|
||||||
|
struct svr4_rlimit64 *rlp); }
|
||||||
|
222 UNIMPL SVR4 pread64
|
||||||
|
223 UNIMPL SVR4 pwrite64
|
||||||
|
224 STD SVR4 { int svr4_sys_creat64(char *path, int mode); }
|
||||||
|
225 STD SVR4 { int svr4_sys_open64(char *path, int flags, \
|
||||||
|
int mode); }
|
||||||
|
226 UNIMPL SVR4 rpcsys
|
||||||
|
227 UNIMPL SVR4 whoknows
|
||||||
|
228 UNIMPL SVR4 whoknows
|
||||||
|
229 UNIMPL SVR4 whoknows
|
||||||
|
230 STD SVR4 { int svr4_sys_socket(int domain, int type, \
|
||||||
|
int protocol); }
|
||||||
|
231 NOPROTO SVR4 { int socketpair(int domain, int type, \
|
||||||
|
int protocol, int *rsv); }
|
||||||
|
232 NOPROTO SVR4 { int bind(int s, const struct sockaddr *name, \
|
||||||
|
int namelen); }
|
||||||
|
233 NOPROTO SVR4 { int listen(int s, int backlog); }
|
||||||
|
234 NOPROTO SVR4 { int accept(int s, struct sockaddr *name, \
|
||||||
|
int *anamelen); }
|
||||||
|
235 NOPROTO SVR4 { int connect(int s, const struct sockaddr *name, \
|
||||||
|
int namelen); }
|
||||||
|
236 NOPROTO SVR4 { int shutdown(int s, int how); }
|
||||||
|
237 STD SVR4 { int svr4_sys_recv(int s, caddr_t buf, int len, int flags); }
|
||||||
|
238 NOPROTO SVR4 { ssize_t recvfrom(int s, void *buf, size_t len, \
|
||||||
|
int flags, struct sockaddr *from, \
|
||||||
|
int *fromlenaddr); }
|
||||||
|
239 NOPROTO SVR4 { ssize_t recvmsg(int s, struct msghdr *msg, \
|
||||||
|
int flags); }
|
||||||
|
240 STD SVR4 { int svr4_sys_send(int s, caddr_t buf, int len, int flags); }
|
||||||
|
241 NOPROTO SVR4 { ssize_t sendmsg(int s, const struct msghdr *msg, \
|
||||||
|
int flags); }
|
||||||
|
242 STD SVR4 { ssize_t svr4_sys_sendto(int s, const void *buf, \
|
||||||
|
size_t len, int flags, \
|
||||||
|
const struct sockaddr *to, int tolen); }
|
||||||
|
243 NOPROTO SVR4 { int getpeername(int fdes, struct sockaddr *asa, \
|
||||||
|
int *alen); }
|
||||||
|
244 NOPROTO SVR4 { int getsockname(int fdes, struct sockaddr *asa, \
|
||||||
|
int *alen); }
|
||||||
|
245 NOPROTO SVR4 { int getsockopt(int s, int level, int name, \
|
||||||
|
void *val, int *avalsize); }
|
||||||
|
246 NOPROTO SVR4 { int setsockopt(int s, int level, int name, \
|
||||||
|
const void *val, int valsize); }
|
||||||
|
247 UNIMPL SVR4 sockconfig
|
||||||
|
248 UNIMPL SVR4 { int ntp_gettime(struct ntptimeval *ntvp); }
|
||||||
|
249 UNIMPL SVR4 { int ntp_adjtime(struct timex *tp); }
|
36
sys/i386/svr4/svr4_genassym.c
Normal file
36
sys/i386/svr4/svr4_genassym.c
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Derived from: Id: linux_genassym.c,v 1.8 1998/07/29 15:50:41 bde Exp */
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
struct proc;
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_ucontext.h>
|
||||||
|
|
||||||
|
/* XXX: This bit sucks rocks, but gets rid of compiler errors. Maybe I should
|
||||||
|
* fix the include files instead... */
|
||||||
|
#define SVR4_MACHDEP_JUST_REGS
|
||||||
|
#include <i386/svr4/svr4_machdep.h>
|
||||||
|
|
||||||
|
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
||||||
|
#define OS(s, m) ((u_int)offsetof(struct s, m))
|
||||||
|
|
||||||
|
int main __P((void));
|
||||||
|
int printf __P((const char *, ...));
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
printf("#define\tSVR4_SIGF_HANDLER %u\n",
|
||||||
|
OS(svr4_sigframe, sf_handler));
|
||||||
|
printf("#define\tSVR4_SIGF_UC %u\n", OS(svr4_sigframe, sf_uc));
|
||||||
|
printf("#define\tSVR4_UC_FS %u\n",
|
||||||
|
OS(svr4_ucontext, uc_mcontext.greg[SVR4_X86_FS]));
|
||||||
|
printf("#define\tSVR4_UC_GS %u\n",
|
||||||
|
OS(svr4_ucontext, uc_mcontext.greg[SVR4_X86_GS]));
|
||||||
|
printf("#define\tSVR4_UC_EFLAGS %u\n",
|
||||||
|
OS(svr4_ucontext, uc_mcontext.greg[SVR4_X86_EFL]));
|
||||||
|
return (0);
|
||||||
|
}
|
46
sys/i386/svr4/svr4_locore.s
Normal file
46
sys/i386/svr4/svr4_locore.s
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#include "svr4_assym.h" /* system definitions */
|
||||||
|
#include <machine/asmacros.h> /* miscellaneous asm macros */
|
||||||
|
|
||||||
|
#include <svr4/svr4_syscall.h> /* system call numbers */
|
||||||
|
|
||||||
|
NON_GPROF_ENTRY(svr4_sigcode)
|
||||||
|
call SVR4_SIGF_HANDLER(%esp)
|
||||||
|
leal SVR4_SIGF_UC(%esp),%eax # ucp (the call may have clobbered the
|
||||||
|
# copy at SIGF_UCP(%esp))
|
||||||
|
#if defined(NOTYET)
|
||||||
|
#ifdef VM86
|
||||||
|
testl $PSL_VM,SVR4_UC_EFLAGS(%eax)
|
||||||
|
jnz 1f
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
movl SVR4_UC_FS(%eax),%ecx
|
||||||
|
movl SVR4_UC_GS(%eax),%edx
|
||||||
|
movl %cx,%fs
|
||||||
|
movl %dx,%gs
|
||||||
|
#if defined(__NetBSD__)
|
||||||
|
1: pushl %eax
|
||||||
|
pushl $1 # setcontext(p) == syscontext(1, p)
|
||||||
|
pushl %eax # junk to fake return address
|
||||||
|
movl $_svr4_sys_context,%eax
|
||||||
|
#else
|
||||||
|
/* must be FreeBSD, right? */
|
||||||
|
1: pushl %eax # fake return address
|
||||||
|
pushl $1 # pointer to ucontext
|
||||||
|
movl $svr4_sys_context,%eax
|
||||||
|
#endif
|
||||||
|
int $0x80 # enter kernel with args on stack
|
||||||
|
movl $exit,%eax
|
||||||
|
int $0x80 # exit if sigreturn fails
|
||||||
|
|
||||||
|
/* .globl _svr4_esigcode*/
|
||||||
|
|
||||||
|
.align 2 /* long word align */
|
||||||
|
svr4_esigcode:
|
||||||
|
|
||||||
|
.data
|
||||||
|
.globl svr4_szsigcode
|
||||||
|
svr4_szsigcode:
|
||||||
|
.long svr4_esigcode - svr4_sigcode
|
||||||
|
|
||||||
|
.text
|
||||||
|
|
526
sys/i386/svr4/svr4_machdep.c
Normal file
526
sys/i386/svr4/svr4_machdep.c
Normal file
|
@ -0,0 +1,526 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/namei.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/exec.h>
|
||||||
|
#include <sys/lock.h>
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <vm/vm_kern.h>
|
||||||
|
#include <vm/vm_param.h>
|
||||||
|
#include <vm/pmap.h>
|
||||||
|
#include <vm/vm_map.h>
|
||||||
|
#include <vm/vm_prot.h>
|
||||||
|
#include <vm/vm_extern.h>
|
||||||
|
#include <sys/user.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/elf32.h>
|
||||||
|
|
||||||
|
#include <machine/cpu.h>
|
||||||
|
#include <machine/cpufunc.h>
|
||||||
|
#include <machine/psl.h>
|
||||||
|
#include <machine/reg.h>
|
||||||
|
#include <machine/specialreg.h>
|
||||||
|
#include <machine/sysarch.h>
|
||||||
|
#include <machine/vm86.h>
|
||||||
|
#include <machine/vmparam.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <i386/svr4/svr4_machdep.h>
|
||||||
|
#include <svr4/svr4_ucontext.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_exec.h>
|
||||||
|
|
||||||
|
#undef sigcode
|
||||||
|
#undef szsigcode
|
||||||
|
|
||||||
|
extern int svr4_szsigcode;
|
||||||
|
extern char svr4_sigcode[];
|
||||||
|
extern int _udatasel, _ucodesel;
|
||||||
|
|
||||||
|
static void svr4_getsiginfo __P((union svr4_siginfo *, int, u_long, caddr_t));
|
||||||
|
extern int bsd_to_svr4_sig[];
|
||||||
|
|
||||||
|
#if !defined(__NetBSD__)
|
||||||
|
/* taken from /sys/arch/i386/include/psl.h on NetBSD-1.3 */
|
||||||
|
# define PSL_MBZ 0xffc08028
|
||||||
|
# define PSL_USERSTATIC (PSL_USER | PSL_MBZ | PSL_IOPL | PSL_NT | PSL_VM | PSL_VIF | PSL_VIP)
|
||||||
|
# define USERMODE(c, f) (ISPL(c) == SEL_UPL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__NetBSD__)
|
||||||
|
void
|
||||||
|
svr4_setregs(p, epp, stack)
|
||||||
|
struct proc *p;
|
||||||
|
struct exec_package *epp;
|
||||||
|
u_long stack;
|
||||||
|
{
|
||||||
|
register struct pcb *pcb = &p->p_addr->u_pcb;
|
||||||
|
|
||||||
|
pcb->pcb_savefpu.sv_env.en_cw = __SVR4_NPXCW__;
|
||||||
|
setregs(p, epp, stack);
|
||||||
|
}
|
||||||
|
#endif /* __NetBSD__ */
|
||||||
|
|
||||||
|
void
|
||||||
|
svr4_getcontext(p, uc, mask, oonstack)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_ucontext *uc;
|
||||||
|
int mask, oonstack;
|
||||||
|
{
|
||||||
|
struct trapframe *tf = p->p_md.md_regs;
|
||||||
|
struct sigacts *psp = p->p_sigacts;
|
||||||
|
svr4_greg_t *r = uc->uc_mcontext.greg;
|
||||||
|
struct svr4_sigaltstack *s = &uc->uc_stack;
|
||||||
|
struct sigaltstack *sf = &psp->ps_sigstk;
|
||||||
|
|
||||||
|
memset(uc, 0, sizeof(struct svr4_ucontext));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the general purpose registers
|
||||||
|
*/
|
||||||
|
#ifdef VM86
|
||||||
|
if (tf->tf_eflags & PSL_VM) {
|
||||||
|
r[SVR4_X86_GS] = tf->tf_vm86_gs;
|
||||||
|
r[SVR4_X86_FS] = tf->tf_vm86_fs;
|
||||||
|
r[SVR4_X86_ES] = tf->tf_vm86_es;
|
||||||
|
r[SVR4_X86_DS] = tf->tf_vm86_ds;
|
||||||
|
r[SVR4_X86_EFL] = get_vflags(p);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
__asm("movl %%gs,%w0" : "=r" (r[SVR4_X86_GS]));
|
||||||
|
__asm("movl %%fs,%w0" : "=r" (r[SVR4_X86_FS]));
|
||||||
|
r[SVR4_X86_ES] = tf->tf_es;
|
||||||
|
r[SVR4_X86_DS] = tf->tf_ds;
|
||||||
|
r[SVR4_X86_EFL] = tf->tf_eflags;
|
||||||
|
}
|
||||||
|
r[SVR4_X86_EDI] = tf->tf_edi;
|
||||||
|
r[SVR4_X86_ESI] = tf->tf_esi;
|
||||||
|
r[SVR4_X86_EBP] = tf->tf_ebp;
|
||||||
|
r[SVR4_X86_ESP] = tf->tf_esp;
|
||||||
|
r[SVR4_X86_EBX] = tf->tf_ebx;
|
||||||
|
r[SVR4_X86_EDX] = tf->tf_edx;
|
||||||
|
r[SVR4_X86_ECX] = tf->tf_ecx;
|
||||||
|
r[SVR4_X86_EAX] = tf->tf_eax;
|
||||||
|
r[SVR4_X86_TRAPNO] = 0;
|
||||||
|
r[SVR4_X86_ERR] = 0;
|
||||||
|
r[SVR4_X86_EIP] = tf->tf_eip;
|
||||||
|
r[SVR4_X86_CS] = tf->tf_cs;
|
||||||
|
r[SVR4_X86_UESP] = 0;
|
||||||
|
r[SVR4_X86_SS] = tf->tf_ss;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the signal stack
|
||||||
|
*/
|
||||||
|
bsd_to_svr4_sigaltstack(sf, s);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the signal mask
|
||||||
|
*/
|
||||||
|
bsd_to_svr4_sigset(&mask, &uc->uc_sigmask);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the flags
|
||||||
|
*/
|
||||||
|
uc->uc_flags = SVR4_UC_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set to ucontext specified.
|
||||||
|
* has been taken. Reset signal mask and
|
||||||
|
* stack state from context.
|
||||||
|
* Return to previous pc and psl as specified by
|
||||||
|
* context left by sendsig. Check carefully to
|
||||||
|
* make sure that the user has not modified the
|
||||||
|
* psl to gain improper privileges or to cause
|
||||||
|
* a machine fault.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
svr4_setcontext(p, uc)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_ucontext *uc;
|
||||||
|
{
|
||||||
|
struct sigacts *psp = p->p_sigacts;
|
||||||
|
register struct trapframe *tf;
|
||||||
|
svr4_greg_t *r = uc->uc_mcontext.greg;
|
||||||
|
struct svr4_sigaltstack *s = &uc->uc_stack;
|
||||||
|
struct sigaltstack *sf = &psp->ps_sigstk;
|
||||||
|
int mask;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX:
|
||||||
|
* Should we check the value of flags to determine what to restore?
|
||||||
|
* What to do with uc_link?
|
||||||
|
* What to do with floating point stuff?
|
||||||
|
* Should we bother with the rest of the registers that we
|
||||||
|
* set to 0 right now?
|
||||||
|
*/
|
||||||
|
|
||||||
|
tf = p->p_md.md_regs;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Restore register context.
|
||||||
|
*/
|
||||||
|
#ifdef VM86
|
||||||
|
if (r[SVR4_X86_EFL] & PSL_VM) {
|
||||||
|
tf->tf_vm86_gs = r[SVR4_X86_GS];
|
||||||
|
tf->tf_vm86_fs = r[SVR4_X86_FS];
|
||||||
|
tf->tf_vm86_es = r[SVR4_X86_ES];
|
||||||
|
tf->tf_vm86_ds = r[SVR4_X86_DS];
|
||||||
|
set_vflags(p, r[SVR4_X86_EFL]);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Check for security violations. If we're returning to
|
||||||
|
* protected mode, the CPU will validate the segment registers
|
||||||
|
* automatically and generate a trap on violations. We handle
|
||||||
|
* the trap, rather than doing all of the checking here.
|
||||||
|
*/
|
||||||
|
if (((r[SVR4_X86_EFL] ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
|
||||||
|
!USERMODE(r[SVR4_X86_CS], r[SVR4_X86_EFL]))
|
||||||
|
return (EINVAL);
|
||||||
|
|
||||||
|
/* %fs and %gs were restored by the trampoline. */
|
||||||
|
tf->tf_es = r[SVR4_X86_ES];
|
||||||
|
tf->tf_ds = r[SVR4_X86_DS];
|
||||||
|
tf->tf_eflags = r[SVR4_X86_EFL];
|
||||||
|
}
|
||||||
|
tf->tf_edi = r[SVR4_X86_EDI];
|
||||||
|
tf->tf_esi = r[SVR4_X86_ESI];
|
||||||
|
tf->tf_ebp = r[SVR4_X86_EBP];
|
||||||
|
tf->tf_ebx = r[SVR4_X86_EBX];
|
||||||
|
tf->tf_edx = r[SVR4_X86_EDX];
|
||||||
|
tf->tf_ecx = r[SVR4_X86_ECX];
|
||||||
|
tf->tf_eax = r[SVR4_X86_EAX];
|
||||||
|
tf->tf_eip = r[SVR4_X86_EIP];
|
||||||
|
tf->tf_cs = r[SVR4_X86_CS];
|
||||||
|
tf->tf_ss = r[SVR4_X86_SS];
|
||||||
|
tf->tf_esp = r[SVR4_X86_ESP];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* restore signal stack
|
||||||
|
*/
|
||||||
|
svr4_to_bsd_sigaltstack(s, sf);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* restore signal mask
|
||||||
|
*/
|
||||||
|
svr4_to_bsd_sigset(&uc->uc_sigmask, &mask);
|
||||||
|
p->p_sigmask = mask & ~sigcantmask;
|
||||||
|
|
||||||
|
return 0; /*EJUSTRETURN;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_getsiginfo(si, sig, code, addr)
|
||||||
|
union svr4_siginfo *si;
|
||||||
|
int sig;
|
||||||
|
u_long code;
|
||||||
|
caddr_t addr;
|
||||||
|
{
|
||||||
|
si->si_signo = bsd_to_svr4_sig[sig];
|
||||||
|
si->si_errno = 0;
|
||||||
|
si->si_addr = addr;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
case T_PRIVINFLT:
|
||||||
|
si->si_code = SVR4_ILL_PRVOPC;
|
||||||
|
si->si_trap = SVR4_T_PRIVINFLT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_BPTFLT:
|
||||||
|
si->si_code = SVR4_TRAP_BRKPT;
|
||||||
|
si->si_trap = SVR4_T_BPTFLT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_ARITHTRAP:
|
||||||
|
si->si_code = SVR4_FPE_INTOVF;
|
||||||
|
si->si_trap = SVR4_T_DIVIDE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_PROTFLT:
|
||||||
|
si->si_code = SVR4_SEGV_ACCERR;
|
||||||
|
si->si_trap = SVR4_T_PROTFLT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_TRCTRAP:
|
||||||
|
si->si_code = SVR4_TRAP_TRACE;
|
||||||
|
si->si_trap = SVR4_T_TRCTRAP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_PAGEFLT:
|
||||||
|
si->si_code = SVR4_SEGV_ACCERR;
|
||||||
|
si->si_trap = SVR4_T_PAGEFLT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_ALIGNFLT:
|
||||||
|
si->si_code = SVR4_BUS_ADRALN;
|
||||||
|
si->si_trap = SVR4_T_ALIGNFLT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_DIVIDE:
|
||||||
|
si->si_code = SVR4_FPE_FLTDIV;
|
||||||
|
si->si_trap = SVR4_T_DIVIDE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_OFLOW:
|
||||||
|
si->si_code = SVR4_FPE_FLTOVF;
|
||||||
|
si->si_trap = SVR4_T_DIVIDE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_BOUND:
|
||||||
|
si->si_code = SVR4_FPE_FLTSUB;
|
||||||
|
si->si_trap = SVR4_T_BOUND;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_DNA:
|
||||||
|
si->si_code = SVR4_FPE_FLTINV;
|
||||||
|
si->si_trap = SVR4_T_DNA;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_FPOPFLT:
|
||||||
|
si->si_code = SVR4_FPE_FLTINV;
|
||||||
|
si->si_trap = SVR4_T_FPOPFLT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_SEGNPFLT:
|
||||||
|
si->si_code = SVR4_SEGV_MAPERR;
|
||||||
|
si->si_trap = SVR4_T_SEGNPFLT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_STKFLT:
|
||||||
|
si->si_code = SVR4_ILL_BADSTK;
|
||||||
|
si->si_trap = SVR4_T_STKFLT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
si->si_code = 0;
|
||||||
|
si->si_trap = 0;
|
||||||
|
#ifdef DIAGNOSTIC
|
||||||
|
printf("sig %d code %ld\n", sig, code);
|
||||||
|
panic("svr4_getsiginfo");
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send an interrupt to process.
|
||||||
|
*
|
||||||
|
* Stack is set up to allow sigcode stored
|
||||||
|
* in u. to call routine. After the handler is
|
||||||
|
* done svr4 will call setcontext for us
|
||||||
|
* with the user context we just set up, and we
|
||||||
|
* will return to the user pc, psl.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
svr4_sendsig(catcher, sig, mask, code)
|
||||||
|
sig_t catcher;
|
||||||
|
int sig, mask;
|
||||||
|
u_long code;
|
||||||
|
{
|
||||||
|
register struct proc *p = curproc;
|
||||||
|
register struct trapframe *tf;
|
||||||
|
struct svr4_sigframe *fp, frame;
|
||||||
|
struct sigacts *psp = p->p_sigacts;
|
||||||
|
int oonstack;
|
||||||
|
|
||||||
|
tf = p->p_md.md_regs;
|
||||||
|
oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate space for the signal handler context.
|
||||||
|
*/
|
||||||
|
if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack &&
|
||||||
|
(psp->ps_sigonstack & sigmask(sig))) {
|
||||||
|
fp = (struct svr4_sigframe *)((caddr_t)psp->ps_sigstk.ss_sp +
|
||||||
|
psp->ps_sigstk.ss_size - sizeof(struct svr4_sigframe));
|
||||||
|
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
|
||||||
|
} else {
|
||||||
|
fp = (struct svr4_sigframe *)tf->tf_esp - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Build the argument list for the signal handler.
|
||||||
|
* Notes:
|
||||||
|
* - we always build the whole argument list, even when we
|
||||||
|
* don't need to [when SA_SIGINFO is not set, we don't need
|
||||||
|
* to pass all sf_si and sf_uc]
|
||||||
|
* - we don't pass the correct signal address [we need to
|
||||||
|
* modify many kernel files to enable that]
|
||||||
|
*/
|
||||||
|
|
||||||
|
svr4_getcontext(p, &frame.sf_uc, mask, oonstack);
|
||||||
|
DPRINTF(("obtained ucontext\n"));
|
||||||
|
svr4_getsiginfo(&frame.sf_si, sig, code, (caddr_t) tf->tf_eip);
|
||||||
|
DPRINTF(("obtained siginfo\n"));
|
||||||
|
frame.sf_signum = frame.sf_si.si_signo;
|
||||||
|
frame.sf_sip = &fp->sf_si;
|
||||||
|
frame.sf_ucp = &fp->sf_uc;
|
||||||
|
frame.sf_handler = catcher;
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
printf("sig = %d, sip %p, ucp = %p, handler = %p\n",
|
||||||
|
frame.sf_signum, frame.sf_sip, frame.sf_ucp, frame.sf_handler);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (copyout(&frame, fp, sizeof(frame)) != 0) {
|
||||||
|
/*
|
||||||
|
* Process has trashed its stack; give it an illegal
|
||||||
|
* instruction to halt it in its tracks.
|
||||||
|
*/
|
||||||
|
sigexit(p, SIGILL);
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
|
#if defined(__NetBSD__)
|
||||||
|
/*
|
||||||
|
* Build context to run handler in.
|
||||||
|
*/
|
||||||
|
tf->tf_es = GSEL(GUSERLDT_SEL, SEL_UPL);
|
||||||
|
tf->tf_ds = GSEL(GUSERLDT_SEL, SEL_UPL);
|
||||||
|
tf->tf_eip = (int)(((char *)PS_STRINGS) -
|
||||||
|
svr4_szsigcode);
|
||||||
|
tf->tf_cs = GSEL(GUSERLDT_SEL, SEL_UPL);
|
||||||
|
|
||||||
|
tf->tf_eflags &= ~(PSL_T|PSL_VM|PSL_AC);
|
||||||
|
tf->tf_esp = (int)fp;
|
||||||
|
tf->tf_ss = GSEL(GUSERLDT_SEL, SEL_UPL);
|
||||||
|
#else
|
||||||
|
tf->tf_esp = (int)fp;
|
||||||
|
tf->tf_eip = (int)(((char *)PS_STRINGS) - *(p->p_sysent->sv_szsigcode));
|
||||||
|
tf->tf_cs = _ucodesel;
|
||||||
|
tf->tf_ds = _udatasel;
|
||||||
|
tf->tf_es = _udatasel;
|
||||||
|
tf->tf_ss = _udatasel;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sysarch(p, v)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_sysarch_args *v;
|
||||||
|
{
|
||||||
|
struct svr4_sys_sysarch_args *uap = v;
|
||||||
|
#ifdef USER_LDT
|
||||||
|
caddr_t sg = stackgap_init(p->p_emul);
|
||||||
|
int error;
|
||||||
|
#endif
|
||||||
|
switch (uap->op) {
|
||||||
|
case SVR4_SYSARCH_FPHW:
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SVR4_SYSARCH_DSCR:
|
||||||
|
#ifdef USER_LDT
|
||||||
|
{
|
||||||
|
struct i386_set_ldt_args sa, *sap;
|
||||||
|
struct sys_sysarch_args ua;
|
||||||
|
|
||||||
|
struct svr4_ssd ssd;
|
||||||
|
union descriptor bsd;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, a1), &ssd,
|
||||||
|
sizeof(ssd))) != 0) {
|
||||||
|
printf("Cannot copy arg1\n");
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("s=%x, b=%x, l=%x, a1=%x a2=%x\n",
|
||||||
|
ssd.selector, ssd.base, ssd.limit,
|
||||||
|
ssd.access1, ssd.access2);
|
||||||
|
|
||||||
|
/* We can only set ldt's for now. */
|
||||||
|
if (!ISLDT(ssd.selector)) {
|
||||||
|
printf("Not an ldt\n");
|
||||||
|
return EPERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Oh, well we don't cleanup either */
|
||||||
|
if (ssd.access1 == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
bsd.sd.sd_lobase = ssd.base & 0xffffff;
|
||||||
|
bsd.sd.sd_hibase = (ssd.base >> 24) & 0xff;
|
||||||
|
|
||||||
|
bsd.sd.sd_lolimit = ssd.limit & 0xffff;
|
||||||
|
bsd.sd.sd_hilimit = (ssd.limit >> 16) & 0xf;
|
||||||
|
|
||||||
|
bsd.sd.sd_type = ssd.access1 & 0x1f;
|
||||||
|
bsd.sd.sd_dpl = (ssd.access1 >> 5) & 0x3;
|
||||||
|
bsd.sd.sd_p = (ssd.access1 >> 7) & 0x1;
|
||||||
|
|
||||||
|
bsd.sd.sd_xx = ssd.access2 & 0x3;
|
||||||
|
bsd.sd.sd_def32 = (ssd.access2 >> 2) & 0x1;
|
||||||
|
bsd.sd.sd_gran = (ssd.access2 >> 3)& 0x1;
|
||||||
|
|
||||||
|
sa.start = IDXSEL(ssd.selector);
|
||||||
|
sa.desc = stackgap_alloc(&sg, sizeof(union descriptor));
|
||||||
|
sa.num = 1;
|
||||||
|
sap = stackgap_alloc(&sg,
|
||||||
|
sizeof(struct i386_set_ldt_args));
|
||||||
|
|
||||||
|
if ((error = copyout(&sa, sap, sizeof(sa))) != 0) {
|
||||||
|
printf("Cannot copyout args\n");
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCARG(&ua, op) = I386_SET_LDT;
|
||||||
|
SCARG(&ua, parms) = (char *) sap;
|
||||||
|
|
||||||
|
if ((error = copyout(&bsd, sa.desc, sizeof(bsd))) != 0) {
|
||||||
|
printf("Cannot copyout desc\n");
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sys_sysarch(p, &ua, retval);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("svr4_sysarch(%d), a1 %p\n", uap->op,
|
||||||
|
uap->a1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
117
sys/i386/svr4/svr4_machdep.h
Normal file
117
sys/i386/svr4/svr4_machdep.h
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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 _I386_SVR4_MACHDEP_H_
|
||||||
|
#define _I386_SVR4_MACHDEP_H_
|
||||||
|
|
||||||
|
#if !defined(SVR4_MACHDEP_JUST_REGS)
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Machine dependent portions [X86]
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SVR4_X86_GS 0
|
||||||
|
#define SVR4_X86_FS 1
|
||||||
|
#define SVR4_X86_ES 2
|
||||||
|
#define SVR4_X86_DS 3
|
||||||
|
#define SVR4_X86_EDI 4
|
||||||
|
#define SVR4_X86_ESI 5
|
||||||
|
#define SVR4_X86_EBP 6
|
||||||
|
#define SVR4_X86_ESP 7
|
||||||
|
#define SVR4_X86_EBX 8
|
||||||
|
#define SVR4_X86_EDX 9
|
||||||
|
#define SVR4_X86_ECX 10
|
||||||
|
#define SVR4_X86_EAX 11
|
||||||
|
#define SVR4_X86_TRAPNO 12
|
||||||
|
#define SVR4_X86_ERR 13
|
||||||
|
#define SVR4_X86_EIP 14
|
||||||
|
#define SVR4_X86_CS 15
|
||||||
|
#define SVR4_X86_EFL 16
|
||||||
|
#define SVR4_X86_UESP 17
|
||||||
|
#define SVR4_X86_SS 18
|
||||||
|
#define SVR4_X86_MAXREG 19
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(SVR4_MACHDEP_JUST_REGS)
|
||||||
|
typedef int svr4_greg_t;
|
||||||
|
typedef svr4_greg_t svr4_gregset_t[SVR4_X86_MAXREG];
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int f_x87[62]; /* x87 registers */
|
||||||
|
long f_weitek[33]; /* weitek */
|
||||||
|
} svr4_fregset_t;
|
||||||
|
|
||||||
|
struct svr4_ucontext;
|
||||||
|
|
||||||
|
void svr4_getcontext __P((struct proc *, struct svr4_ucontext *,
|
||||||
|
int, int));
|
||||||
|
int svr4_setcontext __P((struct proc *p, struct svr4_ucontext *));
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
svr4_gregset_t greg;
|
||||||
|
svr4_fregset_t freg;
|
||||||
|
} svr4_mcontext_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SYSARCH numbers
|
||||||
|
*/
|
||||||
|
#define SVR4_SYSARCH_FPHW 40
|
||||||
|
#define SVR4_SYSARCH_DSCR 75
|
||||||
|
|
||||||
|
struct svr4_ssd {
|
||||||
|
unsigned int selector;
|
||||||
|
unsigned int base;
|
||||||
|
unsigned int limit;
|
||||||
|
unsigned int access1;
|
||||||
|
unsigned int access2;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Processor traps
|
||||||
|
*/
|
||||||
|
#define SVR4_T_DIVIDE 0
|
||||||
|
#define SVR4_T_TRCTRAP 1
|
||||||
|
#define SVR4_T_NMI 2
|
||||||
|
#define SVR4_T_BPTFLT 3
|
||||||
|
#define SVR4_T_OFLOW 4
|
||||||
|
#define SVR4_T_BOUND 5
|
||||||
|
#define SVR4_T_PRIVINFLT 6
|
||||||
|
#define SVR4_T_DNA 7
|
||||||
|
#define SVR4_T_DOUBLEFLT 8
|
||||||
|
#define SVR4_T_FPOPFLT 9
|
||||||
|
#define SVR4_T_TSSFLT 10
|
||||||
|
#define SVR4_T_SEGNPFLT 11
|
||||||
|
#define SVR4_T_STKFLT 12
|
||||||
|
#define SVR4_T_PROTFLT 13
|
||||||
|
#define SVR4_T_PAGEFLT 14
|
||||||
|
#define SVR4_T_ALIGNFLT 17
|
||||||
|
|
||||||
|
#endif /* !SVR4_MACHDEP_JUST_REGS */
|
||||||
|
#endif /* !_I386_SVR4_MACHDEP_H_ */
|
51
sys/modules/svr4/Makefile
Normal file
51
sys/modules/svr4/Makefile
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
.PATH: ${.CURDIR}/../../i386/svr4 ${.CURDIR}/../../svr4
|
||||||
|
KMOD= svr4
|
||||||
|
SRCS= svr4_sysent.c svr4_sysvec.c opt_compat.h opt_vmpage.h vnode_if.h \
|
||||||
|
imgact_svr4.c svr4_signal.c svr4_fcntl.c svr4_misc.c svr4_ioctl.c \
|
||||||
|
svr4_stat.c svr4_filio.c svr4_ttold.c svr4_termios.c svr4_stream.c \
|
||||||
|
svr4_socket.c svr4_sockio.c svr4_machdep.c svr4_resource.c \
|
||||||
|
svr4_ipc.c
|
||||||
|
OBJS= svr4_locore.o
|
||||||
|
NOMAN=1
|
||||||
|
MAN8= svr4.8
|
||||||
|
CFLAGS+= -DKERNEL
|
||||||
|
|
||||||
|
CFLAGS+= -DCOMPAT_SVR4
|
||||||
|
.if defined(DEBUG)
|
||||||
|
CFLAGS+= -DDEBUG_SVR4
|
||||||
|
.endif
|
||||||
|
|
||||||
|
EXPORT_SYMS=_svr4_mod
|
||||||
|
CLEANFILES+= vnode_if.h vnode_if.c svr4_genassym.o svr4_genassym \
|
||||||
|
svr4_assym.h opt_compat.h opt_vmpage.h .depend
|
||||||
|
|
||||||
|
build-tools: svr4_genassym
|
||||||
|
|
||||||
|
svr4_assym.h: svr4_genassym
|
||||||
|
./svr4_genassym > svr4_assym.h
|
||||||
|
|
||||||
|
svr4_locore.o: svr4_locore.s svr4_assym.h
|
||||||
|
${CC} -c -x assembler-with-cpp -DLOCORE -DKERNEL ${CFLAGS} \
|
||||||
|
${.IMPSRC} -o ${.TARGET}
|
||||||
|
|
||||||
|
svr4_genassym.o: svr4_genassym.c svr4.h @ machine
|
||||||
|
${CC} -c ${CFLAGS} -UKERNEL ${.IMPSRC}
|
||||||
|
|
||||||
|
svr4_genassym: svr4_genassym.o
|
||||||
|
${CC} ${CFLAGS} ${.ALLSRC} -o ${.TARGET}
|
||||||
|
|
||||||
|
svr4_sysvec.o: opt_vmpage.h opt_compat.h
|
||||||
|
|
||||||
|
opt_compat.h:
|
||||||
|
echo "#define COMPAT_43 1" > opt_compat.h
|
||||||
|
|
||||||
|
opt_vmpage.h:
|
||||||
|
touch opt_vmpage.h
|
||||||
|
|
||||||
|
afterinstall:
|
||||||
|
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
|
||||||
|
${.CURDIR}/svr4.sh ${DESTDIR}/usr/bin/svr4
|
||||||
|
|
||||||
|
.include <bsd.kmod.mk>
|
BIN
sys/modules/svr4/hello
Executable file
BIN
sys/modules/svr4/hello
Executable file
Binary file not shown.
12
sys/modules/svr4/svr4.sh
Normal file
12
sys/modules/svr4/svr4.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
FOUND=`kldstat -v | egrep 'svr4elf'`
|
||||||
|
|
||||||
|
if [ "x$FOUND" != x ] ; then
|
||||||
|
echo SysVR4 driver already loaded
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
kldload svr4
|
||||||
|
fi
|
13
sys/svr4/Makefile
Normal file
13
sys/svr4/Makefile
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Makefile for syscall tables
|
||||||
|
#
|
||||||
|
# $Id: Makefile,v 1.3 1997/03/29 11:17:26 peter Exp $
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo "make svr4_sysent.c only"
|
||||||
|
|
||||||
|
svr4_sysent.c svr4_syscall.h svr4_proto.h: ../kern/makesyscalls.sh \
|
||||||
|
syscalls.master syscalls.conf
|
||||||
|
-mv -f svr4_sysent.c svr4_sysent.c.bak
|
||||||
|
-mv -f svr4_syscall.h svr4_syscall.h.bak
|
||||||
|
-mv -f svr4_proto.h svr4_proto.h.bak
|
||||||
|
sh ../kern/makesyscalls.sh syscalls.master syscalls.conf
|
237
sys/svr4/imgact_svr4.c
Normal file
237
sys/svr4/imgact_svr4.c
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994-1996 Søren Schmidt
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Based heavily on /sys/kern/imgact_aout.c which is:
|
||||||
|
* Copyright (c) 1993, David Greenman
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* in this position and unchanged.
|
||||||
|
* 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. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software withough 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/resourcevar.h>
|
||||||
|
#include <sys/exec.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/imgact.h>
|
||||||
|
#include <sys/imgact_aout.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/lock.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <vm/vm_kern.h>
|
||||||
|
#include <vm/vm_param.h>
|
||||||
|
#include <vm/pmap.h>
|
||||||
|
#include <vm/vm_map.h>
|
||||||
|
#include <vm/vm_prot.h>
|
||||||
|
#include <vm/vm_extern.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
|
||||||
|
static int exec_svr4_imgact __P((struct image_params *iparams));
|
||||||
|
|
||||||
|
static int
|
||||||
|
exec_svr4_imgact(imgp)
|
||||||
|
struct image_params *imgp;
|
||||||
|
{
|
||||||
|
const struct exec *a_out = (const struct exec *) imgp->image_header;
|
||||||
|
struct vmspace *vmspace;
|
||||||
|
vm_offset_t vmaddr;
|
||||||
|
unsigned long virtual_offset, file_offset;
|
||||||
|
vm_offset_t buffer;
|
||||||
|
unsigned long bss_size;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (((a_out->a_magic >> 16) & 0xff) != 0x64)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set file/virtual offset based on a.out variant.
|
||||||
|
*/
|
||||||
|
switch ((int)(a_out->a_magic & 0xffff)) {
|
||||||
|
case 0413:
|
||||||
|
virtual_offset = 0;
|
||||||
|
file_offset = 1024;
|
||||||
|
break;
|
||||||
|
case 0314:
|
||||||
|
virtual_offset = 4096;
|
||||||
|
file_offset = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
bss_size = round_page(a_out->a_bss);
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: text: %08x, data: %08x, bss: %08x\n", a_out->a_text, a_out->a_data, bss_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check various fields in header for validity/bounds.
|
||||||
|
*/
|
||||||
|
if (a_out->a_entry < virtual_offset ||
|
||||||
|
a_out->a_entry >= virtual_offset + a_out->a_text ||
|
||||||
|
a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
/* text + data can't exceed file size */
|
||||||
|
if (a_out->a_data + a_out->a_text > imgp->attr->va_size)
|
||||||
|
return (EFAULT);
|
||||||
|
/*
|
||||||
|
* text/data/bss must not exceed limits
|
||||||
|
*/
|
||||||
|
if (a_out->a_text > MAXTSIZ ||
|
||||||
|
a_out->a_data + bss_size > imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur)
|
||||||
|
return (ENOMEM);
|
||||||
|
|
||||||
|
/* copy in arguments and/or environment from old process */
|
||||||
|
error = exec_extract_strings(imgp);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy old process VM and create a new one (with a new stack)
|
||||||
|
*/
|
||||||
|
exec_new_vmspace(imgp);
|
||||||
|
vmspace = imgp->proc->p_vmspace;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if file_offset page aligned,.
|
||||||
|
* Currently we cannot handle misalinged file offsets,
|
||||||
|
* and so we read in the entire image (what a waste).
|
||||||
|
*/
|
||||||
|
if (file_offset & PAGE_MASK) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: Non page aligned binary %d\n", file_offset);
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Map text+data+bss read/write/execute
|
||||||
|
*/
|
||||||
|
vmaddr = virtual_offset;
|
||||||
|
error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr,
|
||||||
|
a_out->a_text + a_out->a_data + bss_size, FALSE,
|
||||||
|
VM_PROT_ALL, VM_PROT_ALL, 0);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = vm_mmap(kernel_map, &buffer,
|
||||||
|
round_page(a_out->a_text + a_out->a_data + file_offset),
|
||||||
|
VM_PROT_READ, VM_PROT_READ, 0,
|
||||||
|
(caddr_t) imgp->vp, trunc_page(file_offset));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = copyout((caddr_t)(buffer + file_offset), (caddr_t)vmaddr,
|
||||||
|
a_out->a_text + a_out->a_data);
|
||||||
|
|
||||||
|
vm_map_remove(kernel_map, buffer,
|
||||||
|
buffer + round_page(a_out->a_text + a_out->a_data + file_offset));
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* remove write enable on the 'text' part
|
||||||
|
*/
|
||||||
|
error = vm_map_protect(&vmspace->vm_map,
|
||||||
|
vmaddr,
|
||||||
|
vmaddr + a_out->a_text,
|
||||||
|
VM_PROT_EXECUTE|VM_PROT_READ,
|
||||||
|
TRUE);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: Page aligned binary %d\n", file_offset);
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Map text+data read/execute
|
||||||
|
*/
|
||||||
|
vmaddr = virtual_offset;
|
||||||
|
error = vm_mmap(&vmspace->vm_map, &vmaddr,
|
||||||
|
a_out->a_text + a_out->a_data,
|
||||||
|
VM_PROT_READ | VM_PROT_EXECUTE,
|
||||||
|
VM_PROT_ALL,
|
||||||
|
MAP_PRIVATE | MAP_FIXED,
|
||||||
|
(caddr_t)imgp->vp, file_offset);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: startaddr=%08x, length=%08x\n", vmaddr, a_out->a_text + a_out->a_data);
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* allow read/write of data
|
||||||
|
*/
|
||||||
|
error = vm_map_protect(&vmspace->vm_map,
|
||||||
|
vmaddr + a_out->a_text,
|
||||||
|
vmaddr + a_out->a_text + a_out->a_data,
|
||||||
|
VM_PROT_ALL,
|
||||||
|
FALSE);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate anon demand-zeroed area for uninitialized data
|
||||||
|
*/
|
||||||
|
if (bss_size != 0) {
|
||||||
|
vmaddr = virtual_offset + a_out->a_text + a_out->a_data;
|
||||||
|
error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr,
|
||||||
|
bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("imgact: bssaddr=%08x, length=%08x\n", vmaddr, bss_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Indicate that this file should not be modified */
|
||||||
|
imgp->vp->v_flag |= VTEXT;
|
||||||
|
}
|
||||||
|
/* Fill in process VM information */
|
||||||
|
vmspace->vm_tsize = round_page(a_out->a_text) >> PAGE_SHIFT;
|
||||||
|
vmspace->vm_dsize = round_page(a_out->a_data + bss_size) >> PAGE_SHIFT;
|
||||||
|
vmspace->vm_taddr = (caddr_t)virtual_offset;
|
||||||
|
vmspace->vm_daddr = (caddr_t)virtual_offset + a_out->a_text;
|
||||||
|
|
||||||
|
/* Fill in image_params */
|
||||||
|
imgp->interpreted = 0;
|
||||||
|
imgp->entry_addr = a_out->a_entry;
|
||||||
|
|
||||||
|
imgp->proc->p_sysent = &svr4_sysvec;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tell kern_execve.c about it, with a little help from the linker.
|
||||||
|
* Since `const' objects end up in the text segment, TEXT_SET is the
|
||||||
|
* correct directive to use. Do not staticize; used by Linux LKM.
|
||||||
|
*/
|
||||||
|
const struct execsw svr4_execsw = { exec_svr4_imgact, "svr4 ELF" };
|
||||||
|
TEXT_SET(execsw_set, svr4_execsw);
|
||||||
|
|
38
sys/svr4/svr4.h
Normal file
38
sys/svr4/svr4.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* 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. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(_SVR4_H)
|
||||||
|
#define _SVR4_H
|
||||||
|
|
||||||
|
extern struct sysentvec svr4_sysvec;
|
||||||
|
|
||||||
|
#define memset(x,y,z) bzero(x,z)
|
||||||
|
|
||||||
|
#define COMPAT_SVR4_SOLARIS2
|
||||||
|
#define KTRACE
|
||||||
|
|
||||||
|
#endif
|
44
sys/svr4/svr4_acl.h
Normal file
44
sys/svr4/svr4_acl.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1996 Christos Zoulas.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#ifndef _SVR4_ACL_H_
|
||||||
|
#define _SVR4_ACL_H_
|
||||||
|
|
||||||
|
typedef struct svr4_aclent {
|
||||||
|
int a_type;
|
||||||
|
svr4_uid_t a_id;
|
||||||
|
svr4_o_mode_t a_perm;
|
||||||
|
} svr4_aclent_t;
|
||||||
|
|
||||||
|
#define SVR4_SYS_GETACL 1
|
||||||
|
#define SVR4_SYS_SETACL 2
|
||||||
|
#define SVR4_SYS_GETACLCNT 3
|
||||||
|
|
||||||
|
#endif /* !_SVR4_ACL_H_ */
|
51
sys/svr4/svr4_dirent.h
Normal file
51
sys/svr4/svr4_dirent.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_DIRENT_H_
|
||||||
|
#define _SVR4_DIRENT_H_
|
||||||
|
|
||||||
|
#define SVR4_MAXNAMLEN 512
|
||||||
|
|
||||||
|
struct svr4_dirent {
|
||||||
|
svr4_ino_t d_ino;
|
||||||
|
svr4_off_t d_off;
|
||||||
|
u_short d_reclen;
|
||||||
|
char d_name[SVR4_MAXNAMLEN + 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_dirent64 {
|
||||||
|
svr4_ino64_t d_ino;
|
||||||
|
svr4_off64_t d_off;
|
||||||
|
u_short d_reclen;
|
||||||
|
char d_name[SVR4_MAXNAMLEN + 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp)
|
||||||
|
#define SVR4_RECLEN(de,namlen) ALIGN((SVR4_NAMEOFF(de) + (namlen) + 1))
|
||||||
|
|
||||||
|
#endif /* !_SVR4_DIRENT_H_ */
|
170
sys/svr4/svr4_errno.h
Normal file
170
sys/svr4/svr4_errno.h
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_ERRNO_H_
|
||||||
|
#define _SVR4_ERRNO_H_
|
||||||
|
|
||||||
|
#define SVR4_EPERM 1
|
||||||
|
#define SVR4_ENOENT 2
|
||||||
|
#define SVR4_ESRCH 3
|
||||||
|
#define SVR4_EINTR 4
|
||||||
|
#define SVR4_EIO 5
|
||||||
|
#define SVR4_ENXIO 6
|
||||||
|
#define SVR4_E2BIG 7
|
||||||
|
#define SVR4_ENOEXEC 8
|
||||||
|
#define SVR4_EBADF 9
|
||||||
|
#define SVR4_ECHILD 10
|
||||||
|
#define SVR4_EAGAIN 11
|
||||||
|
#define SVR4_ENOMEM 12
|
||||||
|
#define SVR4_EACCES 13
|
||||||
|
#define SVR4_EFAULT 14
|
||||||
|
#define SVR4_ENOTBLK 15
|
||||||
|
#define SVR4_EBUSY 16
|
||||||
|
#define SVR4_EEXIST 17
|
||||||
|
#define SVR4_EXDEV 18
|
||||||
|
#define SVR4_ENODEV 19
|
||||||
|
#define SVR4_ENOTDIR 20
|
||||||
|
#define SVR4_EISDIR 21
|
||||||
|
#define SVR4_EINVAL 22
|
||||||
|
#define SVR4_ENFILE 23
|
||||||
|
#define SVR4_EMFILE 24
|
||||||
|
#define SVR4_ENOTTY 25
|
||||||
|
#define SVR4_ETXTBSY 26
|
||||||
|
#define SVR4_EFBIG 27
|
||||||
|
#define SVR4_ENOSPC 28
|
||||||
|
#define SVR4_ESPIPE 29
|
||||||
|
#define SVR4_EROFS 30
|
||||||
|
#define SVR4_EMLINK 31
|
||||||
|
#define SVR4_EPIPE 32
|
||||||
|
#define SVR4_EDOM 33
|
||||||
|
#define SVR4_ERANGE 34
|
||||||
|
#define SVR4_ENOMSG 35
|
||||||
|
#define SVR4_EIDRM 36
|
||||||
|
#define SVR4_ECHRNG 37
|
||||||
|
#define SVR4_EL2NSYNC 38
|
||||||
|
#define SVR4_EL3HLT 39
|
||||||
|
#define SVR4_EL3RST 40
|
||||||
|
#define SVR4_ELNRNG 41
|
||||||
|
#define SVR4_EUNATCH 42
|
||||||
|
#define SVR4_ENOCSI 43
|
||||||
|
#define SVR4_EL2HLT 44
|
||||||
|
#define SVR4_EDEADLK 45
|
||||||
|
#define SVR4_ENOLCK 46
|
||||||
|
#define SVR4_EBADE 50
|
||||||
|
#define SVR4_EBADR 51
|
||||||
|
#define SVR4_EXFULL 52
|
||||||
|
#define SVR4_ENOANO 53
|
||||||
|
#define SVR4_EBADRQC 54
|
||||||
|
#define SVR4_EBADSLT 55
|
||||||
|
#define SVR4_EDEADLOCK 56
|
||||||
|
#define SVR4_EBFONT 57
|
||||||
|
#define SVR4_ENOSTR 60
|
||||||
|
#define SVR4_ENODATA 61
|
||||||
|
#define SVR4_ETIME 62
|
||||||
|
#define SVR4_ENOSR 63
|
||||||
|
#define SVR4_ENONET 64
|
||||||
|
#define SVR4_ENOPKG 65
|
||||||
|
#define SVR4_EREMOTE 66
|
||||||
|
#define SVR4_ENOLINK 67
|
||||||
|
#define SVR4_EADV 68
|
||||||
|
#define SVR4_ESRMNT 69
|
||||||
|
#define SVR4_ECOMM 70
|
||||||
|
#define SVR4_EPROTO 71
|
||||||
|
#define SVR4_EMULTIHOP 74
|
||||||
|
#define SVR4_EBADMSG 77
|
||||||
|
#define SVR4_ENAMETOOLONG 78
|
||||||
|
#define SVR4_EOVERFLOW 79
|
||||||
|
#define SVR4_ENOTUNIQ 80
|
||||||
|
#define SVR4_EBADFD 81
|
||||||
|
#define SVR4_EREMCHG 82
|
||||||
|
#define SVR4_ELIBACC 83
|
||||||
|
#define SVR4_ELIBBAD 84
|
||||||
|
#define SVR4_ELIBSCN 85
|
||||||
|
#define SVR4_ELIBMAX 86
|
||||||
|
#define SVR4_ELIBEXEC 87
|
||||||
|
#define SVR4_EILSEQ 88
|
||||||
|
#define SVR4_ENOSYS 89
|
||||||
|
#define SVR4_ELOOP 90
|
||||||
|
#define SVR4_ERESTART 91
|
||||||
|
#define SVR4_ESTRPIPE 92
|
||||||
|
#define SVR4_ENOTEMPTY 93
|
||||||
|
#define SVR4_EUSERS 94
|
||||||
|
#define SVR4_ENOTSOCK 95
|
||||||
|
#define SVR4_EDESTADDRREQ 96
|
||||||
|
#define SVR4_EMSGSIZE 97
|
||||||
|
#define SVR4_EPROTOTYPE 98
|
||||||
|
#define SVR4_ENOPROTOOPT 99
|
||||||
|
#define SVR4_EPROTONOSUPPORT 120
|
||||||
|
#define SVR4_ESOCKTNOSUPPORT 121
|
||||||
|
#define SVR4_EOPNOTSUPP 122
|
||||||
|
#define SVR4_EPFNOSUPPORT 123
|
||||||
|
#define SVR4_EAFNOSUPPORT 124
|
||||||
|
#define SVR4_EADDRINUSE 125
|
||||||
|
#define SVR4_EADDRNOTAVAIL 126
|
||||||
|
#define SVR4_ENETDOWN 127
|
||||||
|
#define SVR4_ENETUNREACH 128
|
||||||
|
#define SVR4_ENETRESET 129
|
||||||
|
#define SVR4_ECONNABORTED 130
|
||||||
|
#define SVR4_ECONNRESET 131
|
||||||
|
#define SVR4_ENOBUFS 132
|
||||||
|
#define SVR4_EISCONN 133
|
||||||
|
#define SVR4_ENOTCONN 134
|
||||||
|
#define SVR4_EUCLEAN 135
|
||||||
|
#define SVR4_ENOTNAM 137
|
||||||
|
#define SVR4_ENAVAIL 138
|
||||||
|
#define SVR4_EISNAM 139
|
||||||
|
#define SVR4_EREMOTEIO 140
|
||||||
|
#define SVR4_EINIT 141
|
||||||
|
#define SVR4_EREMDEV 142
|
||||||
|
#define SVR4_ESHUTDOWN 143
|
||||||
|
#define SVR4_ETOOMANYREFS 144
|
||||||
|
#define SVR4_ETIMEDOUT 145
|
||||||
|
#define SVR4_ECONNREFUSED 146
|
||||||
|
#define SVR4_EHOSTDOWN 147
|
||||||
|
#define SVR4_EHOSTUNREACH 148
|
||||||
|
#define SVR4_EWOULDBLOCK SVR4_EAGAIN
|
||||||
|
#define SVR4_EALREADY 149
|
||||||
|
#define SVR4_EINPROGRESS 150
|
||||||
|
#define SVR4_ESTALE 151
|
||||||
|
#define SVR4_EIORESID 500
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These ones are not translated...
|
||||||
|
*/
|
||||||
|
#define SVR4_EPROCLIM SVR4_ENOSYS
|
||||||
|
#define SVR4_EDQUOT SVR4_ENOSYS
|
||||||
|
#define SVR4_EBADRPC SVR4_ENOSYS
|
||||||
|
#define SVR4_ERPCMISMATCH SVR4_ENOSYS
|
||||||
|
#define SVR4_EPROGUNAVAIL SVR4_ENOSYS
|
||||||
|
#define SVR4_EPROGMISMATCH SVR4_ENOSYS
|
||||||
|
#define SVR4_EPROCUNAVAIL SVR4_ENOSYS
|
||||||
|
#define SVR4_EFTYPE SVR4_ENOSYS
|
||||||
|
#define SVR4_EAUTH SVR4_ENOSYS
|
||||||
|
#define SVR4_ENEEDAUTH SVR4_ENOSYS
|
||||||
|
|
||||||
|
#endif /* !_SVR4_ERRNO_H_ */
|
68
sys/svr4/svr4_exec.h
Normal file
68
sys/svr4/svr4_exec.h
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_EXEC_H_
|
||||||
|
#define _SVR4_EXEC_H_
|
||||||
|
|
||||||
|
#ifdef SVR4_COMPAT_SOLARIS2
|
||||||
|
# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 12 / sizeof(char *))
|
||||||
|
#else
|
||||||
|
# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 8 / sizeof(char *))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Don't think we need all this NetBSD stuff */
|
||||||
|
/*
|
||||||
|
* The following is horrible; there must be a better way. I need to
|
||||||
|
* play with brk(2) a bit more.
|
||||||
|
*/
|
||||||
|
#ifdef i386
|
||||||
|
/*
|
||||||
|
* I cannot load the interpreter after the data segment because brk(2)
|
||||||
|
* breaks. I have to load it somewhere before. Programs start at
|
||||||
|
* 0x08000000 so I load the interpreter far before.
|
||||||
|
*/
|
||||||
|
#define SVR4_INTERP_ADDR 0x01000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef sparc
|
||||||
|
/*
|
||||||
|
* Here programs load at 0x00010000, so I load the interpreter far after
|
||||||
|
* the end of the data segment.
|
||||||
|
*/
|
||||||
|
#define SVR4_INTERP_ADDR 0x10000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SVR4_INTERP_ADDR
|
||||||
|
# define SVR4_INTERP_ADDR 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*void svr4_setregs __P((struct proc *, struct exec_package *, u_long));*/
|
||||||
|
|
||||||
|
#endif /* !_SVR4_EXEC_H_ */
|
721
sys/svr4/svr4_fcntl.c
Normal file
721
sys/svr4/svr4_fcntl.c
Normal file
|
@ -0,0 +1,721 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994, 1997 Christos Zoulas.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#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/ioctl.h>*/
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_fcntl.h>
|
||||||
|
|
||||||
|
static int svr4_to_bsd_flags __P((int));
|
||||||
|
static u_long svr4_to_bsd_cmd __P((u_long));
|
||||||
|
static int fd_revoke __P((struct proc *, int));
|
||||||
|
static int fd_truncate __P((struct proc *, int, struct flock *));
|
||||||
|
static int bsd_to_svr4_flags __P((int));
|
||||||
|
static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *));
|
||||||
|
static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *));
|
||||||
|
static void bsd_to_svr4_flock64 __P((struct flock *, struct svr4_flock64 *));
|
||||||
|
static void svr4_to_bsd_flock64 __P((struct svr4_flock64 *, struct flock *));
|
||||||
|
|
||||||
|
static u_long
|
||||||
|
svr4_to_bsd_cmd(cmd)
|
||||||
|
u_long cmd;
|
||||||
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_F_DUPFD:
|
||||||
|
return F_DUPFD;
|
||||||
|
case SVR4_F_GETFD:
|
||||||
|
return F_GETFD;
|
||||||
|
case SVR4_F_SETFD:
|
||||||
|
return F_SETFD;
|
||||||
|
case SVR4_F_GETFL:
|
||||||
|
return F_GETFL;
|
||||||
|
case SVR4_F_SETFL:
|
||||||
|
return F_SETFL;
|
||||||
|
case SVR4_F_GETLK:
|
||||||
|
return F_GETLK;
|
||||||
|
case SVR4_F_SETLK:
|
||||||
|
return F_SETLK;
|
||||||
|
case SVR4_F_SETLKW:
|
||||||
|
return F_SETLKW;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_to_bsd_flags(l)
|
||||||
|
int l;
|
||||||
|
{
|
||||||
|
int r = 0;
|
||||||
|
r |= (l & SVR4_O_RDONLY) ? O_RDONLY : 0;
|
||||||
|
r |= (l & SVR4_O_WRONLY) ? O_WRONLY : 0;
|
||||||
|
r |= (l & SVR4_O_RDWR) ? O_RDWR : 0;
|
||||||
|
r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0;
|
||||||
|
r |= (l & SVR4_O_APPEND) ? O_APPEND : 0;
|
||||||
|
r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0;
|
||||||
|
r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0;
|
||||||
|
r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0;
|
||||||
|
r |= (l & SVR4_O_CREAT) ? O_CREAT : 0;
|
||||||
|
r |= (l & SVR4_O_TRUNC) ? O_TRUNC : 0;
|
||||||
|
r |= (l & SVR4_O_EXCL) ? O_EXCL : 0;
|
||||||
|
r |= (l & SVR4_O_NOCTTY) ? O_NOCTTY : 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bsd_to_svr4_flags(l)
|
||||||
|
int l;
|
||||||
|
{
|
||||||
|
int r = 0;
|
||||||
|
r |= (l & O_RDONLY) ? SVR4_O_RDONLY : 0;
|
||||||
|
r |= (l & O_WRONLY) ? SVR4_O_WRONLY : 0;
|
||||||
|
r |= (l & O_RDWR) ? SVR4_O_RDWR : 0;
|
||||||
|
r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0;
|
||||||
|
r |= (l & O_APPEND) ? SVR4_O_APPEND : 0;
|
||||||
|
r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0;
|
||||||
|
r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0;
|
||||||
|
r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0;
|
||||||
|
r |= (l & O_CREAT) ? SVR4_O_CREAT : 0;
|
||||||
|
r |= (l & O_TRUNC) ? SVR4_O_TRUNC : 0;
|
||||||
|
r |= (l & O_EXCL) ? SVR4_O_EXCL : 0;
|
||||||
|
r |= (l & O_NOCTTY) ? SVR4_O_NOCTTY : 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_flock(iflp, oflp)
|
||||||
|
struct flock *iflp;
|
||||||
|
struct svr4_flock *oflp;
|
||||||
|
{
|
||||||
|
switch (iflp->l_type) {
|
||||||
|
case F_RDLCK:
|
||||||
|
oflp->l_type = SVR4_F_RDLCK;
|
||||||
|
break;
|
||||||
|
case F_WRLCK:
|
||||||
|
oflp->l_type = SVR4_F_WRLCK;
|
||||||
|
break;
|
||||||
|
case F_UNLCK:
|
||||||
|
oflp->l_type = SVR4_F_UNLCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oflp->l_type = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oflp->l_whence = (short) iflp->l_whence;
|
||||||
|
oflp->l_start = (svr4_off_t) iflp->l_start;
|
||||||
|
oflp->l_len = (svr4_off_t) iflp->l_len;
|
||||||
|
oflp->l_sysid = 0;
|
||||||
|
oflp->l_pid = (svr4_pid_t) iflp->l_pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_flock(iflp, oflp)
|
||||||
|
struct svr4_flock *iflp;
|
||||||
|
struct flock *oflp;
|
||||||
|
{
|
||||||
|
switch (iflp->l_type) {
|
||||||
|
case SVR4_F_RDLCK:
|
||||||
|
oflp->l_type = F_RDLCK;
|
||||||
|
break;
|
||||||
|
case SVR4_F_WRLCK:
|
||||||
|
oflp->l_type = F_WRLCK;
|
||||||
|
break;
|
||||||
|
case SVR4_F_UNLCK:
|
||||||
|
oflp->l_type = F_UNLCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oflp->l_type = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oflp->l_whence = iflp->l_whence;
|
||||||
|
oflp->l_start = (off_t) iflp->l_start;
|
||||||
|
oflp->l_len = (off_t) iflp->l_len;
|
||||||
|
oflp->l_pid = (pid_t) iflp->l_pid;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_flock64(iflp, oflp)
|
||||||
|
struct flock *iflp;
|
||||||
|
struct svr4_flock64 *oflp;
|
||||||
|
{
|
||||||
|
switch (iflp->l_type) {
|
||||||
|
case F_RDLCK:
|
||||||
|
oflp->l_type = SVR4_F_RDLCK;
|
||||||
|
break;
|
||||||
|
case F_WRLCK:
|
||||||
|
oflp->l_type = SVR4_F_WRLCK;
|
||||||
|
break;
|
||||||
|
case F_UNLCK:
|
||||||
|
oflp->l_type = SVR4_F_UNLCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oflp->l_type = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oflp->l_whence = (short) iflp->l_whence;
|
||||||
|
oflp->l_start = (svr4_off64_t) iflp->l_start;
|
||||||
|
oflp->l_len = (svr4_off64_t) iflp->l_len;
|
||||||
|
oflp->l_sysid = 0;
|
||||||
|
oflp->l_pid = (svr4_pid_t) iflp->l_pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_flock64(iflp, oflp)
|
||||||
|
struct svr4_flock64 *iflp;
|
||||||
|
struct flock *oflp;
|
||||||
|
{
|
||||||
|
switch (iflp->l_type) {
|
||||||
|
case SVR4_F_RDLCK:
|
||||||
|
oflp->l_type = F_RDLCK;
|
||||||
|
break;
|
||||||
|
case SVR4_F_WRLCK:
|
||||||
|
oflp->l_type = F_WRLCK;
|
||||||
|
break;
|
||||||
|
case SVR4_F_UNLCK:
|
||||||
|
oflp->l_type = F_UNLCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oflp->l_type = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oflp->l_whence = iflp->l_whence;
|
||||||
|
oflp->l_start = (off_t) iflp->l_start;
|
||||||
|
oflp->l_len = (off_t) iflp->l_len;
|
||||||
|
oflp->l_pid = (pid_t) iflp->l_pid;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
fd_revoke(p, fd)
|
||||||
|
struct proc *p;
|
||||||
|
int fd;
|
||||||
|
{
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
struct file *fp;
|
||||||
|
struct vnode *vp;
|
||||||
|
struct vattr vattr;
|
||||||
|
int error, *retval;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
|
||||||
|
return EBADF;
|
||||||
|
|
||||||
|
switch (fp->f_type) {
|
||||||
|
case DTYPE_VNODE:
|
||||||
|
vp = (struct vnode *) fp->f_data;
|
||||||
|
|
||||||
|
case DTYPE_SOCKET:
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
default:
|
||||||
|
panic("svr4_fcntl(F_REVOKE)");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
||||||
|
error = EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (p->p_ucred->cr_uid != vattr.va_uid &&
|
||||||
|
(error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (vp->v_usecount > 1 || (vp->v_flag & VALIASED))
|
||||||
|
VOP_REVOKE(vp, REVOKEALL);
|
||||||
|
out:
|
||||||
|
vrele(vp);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
fd_truncate(p, fd, flp)
|
||||||
|
struct proc *p;
|
||||||
|
int fd;
|
||||||
|
struct flock *flp;
|
||||||
|
{
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
struct file *fp;
|
||||||
|
off_t start, length;
|
||||||
|
struct vnode *vp;
|
||||||
|
struct vattr vattr;
|
||||||
|
int error, *retval;
|
||||||
|
struct ftruncate_args ft;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We only support truncating the file.
|
||||||
|
*/
|
||||||
|
if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
|
||||||
|
return EBADF;
|
||||||
|
|
||||||
|
vp = (struct vnode *)fp->f_data;
|
||||||
|
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO)
|
||||||
|
return ESPIPE;
|
||||||
|
|
||||||
|
if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
length = vattr.va_size;
|
||||||
|
|
||||||
|
switch (flp->l_whence) {
|
||||||
|
case SEEK_CUR:
|
||||||
|
start = fp->f_offset + flp->l_start;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SEEK_END:
|
||||||
|
start = flp->l_start + length;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SEEK_SET:
|
||||||
|
start = flp->l_start;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start + flp->l_len < length) {
|
||||||
|
/* We don't support free'ing in the middle of the file */
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCARG(&ft, fd) = fd;
|
||||||
|
SCARG(&ft, length) = start;
|
||||||
|
|
||||||
|
return ftruncate(p, &ft);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_open(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_open_args *uap;
|
||||||
|
{
|
||||||
|
int error, retval;
|
||||||
|
struct open_args cup;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
(&cup)->path = uap->path;
|
||||||
|
(&cup)->flags = svr4_to_bsd_flags(uap->flags);
|
||||||
|
(&cup)->mode = uap->mode;
|
||||||
|
error = open(p, &cup);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
/* uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path,
|
||||||
|
uap->flags, uap->mode, error);*/
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = p->p_retval[0];
|
||||||
|
|
||||||
|
if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) &&
|
||||||
|
!(p->p_flag & P_CONTROLT)) {
|
||||||
|
#if defined(NOTYET)
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
struct file *fp = fdp->fd_ofiles[retval];
|
||||||
|
|
||||||
|
/* ignore any error, just give it a try */
|
||||||
|
if (fp->f_type == DTYPE_VNODE)
|
||||||
|
(fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, (caddr_t) 0, p);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_open64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_open64_args *uap;
|
||||||
|
{
|
||||||
|
return svr4_sys_open(p, (struct svr4_sys_open_args *)uap);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_creat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_creat_args *uap;
|
||||||
|
{
|
||||||
|
struct open_args cup;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, mode) = SCARG(uap, mode);
|
||||||
|
SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC;
|
||||||
|
|
||||||
|
return open(p, &cup);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_creat64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_creat64_args *uap;
|
||||||
|
{
|
||||||
|
return svr4_sys_creat(p, (struct svr4_sys_creat_args *)uap);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_llseek(p, v)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_llseek_args *v;
|
||||||
|
{
|
||||||
|
struct svr4_sys_llseek_args *uap = v;
|
||||||
|
struct lseek_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, fd) = SCARG(uap, fd);
|
||||||
|
|
||||||
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
|
SCARG(&ap, offset) = (((long long) SCARG(uap, offset1)) << 32) |
|
||||||
|
SCARG(uap, offset2);
|
||||||
|
#else
|
||||||
|
SCARG(&ap, offset) = (((long long) SCARG(uap, offset2)) << 32) |
|
||||||
|
SCARG(uap, offset1);
|
||||||
|
#endif
|
||||||
|
SCARG(&ap, whence) = SCARG(uap, whence);
|
||||||
|
|
||||||
|
return lseek(p, &ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_access(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_access_args *uap;
|
||||||
|
{
|
||||||
|
struct access_args cup;
|
||||||
|
int *retval;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, flags) = SCARG(uap, flags);
|
||||||
|
|
||||||
|
return access(p, &cup);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int
|
||||||
|
svr4_sys_pread(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_pread_args *uap;
|
||||||
|
{
|
||||||
|
struct pread_args pra;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just translate the args structure and call the NetBSD
|
||||||
|
* pread(2) system call (offset type is 64-bit in NetBSD).
|
||||||
|
*/
|
||||||
|
SCARG(&pra, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&pra, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&pra, nbyte) = SCARG(uap, nbyte);
|
||||||
|
SCARG(&pra, offset) = SCARG(uap, off);
|
||||||
|
|
||||||
|
return pread(p, &pra);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int
|
||||||
|
svr4_sys_pread64(p, v, retval)
|
||||||
|
register struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
|
||||||
|
struct svr4_sys_pread64_args *uap = v;
|
||||||
|
struct sys_pread_args pra;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just translate the args structure and call the NetBSD
|
||||||
|
* pread(2) system call (offset type is 64-bit in NetBSD).
|
||||||
|
*/
|
||||||
|
SCARG(&pra, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&pra, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&pra, nbyte) = SCARG(uap, nbyte);
|
||||||
|
SCARG(&pra, offset) = SCARG(uap, off);
|
||||||
|
|
||||||
|
return (sys_pread(p, &pra, retval));
|
||||||
|
}
|
||||||
|
#endif /* NOTYET */
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int
|
||||||
|
svr4_sys_pwrite(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_pwrite_args *uap;
|
||||||
|
{
|
||||||
|
struct pwrite_args pwa;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just translate the args structure and call the NetBSD
|
||||||
|
* pwrite(2) system call (offset type is 64-bit in NetBSD).
|
||||||
|
*/
|
||||||
|
SCARG(&pwa, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&pwa, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
|
||||||
|
SCARG(&pwa, offset) = SCARG(uap, off);
|
||||||
|
|
||||||
|
return pwrite(p, &pwa);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int
|
||||||
|
svr4_sys_pwrite64(p, v, retval)
|
||||||
|
register struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_pwrite64_args *uap = v;
|
||||||
|
struct sys_pwrite_args pwa;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just translate the args structure and call the NetBSD
|
||||||
|
* pwrite(2) system call (offset type is 64-bit in NetBSD).
|
||||||
|
*/
|
||||||
|
SCARG(&pwa, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&pwa, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
|
||||||
|
SCARG(&pwa, offset) = SCARG(uap, off);
|
||||||
|
|
||||||
|
return (sys_pwrite(p, &pwa, retval));
|
||||||
|
}
|
||||||
|
#endif /* NOTYET */
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fcntl(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fcntl_args *uap;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
struct fcntl_args fa;
|
||||||
|
int *retval;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(&fa, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd));
|
||||||
|
|
||||||
|
switch (SCARG(&fa, cmd)) {
|
||||||
|
case F_DUPFD:
|
||||||
|
case F_GETFD:
|
||||||
|
case F_SETFD:
|
||||||
|
SCARG(&fa, arg) = (long) SCARG(uap, arg);
|
||||||
|
return fcntl(p, &fa);
|
||||||
|
|
||||||
|
case F_GETFL:
|
||||||
|
SCARG(&fa, arg) = (long) SCARG(uap, arg);
|
||||||
|
error = fcntl(p, &fa);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
*retval = bsd_to_svr4_flags(*retval);
|
||||||
|
return error;
|
||||||
|
|
||||||
|
case F_SETFL:
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* we must save the O_ASYNC flag, as that is
|
||||||
|
* handled by ioctl(_, I_SETSIG, _) emulation.
|
||||||
|
*/
|
||||||
|
long cmd;
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
DPRINTF(("Setting flags 0x%x\n", SCARG(uap, arg)));
|
||||||
|
cmd = SCARG(&fa, cmd); /* save it for a while */
|
||||||
|
|
||||||
|
SCARG(&fa, cmd) = F_GETFL;
|
||||||
|
if ((error = fcntl(p, &fa)) != 0)
|
||||||
|
return error;
|
||||||
|
flags = *retval;
|
||||||
|
flags &= O_ASYNC;
|
||||||
|
flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg));
|
||||||
|
SCARG(&fa, cmd) = cmd;
|
||||||
|
SCARG(&fa, arg) = (long) flags;
|
||||||
|
return fcntl(p, &fa);
|
||||||
|
}
|
||||||
|
|
||||||
|
case F_GETLK:
|
||||||
|
case F_SETLK:
|
||||||
|
case F_SETLKW:
|
||||||
|
{
|
||||||
|
struct svr4_flock ifl;
|
||||||
|
struct flock *flp, fl;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
flp = stackgap_alloc(&sg, sizeof(struct flock));
|
||||||
|
SCARG(&fa, arg) = (long) flp;
|
||||||
|
|
||||||
|
error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_to_bsd_flock(&ifl, &fl);
|
||||||
|
|
||||||
|
error = copyout(&fl, flp, sizeof fl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = fcntl(p, &fa);
|
||||||
|
if (error || SCARG(&fa, cmd) != F_GETLK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = copyin(flp, &fl, sizeof fl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_flock(&fl, &ifl);
|
||||||
|
|
||||||
|
return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
|
||||||
|
}
|
||||||
|
case -1:
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_F_DUP2FD:
|
||||||
|
{
|
||||||
|
struct dup2_args du;
|
||||||
|
|
||||||
|
SCARG(&du, from) = SCARG(uap, fd);
|
||||||
|
SCARG(&du, to) = (int)SCARG(uap, arg);
|
||||||
|
error = dup2(p, &du);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
*retval = SCARG(&du, to);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_F_FREESP:
|
||||||
|
{
|
||||||
|
struct svr4_flock ifl;
|
||||||
|
struct flock fl;
|
||||||
|
|
||||||
|
error = copyin(SCARG(uap, arg), &ifl,
|
||||||
|
sizeof ifl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_flock(&ifl, &fl);
|
||||||
|
return fd_truncate(p, SCARG(uap, fd), &fl);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_F_GETLK64:
|
||||||
|
case SVR4_F_SETLK64:
|
||||||
|
case SVR4_F_SETLKW64:
|
||||||
|
{
|
||||||
|
struct svr4_flock64 ifl;
|
||||||
|
struct flock *flp, fl;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
flp = stackgap_alloc(&sg, sizeof(struct flock));
|
||||||
|
SCARG(&fa, arg) = (long) flp;
|
||||||
|
|
||||||
|
error = copyin(SCARG(uap, arg), &ifl,
|
||||||
|
sizeof ifl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_to_bsd_flock64(&ifl, &fl);
|
||||||
|
|
||||||
|
error = copyout(&fl, flp, sizeof fl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = fcntl(p, &fa);
|
||||||
|
if (error || SCARG(&fa, cmd) != F_GETLK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = copyin(flp, &fl, sizeof fl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_flock64(&fl, &ifl);
|
||||||
|
|
||||||
|
return copyout(&ifl, SCARG(uap, arg),
|
||||||
|
sizeof ifl);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_F_FREESP64:
|
||||||
|
{
|
||||||
|
struct svr4_flock64 ifl;
|
||||||
|
struct flock fl;
|
||||||
|
|
||||||
|
error = copyin(SCARG(uap, arg), &ifl,
|
||||||
|
sizeof ifl);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_flock64(&ifl, &fl);
|
||||||
|
return fd_truncate(p, SCARG(uap, fd), &fl);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_F_REVOKE:
|
||||||
|
return fd_revoke(p, SCARG(uap, fd));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
}
|
132
sys/svr4/svr4_fcntl.h
Normal file
132
sys/svr4/svr4_fcntl.h
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_FCNTL_H_
|
||||||
|
#define _SVR4_FCNTL_H_
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
|
||||||
|
#define SVR4_O_RDONLY 0x0000
|
||||||
|
#define SVR4_O_WRONLY 0x0001
|
||||||
|
#define SVR4_O_RDWR 0x0002
|
||||||
|
#define SVR4_O_ACCMODE 0x0003
|
||||||
|
#define SVR4_O_NDELAY 0x0004
|
||||||
|
#define SVR4_O_APPEND 0x0008
|
||||||
|
#define SVR4_O_SYNC 0x0010
|
||||||
|
#define SVR4_O_NONBLOCK 0x0080
|
||||||
|
#define SVR4_O_CREAT 0x0100
|
||||||
|
#define SVR4_O_TRUNC 0x0200
|
||||||
|
#define SVR4_O_EXCL 0x0400
|
||||||
|
#define SVR4_O_NOCTTY 0x0800
|
||||||
|
#define SVR4_O_PRIV 0x1000
|
||||||
|
|
||||||
|
|
||||||
|
#define SVR4_FD_CLOEXEC 1
|
||||||
|
|
||||||
|
#define SVR4_F_DUPFD 0
|
||||||
|
#define SVR4_F_GETFD 1
|
||||||
|
#define SVR4_F_SETFD 2
|
||||||
|
#define SVR4_F_GETFL 3
|
||||||
|
#define SVR4_F_SETFL 4
|
||||||
|
#define SVR4_F_GETLK_SVR3 5
|
||||||
|
#define SVR4_F_SETLK 6
|
||||||
|
#define SVR4_F_SETLKW 7
|
||||||
|
#define SVR4_F_CHKFL 8
|
||||||
|
#define SVR4_F_DUP2FD 9
|
||||||
|
#define SVR4_F_ALLOCSP 10
|
||||||
|
#define SVR4_F_FREESP 11
|
||||||
|
|
||||||
|
#define SVR4_F_ISSTREAM 13
|
||||||
|
#define SVR4_F_GETLK 14
|
||||||
|
#define SVR4_F_PRIV 15
|
||||||
|
#define SVR4_F_NPRIV 16
|
||||||
|
#define SVR4_F_QUOTACTL 17
|
||||||
|
#define SVR4_F_BLOCKS 18
|
||||||
|
#define SVR4_F_BLKSIZE 19
|
||||||
|
#define SVR4_F_RSETLK 20
|
||||||
|
#define SVR4_F_RGETLK 21
|
||||||
|
#define SVR4_F_RSETLKW 22
|
||||||
|
#define SVR4_F_GETOWN 23
|
||||||
|
#define SVR4_F_SETOWN 24
|
||||||
|
#define SVR4_F_REVOKE 25
|
||||||
|
#define SVR4_F_HASREMOTELOCKS 26
|
||||||
|
#define SVR4_F_FREESP64 27
|
||||||
|
|
||||||
|
#define SVR4_F_GETLK64 33
|
||||||
|
#define SVR4_F_SETLK64 34
|
||||||
|
#define SVR4_F_SETLKW64 35
|
||||||
|
|
||||||
|
#define SVR4_F_SHARE 40
|
||||||
|
#define SVR4_F_UNSHARE 41
|
||||||
|
|
||||||
|
#define SVR4_F_CHSIZE_XENIX 0x6000
|
||||||
|
#define SVR4_F_RDCHK_XENIX 0x6001
|
||||||
|
#define SVR4_F_LK_UNLCK_XENIX 0x6300
|
||||||
|
#define SVR4_F_LK_LOCK_XENIX 0x7200
|
||||||
|
#define SVR4_F_LK_NBLCK_XENIX 0x6200
|
||||||
|
#define SVR4_F_LK_RLCK_XENIX 0x7100
|
||||||
|
#define SVR4_F_LK_NBRLCK_XENIX 0x6100
|
||||||
|
|
||||||
|
#define SVR4_LK_CMDTYPE(x) (((x) >> 12) & 0x7)
|
||||||
|
#define SVR4_LK_LCKTYPE(x) (((x) >> 8) & 0x7)
|
||||||
|
|
||||||
|
#define SVR4_F_RDLCK 1
|
||||||
|
#define SVR4_F_WRLCK 2
|
||||||
|
#define SVR4_F_UNLCK 3
|
||||||
|
|
||||||
|
struct svr4_flock_svr3 {
|
||||||
|
short l_type;
|
||||||
|
short l_whence;
|
||||||
|
svr4_off_t l_start;
|
||||||
|
svr4_off_t l_len;
|
||||||
|
short l_sysid;
|
||||||
|
svr4_o_pid_t l_pid;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct svr4_flock {
|
||||||
|
short l_type;
|
||||||
|
short l_whence;
|
||||||
|
svr4_off_t l_start;
|
||||||
|
svr4_off_t l_len;
|
||||||
|
long l_sysid;
|
||||||
|
svr4_pid_t l_pid;
|
||||||
|
long pad[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_flock64 {
|
||||||
|
short l_type;
|
||||||
|
short l_whence;
|
||||||
|
svr4_off64_t l_start;
|
||||||
|
svr4_off64_t l_len;
|
||||||
|
long l_sysid;
|
||||||
|
svr4_pid_t l_pid;
|
||||||
|
long pad[4];
|
||||||
|
};
|
||||||
|
#endif /* !_SVR4_FCNTL_H_ */
|
245
sys/svr4/svr4_filio.c
Normal file
245
sys/svr4/svr4_filio.c
Normal file
|
@ -0,0 +1,245 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filio.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/tty.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/socketvar.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_ioctl.h>
|
||||||
|
#include <svr4/svr4_filio.h>
|
||||||
|
|
||||||
|
/*#define GROTTY_READ_HACK*/
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_poll(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_poll_args *uap;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
struct poll_args pa;
|
||||||
|
struct pollfd *pfd;
|
||||||
|
int idx = 0, cerr;
|
||||||
|
u_long siz;
|
||||||
|
|
||||||
|
SCARG(&pa, fds) = SCARG(uap, fds);
|
||||||
|
SCARG(&pa, nfds) = SCARG(uap, nfds);
|
||||||
|
SCARG(&pa, timeout) = SCARG(uap, timeout);
|
||||||
|
|
||||||
|
siz = SCARG(uap, nfds) * sizeof(struct pollfd);
|
||||||
|
pfd = (struct pollfd *)malloc(siz, M_TEMP, M_WAITOK);
|
||||||
|
|
||||||
|
error = poll(p, (struct poll_args *)uap);
|
||||||
|
|
||||||
|
if ((cerr = copyin(SCARG(uap, fds), pfd, siz)) != 0) {
|
||||||
|
error = cerr;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx = 0; idx < SCARG(uap, nfds); idx++) {
|
||||||
|
/* POLLWRNORM already equals POLLOUT, so we don't worry about that */
|
||||||
|
if (pfd[idx].revents & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI))
|
||||||
|
pfd[idx].revents |= (POLLIN | POLLRDBAND | POLLRDNORM | POLLPRI);
|
||||||
|
if (pfd[idx].revents & (POLLOUT | POLLWRNORM | POLLWRBAND))
|
||||||
|
pfd[idx].revents |= (POLLOUT | POLLWRNORM | POLLWRBAND);
|
||||||
|
pfd[idx].revents &= POLLSTANDARD; /* don't want to surprise SysV */
|
||||||
|
|
||||||
|
DPRINTF(("pollfd[%d]->fd = %d\n", idx, pfd[idx].fd));
|
||||||
|
DPRINTF(("pollfd[%d]->events = %x\n", idx, pfd[idx].events));
|
||||||
|
DPRINTF(("pollfd[%d]->revents = %x\n", idx, pfd[idx].revents));
|
||||||
|
}
|
||||||
|
DPRINTF(("poll(%x, %x, %d) = %d\n", SCARG(uap, fds), SCARG(uap, nfds),
|
||||||
|
SCARG(uap, timeout), p->p_retval[0]));
|
||||||
|
if ((cerr = copyout(pfd, SCARG(uap, fds), siz)) != 0) {
|
||||||
|
error = cerr;
|
||||||
|
goto done; /* yeah, I know it's the next line, but this way I won't
|
||||||
|
forget to update it if I add more code */
|
||||||
|
}
|
||||||
|
done:
|
||||||
|
free(pfd, M_TEMP);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(READ_TEST)
|
||||||
|
int
|
||||||
|
svr4_sys_read(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_read_args *uap;
|
||||||
|
{
|
||||||
|
struct read_args ra;
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
struct file *fp;
|
||||||
|
struct socket *so = NULL;
|
||||||
|
int so_state;
|
||||||
|
sigset_t sigmask;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
SCARG(&ra, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&ra, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&ra, nbyte) = SCARG(uap, nbyte);
|
||||||
|
|
||||||
|
if ((fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) {
|
||||||
|
DPRINTF(("Something fishy with the user-supplied file descriptor...\n"));
|
||||||
|
return EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fp->f_type == DTYPE_SOCKET) {
|
||||||
|
so = (struct socket *)fp->f_data;
|
||||||
|
DPRINTF(("fd %d is a socket\n", SCARG(uap, fd)));
|
||||||
|
if (so->so_state & SS_ASYNC) {
|
||||||
|
DPRINTF(("fd %d is an ASYNC socket!\n", SCARG(uap, fd)));
|
||||||
|
}
|
||||||
|
DPRINTF(("Here are its flags: 0x%x\n", so->so_state));
|
||||||
|
#if defined(GROTTY_READ_HACK)
|
||||||
|
so_state = so->so_state;
|
||||||
|
so->so_state &= ~SS_NBIO;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = read(p, &ra);
|
||||||
|
|
||||||
|
DPRINTF(("svr4_read(%d, 0x%0x, %d) = %d\n",
|
||||||
|
SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv));
|
||||||
|
if (rv == EAGAIN) {
|
||||||
|
DPRINTF(("sigmask = 0x%x\n", p->p_sigmask));
|
||||||
|
DPRINTF(("sigignore = 0x%x\n", p->p_sigignore));
|
||||||
|
DPRINTF(("sigcaught = 0x%x\n", p->p_sigcatch));
|
||||||
|
DPRINTF(("siglist = 0x%x\n", p->p_siglist));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(GROTTY_READ_HACK)
|
||||||
|
if (so) { /* We've already checked to see if this is a socket */
|
||||||
|
so->so_state = so_state;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(rv);
|
||||||
|
}
|
||||||
|
#endif /* READ_TEST */
|
||||||
|
|
||||||
|
#if defined(BOGUS)
|
||||||
|
int
|
||||||
|
svr4_sys_write(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_write_args *uap;
|
||||||
|
{
|
||||||
|
struct write_args wa;
|
||||||
|
struct filedesc *fdp;
|
||||||
|
struct file *fp;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
SCARG(&wa, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&wa, buf) = SCARG(uap, buf);
|
||||||
|
SCARG(&wa, nbyte) = SCARG(uap, nbyte);
|
||||||
|
|
||||||
|
rv = write(p, &wa);
|
||||||
|
|
||||||
|
DPRINTF(("svr4_write(%d, 0x%0x, %d) = %d\n",
|
||||||
|
SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv));
|
||||||
|
|
||||||
|
return(rv);
|
||||||
|
}
|
||||||
|
#endif /* BOGUS */
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_fil_ioctl(fp, p, retval, fd, cmd, data)
|
||||||
|
struct file *fp;
|
||||||
|
struct proc *p;
|
||||||
|
register_t *retval;
|
||||||
|
int fd;
|
||||||
|
u_long cmd;
|
||||||
|
caddr_t data;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
int num;
|
||||||
|
struct filedesc *fdp = p->p_fd;
|
||||||
|
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
|
||||||
|
fp->f_ops->fo_ioctl;
|
||||||
|
|
||||||
|
*retval = 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_FIOCLEX:
|
||||||
|
fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SVR4_FIONCLEX:
|
||||||
|
fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SVR4_FIOGETOWN:
|
||||||
|
case SVR4_FIOSETOWN:
|
||||||
|
case SVR4_FIOASYNC:
|
||||||
|
case SVR4_FIONBIO:
|
||||||
|
case SVR4_FIONREAD:
|
||||||
|
if ((error = copyin(data, &num, sizeof(num))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_FIOGETOWN: cmd = FIOGETOWN; break;
|
||||||
|
case SVR4_FIOSETOWN: cmd = FIOSETOWN; break;
|
||||||
|
case SVR4_FIOASYNC: cmd = FIOASYNC; break;
|
||||||
|
case SVR4_FIONBIO: cmd = FIONBIO; break;
|
||||||
|
case SVR4_FIONREAD: cmd = FIONREAD; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SVR4_DEBUG
|
||||||
|
if (cmd == FIOASYNC) DPRINTF(("FIOASYNC\n"));
|
||||||
|
#endif
|
||||||
|
error = (*ctl)(fp, cmd, (caddr_t) &num, p);
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return copyout(&num, data, sizeof(num));
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Unknown svr4 filio %lx\n", cmd));
|
||||||
|
return 0; /* ENOSYS really */
|
||||||
|
}
|
||||||
|
}
|
43
sys/svr4/svr4_filio.h
Normal file
43
sys/svr4/svr4_filio.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_FILIO_H_
|
||||||
|
#define _SVR4_FILIO_H_
|
||||||
|
|
||||||
|
#define SVR4_FIOC ('f' << 8)
|
||||||
|
|
||||||
|
#define SVR4_FIOCLEX SVR4_IO('f', 1)
|
||||||
|
#define SVR4_FIONCLEX SVR4_IO('f', 2)
|
||||||
|
|
||||||
|
#define SVR4_FIOGETOWN SVR4_IOR('f', 123, int)
|
||||||
|
#define SVR4_FIOSETOWN SVR4_IOW('f', 124, int)
|
||||||
|
#define SVR4_FIOASYNC SVR4_IOW('f', 125, int)
|
||||||
|
#define SVR4_FIONBIO SVR4_IOW('f', 126, int)
|
||||||
|
#define SVR4_FIONREAD SVR4_IOR('f', 127, int)
|
||||||
|
|
||||||
|
#endif /* !_SVR4_FILIO_H_ */
|
96
sys/svr4/svr4_fuser.h
Normal file
96
sys/svr4/svr4_fuser.h
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Derived from:
|
||||||
|
* $NetBSD: svr4_fuser.h,v 1.4 1998/09/04 19:54:38 christos Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Original Copyright:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Christos Zoulas.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions of this code have been derived from code contributed to the
|
||||||
|
* FreeBSD Project by Mark Newton.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mark Newton
|
||||||
|
* 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. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_FUSER_H_
|
||||||
|
#define _SVR4_FUSER_H_
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
|
||||||
|
struct svr4_f_user {
|
||||||
|
svr4_pid_t fu_pid;
|
||||||
|
int fu_flags;
|
||||||
|
uid_t fu_uid;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define SVR4_F_FILE_ONLY 1
|
||||||
|
#define SVR4_F_CONTAINED 2
|
||||||
|
|
||||||
|
#define SVR4_F_CDIR 0x01
|
||||||
|
#define SVR4_F_RDIR 0x02
|
||||||
|
#define SVR4_F_TEXT 0x04
|
||||||
|
#define SVR4_F_MAP 0x08
|
||||||
|
#define SVR4_F_OPEN 0x10
|
||||||
|
#define SVR4_F_TRACE 0x20
|
||||||
|
#define SVR4_F_TTY 0x40
|
||||||
|
|
||||||
|
#endif /* !_SVR4_FUSER_H_ */
|
85
sys/svr4/svr4_hrt.h
Normal file
85
sys/svr4/svr4_hrt.h
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_HRT_H_
|
||||||
|
#define _SVR4_HRT_H_
|
||||||
|
|
||||||
|
#define SVR4_HRT_CNTL 0
|
||||||
|
#define SVR4_HRT_CNTL_RES 0
|
||||||
|
#define SVR4_HRT_CNTL_TOFD 1
|
||||||
|
#define SVR4_HRT_CNTL_START 2
|
||||||
|
#define SVR4_HRT_CNTL_GET 3
|
||||||
|
|
||||||
|
#define SVR4_HRT_ALRM 1
|
||||||
|
#define SVR4_HRT_ALRM_DO 4
|
||||||
|
#define SVR4_HRT_ALRM_REP 5
|
||||||
|
#define SVR4_HRT_ALRM_TOD 6
|
||||||
|
#define SVR4_HRT_ALRM_FUTREP 7
|
||||||
|
#define SVR4_HRT_ALRM_TODREP 8
|
||||||
|
#define SVR4_HRT_ALRM_PEND 9
|
||||||
|
|
||||||
|
#define SVR4_HRT_SLP 2
|
||||||
|
#define SVR4_HRT_SLP_INT 10
|
||||||
|
#define SVR4_HRT_SLP_TOD 11
|
||||||
|
|
||||||
|
#define SVR4_HRT_BSD 12
|
||||||
|
#define SVR4_HRT_BSD_PEND 13
|
||||||
|
#define SVR4_HRT_BSD_REP1 14
|
||||||
|
#define SVR4_HRT_BSD_REP2 15
|
||||||
|
#define SVR4_HRT_BSD_CANCEL 16
|
||||||
|
|
||||||
|
#define SVR4_HRT_CAN 3
|
||||||
|
|
||||||
|
#define SVR4_HRT_SEC 1
|
||||||
|
#define SVR4_HRT_MSEC 1000
|
||||||
|
#define SVR4_HRT_USEC 1000000
|
||||||
|
#define SVR4_HRT_NSEC 1000000000
|
||||||
|
|
||||||
|
#define SVR4_HRT_TRUNC 0
|
||||||
|
#define SVR4_HRT_RND 1
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u_long i_word1;
|
||||||
|
u_long i_word2;
|
||||||
|
int i_clock;
|
||||||
|
} svr4_hrt_interval_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u_long h_sec;
|
||||||
|
long h_rem;
|
||||||
|
u_long h_res;
|
||||||
|
} svr4_hrt_time_t;
|
||||||
|
|
||||||
|
#define SVR4_HRT_DONE 1
|
||||||
|
#define SVR4_HRT_ERROR 2
|
||||||
|
|
||||||
|
#define SVR4_HRT_CLK_STD 1
|
||||||
|
#define SVR4_HRT_CLK_USERVIRT 2
|
||||||
|
#define SVR4_HRT_CLK_PROCVIRT 4
|
||||||
|
|
||||||
|
#endif /* !_SVR4_HRT_H_ */
|
167
sys/svr4/svr4_ioctl.c
Normal file
167
sys/svr4/svr4_ioctl.c
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/tty.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/socketvar.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_stropts.h>
|
||||||
|
#include <svr4/svr4_ioctl.h>
|
||||||
|
#include <svr4/svr4_termios.h>
|
||||||
|
#include <svr4/svr4_ttold.h>
|
||||||
|
#include <svr4/svr4_filio.h>
|
||||||
|
#include <svr4/svr4_sockio.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
static void svr4_decode_cmd __P((u_long, char *, char *, int *, int *));
|
||||||
|
/*
|
||||||
|
* Decode an ioctl command symbolically
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
svr4_decode_cmd(cmd, dir, c, num, argsiz)
|
||||||
|
u_long cmd;
|
||||||
|
char *dir, *c;
|
||||||
|
int *num, *argsiz;
|
||||||
|
{
|
||||||
|
if (cmd & SVR4_IOC_VOID)
|
||||||
|
*dir++ = 'V';
|
||||||
|
if (cmd & SVR4_IOC_IN)
|
||||||
|
*dir++ = 'R';
|
||||||
|
if (cmd & SVR4_IOC_OUT)
|
||||||
|
*dir++ = 'W';
|
||||||
|
*dir = '\0';
|
||||||
|
if (cmd & SVR4_IOC_INOUT)
|
||||||
|
*argsiz = (cmd >> 16) & 0xff;
|
||||||
|
else
|
||||||
|
*argsiz = -1;
|
||||||
|
|
||||||
|
*c = (cmd >> 8) & 0xff;
|
||||||
|
*num = cmd & 0xff;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_ioctl(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_ioctl_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
struct file *fp;
|
||||||
|
struct filedesc *fdp;
|
||||||
|
u_long cmd;
|
||||||
|
int (*fun) __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
#ifdef DEBUG_SVR4
|
||||||
|
char dir[4];
|
||||||
|
char c;
|
||||||
|
int num;
|
||||||
|
int argsiz;
|
||||||
|
|
||||||
|
svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz);
|
||||||
|
|
||||||
|
DPRINTF(("svr4_ioctl[%x](%d, _IO%s(%c, %d, %d), %p);\n", SCARG(uap, com), SCARG(uap, fd),
|
||||||
|
dir, c, num, argsiz, SCARG(uap, data)));
|
||||||
|
#endif
|
||||||
|
retval = p->p_retval;
|
||||||
|
fdp = p->p_fd;
|
||||||
|
cmd = SCARG(uap, com);
|
||||||
|
|
||||||
|
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
|
||||||
|
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
|
||||||
|
return EBADF;
|
||||||
|
|
||||||
|
if ((fp->f_flag & (FREAD | FWRITE)) == 0)
|
||||||
|
return EBADF;
|
||||||
|
|
||||||
|
#if defined(DEBUG_SVR4)
|
||||||
|
if (fp->f_type == DTYPE_SOCKET) {
|
||||||
|
struct socket *so = fp->f_data;
|
||||||
|
DPRINTF(("<<< IN: so_state = 0x%x\n", so->so_state));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (cmd & 0xff00) {
|
||||||
|
case SVR4_tIOC:
|
||||||
|
DPRINTF(("ttold\n"));
|
||||||
|
fun = svr4_ttold_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_TIOC:
|
||||||
|
DPRINTF(("term\n"));
|
||||||
|
fun = svr4_term_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_STR:
|
||||||
|
DPRINTF(("stream\n"));
|
||||||
|
fun = svr4_stream_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_FIOC:
|
||||||
|
DPRINTF(("file\n"));
|
||||||
|
fun = svr4_fil_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SIOC:
|
||||||
|
DPRINTF(("socket\n"));
|
||||||
|
fun = svr4_sock_ioctl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_XIOC:
|
||||||
|
/* We do not support those */
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Unimplemented ioctl %lx\n", cmd));
|
||||||
|
return 0; /* XXX: really ENOSYS */
|
||||||
|
}
|
||||||
|
#if defined(DEBUG_SVR4)
|
||||||
|
if (fp->f_type == DTYPE_SOCKET) {
|
||||||
|
struct socket *so = fp->f_data;
|
||||||
|
DPRINTF((">>> OUT: so_state = 0x%x\n", so->so_state));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return (*fun)(fp, p, retval, SCARG(uap, fd), cmd, SCARG(uap, data));
|
||||||
|
}
|
60
sys/svr4/svr4_ioctl.h
Normal file
60
sys/svr4/svr4_ioctl.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_IOCTL_H_
|
||||||
|
#define _SVR4_IOCTL_H_
|
||||||
|
|
||||||
|
#define SVR4_IOC_VOID 0x20000000
|
||||||
|
#define SVR4_IOC_OUT 0x40000000
|
||||||
|
#define SVR4_IOC_IN 0x80000000
|
||||||
|
#define SVR4_IOC_INOUT (SVR4_IOC_IN|SVR4_IOC_OUT)
|
||||||
|
|
||||||
|
#define SVR4_IOC(inout,group,num,len) \
|
||||||
|
(inout | ((len & 0xff) << 16) | ((group) << 8) | (num))
|
||||||
|
|
||||||
|
#define SVR4_XIOC ('X' << 8)
|
||||||
|
|
||||||
|
#define SVR4_IO(g,n) SVR4_IOC(SVR4_IOC_VOID, (g), (n), 0)
|
||||||
|
#define SVR4_IOR(g,n,t) SVR4_IOC(SVR4_IOC_OUT, (g), (n), sizeof(t))
|
||||||
|
#define SVR4_IOW(g,n,t) SVR4_IOC(SVR4_IOC_IN, (g), (n), sizeof(t))
|
||||||
|
#define SVR4_IOWR(g,n,t) SVR4_IOC(SVR4_IOC_INOUT,(g), (n), sizeof(t))
|
||||||
|
|
||||||
|
int svr4_stream_ti_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_stream_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_term_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_ttold_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_fil_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
int svr4_sock_ioctl __P((struct file *, struct proc *, register_t *,
|
||||||
|
int, u_long, caddr_t));
|
||||||
|
|
||||||
|
#endif /* !_SVR4_IOCTL_H_ */
|
831
sys/svr4/svr4_ipc.c
Normal file
831
sys/svr4/svr4_ipc.c
Normal file
|
@ -0,0 +1,831 @@
|
||||||
|
/*
|
||||||
|
* Derived from:
|
||||||
|
* $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Original copyright:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Christos Zoulas.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions of this code have been derived from software contributed
|
||||||
|
* to the FreeBSD Project by Mark Newton.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mark Newton
|
||||||
|
* 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. 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.
|
||||||
|
*
|
||||||
|
* XXX- This code is presently a no-op on FreeBSD (and isn't compiled due
|
||||||
|
* to preprocessor conditionals). A nice project for a kernel hacking
|
||||||
|
* novice might be to MakeItGo, but I have more important fish to fry
|
||||||
|
* at present.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/msg.h>
|
||||||
|
#include <sys/sem.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_ipc.h>
|
||||||
|
|
||||||
|
#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
|
||||||
|
static void svr4_to_bsd_ipc_perm __P((const struct svr4_ipc_perm *,
|
||||||
|
struct ipc_perm *));
|
||||||
|
static void bsd_to_svr4_ipc_perm __P((const struct ipc_perm *,
|
||||||
|
struct svr4_ipc_perm *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVSEM
|
||||||
|
static void bsd_to_svr4_semid_ds __P((const struct semid_ds *,
|
||||||
|
struct svr4_semid_ds *));
|
||||||
|
static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *,
|
||||||
|
struct semid_ds *));
|
||||||
|
static int svr4_setsemun __P((caddr_t *sgp, union semun **argp,
|
||||||
|
union semun *usp));
|
||||||
|
static int svr4_semop __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_semget __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_semctl __P((struct proc *, void *, register_t *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVMSG
|
||||||
|
static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *,
|
||||||
|
struct svr4_msqid_ds *));
|
||||||
|
static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *,
|
||||||
|
struct msqid_ds *));
|
||||||
|
static int svr4_msgsnd __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_msgrcv __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_msgget __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_msgctl __P((struct proc *, void *, register_t *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVSHM
|
||||||
|
static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *,
|
||||||
|
struct svr4_shmid_ds *));
|
||||||
|
static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *,
|
||||||
|
struct shmid_ds *));
|
||||||
|
static int svr4_shmat __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_shmdt __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_shmget __P((struct proc *, void *, register_t *));
|
||||||
|
static int svr4_shmctl __P((struct proc *, void *, register_t *));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_ipc_perm(spp, bpp)
|
||||||
|
const struct svr4_ipc_perm *spp;
|
||||||
|
struct ipc_perm *bpp;
|
||||||
|
{
|
||||||
|
bpp->key = spp->key;
|
||||||
|
bpp->uid = spp->uid;
|
||||||
|
bpp->gid = spp->gid;
|
||||||
|
bpp->cuid = spp->cuid;
|
||||||
|
bpp->cgid = spp->cgid;
|
||||||
|
bpp->mode = spp->mode;
|
||||||
|
bpp->seq = spp->seq;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_ipc_perm(bpp, spp)
|
||||||
|
const struct ipc_perm *bpp;
|
||||||
|
struct svr4_ipc_perm *spp;
|
||||||
|
{
|
||||||
|
spp->key = bpp->key;
|
||||||
|
spp->uid = bpp->uid;
|
||||||
|
spp->gid = bpp->gid;
|
||||||
|
spp->cuid = bpp->cuid;
|
||||||
|
spp->cgid = bpp->cgid;
|
||||||
|
spp->mode = bpp->mode;
|
||||||
|
spp->seq = bpp->seq;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVSEM
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_semid_ds(bds, sds)
|
||||||
|
const struct semid_ds *bds;
|
||||||
|
struct svr4_semid_ds *sds;
|
||||||
|
{
|
||||||
|
bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
|
||||||
|
sds->sem_base = (struct svr4_sem *) bds->sem_base;
|
||||||
|
sds->sem_nsems = bds->sem_nsems;
|
||||||
|
sds->sem_otime = bds->sem_otime;
|
||||||
|
sds->sem_pad1 = bds->sem_pad1;
|
||||||
|
sds->sem_ctime = bds->sem_ctime;
|
||||||
|
sds->sem_pad2 = bds->sem_pad2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_semid_ds(sds, bds)
|
||||||
|
const struct svr4_semid_ds *sds;
|
||||||
|
struct semid_ds *bds;
|
||||||
|
{
|
||||||
|
svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
|
||||||
|
bds->sem_base = (struct sem *) bds->sem_base;
|
||||||
|
bds->sem_nsems = sds->sem_nsems;
|
||||||
|
bds->sem_otime = sds->sem_otime;
|
||||||
|
bds->sem_pad1 = sds->sem_pad1;
|
||||||
|
bds->sem_ctime = sds->sem_ctime;
|
||||||
|
bds->sem_pad2 = sds->sem_pad2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_setsemun(sgp, argp, usp)
|
||||||
|
caddr_t *sgp;
|
||||||
|
union semun **argp;
|
||||||
|
union semun *usp;
|
||||||
|
{
|
||||||
|
*argp = stackgap_alloc(sgp, sizeof(union semun));
|
||||||
|
return copyout((caddr_t)usp, *argp, sizeof(union semun));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_semctl_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) semid;
|
||||||
|
syscallarg(int) semnum;
|
||||||
|
syscallarg(int) cmd;
|
||||||
|
syscallarg(union semun) arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_semctl(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
struct svr4_sys_semctl_args *uap = v;
|
||||||
|
struct sys___semctl_args ap;
|
||||||
|
struct svr4_semid_ds ss;
|
||||||
|
struct semid_ds bs, *bsp;
|
||||||
|
caddr_t sg = stackgap_init(p->p_emul);
|
||||||
|
|
||||||
|
SCARG(&ap, semid) = SCARG(uap, semid);
|
||||||
|
SCARG(&ap, semnum) = SCARG(uap, semnum);
|
||||||
|
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_SEM_GETZCNT:
|
||||||
|
case SVR4_SEM_GETNCNT:
|
||||||
|
case SVR4_SEM_GETPID:
|
||||||
|
case SVR4_SEM_GETVAL:
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_SEM_GETZCNT:
|
||||||
|
SCARG(&ap, cmd) = GETZCNT;
|
||||||
|
break;
|
||||||
|
case SVR4_SEM_GETNCNT:
|
||||||
|
SCARG(&ap, cmd) = GETNCNT;
|
||||||
|
break;
|
||||||
|
case SVR4_SEM_GETPID:
|
||||||
|
SCARG(&ap, cmd) = GETPID;
|
||||||
|
break;
|
||||||
|
case SVR4_SEM_GETVAL:
|
||||||
|
SCARG(&ap, cmd) = GETVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_SEM_SETVAL:
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
SCARG(&ap, cmd) = SETVAL;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_SEM_GETALL:
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
SCARG(&ap, cmd) = GETVAL;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_SEM_SETALL:
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
SCARG(&ap, cmd) = SETVAL;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_IPC_STAT:
|
||||||
|
SCARG(&ap, cmd) = IPC_STAT;
|
||||||
|
bsp = stackgap_alloc(&sg, sizeof(bs));
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg),
|
||||||
|
(union semun *)&bsp);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
if ((error = sys___semctl(p, &ap, retval)) != 0)
|
||||||
|
return error;
|
||||||
|
error = copyin((caddr_t)bsp, (caddr_t)&bs, sizeof(bs));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_semid_ds(&bs, &ss);
|
||||||
|
return copyout(&ss, SCARG(uap, arg).buf, sizeof(ss));
|
||||||
|
|
||||||
|
case SVR4_IPC_SET:
|
||||||
|
SCARG(&ap, cmd) = IPC_SET;
|
||||||
|
bsp = stackgap_alloc(&sg, sizeof(bs));
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg),
|
||||||
|
(union semun *)&bsp);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
error = copyin(SCARG(uap, arg).buf, (caddr_t) &ss, sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_semid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, bsp, sizeof(bs));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
SCARG(&ap, cmd) = IPC_RMID;
|
||||||
|
bsp = stackgap_alloc(&sg, sizeof(bs));
|
||||||
|
error = svr4_setsemun(&sg, &SCARG(&ap, arg),
|
||||||
|
(union semun *)&bsp);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
error = copyin(SCARG(uap, arg).buf, &ss, sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_semid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, bsp, sizeof(bs));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return sys___semctl(p, &ap, retval);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_semget_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(svr4_key_t) key;
|
||||||
|
syscallarg(int) nsems;
|
||||||
|
syscallarg(int) semflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_semget(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_semget_args *uap = v;
|
||||||
|
struct sys_semget_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, key) = SCARG(uap, key);
|
||||||
|
SCARG(&ap, nsems) = SCARG(uap, nsems);
|
||||||
|
SCARG(&ap, semflg) = SCARG(uap, semflg);
|
||||||
|
|
||||||
|
return sys_semget(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_semop_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) semid;
|
||||||
|
syscallarg(struct svr4_sembuf *) sops;
|
||||||
|
syscallarg(u_int) nsops;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_semop(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_semop_args *uap = v;
|
||||||
|
struct sys_semop_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, semid) = SCARG(uap, semid);
|
||||||
|
/* These are the same */
|
||||||
|
SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops);
|
||||||
|
SCARG(&ap, nsops) = SCARG(uap, nsops);
|
||||||
|
|
||||||
|
return sys_semop(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_semsys(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_semsys_args *uap = v;
|
||||||
|
|
||||||
|
DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what)));
|
||||||
|
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case SVR4_semctl:
|
||||||
|
return svr4_semctl(p, v, retval);
|
||||||
|
case SVR4_semget:
|
||||||
|
return svr4_semget(p, v, retval);
|
||||||
|
case SVR4_semop:
|
||||||
|
return svr4_semop(p, v, retval);
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVMSG
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_msqid_ds(bds, sds)
|
||||||
|
const struct msqid_ds *bds;
|
||||||
|
struct svr4_msqid_ds *sds;
|
||||||
|
{
|
||||||
|
bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
|
||||||
|
sds->msg_first = (struct svr4_msg *) bds->msg_first;
|
||||||
|
sds->msg_last = (struct svr4_msg *) bds->msg_last;
|
||||||
|
sds->msg_cbytes = bds->msg_cbytes;
|
||||||
|
sds->msg_qnum = bds->msg_qnum;
|
||||||
|
sds->msg_qbytes = bds->msg_qbytes;
|
||||||
|
sds->msg_lspid = bds->msg_lspid;
|
||||||
|
sds->msg_lrpid = bds->msg_lrpid;
|
||||||
|
sds->msg_stime = bds->msg_stime;
|
||||||
|
sds->msg_pad1 = bds->msg_pad1;
|
||||||
|
sds->msg_rtime = bds->msg_rtime;
|
||||||
|
sds->msg_pad2 = bds->msg_pad2;
|
||||||
|
sds->msg_ctime = bds->msg_ctime;
|
||||||
|
sds->msg_pad3 = bds->msg_pad3;
|
||||||
|
|
||||||
|
/* use the padding for the rest of the fields */
|
||||||
|
{
|
||||||
|
const short *pad = (const short *) bds->msg_pad4;
|
||||||
|
sds->msg_cv = pad[0];
|
||||||
|
sds->msg_qnum_cv = pad[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_msqid_ds(sds, bds)
|
||||||
|
const struct svr4_msqid_ds *sds;
|
||||||
|
struct msqid_ds *bds;
|
||||||
|
{
|
||||||
|
svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
|
||||||
|
bds->msg_first = (struct msg *) sds->msg_first;
|
||||||
|
bds->msg_last = (struct msg *) sds->msg_last;
|
||||||
|
bds->msg_cbytes = sds->msg_cbytes;
|
||||||
|
bds->msg_qnum = sds->msg_qnum;
|
||||||
|
bds->msg_qbytes = sds->msg_qbytes;
|
||||||
|
bds->msg_lspid = sds->msg_lspid;
|
||||||
|
bds->msg_lrpid = sds->msg_lrpid;
|
||||||
|
bds->msg_stime = sds->msg_stime;
|
||||||
|
bds->msg_pad1 = sds->msg_pad1;
|
||||||
|
bds->msg_rtime = sds->msg_rtime;
|
||||||
|
bds->msg_pad2 = sds->msg_pad2;
|
||||||
|
bds->msg_ctime = sds->msg_ctime;
|
||||||
|
bds->msg_pad3 = sds->msg_pad3;
|
||||||
|
|
||||||
|
/* use the padding for the rest of the fields */
|
||||||
|
{
|
||||||
|
short *pad = (short *) bds->msg_pad4;
|
||||||
|
pad[0] = sds->msg_cv;
|
||||||
|
pad[1] = sds->msg_qnum_cv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_msgsnd_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) msqid;
|
||||||
|
syscallarg(void *) msgp;
|
||||||
|
syscallarg(size_t) msgsz;
|
||||||
|
syscallarg(int) msgflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_msgsnd(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_msgsnd_args *uap = v;
|
||||||
|
struct sys_msgsnd_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
||||||
|
SCARG(&ap, msgp) = SCARG(uap, msgp);
|
||||||
|
SCARG(&ap, msgsz) = SCARG(uap, msgsz);
|
||||||
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
||||||
|
|
||||||
|
return sys_msgsnd(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_msgrcv_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) msqid;
|
||||||
|
syscallarg(void *) msgp;
|
||||||
|
syscallarg(size_t) msgsz;
|
||||||
|
syscallarg(long) msgtyp;
|
||||||
|
syscallarg(int) msgflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_msgrcv(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_msgrcv_args *uap = v;
|
||||||
|
struct sys_msgrcv_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
||||||
|
SCARG(&ap, msgp) = SCARG(uap, msgp);
|
||||||
|
SCARG(&ap, msgsz) = SCARG(uap, msgsz);
|
||||||
|
SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
|
||||||
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
||||||
|
|
||||||
|
return sys_msgrcv(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_msgget_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(svr4_key_t) key;
|
||||||
|
syscallarg(int) msgflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_msgget(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_msgget_args *uap = v;
|
||||||
|
struct sys_msgget_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, key) = SCARG(uap, key);
|
||||||
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
||||||
|
|
||||||
|
return sys_msgget(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_msgctl_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) msqid;
|
||||||
|
syscallarg(int) cmd;
|
||||||
|
syscallarg(struct svr4_msqid_ds *) buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_msgctl(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
struct svr4_sys_msgctl_args *uap = v;
|
||||||
|
struct sys_msgctl_args ap;
|
||||||
|
struct svr4_msqid_ds ss;
|
||||||
|
struct msqid_ds bs;
|
||||||
|
caddr_t sg = stackgap_init(p->p_emul);
|
||||||
|
|
||||||
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
||||||
|
SCARG(&ap, cmd) = SCARG(uap, cmd);
|
||||||
|
SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs));
|
||||||
|
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_IPC_STAT:
|
||||||
|
SCARG(&ap, cmd) = IPC_STAT;
|
||||||
|
if ((error = sys_msgctl(p, &ap, retval)) != 0)
|
||||||
|
return error;
|
||||||
|
error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_msqid_ds(&bs, &ss);
|
||||||
|
return copyout(&ss, SCARG(uap, buf), sizeof ss);
|
||||||
|
|
||||||
|
case SVR4_IPC_SET:
|
||||||
|
SCARG(&ap, cmd) = IPC_SET;
|
||||||
|
error = copyin(SCARG(uap, buf), &ss, sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_msqid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return sys_msgctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
SCARG(&ap, cmd) = IPC_RMID;
|
||||||
|
error = copyin(SCARG(uap, buf), &ss, sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_msqid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
return sys_msgctl(p, &ap, retval);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_msgsys(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_msgsys_args *uap = v;
|
||||||
|
|
||||||
|
DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what)));
|
||||||
|
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case SVR4_msgsnd:
|
||||||
|
return svr4_msgsnd(p, v, retval);
|
||||||
|
case SVR4_msgrcv:
|
||||||
|
return svr4_msgrcv(p, v, retval);
|
||||||
|
case SVR4_msgget:
|
||||||
|
return svr4_msgget(p, v, retval);
|
||||||
|
case SVR4_msgctl:
|
||||||
|
return svr4_msgctl(p, v, retval);
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYSVSHM
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_shmid_ds(bds, sds)
|
||||||
|
const struct shmid_ds *bds;
|
||||||
|
struct svr4_shmid_ds *sds;
|
||||||
|
{
|
||||||
|
bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm);
|
||||||
|
sds->shm_segsz = bds->shm_segsz;
|
||||||
|
sds->shm_lkcnt = 0;
|
||||||
|
sds->shm_lpid = bds->shm_lpid;
|
||||||
|
sds->shm_cpid = bds->shm_cpid;
|
||||||
|
sds->shm_amp = bds->shm_internal;
|
||||||
|
sds->shm_nattch = bds->shm_nattch;
|
||||||
|
sds->shm_cnattch = 0;
|
||||||
|
sds->shm_atime = bds->shm_atime;
|
||||||
|
sds->shm_pad1 = 0;
|
||||||
|
sds->shm_dtime = bds->shm_dtime;
|
||||||
|
sds->shm_pad2 = 0;
|
||||||
|
sds->shm_ctime = bds->shm_ctime;
|
||||||
|
sds->shm_pad3 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
svr4_to_bsd_shmid_ds(sds, bds)
|
||||||
|
const struct svr4_shmid_ds *sds;
|
||||||
|
struct shmid_ds *bds;
|
||||||
|
{
|
||||||
|
svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
|
||||||
|
bds->shm_segsz = sds->shm_segsz;
|
||||||
|
bds->shm_lpid = sds->shm_lpid;
|
||||||
|
bds->shm_cpid = sds->shm_cpid;
|
||||||
|
bds->shm_internal = sds->shm_amp;
|
||||||
|
bds->shm_nattch = sds->shm_nattch;
|
||||||
|
bds->shm_atime = sds->shm_atime;
|
||||||
|
bds->shm_dtime = sds->shm_dtime;
|
||||||
|
bds->shm_ctime = sds->shm_ctime;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_shmat_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) shmid;
|
||||||
|
syscallarg(void *) shmaddr;
|
||||||
|
syscallarg(int) shmflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_shmat(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmat_args *uap = v;
|
||||||
|
struct sys_shmat_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, shmid) = SCARG(uap, shmid);
|
||||||
|
SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
|
||||||
|
SCARG(&ap, shmflg) = SCARG(uap, shmflg);
|
||||||
|
|
||||||
|
return sys_shmat(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_shmdt_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(void *) shmaddr;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_shmdt(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmdt_args *uap = v;
|
||||||
|
struct sys_shmdt_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
|
||||||
|
|
||||||
|
return sys_shmdt(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_shmget_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(key_t) key;
|
||||||
|
syscallarg(int) size;
|
||||||
|
syscallarg(int) shmflg;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_shmget(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmget_args *uap = v;
|
||||||
|
struct sys_shmget_args ap;
|
||||||
|
|
||||||
|
SCARG(&ap, key) = SCARG(uap, key);
|
||||||
|
SCARG(&ap, size) = SCARG(uap, size);
|
||||||
|
SCARG(&ap, shmflg) = SCARG(uap, shmflg);
|
||||||
|
|
||||||
|
return sys_shmget(p, &ap, retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct svr4_sys_shmctl_args {
|
||||||
|
syscallarg(int) what;
|
||||||
|
syscallarg(int) shmid;
|
||||||
|
syscallarg(int) cmd;
|
||||||
|
syscallarg(struct svr4_shmid_ds *) buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_shmctl(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmctl_args *uap = v;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init(p->p_emul);
|
||||||
|
struct sys_shmctl_args ap;
|
||||||
|
struct shmid_ds bs;
|
||||||
|
struct svr4_shmid_ds ss;
|
||||||
|
|
||||||
|
SCARG(&ap, shmid) = SCARG(uap, shmid);
|
||||||
|
|
||||||
|
if (SCARG(uap, buf) != NULL) {
|
||||||
|
SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof (struct shmid_ds));
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_IPC_SET:
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
case SVR4_SHM_LOCK:
|
||||||
|
case SVR4_SHM_UNLOCK:
|
||||||
|
error = copyin(SCARG(uap, buf), (caddr_t) &ss,
|
||||||
|
sizeof ss);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_shmid_ds(&ss, &bs);
|
||||||
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SCARG(&ap, buf) = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_IPC_STAT:
|
||||||
|
SCARG(&ap, cmd) = IPC_STAT;
|
||||||
|
if ((error = sys_shmctl(p, &ap, retval)) != 0)
|
||||||
|
return error;
|
||||||
|
if (SCARG(uap, buf) == NULL)
|
||||||
|
return 0;
|
||||||
|
error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_shmid_ds(&bs, &ss);
|
||||||
|
return copyout(&ss, SCARG(uap, buf), sizeof ss);
|
||||||
|
|
||||||
|
case SVR4_IPC_SET:
|
||||||
|
SCARG(&ap, cmd) = IPC_SET;
|
||||||
|
return sys_shmctl(p, &ap, retval);
|
||||||
|
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
case SVR4_SHM_LOCK:
|
||||||
|
case SVR4_SHM_UNLOCK:
|
||||||
|
switch (SCARG(uap, cmd)) {
|
||||||
|
case SVR4_IPC_RMID:
|
||||||
|
SCARG(&ap, cmd) = IPC_RMID;
|
||||||
|
break;
|
||||||
|
case SVR4_SHM_LOCK:
|
||||||
|
SCARG(&ap, cmd) = SHM_LOCK;
|
||||||
|
break;
|
||||||
|
case SVR4_SHM_UNLOCK:
|
||||||
|
SCARG(&ap, cmd) = SHM_UNLOCK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
return sys_shmctl(p, &ap, retval);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_shmsys(p, v, retval)
|
||||||
|
struct proc *p;
|
||||||
|
void *v;
|
||||||
|
register_t *retval;
|
||||||
|
{
|
||||||
|
struct svr4_sys_shmsys_args *uap = v;
|
||||||
|
|
||||||
|
DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what)));
|
||||||
|
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case SVR4_shmat:
|
||||||
|
return svr4_shmat(p, v, retval);
|
||||||
|
case SVR4_shmdt:
|
||||||
|
return svr4_shmdt(p, v, retval);
|
||||||
|
case SVR4_shmget:
|
||||||
|
return svr4_shmget(p, v, retval);
|
||||||
|
case SVR4_shmctl:
|
||||||
|
return svr4_shmctl(p, v, retval);
|
||||||
|
default:
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* SYSVSHM */
|
174
sys/svr4/svr4_ipc.h
Normal file
174
sys/svr4/svr4_ipc.h
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1995 Christos Zoulas. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_IPC_H_
|
||||||
|
#define _SVR4_IPC_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* General IPC
|
||||||
|
*/
|
||||||
|
#define SVR4_IPC_RMID 10
|
||||||
|
#define SVR4_IPC_SET 11
|
||||||
|
#define SVR4_IPC_STAT 12
|
||||||
|
|
||||||
|
struct svr4_ipc_perm {
|
||||||
|
svr4_uid_t uid;
|
||||||
|
svr4_gid_t gid;
|
||||||
|
svr4_uid_t cuid;
|
||||||
|
svr4_gid_t cgid;
|
||||||
|
svr4_mode_t mode;
|
||||||
|
u_long seq;
|
||||||
|
svr4_key_t key;
|
||||||
|
long pad[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Message queues
|
||||||
|
*/
|
||||||
|
#define SVR4_msgget 0
|
||||||
|
#define SVR4_msgctl 1
|
||||||
|
#define SVR4_msgrcv 2
|
||||||
|
#define SVR4_msgsnd 3
|
||||||
|
|
||||||
|
struct svr4_msg {
|
||||||
|
struct svr4_msg *msg_next;
|
||||||
|
long msg_type;
|
||||||
|
u_short msg_ts;
|
||||||
|
short msg_spot;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_msqid_ds {
|
||||||
|
struct svr4_ipc_perm msg_perm;
|
||||||
|
struct svr4_msg *msg_first;
|
||||||
|
struct svr4_msg *msg_last;
|
||||||
|
u_long msg_cbytes;
|
||||||
|
u_long msg_qnum;
|
||||||
|
u_long msg_qbytes;
|
||||||
|
svr4_pid_t msg_lspid;
|
||||||
|
svr4_pid_t msg_lrpid;
|
||||||
|
svr4_time_t msg_stime;
|
||||||
|
long msg_pad1;
|
||||||
|
svr4_time_t msg_rtime;
|
||||||
|
long msg_pad2;
|
||||||
|
svr4_time_t msg_ctime;
|
||||||
|
long msg_pad3;
|
||||||
|
short msg_cv;
|
||||||
|
short msg_qnum_cv;
|
||||||
|
long msg_pad4[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_msgbuf {
|
||||||
|
long mtype; /* message type */
|
||||||
|
char mtext[1]; /* message text */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_msginfo {
|
||||||
|
int msgmap;
|
||||||
|
int msgmax;
|
||||||
|
int msgmnb;
|
||||||
|
int msgmni;
|
||||||
|
int msgssz;
|
||||||
|
int msgtql;
|
||||||
|
u_short msgseg;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shared memory
|
||||||
|
*/
|
||||||
|
#define SVR4_shmat 0
|
||||||
|
#define SVR4_shmctl 1
|
||||||
|
#define SVR4_shmdt 2
|
||||||
|
#define SVR4_shmget 3
|
||||||
|
|
||||||
|
/* shmctl() operations */
|
||||||
|
#define SVR4_SHM_LOCK 3
|
||||||
|
#define SVR4_SHM_UNLOCK 4
|
||||||
|
|
||||||
|
struct svr4_shmid_ds {
|
||||||
|
struct svr4_ipc_perm shm_perm;
|
||||||
|
int shm_segsz;
|
||||||
|
void *shm_amp;
|
||||||
|
u_short shm_lkcnt;
|
||||||
|
svr4_pid_t shm_lpid;
|
||||||
|
svr4_pid_t shm_cpid;
|
||||||
|
u_long shm_nattch;
|
||||||
|
u_long shm_cnattch;
|
||||||
|
svr4_time_t shm_atime;
|
||||||
|
long shm_pad1;
|
||||||
|
svr4_time_t shm_dtime;
|
||||||
|
long shm_pad2;
|
||||||
|
svr4_time_t shm_ctime;
|
||||||
|
long shm_pad3;
|
||||||
|
long shm_pad4[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Semaphores
|
||||||
|
*/
|
||||||
|
#define SVR4_semctl 0
|
||||||
|
#define SVR4_semget 1
|
||||||
|
#define SVR4_semop 2
|
||||||
|
|
||||||
|
/* semctl() operations */
|
||||||
|
#define SVR4_SEM_GETNCNT 3
|
||||||
|
#define SVR4_SEM_GETPID 4
|
||||||
|
#define SVR4_SEM_GETVAL 5
|
||||||
|
#define SVR4_SEM_GETALL 6
|
||||||
|
#define SVR4_SEM_GETZCNT 7
|
||||||
|
#define SVR4_SEM_SETVAL 8
|
||||||
|
#define SVR4_SEM_SETALL 9
|
||||||
|
|
||||||
|
struct svr4_sem {
|
||||||
|
u_short semval;
|
||||||
|
svr4_pid_t sempid;
|
||||||
|
u_short semncnt;
|
||||||
|
u_short semzcnt;
|
||||||
|
u_short semncnt_cv;
|
||||||
|
u_short semzcnt_cv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_semid_ds {
|
||||||
|
struct svr4_ipc_perm sem_perm;
|
||||||
|
struct svr4_sem *sem_base;
|
||||||
|
u_short sem_nsems;
|
||||||
|
svr4_time_t sem_otime;
|
||||||
|
long sem_pad1;
|
||||||
|
svr4_time_t sem_ctime;
|
||||||
|
long sem_pad2;
|
||||||
|
long sem_pad3[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_sembuf {
|
||||||
|
u_short sem_num;
|
||||||
|
short sem_op;
|
||||||
|
short sem_flg;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _SVR4_IPC_H */
|
1629
sys/svr4/svr4_misc.c
Normal file
1629
sys/svr4/svr4_misc.c
Normal file
File diff suppressed because it is too large
Load diff
45
sys/svr4/svr4_mman.h
Normal file
45
sys/svr4/svr4_mman.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1997 Todd Vierling
|
||||||
|
* 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. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_MMAN_H_
|
||||||
|
#define _SVR4_MMAN_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Commands and flags passed to memcntl().
|
||||||
|
* Most of them are the same as <sys/mman.h>, but we need the MC_
|
||||||
|
* memcntl command definitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SVR4_MC_SYNC 1
|
||||||
|
#define SVR4_MC_LOCK 2
|
||||||
|
#define SVR4_MC_UNLOCK 3
|
||||||
|
#define SVR4_MC_ADVISE 4
|
||||||
|
#define SVR4_MC_LOCKAS 5
|
||||||
|
#define SVR4_MC_UNLOCKAS 6
|
||||||
|
|
||||||
|
#endif /* !_SVR4_MMAN_H */
|
472
sys/svr4/svr4_proto.h
Normal file
472
sys/svr4/svr4_proto.h
Normal file
|
@ -0,0 +1,472 @@
|
||||||
|
/*
|
||||||
|
* System call prototypes.
|
||||||
|
*
|
||||||
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
|
* created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SYSPROTO_H_
|
||||||
|
#define _SVR4_SYSPROTO_H_
|
||||||
|
|
||||||
|
#include <sys/signal.h>
|
||||||
|
|
||||||
|
struct proc;
|
||||||
|
|
||||||
|
#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
|
||||||
|
0 : sizeof(register_t) - sizeof(t))
|
||||||
|
|
||||||
|
struct svr4_sys_open_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_wait_args {
|
||||||
|
int * status; char status_[PAD_(int *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_creat_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_execv_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
char ** argp; char argp_[PAD_(char **)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_time_args {
|
||||||
|
time_t * t; char t_[PAD_(time_t *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_mknod_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
int dev; char dev_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_break_args {
|
||||||
|
caddr_t nsize; char nsize_[PAD_(caddr_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_stat_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_stat * ub; char ub_[PAD_(struct svr4_stat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_alarm_args {
|
||||||
|
unsigned sec; char sec_[PAD_(unsigned)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fstat_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_stat * sb; char sb_[PAD_(struct svr4_stat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_pause_args {
|
||||||
|
register_t dummy;
|
||||||
|
};
|
||||||
|
struct svr4_sys_utime_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_utimbuf * ubuf; char ubuf_[PAD_(struct svr4_utimbuf *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_access_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_nice_args {
|
||||||
|
int prio; char prio_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_kill_args {
|
||||||
|
int pid; char pid_[PAD_(int)];
|
||||||
|
int signum; char signum_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_pgrpsys_args {
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
int pid; char pid_[PAD_(int)];
|
||||||
|
int pgid; char pgid_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_times_args {
|
||||||
|
struct tms * tp; char tp_[PAD_(struct tms *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_signal_args {
|
||||||
|
int signum; char signum_[PAD_(int)];
|
||||||
|
svr4_sig_t handler; char handler_[PAD_(svr4_sig_t)];
|
||||||
|
};
|
||||||
|
#if defined(NOTYET)
|
||||||
|
struct svr4_sys_msgsys_args {
|
||||||
|
int what; char what_[PAD_(int)];
|
||||||
|
int a2; char a2_[PAD_(int)];
|
||||||
|
int a3; char a3_[PAD_(int)];
|
||||||
|
int a4; char a4_[PAD_(int)];
|
||||||
|
int a5; char a5_[PAD_(int)];
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
struct svr4_sys_sysarch_args {
|
||||||
|
int op; char op_[PAD_(int)];
|
||||||
|
void * a1; char a1_[PAD_(void *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_ioctl_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
u_long com; char com_[PAD_(u_long)];
|
||||||
|
caddr_t data; char data_[PAD_(caddr_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_utssys_args {
|
||||||
|
void * a1; char a1_[PAD_(void *)];
|
||||||
|
void * a2; char a2_[PAD_(void *)];
|
||||||
|
int sel; char sel_[PAD_(int)];
|
||||||
|
void * a3; char a3_[PAD_(void *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_execve_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
char ** argp; char argp_[PAD_(char **)];
|
||||||
|
char ** envp; char envp_[PAD_(char **)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fcntl_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
char * arg; char arg_[PAD_(char *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_ulimit_args {
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
long newlimit; char newlimit_[PAD_(long)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getdents_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
char * buf; char buf_[PAD_(char *)];
|
||||||
|
int nbytes; char nbytes_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getmsg_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_strbuf * ctl; char ctl_[PAD_(struct svr4_strbuf *)];
|
||||||
|
struct svr4_strbuf * dat; char dat_[PAD_(struct svr4_strbuf *)];
|
||||||
|
int * flags; char flags_[PAD_(int *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_putmsg_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_strbuf * ctl; char ctl_[PAD_(struct svr4_strbuf *)];
|
||||||
|
struct svr4_strbuf * dat; char dat_[PAD_(struct svr4_strbuf *)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_poll_args {
|
||||||
|
struct pollfd * fds; char fds_[PAD_(struct pollfd *)];
|
||||||
|
unsigned int nfds; char nfds_[PAD_(unsigned int)];
|
||||||
|
int timeout; char timeout_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_lstat_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_stat * ub; char ub_[PAD_(struct svr4_stat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigprocmask_args {
|
||||||
|
int how; char how_[PAD_(int)];
|
||||||
|
svr4_sigset_t * set; char set_[PAD_(svr4_sigset_t *)];
|
||||||
|
svr4_sigset_t * oset; char oset_[PAD_(svr4_sigset_t *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigsuspend_args {
|
||||||
|
svr4_sigset_t * ss; char ss_[PAD_(svr4_sigset_t *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigaltstack_args {
|
||||||
|
struct svr4_sigaltstack * nss; char nss_[PAD_(struct svr4_sigaltstack *)];
|
||||||
|
struct svr4_sigaltstack * oss; char oss_[PAD_(struct svr4_sigaltstack *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigaction_args {
|
||||||
|
int signum; char signum_[PAD_(int)];
|
||||||
|
struct svr4_sigaction * nsa; char nsa_[PAD_(struct svr4_sigaction *)];
|
||||||
|
struct svr4_sigaction * osa; char osa_[PAD_(struct svr4_sigaction *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sigpending_args {
|
||||||
|
int what; char what_[PAD_(int)];
|
||||||
|
svr4_sigset_t * mask; char mask_[PAD_(svr4_sigset_t *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_context_args {
|
||||||
|
int func; char func_[PAD_(int)];
|
||||||
|
struct svr4_ucontext * uc; char uc_[PAD_(struct svr4_ucontext *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_statvfs_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_statvfs * fs; char fs_[PAD_(struct svr4_statvfs *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fstatvfs_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_statvfs * fs; char fs_[PAD_(struct svr4_statvfs *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_waitsys_args {
|
||||||
|
int grp; char grp_[PAD_(int)];
|
||||||
|
int id; char id_[PAD_(int)];
|
||||||
|
union svr4_siginfo * info; char info_[PAD_(union svr4_siginfo *)];
|
||||||
|
int options; char options_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_hrtsys_args {
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
int fun; char fun_[PAD_(int)];
|
||||||
|
int sub; char sub_[PAD_(int)];
|
||||||
|
void * rv1; char rv1_[PAD_(void *)];
|
||||||
|
void * rv2; char rv2_[PAD_(void *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_pathconf_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int name; char name_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_mmap_args {
|
||||||
|
caddr_t addr; char addr_[PAD_(caddr_t)];
|
||||||
|
svr4_size_t len; char len_[PAD_(svr4_size_t)];
|
||||||
|
int prot; char prot_[PAD_(int)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
svr4_off_t pos; char pos_[PAD_(svr4_off_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fpathconf_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
int name; char name_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_xstat_args {
|
||||||
|
int two; char two_[PAD_(int)];
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_xstat * ub; char ub_[PAD_(struct svr4_xstat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_lxstat_args {
|
||||||
|
int two; char two_[PAD_(int)];
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_xstat * ub; char ub_[PAD_(struct svr4_xstat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fxstat_args {
|
||||||
|
int two; char two_[PAD_(int)];
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_xstat * sb; char sb_[PAD_(struct svr4_xstat *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_xmknod_args {
|
||||||
|
int two; char two_[PAD_(int)];
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
svr4_mode_t mode; char mode_[PAD_(svr4_mode_t)];
|
||||||
|
svr4_dev_t dev; char dev_[PAD_(svr4_dev_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_setrlimit_args {
|
||||||
|
int which; char which_[PAD_(int)];
|
||||||
|
const struct svr4_rlimit * rlp; char rlp_[PAD_(const struct svr4_rlimit *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getrlimit_args {
|
||||||
|
int which; char which_[PAD_(int)];
|
||||||
|
struct svr4_rlimit * rlp; char rlp_[PAD_(struct svr4_rlimit *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_memcntl_args {
|
||||||
|
void * addr; char addr_[PAD_(void *)];
|
||||||
|
svr4_size_t len; char len_[PAD_(svr4_size_t)];
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
void * arg; char arg_[PAD_(void *)];
|
||||||
|
int attr; char attr_[PAD_(int)];
|
||||||
|
int mask; char mask_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_uname_args {
|
||||||
|
struct svr4_utsname * name; char name_[PAD_(struct svr4_utsname *)];
|
||||||
|
int dummy; char dummy_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sysconfig_args {
|
||||||
|
int name; char name_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_systeminfo_args {
|
||||||
|
int what; char what_[PAD_(int)];
|
||||||
|
char * buf; char buf_[PAD_(char *)];
|
||||||
|
long len; char len_[PAD_(long)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fchroot_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_utimes_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct timeval * tptr; char tptr_[PAD_(struct timeval *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_vhangup_args {
|
||||||
|
register_t dummy;
|
||||||
|
};
|
||||||
|
struct svr4_sys_gettimeofday_args {
|
||||||
|
struct timeval * tp; char tp_[PAD_(struct timeval *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_llseek_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
long offset1; char offset1_[PAD_(long)];
|
||||||
|
long offset2; char offset2_[PAD_(long)];
|
||||||
|
int whence; char whence_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_acl_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
int num; char num_[PAD_(int)];
|
||||||
|
struct svr4_aclent * buf; char buf_[PAD_(struct svr4_aclent *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_auditsys_args {
|
||||||
|
int code; char code_[PAD_(int)];
|
||||||
|
int a1; char a1_[PAD_(int)];
|
||||||
|
int a2; char a2_[PAD_(int)];
|
||||||
|
int a3; char a3_[PAD_(int)];
|
||||||
|
int a4; char a4_[PAD_(int)];
|
||||||
|
int a5; char a5_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_facl_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
int cmd; char cmd_[PAD_(int)];
|
||||||
|
int num; char num_[PAD_(int)];
|
||||||
|
struct svr4_aclent * buf; char buf_[PAD_(struct svr4_aclent *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_resolvepath_args {
|
||||||
|
const char * path; char path_[PAD_(const char *)];
|
||||||
|
char * buf; char buf_[PAD_(char *)];
|
||||||
|
size_t bufsiz; char bufsiz_[PAD_(size_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getdents64_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_dirent64 * dp; char dp_[PAD_(struct svr4_dirent64 *)];
|
||||||
|
int nbytes; char nbytes_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_mmap64_args {
|
||||||
|
void * addr; char addr_[PAD_(void *)];
|
||||||
|
svr4_size_t len; char len_[PAD_(svr4_size_t)];
|
||||||
|
int prot; char prot_[PAD_(int)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
svr4_off64_t pos; char pos_[PAD_(svr4_off64_t)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_stat64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_lstat64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fstat64_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_statvfs64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
struct svr4_statvfs64 * fs; char fs_[PAD_(struct svr4_statvfs64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_fstatvfs64_args {
|
||||||
|
int fd; char fd_[PAD_(int)];
|
||||||
|
struct svr4_statvfs64 * fs; char fs_[PAD_(struct svr4_statvfs64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_setrlimit64_args {
|
||||||
|
int which; char which_[PAD_(int)];
|
||||||
|
const struct svr4_rlimit64 * rlp; char rlp_[PAD_(const struct svr4_rlimit64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_getrlimit64_args {
|
||||||
|
int which; char which_[PAD_(int)];
|
||||||
|
struct svr4_rlimit64 * rlp; char rlp_[PAD_(struct svr4_rlimit64 *)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_creat64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_open64_args {
|
||||||
|
char * path; char path_[PAD_(char *)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
int mode; char mode_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_socket_args {
|
||||||
|
int domain; char domain_[PAD_(int)];
|
||||||
|
int type; char type_[PAD_(int)];
|
||||||
|
int protocol; char protocol_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_recv_args {
|
||||||
|
int s; char s_[PAD_(int)];
|
||||||
|
caddr_t buf; char buf_[PAD_(caddr_t)];
|
||||||
|
int len; char len_[PAD_(int)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_send_args {
|
||||||
|
int s; char s_[PAD_(int)];
|
||||||
|
caddr_t buf; char buf_[PAD_(caddr_t)];
|
||||||
|
int len; char len_[PAD_(int)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
};
|
||||||
|
struct svr4_sys_sendto_args {
|
||||||
|
int s; char s_[PAD_(int)];
|
||||||
|
const void * buf; char buf_[PAD_(const void *)];
|
||||||
|
size_t len; char len_[PAD_(size_t)];
|
||||||
|
int flags; char flags_[PAD_(int)];
|
||||||
|
const struct sockaddr * to; char to_[PAD_(const struct sockaddr *)];
|
||||||
|
int tolen; char tolen_[PAD_(int)];
|
||||||
|
};
|
||||||
|
int svr4_sys_open __P((struct proc *, struct svr4_sys_open_args *));
|
||||||
|
int svr4_sys_wait __P((struct proc *, struct svr4_sys_wait_args *));
|
||||||
|
int svr4_sys_creat __P((struct proc *, struct svr4_sys_creat_args *));
|
||||||
|
int svr4_sys_execv __P((struct proc *, struct svr4_sys_execv_args *));
|
||||||
|
int svr4_sys_time __P((struct proc *, struct svr4_sys_time_args *));
|
||||||
|
int svr4_sys_mknod __P((struct proc *, struct svr4_sys_mknod_args *));
|
||||||
|
int svr4_sys_break __P((struct proc *, struct svr4_sys_break_args *));
|
||||||
|
int svr4_sys_stat __P((struct proc *, struct svr4_sys_stat_args *));
|
||||||
|
int svr4_sys_alarm __P((struct proc *, struct svr4_sys_alarm_args *));
|
||||||
|
int svr4_sys_fstat __P((struct proc *, struct svr4_sys_fstat_args *));
|
||||||
|
int svr4_sys_pause __P((struct proc *, struct svr4_sys_pause_args *));
|
||||||
|
int svr4_sys_utime __P((struct proc *, struct svr4_sys_utime_args *));
|
||||||
|
int svr4_sys_access __P((struct proc *, struct svr4_sys_access_args *));
|
||||||
|
int svr4_sys_nice __P((struct proc *, struct svr4_sys_nice_args *));
|
||||||
|
int svr4_sys_kill __P((struct proc *, struct svr4_sys_kill_args *));
|
||||||
|
int svr4_sys_pgrpsys __P((struct proc *, struct svr4_sys_pgrpsys_args *));
|
||||||
|
int svr4_sys_times __P((struct proc *, struct svr4_sys_times_args *));
|
||||||
|
int svr4_sys_signal __P((struct proc *, struct svr4_sys_signal_args *));
|
||||||
|
#if defined(NOTYET)
|
||||||
|
int svr4_sys_msgsys __P((struct proc *, struct svr4_sys_msgsys_args *));
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
int svr4_sys_sysarch __P((struct proc *, struct svr4_sys_sysarch_args *));
|
||||||
|
int svr4_sys_ioctl __P((struct proc *, struct svr4_sys_ioctl_args *));
|
||||||
|
int svr4_sys_utssys __P((struct proc *, struct svr4_sys_utssys_args *));
|
||||||
|
int svr4_sys_execve __P((struct proc *, struct svr4_sys_execve_args *));
|
||||||
|
int svr4_sys_fcntl __P((struct proc *, struct svr4_sys_fcntl_args *));
|
||||||
|
int svr4_sys_ulimit __P((struct proc *, struct svr4_sys_ulimit_args *));
|
||||||
|
int svr4_sys_getdents __P((struct proc *, struct svr4_sys_getdents_args *));
|
||||||
|
int svr4_sys_getmsg __P((struct proc *, struct svr4_sys_getmsg_args *));
|
||||||
|
int svr4_sys_putmsg __P((struct proc *, struct svr4_sys_putmsg_args *));
|
||||||
|
int svr4_sys_poll __P((struct proc *, struct svr4_sys_poll_args *));
|
||||||
|
int svr4_sys_lstat __P((struct proc *, struct svr4_sys_lstat_args *));
|
||||||
|
int svr4_sys_sigprocmask __P((struct proc *, struct svr4_sys_sigprocmask_args *));
|
||||||
|
int svr4_sys_sigsuspend __P((struct proc *, struct svr4_sys_sigsuspend_args *));
|
||||||
|
int svr4_sys_sigaltstack __P((struct proc *, struct svr4_sys_sigaltstack_args *));
|
||||||
|
int svr4_sys_sigaction __P((struct proc *, struct svr4_sys_sigaction_args *));
|
||||||
|
int svr4_sys_sigpending __P((struct proc *, struct svr4_sys_sigpending_args *));
|
||||||
|
int svr4_sys_context __P((struct proc *, struct svr4_sys_context_args *));
|
||||||
|
int svr4_sys_statvfs __P((struct proc *, struct svr4_sys_statvfs_args *));
|
||||||
|
int svr4_sys_fstatvfs __P((struct proc *, struct svr4_sys_fstatvfs_args *));
|
||||||
|
int svr4_sys_waitsys __P((struct proc *, struct svr4_sys_waitsys_args *));
|
||||||
|
int svr4_sys_hrtsys __P((struct proc *, struct svr4_sys_hrtsys_args *));
|
||||||
|
int svr4_sys_pathconf __P((struct proc *, struct svr4_sys_pathconf_args *));
|
||||||
|
int svr4_sys_mmap __P((struct proc *, struct svr4_sys_mmap_args *));
|
||||||
|
int svr4_sys_fpathconf __P((struct proc *, struct svr4_sys_fpathconf_args *));
|
||||||
|
int svr4_sys_xstat __P((struct proc *, struct svr4_sys_xstat_args *));
|
||||||
|
int svr4_sys_lxstat __P((struct proc *, struct svr4_sys_lxstat_args *));
|
||||||
|
int svr4_sys_fxstat __P((struct proc *, struct svr4_sys_fxstat_args *));
|
||||||
|
int svr4_sys_xmknod __P((struct proc *, struct svr4_sys_xmknod_args *));
|
||||||
|
int svr4_sys_setrlimit __P((struct proc *, struct svr4_sys_setrlimit_args *));
|
||||||
|
int svr4_sys_getrlimit __P((struct proc *, struct svr4_sys_getrlimit_args *));
|
||||||
|
int svr4_sys_memcntl __P((struct proc *, struct svr4_sys_memcntl_args *));
|
||||||
|
int svr4_sys_uname __P((struct proc *, struct svr4_sys_uname_args *));
|
||||||
|
int svr4_sys_sysconfig __P((struct proc *, struct svr4_sys_sysconfig_args *));
|
||||||
|
int svr4_sys_systeminfo __P((struct proc *, struct svr4_sys_systeminfo_args *));
|
||||||
|
int svr4_sys_fchroot __P((struct proc *, struct svr4_sys_fchroot_args *));
|
||||||
|
int svr4_sys_utimes __P((struct proc *, struct svr4_sys_utimes_args *));
|
||||||
|
int svr4_sys_vhangup __P((struct proc *, struct svr4_sys_vhangup_args *));
|
||||||
|
int svr4_sys_gettimeofday __P((struct proc *, struct svr4_sys_gettimeofday_args *));
|
||||||
|
int svr4_sys_llseek __P((struct proc *, struct svr4_sys_llseek_args *));
|
||||||
|
int svr4_sys_acl __P((struct proc *, struct svr4_sys_acl_args *));
|
||||||
|
int svr4_sys_auditsys __P((struct proc *, struct svr4_sys_auditsys_args *));
|
||||||
|
int svr4_sys_facl __P((struct proc *, struct svr4_sys_facl_args *));
|
||||||
|
int svr4_sys_resolvepath __P((struct proc *, struct svr4_sys_resolvepath_args *));
|
||||||
|
int svr4_sys_getdents64 __P((struct proc *, struct svr4_sys_getdents64_args *));
|
||||||
|
int svr4_sys_mmap64 __P((struct proc *, struct svr4_sys_mmap64_args *));
|
||||||
|
int svr4_sys_stat64 __P((struct proc *, struct svr4_sys_stat64_args *));
|
||||||
|
int svr4_sys_lstat64 __P((struct proc *, struct svr4_sys_lstat64_args *));
|
||||||
|
int svr4_sys_fstat64 __P((struct proc *, struct svr4_sys_fstat64_args *));
|
||||||
|
int svr4_sys_statvfs64 __P((struct proc *, struct svr4_sys_statvfs64_args *));
|
||||||
|
int svr4_sys_fstatvfs64 __P((struct proc *, struct svr4_sys_fstatvfs64_args *));
|
||||||
|
int svr4_sys_setrlimit64 __P((struct proc *, struct svr4_sys_setrlimit64_args *));
|
||||||
|
int svr4_sys_getrlimit64 __P((struct proc *, struct svr4_sys_getrlimit64_args *));
|
||||||
|
int svr4_sys_creat64 __P((struct proc *, struct svr4_sys_creat64_args *));
|
||||||
|
int svr4_sys_open64 __P((struct proc *, struct svr4_sys_open64_args *));
|
||||||
|
int svr4_sys_socket __P((struct proc *, struct svr4_sys_socket_args *));
|
||||||
|
int svr4_sys_recv __P((struct proc *, struct svr4_sys_recv_args *));
|
||||||
|
int svr4_sys_send __P((struct proc *, struct svr4_sys_send_args *));
|
||||||
|
int svr4_sys_sendto __P((struct proc *, struct svr4_sys_sendto_args *));
|
||||||
|
|
||||||
|
#ifdef COMPAT_43
|
||||||
|
|
||||||
|
#if defined(NOTYET)
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* COMPAT_43 */
|
||||||
|
|
||||||
|
#undef PAD_
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SYSPROTO_H_ */
|
311
sys/svr4/svr4_resource.c
Normal file
311
sys/svr4/svr4_resource.c
Normal file
|
@ -0,0 +1,311 @@
|
||||||
|
/* Derived from:
|
||||||
|
* $NetBSD: svr4_resource.c,v 1.3 1998/12/13 18:00:52 christos Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Original copyright:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Christos Zoulas.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions of this software have been derived from software contributed
|
||||||
|
* to the FreeBSD Project by Mark Newton.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mark Newton
|
||||||
|
* 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. 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/file.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/resourcevar.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_resource.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
|
||||||
|
static __inline int svr4_to_native_rl __P((int));
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
svr4_to_native_rl(rl)
|
||||||
|
int rl;
|
||||||
|
{
|
||||||
|
switch (rl) {
|
||||||
|
case SVR4_RLIMIT_CPU:
|
||||||
|
return RLIMIT_CPU;
|
||||||
|
case SVR4_RLIMIT_FSIZE:
|
||||||
|
return RLIMIT_FSIZE;
|
||||||
|
case SVR4_RLIMIT_DATA:
|
||||||
|
return RLIMIT_DATA;
|
||||||
|
case SVR4_RLIMIT_STACK:
|
||||||
|
return RLIMIT_STACK;
|
||||||
|
case SVR4_RLIMIT_CORE:
|
||||||
|
return RLIMIT_CORE;
|
||||||
|
case SVR4_RLIMIT_NOFILE:
|
||||||
|
return RLIMIT_NOFILE;
|
||||||
|
case SVR4_RLIMIT_VMEM:
|
||||||
|
return RLIMIT_RSS;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the resource limit fits within the BSD range and it is not
|
||||||
|
* one of the magic SVR4 limit values
|
||||||
|
*/
|
||||||
|
#define OKLIMIT(l) (((int32_t)(l)) >= 0 && ((int32_t)(l)) < 0x7fffffff && \
|
||||||
|
((svr4_rlim_t)(l)) != SVR4_RLIM_INFINITY && \
|
||||||
|
((svr4_rlim_t)(l)) != SVR4_RLIM_SAVED_CUR && \
|
||||||
|
((svr4_rlim_t)(l)) != SVR4_RLIM_SAVED_MAX)
|
||||||
|
|
||||||
|
#define OKLIMIT64(l) (((rlim_t)(l)) >= 0 && ((rlim_t)(l)) < RLIM_INFINITY && \
|
||||||
|
((svr4_rlim64_t)(l)) != SVR4_RLIM64_INFINITY && \
|
||||||
|
((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_CUR && \
|
||||||
|
((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_MAX)
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_getrlimit(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_getrlimit_args *uap;
|
||||||
|
{
|
||||||
|
int rl = svr4_to_native_rl(SCARG(uap, which));
|
||||||
|
struct rlimit blim;
|
||||||
|
struct svr4_rlimit slim;
|
||||||
|
|
||||||
|
if (rl == -1)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
blim = p->p_rlimit[rl];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our infinity, is their maxfiles.
|
||||||
|
*/
|
||||||
|
if (rl == RLIMIT_NOFILE && blim.rlim_max == RLIM_INFINITY)
|
||||||
|
blim.rlim_max = maxfiles;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the limit can be be represented, it is returned.
|
||||||
|
* Otherwise, if rlim_cur == rlim_max, return RLIM_SAVED_MAX
|
||||||
|
* else return RLIM_SAVED_CUR
|
||||||
|
*/
|
||||||
|
if (blim.rlim_max == RLIM_INFINITY)
|
||||||
|
slim.rlim_max = SVR4_RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT(blim.rlim_max))
|
||||||
|
slim.rlim_max = (svr4_rlim_t) blim.rlim_max;
|
||||||
|
else
|
||||||
|
slim.rlim_max = SVR4_RLIM_SAVED_MAX;
|
||||||
|
|
||||||
|
if (blim.rlim_cur == RLIM_INFINITY)
|
||||||
|
slim.rlim_cur = SVR4_RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT(blim.rlim_cur))
|
||||||
|
slim.rlim_cur = (svr4_rlim_t) blim.rlim_cur;
|
||||||
|
else if (blim.rlim_max == blim.rlim_cur)
|
||||||
|
slim.rlim_cur = SVR4_RLIM_SAVED_MAX;
|
||||||
|
else
|
||||||
|
slim.rlim_cur = SVR4_RLIM_SAVED_CUR;
|
||||||
|
|
||||||
|
return copyout(&slim, SCARG(uap, rlp), sizeof(*SCARG(uap, rlp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_setrlimit(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_setrlimit_args *uap;
|
||||||
|
{
|
||||||
|
int rl = svr4_to_native_rl(SCARG(uap, which));
|
||||||
|
struct rlimit blim, *limp;
|
||||||
|
struct svr4_rlimit slim;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (rl == -1)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
limp = &p->p_rlimit[rl];
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, rlp), &slim, sizeof(slim))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if the limit is SVR4_RLIM_INFINITY, then we set it to our
|
||||||
|
* unlimited.
|
||||||
|
* We should also: If it is SVR4_RLIM_SAVED_MAX, we should set the
|
||||||
|
* new limit to the corresponding saved hard limit, and if
|
||||||
|
* it is equal to SVR4_RLIM_SAVED_CUR, we should set it to the
|
||||||
|
* corresponding saved soft limit.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if (slim.rlim_max == SVR4_RLIM_INFINITY)
|
||||||
|
blim.rlim_max = RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT(slim.rlim_max))
|
||||||
|
blim.rlim_max = (rlim_t) slim.rlim_max;
|
||||||
|
else if (slim.rlim_max == SVR4_RLIM_SAVED_MAX)
|
||||||
|
blim.rlim_max = limp->rlim_max;
|
||||||
|
else if (slim.rlim_max == SVR4_RLIM_SAVED_CUR)
|
||||||
|
blim.rlim_max = limp->rlim_cur;
|
||||||
|
|
||||||
|
if (slim.rlim_cur == SVR4_RLIM_INFINITY)
|
||||||
|
blim.rlim_cur = RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT(slim.rlim_cur))
|
||||||
|
blim.rlim_cur = (rlim_t) slim.rlim_cur;
|
||||||
|
else if (slim.rlim_cur == SVR4_RLIM_SAVED_MAX)
|
||||||
|
blim.rlim_cur = limp->rlim_max;
|
||||||
|
else if (slim.rlim_cur == SVR4_RLIM_SAVED_CUR)
|
||||||
|
blim.rlim_cur = limp->rlim_cur;
|
||||||
|
|
||||||
|
return dosetrlimit(p, rl, &blim);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_getrlimit64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_getrlimit64_args *uap;
|
||||||
|
{
|
||||||
|
int rl = svr4_to_native_rl(SCARG(uap, which));
|
||||||
|
struct rlimit blim;
|
||||||
|
struct svr4_rlimit64 slim;
|
||||||
|
|
||||||
|
if (rl == -1)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
blim = p->p_rlimit[rl];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our infinity, is their maxfiles.
|
||||||
|
*/
|
||||||
|
if (rl == RLIMIT_NOFILE && blim.rlim_max == RLIM_INFINITY)
|
||||||
|
blim.rlim_max = maxfiles;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the limit can be be represented, it is returned.
|
||||||
|
* Otherwise, if rlim_cur == rlim_max, return SVR4_RLIM_SAVED_MAX
|
||||||
|
* else return SVR4_RLIM_SAVED_CUR
|
||||||
|
*/
|
||||||
|
if (blim.rlim_max == RLIM_INFINITY)
|
||||||
|
slim.rlim_max = SVR4_RLIM64_INFINITY;
|
||||||
|
else if (OKLIMIT64(blim.rlim_max))
|
||||||
|
slim.rlim_max = (svr4_rlim64_t) blim.rlim_max;
|
||||||
|
else
|
||||||
|
slim.rlim_max = SVR4_RLIM64_SAVED_MAX;
|
||||||
|
|
||||||
|
if (blim.rlim_cur == RLIM_INFINITY)
|
||||||
|
slim.rlim_cur = SVR4_RLIM64_INFINITY;
|
||||||
|
else if (OKLIMIT64(blim.rlim_cur))
|
||||||
|
slim.rlim_cur = (svr4_rlim64_t) blim.rlim_cur;
|
||||||
|
else if (blim.rlim_max == blim.rlim_cur)
|
||||||
|
slim.rlim_cur = SVR4_RLIM64_SAVED_MAX;
|
||||||
|
else
|
||||||
|
slim.rlim_cur = SVR4_RLIM64_SAVED_CUR;
|
||||||
|
|
||||||
|
return copyout(&slim, SCARG(uap, rlp), sizeof(*SCARG(uap, rlp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_setrlimit64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_setrlimit64_args *uap;
|
||||||
|
{
|
||||||
|
int rl = svr4_to_native_rl(SCARG(uap, which));
|
||||||
|
struct rlimit blim, *limp;
|
||||||
|
struct svr4_rlimit64 slim;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (rl == -1)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
limp = &p->p_rlimit[rl];
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, rlp), &slim, sizeof(slim))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if the limit is SVR4_RLIM64_INFINITY, then we set it to our
|
||||||
|
* unlimited.
|
||||||
|
* We should also: If it is SVR4_RLIM64_SAVED_MAX, we should set the
|
||||||
|
* new limit to the corresponding saved hard limit, and if
|
||||||
|
* it is equal to SVR4_RLIM64_SAVED_CUR, we should set it to the
|
||||||
|
* corresponding saved soft limit.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if (slim.rlim_max == SVR4_RLIM64_INFINITY)
|
||||||
|
blim.rlim_max = RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT64(slim.rlim_max))
|
||||||
|
blim.rlim_max = (rlim_t) slim.rlim_max;
|
||||||
|
else if (slim.rlim_max == SVR4_RLIM64_SAVED_MAX)
|
||||||
|
blim.rlim_max = limp->rlim_max;
|
||||||
|
else if (slim.rlim_max == SVR4_RLIM64_SAVED_CUR)
|
||||||
|
blim.rlim_max = limp->rlim_cur;
|
||||||
|
|
||||||
|
if (slim.rlim_cur == SVR4_RLIM64_INFINITY)
|
||||||
|
blim.rlim_cur = RLIM_INFINITY;
|
||||||
|
else if (OKLIMIT64(slim.rlim_cur))
|
||||||
|
blim.rlim_cur = (rlim_t) slim.rlim_cur;
|
||||||
|
else if (slim.rlim_cur == SVR4_RLIM64_SAVED_MAX)
|
||||||
|
blim.rlim_cur = limp->rlim_max;
|
||||||
|
else if (slim.rlim_cur == SVR4_RLIM64_SAVED_CUR)
|
||||||
|
blim.rlim_cur = limp->rlim_cur;
|
||||||
|
|
||||||
|
return dosetrlimit(p, rl, &blim);
|
||||||
|
}
|
107
sys/svr4/svr4_resource.h
Normal file
107
sys/svr4/svr4_resource.h
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
/* Derived from:
|
||||||
|
* $NetBSD: svr4_resource.h,v 1.1 1998/11/28 21:53:02 christos Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Original copyright:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Christos Zoulas.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Portions of this code derived from software contributed to the
|
||||||
|
* FreeBSD Project by Mark Newton.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mark Newton
|
||||||
|
* 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. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_RESOURCE_H_
|
||||||
|
#define _SVR4_RESOURCE_H_
|
||||||
|
|
||||||
|
#define SVR4_RLIMIT_CPU 0
|
||||||
|
#define SVR4_RLIMIT_FSIZE 1
|
||||||
|
#define SVR4_RLIMIT_DATA 2
|
||||||
|
#define SVR4_RLIMIT_STACK 3
|
||||||
|
#define SVR4_RLIMIT_CORE 4
|
||||||
|
#define SVR4_RLIMIT_NOFILE 5
|
||||||
|
#define SVR4_RLIMIT_VMEM 6
|
||||||
|
#define SVR4_RLIMIT_AS SVR4_RLIMIT_VMEM
|
||||||
|
#define SVR4_RLIM_NLIMITS 7
|
||||||
|
|
||||||
|
typedef u_int32_t svr4_rlim_t;
|
||||||
|
|
||||||
|
#define SVR4_RLIM_SAVED_CUR 0x7ffffffd
|
||||||
|
#define SVR4_RLIM_SAVED_MAX 0x7ffffffe
|
||||||
|
#define SVR4_RLIM_INFINITY 0x7fffffff
|
||||||
|
|
||||||
|
struct svr4_rlimit {
|
||||||
|
svr4_rlim_t rlim_cur;
|
||||||
|
svr4_rlim_t rlim_max;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef u_int64_t svr4_rlim64_t;
|
||||||
|
|
||||||
|
#define SVR4_RLIM64_SAVED_CUR ((svr4_rlim64_t) -1)
|
||||||
|
#define SVR4_RLIM64_SAVED_MAX ((svr4_rlim64_t) -2)
|
||||||
|
#define SVR4_RLIM64_INFINITY ((svr4_rlim64_t) -3)
|
||||||
|
|
||||||
|
struct svr4_rlimit64 {
|
||||||
|
svr4_rlim64_t rlim_cur;
|
||||||
|
svr4_rlim64_t rlim_max;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_SVR4_RESOURCE_H_ */
|
109
sys/svr4/svr4_siginfo.h
Normal file
109
sys/svr4/svr4_siginfo.h
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SIGINFO_H_
|
||||||
|
#define _SVR4_SIGINFO_H_
|
||||||
|
|
||||||
|
#define SVR4_ILL_ILLOPC 1
|
||||||
|
#define SVR4_ILL_ILLOPN 2
|
||||||
|
#define SVR4_ILL_ILLADR 3
|
||||||
|
#define SVR4_ILL_ILLTRP 4
|
||||||
|
#define SVR4_ILL_PRVOPC 5
|
||||||
|
#define SVR4_ILL_PRVREG 6
|
||||||
|
#define SVR4_ILL_COPROC 7
|
||||||
|
#define SVR4_ILL_BADSTK 8
|
||||||
|
|
||||||
|
#define SVR4_FPE_INTDIV 1
|
||||||
|
#define SVR4_FPE_INTOVF 2
|
||||||
|
#define SVR4_FPE_FLTDIV 3
|
||||||
|
#define SVR4_FPE_FLTOVF 4
|
||||||
|
#define SVR4_FPE_FLTUND 5
|
||||||
|
#define SVR4_FPE_FLTRES 6
|
||||||
|
#define SVR4_FPE_FLTINV 7
|
||||||
|
#define SVR4_FPE_FLTSUB 8
|
||||||
|
|
||||||
|
#define SVR4_SEGV_MAPERR 1
|
||||||
|
#define SVR4_SEGV_ACCERR 2
|
||||||
|
|
||||||
|
#define SVR4_BUS_ADRALN 1
|
||||||
|
#define SVR4_BUS_ADRERR 2
|
||||||
|
#define SVR4_BUS_OBJERR 3
|
||||||
|
|
||||||
|
#define SVR4_TRAP_BRKPT 1
|
||||||
|
#define SVR4_TRAP_TRACE 2
|
||||||
|
|
||||||
|
#define SVR4_POLL_IN 1
|
||||||
|
#define SVR4_POLL_OUT 2
|
||||||
|
#define SVR4_POLL_MSG 3
|
||||||
|
#define SVR4_POLL_ERR 4
|
||||||
|
#define SVR4_POLL_PRI 5
|
||||||
|
|
||||||
|
#define SVR4_CLD_EXITED 1
|
||||||
|
#define SVR4_CLD_KILLED 2
|
||||||
|
#define SVR4_CLD_DUMPED 3
|
||||||
|
#define SVR4_CLD_TRAPPED 4
|
||||||
|
#define SVR4_CLD_STOPPED 5
|
||||||
|
#define SVR4_CLD_CONTINUED 6
|
||||||
|
|
||||||
|
#define SVR4_EMT_TAGOVF 1
|
||||||
|
|
||||||
|
typedef union svr4_siginfo {
|
||||||
|
char si_pad[128]; /* Total size; for future expansion */
|
||||||
|
struct {
|
||||||
|
int _signo;
|
||||||
|
int _code;
|
||||||
|
int _errno;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
svr4_pid_t _pid;
|
||||||
|
svr4_clock_t _utime;
|
||||||
|
int _status;
|
||||||
|
svr4_clock_t _stime;
|
||||||
|
} _child;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
caddr_t _addr;
|
||||||
|
int _trap;
|
||||||
|
} _fault;
|
||||||
|
} _reason;
|
||||||
|
} _info;
|
||||||
|
} svr4_siginfo_t;
|
||||||
|
|
||||||
|
#define si_signo _info._signo
|
||||||
|
#define si_code _info._code
|
||||||
|
#define si_errno _info._errno
|
||||||
|
|
||||||
|
#define si_pid _info._reason._child._pid
|
||||||
|
#define si_stime _info._reason._child._stime
|
||||||
|
#define si_status _info._reason._child._status
|
||||||
|
#define si_utime _info._reason._child._utime
|
||||||
|
|
||||||
|
#define si_addr _info._reason._fault._addr
|
||||||
|
#define si_trap _info._reason._fault._trap
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SIGINFO_H_ */
|
623
sys/svr4/svr4_signal.c
Normal file
623
sys/svr4/svr4_signal.c
Normal file
|
@ -0,0 +1,623 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/filedesc.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_ucontext.h>
|
||||||
|
|
||||||
|
#define sigemptyset(s) memset((s), 0, sizeof(*(s)))
|
||||||
|
#define sigismember(s, n) (*(s) & sigmask(n))
|
||||||
|
#define sigaddset(s, n) (*(s) |= sigmask(n))
|
||||||
|
|
||||||
|
#define svr4_sigmask(n) (1 << (((n) - 1) & 31))
|
||||||
|
#define svr4_sigword(n) (((n) - 1) >> 5)
|
||||||
|
#define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s)))
|
||||||
|
#define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n))
|
||||||
|
#define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n))
|
||||||
|
|
||||||
|
static __inline void svr4_sigfillset __P((svr4_sigset_t *));
|
||||||
|
void svr4_to_bsd_sigaction __P((const struct svr4_sigaction *,
|
||||||
|
struct sigaction *));
|
||||||
|
void bsd_to_svr4_sigaction __P((const struct sigaction *,
|
||||||
|
struct svr4_sigaction *));
|
||||||
|
|
||||||
|
int bsd_to_svr4_sig[] = {
|
||||||
|
0,
|
||||||
|
SVR4_SIGHUP,
|
||||||
|
SVR4_SIGINT,
|
||||||
|
SVR4_SIGQUIT,
|
||||||
|
SVR4_SIGILL,
|
||||||
|
SVR4_SIGTRAP,
|
||||||
|
SVR4_SIGABRT,
|
||||||
|
SVR4_SIGEMT,
|
||||||
|
SVR4_SIGFPE,
|
||||||
|
SVR4_SIGKILL,
|
||||||
|
SVR4_SIGBUS,
|
||||||
|
SVR4_SIGSEGV,
|
||||||
|
SVR4_SIGSYS,
|
||||||
|
SVR4_SIGPIPE,
|
||||||
|
SVR4_SIGALRM,
|
||||||
|
SVR4_SIGTERM,
|
||||||
|
SVR4_SIGURG,
|
||||||
|
SVR4_SIGSTOP,
|
||||||
|
SVR4_SIGTSTP,
|
||||||
|
SVR4_SIGCONT,
|
||||||
|
SVR4_SIGCHLD,
|
||||||
|
SVR4_SIGTTIN,
|
||||||
|
SVR4_SIGTTOU,
|
||||||
|
SVR4_SIGIO,
|
||||||
|
SVR4_SIGXCPU,
|
||||||
|
SVR4_SIGXFSZ,
|
||||||
|
SVR4_SIGVTALRM,
|
||||||
|
SVR4_SIGPROF,
|
||||||
|
SVR4_SIGWINCH,
|
||||||
|
0, /* SIGINFO */
|
||||||
|
SVR4_SIGUSR1,
|
||||||
|
SVR4_SIGUSR2,
|
||||||
|
};
|
||||||
|
|
||||||
|
int svr4_to_bsd_sig[] = {
|
||||||
|
0,
|
||||||
|
SIGHUP,
|
||||||
|
SIGINT,
|
||||||
|
SIGQUIT,
|
||||||
|
SIGILL,
|
||||||
|
SIGTRAP,
|
||||||
|
SIGABRT,
|
||||||
|
SIGEMT,
|
||||||
|
SIGFPE,
|
||||||
|
SIGKILL,
|
||||||
|
SIGBUS,
|
||||||
|
SIGSEGV,
|
||||||
|
SIGSYS,
|
||||||
|
SIGPIPE,
|
||||||
|
SIGALRM,
|
||||||
|
SIGTERM,
|
||||||
|
SIGUSR1,
|
||||||
|
SIGUSR2,
|
||||||
|
SIGCHLD,
|
||||||
|
0, /* XXX NetBSD uses SIGPWR here, but we don't seem to have one */
|
||||||
|
SIGWINCH,
|
||||||
|
SIGURG,
|
||||||
|
SIGIO,
|
||||||
|
SIGSTOP,
|
||||||
|
SIGTSTP,
|
||||||
|
SIGCONT,
|
||||||
|
SIGTTIN,
|
||||||
|
SIGTTOU,
|
||||||
|
SIGVTALRM,
|
||||||
|
SIGPROF,
|
||||||
|
SIGXCPU,
|
||||||
|
SIGXFSZ,
|
||||||
|
};
|
||||||
|
|
||||||
|
static __inline void
|
||||||
|
svr4_sigfillset(s)
|
||||||
|
svr4_sigset_t *s;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
svr4_sigemptyset(s);
|
||||||
|
for (i = 1; i < SVR4_NSIG; i++)
|
||||||
|
svr4_sigaddset(s, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
svr4_to_bsd_sigset(sss, bss)
|
||||||
|
const svr4_sigset_t *sss;
|
||||||
|
sigset_t *bss;
|
||||||
|
{
|
||||||
|
int i, newsig;
|
||||||
|
|
||||||
|
sigemptyset(bss);
|
||||||
|
for (i = 1; i < SVR4_NSIG; i++) {
|
||||||
|
if (svr4_sigismember(sss, i)) {
|
||||||
|
newsig = svr4_to_bsd_sig[i];
|
||||||
|
if (newsig)
|
||||||
|
sigaddset(bss, newsig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
bsd_to_svr4_sigset(bss, sss)
|
||||||
|
const sigset_t *bss;
|
||||||
|
svr4_sigset_t *sss;
|
||||||
|
{
|
||||||
|
int i, newsig;
|
||||||
|
|
||||||
|
svr4_sigemptyset(sss);
|
||||||
|
for (i = 1; i < NSIG; i++) {
|
||||||
|
if (sigismember(bss, i)) {
|
||||||
|
newsig = bsd_to_svr4_sig[i];
|
||||||
|
if (newsig)
|
||||||
|
svr4_sigaddset(sss, newsig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: Only a subset of the flags is currently implemented.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
svr4_to_bsd_sigaction(ssa, bsa)
|
||||||
|
const struct svr4_sigaction *ssa;
|
||||||
|
struct sigaction *bsa;
|
||||||
|
{
|
||||||
|
|
||||||
|
bsa->sa_handler = (sig_t) ssa->sa_handler;
|
||||||
|
svr4_to_bsd_sigset(&ssa->sa_mask, &bsa->sa_mask);
|
||||||
|
bsa->sa_flags = 0;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_ONSTACK) != 0)
|
||||||
|
bsa->sa_flags |= SA_ONSTACK;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_RESETHAND) != 0)
|
||||||
|
bsa->sa_flags |= SA_RESETHAND;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_RESTART) != 0)
|
||||||
|
bsa->sa_flags |= SA_RESTART;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_SIGINFO) != 0)
|
||||||
|
DPRINTF(("svr4_to_bsd_sigaction: SA_SIGINFO ignored\n"));
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_NOCLDSTOP) != 0)
|
||||||
|
bsa->sa_flags |= SA_NOCLDSTOP;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_NODEFER) != 0)
|
||||||
|
bsa->sa_flags |= SA_NODEFER;
|
||||||
|
if ((ssa->sa_flags & SVR4_SA_NOCLDWAIT) != 0)
|
||||||
|
bsa->sa_flags |= SA_NOCLDWAIT;
|
||||||
|
if ((ssa->sa_flags & ~SVR4_SA_ALLBITS) != 0)
|
||||||
|
DPRINTF(("svr4_to_bsd_sigaction: extra bits ignored\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bsd_to_svr4_sigaction(bsa, ssa)
|
||||||
|
const struct sigaction *bsa;
|
||||||
|
struct svr4_sigaction *ssa;
|
||||||
|
{
|
||||||
|
|
||||||
|
ssa->sa_handler = (svr4_sig_t) bsa->sa_handler;
|
||||||
|
bsd_to_svr4_sigset(&bsa->sa_mask, &ssa->sa_mask);
|
||||||
|
ssa->sa_flags = 0;
|
||||||
|
if ((bsa->sa_flags & SA_ONSTACK) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_ONSTACK;
|
||||||
|
if ((bsa->sa_flags & SA_RESETHAND) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_RESETHAND;
|
||||||
|
if ((bsa->sa_flags & SA_RESTART) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_RESTART;
|
||||||
|
if ((bsa->sa_flags & SA_NODEFER) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_NODEFER;
|
||||||
|
if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
|
||||||
|
ssa->sa_flags |= SVR4_SA_NOCLDSTOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
svr4_to_bsd_sigaltstack(sss, bss)
|
||||||
|
const struct svr4_sigaltstack *sss;
|
||||||
|
struct sigaltstack *bss;
|
||||||
|
{
|
||||||
|
|
||||||
|
bss->ss_sp = sss->ss_sp;
|
||||||
|
bss->ss_size = sss->ss_size;
|
||||||
|
bss->ss_flags = 0;
|
||||||
|
if ((sss->ss_flags & SVR4_SS_DISABLE) != 0)
|
||||||
|
bss->ss_flags |= SS_DISABLE;
|
||||||
|
if ((sss->ss_flags & SVR4_SS_ONSTACK) != 0)
|
||||||
|
bss->ss_flags |= SS_ONSTACK;
|
||||||
|
if ((sss->ss_flags & ~SVR4_SS_ALLBITS) != 0)
|
||||||
|
/*XXX*/ uprintf("svr4_to_bsd_sigaltstack: extra bits ignored\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bsd_to_svr4_sigaltstack(bss, sss)
|
||||||
|
const struct sigaltstack *bss;
|
||||||
|
struct svr4_sigaltstack *sss;
|
||||||
|
{
|
||||||
|
|
||||||
|
sss->ss_sp = bss->ss_sp;
|
||||||
|
sss->ss_size = bss->ss_size;
|
||||||
|
sss->ss_flags = 0;
|
||||||
|
if ((bss->ss_flags & SS_DISABLE) != 0)
|
||||||
|
sss->ss_flags |= SVR4_SS_DISABLE;
|
||||||
|
if ((bss->ss_flags & SS_ONSTACK) != 0)
|
||||||
|
sss->ss_flags |= SVR4_SS_ONSTACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigaction(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_sigaction_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_sigaction *nisa, *oisa, tmpisa;
|
||||||
|
struct sigaction *nbsa, *obsa, tmpbsa;
|
||||||
|
struct sigaction_args sa;
|
||||||
|
caddr_t sg;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
sg = stackgap_init();
|
||||||
|
nisa = SCARG(uap, nsa);
|
||||||
|
oisa = SCARG(uap, osa);
|
||||||
|
|
||||||
|
if (oisa != NULL)
|
||||||
|
obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
else
|
||||||
|
obsa = NULL;
|
||||||
|
|
||||||
|
if (nisa != NULL) {
|
||||||
|
nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
if ((error = copyin(nisa, &tmpisa, sizeof(tmpisa))) != 0)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_sigaction(&tmpisa, &tmpbsa);
|
||||||
|
if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
|
||||||
|
return error;
|
||||||
|
} else
|
||||||
|
nbsa = NULL;
|
||||||
|
|
||||||
|
SCARG(&sa, signum) = svr4_to_bsd_sig[SCARG(uap, signum)];
|
||||||
|
SCARG(&sa, nsa) = nbsa;
|
||||||
|
SCARG(&sa, osa) = obsa;
|
||||||
|
|
||||||
|
if ((error = sigaction(p, &sa)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (oisa != NULL) {
|
||||||
|
if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_sigaction(&tmpbsa, &tmpisa);
|
||||||
|
if ((error = copyout(&tmpisa, oisa, sizeof(tmpisa))) != 0)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigaltstack(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_sigaltstack_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_sigaltstack *nsss, *osss, tmpsss;
|
||||||
|
struct sigaltstack *nbss, *obss, tmpbss;
|
||||||
|
struct sigaltstack_args sa;
|
||||||
|
caddr_t sg;
|
||||||
|
int error, *retval;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
sg = stackgap_init();
|
||||||
|
nsss = SCARG(uap, nss);
|
||||||
|
osss = SCARG(uap, oss);
|
||||||
|
|
||||||
|
if (osss != NULL)
|
||||||
|
obss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
|
||||||
|
else
|
||||||
|
obss = NULL;
|
||||||
|
|
||||||
|
if (nsss != NULL) {
|
||||||
|
nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
|
||||||
|
if ((error = copyin(nsss, &tmpsss, sizeof(tmpsss))) != 0)
|
||||||
|
return error;
|
||||||
|
svr4_to_bsd_sigaltstack(&tmpsss, &tmpbss);
|
||||||
|
if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0)
|
||||||
|
return error;
|
||||||
|
} else
|
||||||
|
nbss = NULL;
|
||||||
|
|
||||||
|
SCARG(&sa, nss) = nbss;
|
||||||
|
SCARG(&sa, oss) = obss;
|
||||||
|
|
||||||
|
if ((error = sigaltstack(p, &sa)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (obss != NULL) {
|
||||||
|
if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0)
|
||||||
|
return error;
|
||||||
|
bsd_to_svr4_sigaltstack(&tmpbss, &tmpsss);
|
||||||
|
if ((error = copyout(&tmpsss, osss, sizeof(tmpsss))) != 0)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stolen from the ibcs2 one
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
svr4_sys_signal(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_signal_args *uap;
|
||||||
|
{
|
||||||
|
int signum = svr4_to_bsd_sig[SVR4_SIGNO(SCARG(uap, signum))];
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
if (signum <= 0 || signum >= SVR4_NSIG)
|
||||||
|
return (EINVAL);
|
||||||
|
|
||||||
|
switch (SVR4_SIGCALL(SCARG(uap, signum))) {
|
||||||
|
case SVR4_SIGDEFER_MASK:
|
||||||
|
if (SCARG(uap, handler) == SVR4_SIG_HOLD)
|
||||||
|
goto sighold;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
|
case SVR4_SIGNAL_MASK:
|
||||||
|
{
|
||||||
|
struct sigaction_args sa_args;
|
||||||
|
struct sigaction *nbsa, *obsa, sa;
|
||||||
|
|
||||||
|
nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
SCARG(&sa_args, signum) = signum;
|
||||||
|
SCARG(&sa_args, nsa) = nbsa;
|
||||||
|
SCARG(&sa_args, osa) = obsa;
|
||||||
|
|
||||||
|
sa.sa_handler = (sig_t) SCARG(uap, handler);
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_flags = 0;
|
||||||
|
|
||||||
|
if (signum != SIGALRM)
|
||||||
|
sa.sa_flags = SA_RESTART;
|
||||||
|
|
||||||
|
if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
|
||||||
|
return error;
|
||||||
|
if ((error = sigaction(p, &sa_args)) != 0) {
|
||||||
|
DPRINTF(("signal: sigaction failed: %d\n",
|
||||||
|
error));
|
||||||
|
*retval = (int)SVR4_SIG_ERR;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
|
||||||
|
return error;
|
||||||
|
*retval = (int)sa.sa_handler;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIGHOLD_MASK:
|
||||||
|
sighold:
|
||||||
|
{
|
||||||
|
struct sigprocmask_args sa;
|
||||||
|
|
||||||
|
SCARG(&sa, how) = SIG_BLOCK;
|
||||||
|
SCARG(&sa, mask) = sigmask(signum);
|
||||||
|
return sigprocmask(p, &sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIGRELSE_MASK:
|
||||||
|
{
|
||||||
|
struct sigprocmask_args sa;
|
||||||
|
|
||||||
|
SCARG(&sa, how) = SIG_UNBLOCK;
|
||||||
|
SCARG(&sa, mask) = sigmask(signum);
|
||||||
|
return sigprocmask(p, &sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIGIGNORE_MASK:
|
||||||
|
{
|
||||||
|
struct sigaction_args sa_args;
|
||||||
|
struct sigaction *bsa, sa;
|
||||||
|
|
||||||
|
bsa = stackgap_alloc(&sg, sizeof(struct sigaction));
|
||||||
|
SCARG(&sa_args, signum) = signum;
|
||||||
|
SCARG(&sa_args, nsa) = bsa;
|
||||||
|
SCARG(&sa_args, osa) = NULL;
|
||||||
|
|
||||||
|
sa.sa_handler = SIG_IGN;
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_flags = 0;
|
||||||
|
if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
|
||||||
|
return error;
|
||||||
|
if ((error = sigaction(p, &sa_args)) != 0) {
|
||||||
|
DPRINTF(("sigignore: sigaction failed\n"));
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIGPAUSE_MASK:
|
||||||
|
{
|
||||||
|
struct sigsuspend_args sa;
|
||||||
|
|
||||||
|
SCARG(&sa, mask) = p->p_sigmask & ~sigmask(signum);
|
||||||
|
return sigsuspend(p, &sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return (ENOSYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigprocmask(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_sigprocmask_args *uap;
|
||||||
|
{
|
||||||
|
svr4_sigset_t sss;
|
||||||
|
sigset_t bss;
|
||||||
|
int error = 0, *retval;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
if (SCARG(uap, oset) != NULL) {
|
||||||
|
/* Fix the return value first if needed */
|
||||||
|
bsd_to_svr4_sigset(&p->p_sigmask, &sss);
|
||||||
|
if ((error = copyout(&sss, SCARG(uap, oset), sizeof(sss))) != 0)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SCARG(uap, set) == NULL)
|
||||||
|
/* Just examine */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, set), &sss, sizeof(sss))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_to_bsd_sigset(&sss, &bss);
|
||||||
|
|
||||||
|
(void) splhigh();
|
||||||
|
|
||||||
|
switch (SCARG(uap, how)) {
|
||||||
|
case SVR4_SIG_BLOCK:
|
||||||
|
p->p_sigmask |= bss & ~sigcantmask;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SIG_UNBLOCK:
|
||||||
|
p->p_sigmask &= ~bss;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SIG_SETMASK:
|
||||||
|
p->p_sigmask = bss & ~sigcantmask;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
error = EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) spl0();
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigpending(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_sigpending_args *uap;
|
||||||
|
{
|
||||||
|
sigset_t bss;
|
||||||
|
int *retval;
|
||||||
|
svr4_sigset_t sss;
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case 1: /* sigpending */
|
||||||
|
if (SCARG(uap, mask) == NULL)
|
||||||
|
return 0;
|
||||||
|
bss = p->p_siglist & p->p_sigmask;
|
||||||
|
bsd_to_svr4_sigset(&bss, &sss);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: /* sigfillset */
|
||||||
|
svr4_sigfillset(&sss);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return copyout(&sss, SCARG(uap, mask), sizeof(sss));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_sigsuspend(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_sigsuspend_args *uap;
|
||||||
|
{
|
||||||
|
svr4_sigset_t sss;
|
||||||
|
sigset_t bss;
|
||||||
|
struct sigsuspend_args sa;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(uap, ss), &sss, sizeof(sss))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
svr4_to_bsd_sigset(&sss, &bss);
|
||||||
|
|
||||||
|
SCARG(&sa, mask) = bss;
|
||||||
|
return sigsuspend(p, &sa);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_kill(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_kill_args *uap;
|
||||||
|
{
|
||||||
|
struct kill_args ka;
|
||||||
|
|
||||||
|
SCARG(&ka, pid) = SCARG(uap, pid);
|
||||||
|
SCARG(&ka, signum) = svr4_to_bsd_sig[SCARG(uap, signum)];
|
||||||
|
return kill(p, &ka);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_context(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_context_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_ucontext uc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
switch (uap->func) {
|
||||||
|
case 0:
|
||||||
|
DPRINTF(("getcontext(%p)\n", uap->uc));
|
||||||
|
svr4_getcontext(p, &uc, p->p_sigmask,
|
||||||
|
p->p_sigacts->ps_sigstk.ss_flags & SS_ONSTACK);
|
||||||
|
return copyout(&uc, uap->uc, sizeof(uc));
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
DPRINTF(("setcontext(%p)\n", uap->uc));
|
||||||
|
if ((error = copyin(uap->uc, &uc, sizeof(uc))) != 0)
|
||||||
|
return error;
|
||||||
|
DPRINTF(("uc_flags = %x\n", uc.uc_flags));
|
||||||
|
DPRINTF(("uc_sigmask = %x\n", uc.uc_sigmask));
|
||||||
|
|
||||||
|
return svr4_setcontext(p, &uc);
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("context(%d, %p)\n", uap->func,
|
||||||
|
uap->uc));
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_pause(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_pause_args *uap;
|
||||||
|
{
|
||||||
|
struct sigsuspend_args bsa;
|
||||||
|
|
||||||
|
SCARG(&bsa, mask) = p->p_sigmask;
|
||||||
|
return sigsuspend(p, &bsa);
|
||||||
|
}
|
130
sys/svr4/svr4_signal.h
Normal file
130
sys/svr4/svr4_signal.h
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SIGNAL_H_
|
||||||
|
#define _SVR4_SIGNAL_H_
|
||||||
|
|
||||||
|
#include <i386/svr4/svr4_machdep.h>
|
||||||
|
#include <svr4/svr4_siginfo.h>
|
||||||
|
|
||||||
|
#define SVR4_SIGHUP 1
|
||||||
|
#define SVR4_SIGINT 2
|
||||||
|
#define SVR4_SIGQUIT 3
|
||||||
|
#define SVR4_SIGILL 4
|
||||||
|
#define SVR4_SIGTRAP 5
|
||||||
|
#define SVR4_SIGIOT 6
|
||||||
|
#define SVR4_SIGABRT 6
|
||||||
|
#define SVR4_SIGEMT 7
|
||||||
|
#define SVR4_SIGFPE 8
|
||||||
|
#define SVR4_SIGKILL 9
|
||||||
|
#define SVR4_SIGBUS 10
|
||||||
|
#define SVR4_SIGSEGV 11
|
||||||
|
#define SVR4_SIGSYS 12
|
||||||
|
#define SVR4_SIGPIPE 13
|
||||||
|
#define SVR4_SIGALRM 14
|
||||||
|
#define SVR4_SIGTERM 15
|
||||||
|
#define SVR4_SIGUSR1 16
|
||||||
|
#define SVR4_SIGUSR2 17
|
||||||
|
#define SVR4_SIGCLD 18
|
||||||
|
#define SVR4_SIGCHLD 18
|
||||||
|
#define SVR4_SIGPWR 19
|
||||||
|
#define SVR4_SIGWINCH 20
|
||||||
|
#define SVR4_SIGURG 21
|
||||||
|
#define SVR4_SIGPOLL 22
|
||||||
|
#define SVR4_SIGIO 22
|
||||||
|
#define SVR4_SIGSTOP 23
|
||||||
|
#define SVR4_SIGTSTP 24
|
||||||
|
#define SVR4_SIGCONT 25
|
||||||
|
#define SVR4_SIGTTIN 26
|
||||||
|
#define SVR4_SIGTTOU 27
|
||||||
|
#define SVR4_SIGVTALRM 28
|
||||||
|
#define SVR4_SIGPROF 29
|
||||||
|
#define SVR4_SIGXCPU 30
|
||||||
|
#define SVR4_SIGXFSZ 31
|
||||||
|
#define SVR4_NSIG 32
|
||||||
|
|
||||||
|
#define SVR4_SIGNO_MASK 0x00FF
|
||||||
|
#define SVR4_SIGNAL_MASK 0x0000
|
||||||
|
#define SVR4_SIGDEFER_MASK 0x0100
|
||||||
|
#define SVR4_SIGHOLD_MASK 0x0200
|
||||||
|
#define SVR4_SIGRELSE_MASK 0x0400
|
||||||
|
#define SVR4_SIGIGNORE_MASK 0x0800
|
||||||
|
#define SVR4_SIGPAUSE_MASK 0x1000
|
||||||
|
|
||||||
|
typedef void (*svr4_sig_t) __P((int, svr4_siginfo_t *, void *));
|
||||||
|
#define SVR4_SIG_DFL (svr4_sig_t) 0
|
||||||
|
#define SVR4_SIG_ERR (svr4_sig_t) -1
|
||||||
|
#define SVR4_SIG_IGN (svr4_sig_t) 1
|
||||||
|
#define SVR4_SIG_HOLD (svr4_sig_t) 2
|
||||||
|
|
||||||
|
#define SVR4_SIGNO(a) ((a) & SVR4_SIGNO_MASK)
|
||||||
|
#define SVR4_SIGCALL(a) ((a) & ~SVR4_SIGNO_MASK)
|
||||||
|
|
||||||
|
#define SVR4_SIG_BLOCK 1
|
||||||
|
#define SVR4_SIG_UNBLOCK 2
|
||||||
|
#define SVR4_SIG_SETMASK 3
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u_long bits[4];
|
||||||
|
} svr4_sigset_t;
|
||||||
|
|
||||||
|
struct svr4_sigaction {
|
||||||
|
int sa_flags;
|
||||||
|
svr4_sig_t sa_handler;
|
||||||
|
svr4_sigset_t sa_mask;
|
||||||
|
int sa_reserved[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_sigaltstack {
|
||||||
|
char *ss_sp;
|
||||||
|
int ss_size;
|
||||||
|
int ss_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* sa_flags */
|
||||||
|
#define SVR4_SA_ONSTACK 0x00000001
|
||||||
|
#define SVR4_SA_RESETHAND 0x00000002
|
||||||
|
#define SVR4_SA_RESTART 0x00000004
|
||||||
|
#define SVR4_SA_SIGINFO 0x00000008
|
||||||
|
#define SVR4_SA_NODEFER 0x00000010
|
||||||
|
#define SVR4_SA_NOCLDWAIT 0x00010000 /* No zombies */
|
||||||
|
#define SVR4_SA_NOCLDSTOP 0x00020000 /* No jcl */
|
||||||
|
#define SVR4_SA_ALLBITS 0x0003001f
|
||||||
|
|
||||||
|
/* ss_flags */
|
||||||
|
#define SVR4_SS_ONSTACK 0x00000001
|
||||||
|
#define SVR4_SS_DISABLE 0x00000002
|
||||||
|
#define SVR4_SS_ALLBITS 0x00000003
|
||||||
|
|
||||||
|
void bsd_to_svr4_sigaltstack __P((const struct sigaltstack *, struct svr4_sigaltstack *));
|
||||||
|
void bsd_to_svr4_sigset __P((const sigset_t *, svr4_sigset_t *));
|
||||||
|
void svr4_to_bsd_sigaltstack __P((const struct svr4_sigaltstack *, struct sigaltstack *));
|
||||||
|
void svr4_to_bsd_sigset __P((const svr4_sigset_t *, sigset_t *));
|
||||||
|
void svr4_sendsig(sig_t, int, int, u_long);
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SIGNAL_H_ */
|
204
sys/svr4/svr4_socket.c
Normal file
204
sys/svr4/svr4_socket.c
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1996 Christos Zoulas.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In SVR4 unix domain sockets are referenced sometimes
|
||||||
|
* (in putmsg(2) for example) as a [device, inode] pair instead of a pathname.
|
||||||
|
* Since there is no iname() routine in the kernel, and we need access to
|
||||||
|
* a mapping from inode to pathname, we keep our own table. This is a simple
|
||||||
|
* linked list that contains the pathname, the [device, inode] pair, the
|
||||||
|
* file corresponding to that socket and the process. When the
|
||||||
|
* socket gets closed we remove the item from the list. The list gets loaded
|
||||||
|
* every time a stat(2) call finds a socket.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/queue.h>
|
||||||
|
#include <sys/mbuf.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/socketvar.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_socket.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_sockmod.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
|
||||||
|
struct svr4_sockcache_entry {
|
||||||
|
struct proc *p; /* Process for the socket */
|
||||||
|
void *cookie; /* Internal cookie used for matching */
|
||||||
|
struct sockaddr_un sock;/* Pathname for the socket */
|
||||||
|
dev_t dev; /* Device where the socket lives on */
|
||||||
|
ino_t ino; /* Inode where the socket lives on */
|
||||||
|
TAILQ_ENTRY(svr4_sockcache_entry) entries;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern TAILQ_HEAD(svr4_sockcache_head, svr4_sockcache_entry) svr4_head;
|
||||||
|
extern int svr4_str_initialized;
|
||||||
|
|
||||||
|
struct sockaddr_un *
|
||||||
|
svr4_find_socket(p, fp, dev, ino)
|
||||||
|
struct proc *p;
|
||||||
|
struct file *fp;
|
||||||
|
dev_t dev;
|
||||||
|
ino_t ino;
|
||||||
|
{
|
||||||
|
struct svr4_sockcache_entry *e;
|
||||||
|
void *cookie = ((struct socket *) fp->f_data)->so_emuldata;
|
||||||
|
|
||||||
|
if (!svr4_str_initialized) {
|
||||||
|
DPRINTF(("svr4_find_socket: uninitialized [%p,%d,%d]\n",
|
||||||
|
p, dev, ino));
|
||||||
|
TAILQ_INIT(&svr4_head);
|
||||||
|
svr4_str_initialized = 1;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", p, dev, ino));
|
||||||
|
for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next)
|
||||||
|
if (e->p == p && e->dev == dev && e->ino == ino) {
|
||||||
|
#ifdef DIAGNOSTIC
|
||||||
|
if (e->cookie != NULL && e->cookie != cookie)
|
||||||
|
panic("svr4 socket cookie mismatch");
|
||||||
|
#endif
|
||||||
|
e->cookie = cookie;
|
||||||
|
DPRINTF(("%s\n", e->sock.sun_path));
|
||||||
|
return &e->sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINTF(("not found\n"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
svr4_delete_socket(p, fp)
|
||||||
|
struct proc *p;
|
||||||
|
struct file *fp;
|
||||||
|
{
|
||||||
|
struct svr4_sockcache_entry *e;
|
||||||
|
void *cookie = ((struct socket *) fp->f_data)->so_emuldata;
|
||||||
|
|
||||||
|
if (!svr4_str_initialized) {
|
||||||
|
TAILQ_INIT(&svr4_head);
|
||||||
|
svr4_str_initialized = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next)
|
||||||
|
if (e->p == p && e->cookie == cookie) {
|
||||||
|
TAILQ_REMOVE(&svr4_head, e, entries);
|
||||||
|
DPRINTF(("svr4_delete_socket: %s [%p,%d,%d]\n",
|
||||||
|
e->sock.sun_path, p, e->dev, e->ino));
|
||||||
|
free(e, M_TEMP);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_add_socket(p, path, st)
|
||||||
|
struct proc *p;
|
||||||
|
const char *path;
|
||||||
|
struct stat *st;
|
||||||
|
{
|
||||||
|
struct svr4_sockcache_entry *e;
|
||||||
|
int len, error;
|
||||||
|
|
||||||
|
if (!svr4_str_initialized) {
|
||||||
|
TAILQ_INIT(&svr4_head);
|
||||||
|
svr4_str_initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = malloc(sizeof(*e), M_TEMP, M_WAITOK);
|
||||||
|
e->cookie = NULL;
|
||||||
|
e->dev = st->st_dev;
|
||||||
|
e->ino = st->st_ino;
|
||||||
|
e->p = p;
|
||||||
|
|
||||||
|
if ((error = copyinstr(path, e->sock.sun_path,
|
||||||
|
sizeof(e->sock.sun_path), &len)) != 0) {
|
||||||
|
DPRINTF(("svr4_add_socket: copyinstr failed %d\n", error));
|
||||||
|
free(e, M_TEMP);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
e->sock.sun_family = AF_LOCAL;
|
||||||
|
e->sock.sun_len = len;
|
||||||
|
|
||||||
|
TAILQ_INSERT_HEAD(&svr4_head, e, entries);
|
||||||
|
DPRINTF(("svr4_add_socket: %s [%p,%d,%d]\n", e->sock.sun_path,
|
||||||
|
p, e->dev, e->ino));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_socket(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_socket_args *uap;
|
||||||
|
{
|
||||||
|
switch (SCARG(uap, type)) {
|
||||||
|
case SVR4_SOCK_DGRAM:
|
||||||
|
SCARG(uap, type) = SOCK_DGRAM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SOCK_STREAM:
|
||||||
|
SCARG(uap, type) = SOCK_STREAM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SOCK_RAW:
|
||||||
|
SCARG(uap, type) = SOCK_RAW;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SOCK_RDM:
|
||||||
|
SCARG(uap, type) = SOCK_RDM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SOCK_SEQPACKET:
|
||||||
|
SCARG(uap, type) = SOCK_SEQPACKET;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
return socket(p, (struct socket_args *)uap);
|
||||||
|
}
|
53
sys/svr4/svr4_socket.h
Normal file
53
sys/svr4/svr4_socket.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1996 Christos Zoulas.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Christos Zoulas.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SOCKET_H_
|
||||||
|
#define _SVR4_SOCKET_H_
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
struct sockaddr_un;
|
||||||
|
struct proc;
|
||||||
|
struct file;
|
||||||
|
|
||||||
|
struct svr4_sockaddr_in {
|
||||||
|
u_char sin_family;
|
||||||
|
u_short sin_port;
|
||||||
|
struct in_addr sin_addr;
|
||||||
|
u_char sin_zero[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr_un *svr4_find_socket __P((struct proc *, struct file *,
|
||||||
|
dev_t, ino_t));
|
||||||
|
void svr4_delete_socket __P((struct proc *, struct file *));
|
||||||
|
int svr4_add_socket __P((struct proc *, const char *, struct stat *));
|
||||||
|
|
||||||
|
#endif /* _SVR4_SOCKET_H_ */
|
174
sys/svr4/svr4_sockio.c
Normal file
174
sys/svr4/svr4_sockio.c
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1995 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/proc.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <sys/tty.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_stropts.h>
|
||||||
|
#include <svr4/svr4_ioctl.h>
|
||||||
|
#include <svr4/svr4_sockio.h>
|
||||||
|
|
||||||
|
static int bsd_to_svr4_flags __P((int));
|
||||||
|
|
||||||
|
#define bsd_to_svr4_flag(a) \
|
||||||
|
if (bf & __CONCAT(I,a)) sf |= __CONCAT(SVR4_I,a)
|
||||||
|
|
||||||
|
static int
|
||||||
|
bsd_to_svr4_flags(bf)
|
||||||
|
int bf;
|
||||||
|
{
|
||||||
|
int sf = 0;
|
||||||
|
bsd_to_svr4_flag(FF_UP);
|
||||||
|
bsd_to_svr4_flag(FF_BROADCAST);
|
||||||
|
bsd_to_svr4_flag(FF_DEBUG);
|
||||||
|
bsd_to_svr4_flag(FF_LOOPBACK);
|
||||||
|
bsd_to_svr4_flag(FF_POINTOPOINT);
|
||||||
|
#if defined(IFF_NOTRAILERS)
|
||||||
|
bsd_to_svr4_flag(FF_NOTRAILERS);
|
||||||
|
#endif
|
||||||
|
bsd_to_svr4_flag(FF_RUNNING);
|
||||||
|
bsd_to_svr4_flag(FF_NOARP);
|
||||||
|
bsd_to_svr4_flag(FF_PROMISC);
|
||||||
|
bsd_to_svr4_flag(FF_ALLMULTI);
|
||||||
|
bsd_to_svr4_flag(FF_MULTICAST);
|
||||||
|
return sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sock_ioctl(fp, p, retval, fd, cmd, data)
|
||||||
|
struct file *fp;
|
||||||
|
struct proc *p;
|
||||||
|
register_t *retval;
|
||||||
|
int fd;
|
||||||
|
u_long cmd;
|
||||||
|
caddr_t data;
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
|
||||||
|
fp->f_ops->fo_ioctl;
|
||||||
|
|
||||||
|
*retval = 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SVR4_SIOCGIFNUM:
|
||||||
|
{
|
||||||
|
struct ifnet *ifp;
|
||||||
|
struct ifaddr *ifa;
|
||||||
|
int ifnum = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This does not return the number of physical
|
||||||
|
* interfaces (if_index), but the number of interfaces
|
||||||
|
* + addresses like ifconf() does, because this number
|
||||||
|
* is used by code that will call SVR4_SIOCGIFCONF to
|
||||||
|
* find the space needed for SVR4_SIOCGIFCONF. So we
|
||||||
|
* count the number of ifreq entries that the next
|
||||||
|
* SVR4_SIOCGIFCONF will return. Maybe a more correct
|
||||||
|
* fix is to make SVR4_SIOCGIFCONF return only one
|
||||||
|
* entry per physical interface?
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (ifp = ifnet.tqh_first;
|
||||||
|
ifp != 0; ifp = ifp->if_link.tqe_next)
|
||||||
|
if ((ifa = ifp->if_addrhead.tqh_first) == NULL)
|
||||||
|
ifnum++;
|
||||||
|
else
|
||||||
|
for (;ifa != NULL;
|
||||||
|
ifa = ifa->ifa_link.tqe_next)
|
||||||
|
ifnum++;
|
||||||
|
|
||||||
|
|
||||||
|
DPRINTF(("SIOCGIFNUM %d\n", ifnum));
|
||||||
|
return copyout(&ifnum, data, sizeof(ifnum));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIOCGIFFLAGS:
|
||||||
|
{
|
||||||
|
struct ifreq br;
|
||||||
|
struct svr4_ifreq sr;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &sr, sizeof(sr))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
(void) strncpy(br.ifr_name, "de0", /*sr.svr4_ifr_name,*/
|
||||||
|
sizeof(br.ifr_name));
|
||||||
|
if ((error = (*ctl)(fp, SIOCGIFFLAGS,
|
||||||
|
(caddr_t) &br, p)) != 0) {
|
||||||
|
DPRINTF(("SIOCGIFFLAGS (%s) %s: error %d\n",
|
||||||
|
br.ifr_name, sr.svr4_ifr_name, error));
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
sr.svr4_ifr_flags = bsd_to_svr4_flags(br.ifr_flags);
|
||||||
|
DPRINTF(("SIOCGIFFLAGS %s = %x\n",
|
||||||
|
sr.svr4_ifr_name, sr.svr4_ifr_flags));
|
||||||
|
return copyout(&sr, data, sizeof(sr));
|
||||||
|
}
|
||||||
|
|
||||||
|
case SVR4_SIOCGIFCONF:
|
||||||
|
{
|
||||||
|
struct svr4_ifconf sc;
|
||||||
|
|
||||||
|
if ((error = copyin(data, &sc, sizeof(sc))) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
DPRINTF(("ifreq %d svr4_ifreq %d ifc_len %d\n",
|
||||||
|
sizeof(struct ifreq), sizeof(struct svr4_ifreq),
|
||||||
|
sc.svr4_ifc_len));
|
||||||
|
|
||||||
|
if ((error = (*ctl)(fp, OSIOCGIFCONF,
|
||||||
|
(caddr_t) &sc, p)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
DPRINTF(("SIOCGIFCONF\n"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Unknown svr4 sockio %lx\n", cmd));
|
||||||
|
return 0; /* ENOSYS really */
|
||||||
|
}
|
||||||
|
}
|
91
sys/svr4/svr4_sockio.h
Normal file
91
sys/svr4/svr4_sockio.h
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1995 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SOCKIO_H_
|
||||||
|
#define _SVR4_SOCKIO_H_
|
||||||
|
|
||||||
|
#define SVR4_IFF_UP 0x0001
|
||||||
|
#define SVR4_IFF_BROADCAST 0x0002
|
||||||
|
#define SVR4_IFF_DEBUG 0x0004
|
||||||
|
#define SVR4_IFF_LOOPBACK 0x0008
|
||||||
|
#define SVR4_IFF_POINTOPOINT 0x0010
|
||||||
|
#define SVR4_IFF_NOTRAILERS 0x0020
|
||||||
|
#define SVR4_IFF_RUNNING 0x0040
|
||||||
|
#define SVR4_IFF_NOARP 0x0080
|
||||||
|
#define SVR4_IFF_PROMISC 0x0100
|
||||||
|
#define SVR4_IFF_ALLMULTI 0x0200
|
||||||
|
#define SVR4_IFF_INTELLIGENT 0x0400
|
||||||
|
#define SVR4_IFF_MULTICAST 0x0800
|
||||||
|
#define SVR4_IFF_MULTI_BCAST 0x1000
|
||||||
|
#define SVR4_IFF_UNNUMBERED 0x2000
|
||||||
|
#define SVR4_IFF_PRIVATE 0x8000
|
||||||
|
|
||||||
|
struct svr4_ifreq {
|
||||||
|
#define SVR4_IFNAMSIZ 16
|
||||||
|
char svr4_ifr_name[SVR4_IFNAMSIZ];
|
||||||
|
union {
|
||||||
|
struct osockaddr ifru_addr;
|
||||||
|
struct osockaddr ifru_dstaddr;
|
||||||
|
struct osockaddr ifru_broadaddr;
|
||||||
|
short ifru_flags;
|
||||||
|
int ifru_metric;
|
||||||
|
char ifru_data;
|
||||||
|
char ifru_enaddr[6];
|
||||||
|
int if_muxid[2];
|
||||||
|
|
||||||
|
} ifr_ifru;
|
||||||
|
|
||||||
|
#define svr4_ifr_addr ifr_ifru.ifru_addr
|
||||||
|
#define svr4_ifr_dstaddr ifr_ifru.ifru_dstaddr
|
||||||
|
#define svr4_ifr_broadaddr ifr_ifru.ifru_broadaddr
|
||||||
|
#define svr4_ifr_flags ifr_ifru.ifru_flags
|
||||||
|
#define svr4_ifr_metric ifr_ifru.ifru_metric
|
||||||
|
#define svr4_ifr_data ifr_ifru.ifru_data
|
||||||
|
#define svr4_ifr_enaddr ifr_ifru.ifru_enaddr
|
||||||
|
#define svr4_ifr_muxid ifr_ifru.ifru_muxid
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_ifconf {
|
||||||
|
int svr4_ifc_len;
|
||||||
|
union {
|
||||||
|
caddr_t ifcu_buf;
|
||||||
|
struct svr4_ifreq *ifcu_req;
|
||||||
|
} ifc_ifcu;
|
||||||
|
|
||||||
|
#define svr4_ifc_buf ifc_ifcu.ifcu_buf
|
||||||
|
#define svr4_ifc_req ifc_ifcu.ifcu_req
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_SIOC ('i' << 8)
|
||||||
|
|
||||||
|
#define SVR4_SIOCGIFFLAGS SVR4_IOWR('i', 17, struct svr4_ifreq)
|
||||||
|
#define SVR4_SIOCGIFCONF SVR4_IOWR('i', 20, struct svr4_ifconf)
|
||||||
|
#define SVR4_SIOCGIFNUM SVR4_IOR('i', 87, int)
|
||||||
|
|
||||||
|
#endif /* !_SVR4_SOCKIO_H_ */
|
81
sys/svr4/svr4_sockmod.h
Normal file
81
sys/svr4/svr4_sockmod.h
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_SOCKMOD_H_
|
||||||
|
#define _SVR4_SOCKMOD_H_
|
||||||
|
|
||||||
|
#define SVR4_SIMOD ('I' << 8)
|
||||||
|
|
||||||
|
#define SVR4_SI_OGETUDATA (SVR4_SIMOD|101)
|
||||||
|
#define SVR4_SI_SHUTDOWN (SVR4_SIMOD|102)
|
||||||
|
#define SVR4_SI_LISTEN (SVR4_SIMOD|103)
|
||||||
|
#define SVR4_SI_SETMYNAME (SVR4_SIMOD|104)
|
||||||
|
#define SVR4_SI_SETPEERNAME (SVR4_SIMOD|105)
|
||||||
|
#define SVR4_SI_GETINTRANSIT (SVR4_SIMOD|106)
|
||||||
|
#define SVR4_SI_TCL_LINK (SVR4_SIMOD|107)
|
||||||
|
#define SVR4_SI_TCL_UNLINK (SVR4_SIMOD|108)
|
||||||
|
#define SVR4_SI_SOCKPARAMS (SVR4_SIMOD|109)
|
||||||
|
#define SVR4_SI_GETUDATA (SVR4_SIMOD|110)
|
||||||
|
|
||||||
|
|
||||||
|
#define SVR4_SOCK_DGRAM 1
|
||||||
|
#define SVR4_SOCK_STREAM 2
|
||||||
|
#define SVR4_SOCK_STREAM_ORD 3
|
||||||
|
#define SVR4_SOCK_RAW 4
|
||||||
|
#define SVR4_SOCK_RDM 5
|
||||||
|
#define SVR4_SOCK_SEQPACKET 6
|
||||||
|
|
||||||
|
struct svr4_si_sockparms {
|
||||||
|
int family;
|
||||||
|
int type;
|
||||||
|
int protocol;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_si_oudata {
|
||||||
|
int tidusize;
|
||||||
|
int addrsize;
|
||||||
|
int optsize;
|
||||||
|
int etsdusize;
|
||||||
|
int servtype;
|
||||||
|
int so_state;
|
||||||
|
int so_options;
|
||||||
|
int tsdusize;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_si_udata {
|
||||||
|
int tidusize;
|
||||||
|
int addrsize;
|
||||||
|
int optsize;
|
||||||
|
int etsdusize;
|
||||||
|
int servtype;
|
||||||
|
int so_state;
|
||||||
|
int so_options;
|
||||||
|
int tsdusize;
|
||||||
|
struct svr4_si_sockparms sockparms;
|
||||||
|
};
|
||||||
|
#endif /* !_SVR4_SOCKMOD_H_ */
|
803
sys/svr4/svr4_stat.c
Normal file
803
sys/svr4/svr4_stat.c
Normal file
|
@ -0,0 +1,803 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. 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/stat.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/ucred.h>
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
|
||||||
|
#include <svr4/svr4.h>
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <svr4/svr4_signal.h>
|
||||||
|
#include <svr4/svr4_proto.h>
|
||||||
|
#include <svr4/svr4_util.h>
|
||||||
|
#include <svr4/svr4_stat.h>
|
||||||
|
#include <svr4/svr4_ustat.h>
|
||||||
|
#include <svr4/svr4_utsname.h>
|
||||||
|
#include <svr4/svr4_systeminfo.h>
|
||||||
|
#include <svr4/svr4_socket.h>
|
||||||
|
#include <svr4/svr4_time.h>
|
||||||
|
#if defined(NOTYET)
|
||||||
|
#include "svr4_fuser.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef sparc
|
||||||
|
/*
|
||||||
|
* Solaris-2.4 on the sparc has the old stat call using the new
|
||||||
|
* stat data structure...
|
||||||
|
*/
|
||||||
|
# define SVR4_NO_OSTAT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct svr4_ustat_args {
|
||||||
|
svr4_dev_t dev;
|
||||||
|
struct svr4_ustat * name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *));
|
||||||
|
static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *));
|
||||||
|
int svr4_ustat __P((struct proc *, struct svr4_ustat_args *));
|
||||||
|
static int svr4_to_bsd_pathconf __P((int));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SVR4 uses named pipes as named sockets, so we tell programs
|
||||||
|
* that sockets are named pipes with mode 0
|
||||||
|
*/
|
||||||
|
#define BSD_TO_SVR4_MODE(mode) (S_ISSOCK(mode) ? S_IFIFO : (mode))
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SVR4_NO_OSTAT
|
||||||
|
static void bsd_to_svr4_stat __P((struct stat *, struct svr4_stat *));
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_stat(st, st4)
|
||||||
|
struct stat *st;
|
||||||
|
struct svr4_stat *st4;
|
||||||
|
{
|
||||||
|
memset(st4, 0, sizeof(*st4));
|
||||||
|
st4->st_dev = bsd_to_svr4_odev_t(st->st_dev);
|
||||||
|
st4->st_ino = st->st_ino;
|
||||||
|
st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
|
||||||
|
st4->st_nlink = st->st_nlink;
|
||||||
|
st4->st_uid = st->st_uid;
|
||||||
|
st4->st_gid = st->st_gid;
|
||||||
|
st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
|
||||||
|
st4->st_size = st->st_size;
|
||||||
|
st4->st_atim = st->st_atimespec.tv_sec;
|
||||||
|
st4->st_mtim = st->st_mtimespec.tv_sec;
|
||||||
|
st4->st_ctim = st->st_ctimespec.tv_sec;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_xstat(st, st4)
|
||||||
|
struct stat *st;
|
||||||
|
struct svr4_xstat *st4;
|
||||||
|
{
|
||||||
|
memset(st4, 0, sizeof(*st4));
|
||||||
|
st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
|
||||||
|
st4->st_ino = st->st_ino;
|
||||||
|
st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
|
||||||
|
st4->st_nlink = st->st_nlink;
|
||||||
|
st4->st_uid = st->st_uid;
|
||||||
|
st4->st_gid = st->st_gid;
|
||||||
|
st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
|
||||||
|
st4->st_size = st->st_size;
|
||||||
|
st4->st_atim = st->st_atimespec;
|
||||||
|
st4->st_mtim = st->st_mtimespec;
|
||||||
|
st4->st_ctim = st->st_ctimespec;
|
||||||
|
st4->st_blksize = st->st_blksize;
|
||||||
|
st4->st_blocks = st->st_blocks;
|
||||||
|
strcpy(st4->st_fstype, "unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bsd_to_svr4_stat64(st, st4)
|
||||||
|
struct stat *st;
|
||||||
|
struct svr4_stat64 *st4;
|
||||||
|
{
|
||||||
|
memset(st4, 0, sizeof(*st4));
|
||||||
|
st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
|
||||||
|
st4->st_ino = st->st_ino;
|
||||||
|
st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
|
||||||
|
st4->st_nlink = st->st_nlink;
|
||||||
|
st4->st_uid = st->st_uid;
|
||||||
|
st4->st_gid = st->st_gid;
|
||||||
|
st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
|
||||||
|
st4->st_size = st->st_size;
|
||||||
|
st4->st_atim = st->st_atimespec;
|
||||||
|
st4->st_mtim = st->st_mtimespec;
|
||||||
|
st4->st_ctim = st->st_ctimespec;
|
||||||
|
st4->st_blksize = st->st_blksize;
|
||||||
|
st4->st_blocks = st->st_blocks;
|
||||||
|
strcpy(st4->st_fstype, "unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_stat(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_stat_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
#ifdef SVR4_NO_OSTAT
|
||||||
|
struct svr4_sys_xstat_args cup;
|
||||||
|
|
||||||
|
retval = &(p->p_retval[0]);
|
||||||
|
SCARG(&cup, two) = 2;
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub);
|
||||||
|
return svr4_sys_xstat(p, &cup, retval);
|
||||||
|
#else
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat svr4_st;
|
||||||
|
struct stat_args cup;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
|
||||||
|
if ((error = stat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat(&st, &svr4_st);
|
||||||
|
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_lstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_lstat_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat svr4_st;
|
||||||
|
struct lstat_args cup;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = lstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat(&st, &svr4_st);
|
||||||
|
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fstat_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat svr4_st;
|
||||||
|
struct fstat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
SCARG(&cup, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = fstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat(&st, &svr4_st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_xstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_xstat_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_xstat svr4_st;
|
||||||
|
struct stat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = stat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_xstat(&st, &svr4_st);
|
||||||
|
|
||||||
|
#if defined(SOCKET_NOTYET)
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_lxstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_lxstat_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_xstat svr4_st;
|
||||||
|
struct lstat_args cup;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = lstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_xstat(&st, &svr4_st);
|
||||||
|
|
||||||
|
#if defined(SOCKET_NOTYET)
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
#endif
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fxstat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fxstat_args *uap;
|
||||||
|
{
|
||||||
|
int *retval;
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_xstat svr4_st;
|
||||||
|
struct fstat_args cup;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
SCARG(&cup, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = fstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_xstat(&st, &svr4_st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_stat64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_stat64_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat64 svr4_st;
|
||||||
|
struct stat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = stat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat64(&st, &svr4_st);
|
||||||
|
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_lstat64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_lstat64_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat64 svr4_st;
|
||||||
|
struct stat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
CHECKALTEXIST(p, &sg, (char *) SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(&cup, path) = SCARG(uap, path);
|
||||||
|
SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = lstat(p, (struct lstat_args *)&cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat64(&st, &svr4_st);
|
||||||
|
|
||||||
|
if (S_ISSOCK(st.st_mode))
|
||||||
|
(void) svr4_add_socket(p, SCARG(uap, path), &st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fstat64(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fstat64_args *uap;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
struct svr4_stat64 svr4_st;
|
||||||
|
struct fstat_args cup;
|
||||||
|
int error, *retval;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
|
||||||
|
retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(&cup, fd) = SCARG(uap, fd);
|
||||||
|
SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
|
||||||
|
|
||||||
|
if ((error = fstat(p, &cup)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
bsd_to_svr4_stat64(&st, &svr4_st);
|
||||||
|
|
||||||
|
if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_ustat(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_ustat_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_ustat us;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
memset(&us, 0, sizeof us);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: should set f_tfree and f_tinode at least
|
||||||
|
* How do we translate dev -> fstat? (and then to svr4_ustat)
|
||||||
|
*/
|
||||||
|
if ((error = copyout(&us, SCARG(uap, name), sizeof us)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*extern char ostype[], hostname[], osrelease[], version[], machine[];*/
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_uname(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_uname_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_utsname sut;
|
||||||
|
|
||||||
|
|
||||||
|
memset(&sut, 0, sizeof(sut));
|
||||||
|
|
||||||
|
strncpy(sut.sysname, ostype, sizeof(sut.sysname));
|
||||||
|
sut.sysname[sizeof(sut.sysname) - 1] = '\0';
|
||||||
|
|
||||||
|
strncpy(sut.nodename, hostname, sizeof(sut.nodename));
|
||||||
|
sut.nodename[sizeof(sut.nodename) - 1] = '\0';
|
||||||
|
|
||||||
|
strncpy(sut.release, osrelease, sizeof(sut.release));
|
||||||
|
sut.release[sizeof(sut.release) - 1] = '\0';
|
||||||
|
|
||||||
|
strncpy(sut.version, version, sizeof(sut.version));
|
||||||
|
sut.version[sizeof(sut.version) - 1] = '\0';
|
||||||
|
|
||||||
|
strncpy(sut.machine, machine, sizeof(sut.machine));
|
||||||
|
sut.machine[sizeof(sut.machine) - 1] = '\0';
|
||||||
|
|
||||||
|
return copyout((caddr_t) &sut, (caddr_t) SCARG(uap, name),
|
||||||
|
sizeof(struct svr4_utsname));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_systeminfo(p, uap)
|
||||||
|
struct proc *p;
|
||||||
|
struct svr4_sys_systeminfo_args *uap;
|
||||||
|
{
|
||||||
|
char *str = NULL;
|
||||||
|
int error = 0, *retval = p->p_retval;
|
||||||
|
size_t len = 0;
|
||||||
|
char buf[1]; /* XXX NetBSD uses 256, but that seems like awfully
|
||||||
|
excessive kstack usage for an empty string... */
|
||||||
|
u_int rlen = SCARG(uap, len);
|
||||||
|
|
||||||
|
switch (SCARG(uap, what)) {
|
||||||
|
case SVR4_SI_SYSNAME:
|
||||||
|
str = ostype;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_HOSTNAME:
|
||||||
|
str = hostname;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_RELEASE:
|
||||||
|
str = osrelease;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_VERSION:
|
||||||
|
str = version;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_MACHINE:
|
||||||
|
str = machine;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_ARCHITECTURE:
|
||||||
|
str = machine;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_HW_SERIAL:
|
||||||
|
str = "0";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_HW_PROVIDER:
|
||||||
|
str = ostype;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_SRPC_DOMAIN:
|
||||||
|
str = domainname;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_PLATFORM:
|
||||||
|
#ifdef __i386__
|
||||||
|
str = "i86pc";
|
||||||
|
#else
|
||||||
|
str = "unknown";
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SVR4_SI_KERB_REALM:
|
||||||
|
str = "unsupported";
|
||||||
|
break;
|
||||||
|
#if defined(WHY_DOES_AN_EMULATOR_WANT_TO_SET_HOSTNAMES)
|
||||||
|
case SVR4_SI_SET_HOSTNAME:
|
||||||
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||||
|
return error;
|
||||||
|
name = KERN_HOSTNAME;
|
||||||
|
return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
|
||||||
|
|
||||||
|
case SVR4_SI_SET_SRPC_DOMAIN:
|
||||||
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||||
|
return error;
|
||||||
|
name = KERN_NISDOMAINNAME;
|
||||||
|
return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
|
||||||
|
#else
|
||||||
|
case SVR4_SI_SET_HOSTNAME:
|
||||||
|
case SVR4_SI_SET_SRPC_DOMAIN:
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
#endif
|
||||||
|
case SVR4_SI_SET_KERB_REALM:
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str) {
|
||||||
|
len = strlen(str) + 1;
|
||||||
|
if (len > rlen)
|
||||||
|
len = rlen;
|
||||||
|
|
||||||
|
if (SCARG(uap, buf)) {
|
||||||
|
error = copyout(str, SCARG(uap, buf), len);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
/* make sure we are NULL terminated */
|
||||||
|
buf[0] = '\0';
|
||||||
|
error = copyout(buf, &(SCARG(uap, buf)[len - 1]), 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
error = 0;
|
||||||
|
}
|
||||||
|
/* XXX NetBSD has hostname setting stuff here. Why would an emulator
|
||||||
|
want to do that? */
|
||||||
|
|
||||||
|
*retval = len;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_utssys(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_utssys_args *uap;
|
||||||
|
{
|
||||||
|
switch (SCARG(uap, sel)) {
|
||||||
|
case 0: /* uname(2) */
|
||||||
|
{
|
||||||
|
struct svr4_sys_uname_args ua;
|
||||||
|
SCARG(&ua, name) = SCARG(uap, a1);
|
||||||
|
return svr4_sys_uname(p, &ua);
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2: /* ustat(2) */
|
||||||
|
{
|
||||||
|
struct svr4_ustat_args ua;
|
||||||
|
SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2);
|
||||||
|
SCARG(&ua, name) = SCARG(uap, a1);
|
||||||
|
return svr4_ustat(p, &ua);
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3: /* fusers(2) */
|
||||||
|
return ENOSYS;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
return ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_utime(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_utime_args *uap;
|
||||||
|
{
|
||||||
|
struct svr4_utimbuf ub;
|
||||||
|
struct timeval tbuf[2];
|
||||||
|
struct utimes_args ap;
|
||||||
|
int error;
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
void *ttp;
|
||||||
|
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
SCARG(&ap, path) = SCARG(uap, path);
|
||||||
|
if (SCARG(uap, ubuf) != NULL) {
|
||||||
|
if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0)
|
||||||
|
return error;
|
||||||
|
tbuf[0].tv_sec = ub.actime;
|
||||||
|
tbuf[0].tv_usec = 0;
|
||||||
|
tbuf[1].tv_sec = ub.modtime;
|
||||||
|
tbuf[1].tv_usec = 0;
|
||||||
|
ttp = stackgap_alloc(&sg, sizeof(tbuf));
|
||||||
|
error = copyout(tbuf, ttp, sizeof(tbuf));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
SCARG(&ap, tptr) = ttp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SCARG(&ap, tptr) = NULL;
|
||||||
|
return utimes(p, &ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_utimes(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_utimes_args *uap;
|
||||||
|
{
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
return utimes(p, (struct utimes_args *)uap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
svr4_to_bsd_pathconf(name)
|
||||||
|
int name;
|
||||||
|
{
|
||||||
|
switch (name) {
|
||||||
|
case SVR4_PC_LINK_MAX:
|
||||||
|
return _PC_LINK_MAX;
|
||||||
|
|
||||||
|
case SVR4_PC_MAX_CANON:
|
||||||
|
return _PC_MAX_CANON;
|
||||||
|
|
||||||
|
case SVR4_PC_MAX_INPUT:
|
||||||
|
return _PC_MAX_INPUT;
|
||||||
|
|
||||||
|
case SVR4_PC_NAME_MAX:
|
||||||
|
return _PC_NAME_MAX;
|
||||||
|
|
||||||
|
case SVR4_PC_PATH_MAX:
|
||||||
|
return _PC_PATH_MAX;
|
||||||
|
|
||||||
|
case SVR4_PC_PIPE_BUF:
|
||||||
|
return _PC_PIPE_BUF;
|
||||||
|
|
||||||
|
case SVR4_PC_NO_TRUNC:
|
||||||
|
return _PC_NO_TRUNC;
|
||||||
|
|
||||||
|
case SVR4_PC_VDISABLE:
|
||||||
|
return _PC_VDISABLE;
|
||||||
|
|
||||||
|
case SVR4_PC_CHOWN_RESTRICTED:
|
||||||
|
return _PC_CHOWN_RESTRICTED;
|
||||||
|
case SVR4_PC_SYNC_IO:
|
||||||
|
#if defined(_PC_SYNC_IO)
|
||||||
|
return _PC_SYNC_IO;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
case SVR4_PC_ASYNC_IO:
|
||||||
|
case SVR4_PC_PRIO_IO:
|
||||||
|
/* Not supported */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* Invalid */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_pathconf(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_pathconf_args *uap;
|
||||||
|
{
|
||||||
|
caddr_t sg = stackgap_init();
|
||||||
|
int *retval = p->p_retval;
|
||||||
|
|
||||||
|
CHECKALTEXIST(p, &sg, SCARG(uap, path));
|
||||||
|
|
||||||
|
SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
|
||||||
|
|
||||||
|
switch (SCARG(uap, name)) {
|
||||||
|
case -1:
|
||||||
|
*retval = -1;
|
||||||
|
return EINVAL;
|
||||||
|
case 0:
|
||||||
|
*retval = 0;
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return pathconf(p, (struct pathconf_args *)uap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
svr4_sys_fpathconf(p, uap)
|
||||||
|
register struct proc *p;
|
||||||
|
struct svr4_sys_fpathconf_args *uap;
|
||||||
|
{
|
||||||
|
int *retval = p->p_retval;
|
||||||
|
|
||||||
|
SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
|
||||||
|
|
||||||
|
switch (SCARG(uap, name)) {
|
||||||
|
case -1:
|
||||||
|
*retval = -1;
|
||||||
|
return EINVAL;
|
||||||
|
case 0:
|
||||||
|
*retval = 0;
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return fpathconf(p, (struct fpathconf_args *)uap);
|
||||||
|
}
|
||||||
|
}
|
103
sys/svr4/svr4_stat.h
Normal file
103
sys/svr4/svr4_stat.h
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_STAT_H_
|
||||||
|
#define _SVR4_STAT_H_
|
||||||
|
|
||||||
|
#include <svr4/svr4_types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
struct svr4_stat {
|
||||||
|
svr4_o_dev_t st_dev;
|
||||||
|
svr4_o_ino_t st_ino;
|
||||||
|
svr4_o_mode_t st_mode;
|
||||||
|
svr4_o_nlink_t st_nlink;
|
||||||
|
svr4_o_uid_t st_uid;
|
||||||
|
svr4_o_gid_t st_gid;
|
||||||
|
svr4_o_dev_t st_rdev;
|
||||||
|
svr4_off_t st_size;
|
||||||
|
svr4_time_t st_atim;
|
||||||
|
svr4_time_t st_mtim;
|
||||||
|
svr4_time_t st_ctim;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_xstat {
|
||||||
|
svr4_dev_t st_dev;
|
||||||
|
long st_pad1[3];
|
||||||
|
svr4_ino_t st_ino;
|
||||||
|
svr4_mode_t st_mode;
|
||||||
|
svr4_nlink_t st_nlink;
|
||||||
|
svr4_uid_t st_uid;
|
||||||
|
svr4_gid_t st_gid;
|
||||||
|
svr4_dev_t st_rdev;
|
||||||
|
long st_pad2[2];
|
||||||
|
svr4_off_t st_size;
|
||||||
|
long st_pad3;
|
||||||
|
svr4_timestruc_t st_atim;
|
||||||
|
svr4_timestruc_t st_mtim;
|
||||||
|
svr4_timestruc_t st_ctim;
|
||||||
|
long st_blksize;
|
||||||
|
svr4_blkcnt_t st_blocks;
|
||||||
|
char st_fstype[16];
|
||||||
|
long st_pad4[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_stat64 {
|
||||||
|
svr4_dev_t st_dev;
|
||||||
|
long st_pad1[3];
|
||||||
|
svr4_ino64_t st_ino;
|
||||||
|
svr4_mode_t st_mode;
|
||||||
|
svr4_nlink_t st_nlink;
|
||||||
|
svr4_uid_t st_uid;
|
||||||
|
svr4_gid_t st_gid;
|
||||||
|
svr4_dev_t st_rdev;
|
||||||
|
long st_pad2[2];
|
||||||
|
svr4_off64_t st_size;
|
||||||
|
svr4_timestruc_t st_atim;
|
||||||
|
svr4_timestruc_t st_mtim;
|
||||||
|
svr4_timestruc_t st_ctim;
|
||||||
|
long st_blksize;
|
||||||
|
svr4_blkcnt64_t st_blocks;
|
||||||
|
char st_fstype[16];
|
||||||
|
long st_pad4[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_PC_LINK_MAX 1
|
||||||
|
#define SVR4_PC_MAX_CANON 2
|
||||||
|
#define SVR4_PC_MAX_INPUT 3
|
||||||
|
#define SVR4_PC_NAME_MAX 4
|
||||||
|
#define SVR4_PC_PATH_MAX 5
|
||||||
|
#define SVR4_PC_PIPE_BUF 6
|
||||||
|
#define SVR4_PC_NO_TRUNC 7
|
||||||
|
#define SVR4_PC_VDISABLE 8
|
||||||
|
#define SVR4_PC_CHOWN_RESTRICTED 9
|
||||||
|
#define SVR4_PC_ASYNC_IO 10
|
||||||
|
#define SVR4_PC_PRIO_IO 11
|
||||||
|
#define SVR4_PC_SYNC_IO 12
|
||||||
|
|
||||||
|
#endif /* !_SVR4_STAT_H_ */
|
70
sys/svr4/svr4_statvfs.h
Normal file
70
sys/svr4/svr4_statvfs.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_STATVFS_H_
|
||||||
|
#define _SVR4_STATVFS_H_
|
||||||
|
|
||||||
|
typedef struct svr4_statvfs {
|
||||||
|
u_long f_bsize;
|
||||||
|
u_long f_frsize;
|
||||||
|
svr4_fsblkcnt_t f_blocks;
|
||||||
|
svr4_fsblkcnt_t f_bfree;
|
||||||
|
svr4_fsblkcnt_t f_bavail;
|
||||||
|
svr4_fsblkcnt_t f_files;
|
||||||
|
svr4_fsblkcnt_t f_ffree;
|
||||||
|
svr4_fsblkcnt_t f_favail;
|
||||||
|
u_long f_fsid;
|
||||||
|
char f_basetype[16];
|
||||||
|
u_long f_flag;
|
||||||
|
u_long f_namemax;
|
||||||
|
char f_fstr[32];
|
||||||
|
u_long f_filler[16];
|
||||||
|
} svr4_statvfs_t;
|
||||||
|
|
||||||
|
typedef struct svr4_statvfs64 {
|
||||||
|
u_long f_bsize;
|
||||||
|
u_long f_frsize;
|
||||||
|
svr4_fsblkcnt64_t f_blocks;
|
||||||
|
svr4_fsblkcnt64_t f_bfree;
|
||||||
|
svr4_fsblkcnt64_t f_bavail;
|
||||||
|
svr4_fsblkcnt64_t f_files;
|
||||||
|
svr4_fsblkcnt64_t f_ffree;
|
||||||
|
svr4_fsblkcnt64_t f_favail;
|
||||||
|
u_long f_fsid;
|
||||||
|
char f_basetype[16];
|
||||||
|
u_long f_flag;
|
||||||
|
u_long f_namemax;
|
||||||
|
char f_fstr[32];
|
||||||
|
u_long f_filler[16];
|
||||||
|
} svr4_statvfs64_t;
|
||||||
|
|
||||||
|
#define SVR4_ST_RDONLY 0x01
|
||||||
|
#define SVR4_ST_NOSUID 0x02
|
||||||
|
#define SVR4_ST_NOTRUNC 0x04
|
||||||
|
|
||||||
|
#endif /* !_SVR4_STATVFS_H_ */
|
2264
sys/svr4/svr4_stream.c
Normal file
2264
sys/svr4/svr4_stream.c
Normal file
File diff suppressed because it is too large
Load diff
0
sys/svr4/svr4_stream.h
Normal file
0
sys/svr4/svr4_stream.h
Normal file
173
sys/svr4/svr4_stropts.h
Normal file
173
sys/svr4/svr4_stropts.h
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Mark Newton
|
||||||
|
* Copyright (c) 1994 Christos Zoulas
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SVR4_STROPTS_H_
|
||||||
|
#define _SVR4_STROPTS_H_
|
||||||
|
|
||||||
|
|
||||||
|
struct svr4_strbuf {
|
||||||
|
int maxlen;
|
||||||
|
int len;
|
||||||
|
char *buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_STR ('S' << 8)
|
||||||
|
#define SVR4_I_NREAD (SVR4_STR| 1)
|
||||||
|
#define SVR4_I_PUSH (SVR4_STR| 2)
|
||||||
|
#define SVR4_I_POP (SVR4_STR| 3)
|
||||||
|
#define SVR4_I_LOOK (SVR4_STR| 4)
|
||||||
|
#define SVR4_I_FLUSH (SVR4_STR| 5)
|
||||||
|
#define SVR4_I_SRDOPT (SVR4_STR| 6)
|
||||||
|
#define SVR4_I_GRDOPT (SVR4_STR| 7)
|
||||||
|
#define SVR4_I_STR (SVR4_STR| 8)
|
||||||
|
#define SVR4_I_SETSIG (SVR4_STR| 9)
|
||||||
|
#define SVR4_I_GETSIG (SVR4_STR|10)
|
||||||
|
#define SVR4_I_FIND (SVR4_STR|11)
|
||||||
|
#define SVR4_I_LINK (SVR4_STR|12)
|
||||||
|
#define SVR4_I_UNLINK (SVR4_STR|13)
|
||||||
|
#define SVR4_I_ERECVFD (SVR4_STR|14)
|
||||||
|
#define SVR4_I_PEEK (SVR4_STR|15)
|
||||||
|
#define SVR4_I_FDINSERT (SVR4_STR|16)
|
||||||
|
#define SVR4_I_SENDFD (SVR4_STR|17)
|
||||||
|
#define SVR4_I_RECVFD (SVR4_STR|18)
|
||||||
|
#define SVR4_I_SWROPT (SVR4_STR|19)
|
||||||
|
#define SVR4_I_GWROPT (SVR4_STR|20)
|
||||||
|
#define SVR4_I_LIST (SVR4_STR|21)
|
||||||
|
#define SVR4_I_PLINK (SVR4_STR|22)
|
||||||
|
#define SVR4_I_PUNLINK (SVR4_STR|23)
|
||||||
|
#define SVR4_I_SETEV (SVR4_STR|24)
|
||||||
|
#define SVR4_I_GETEV (SVR4_STR|25)
|
||||||
|
#define SVR4_I_STREV (SVR4_STR|26)
|
||||||
|
#define SVR4_I_UNSTREV (SVR4_STR|27)
|
||||||
|
#define SVR4_I_FLUSHBAND (SVR4_STR|28)
|
||||||
|
#define SVR4_I_CKBAND (SVR4_STR|29)
|
||||||
|
#define SVR4_I_GETBAND (SVR4_STR|30)
|
||||||
|
#define SVR4_I_ATMARK (SVR4_STR|31)
|
||||||
|
#define SVR4_I_SETCLTIME (SVR4_STR|32)
|
||||||
|
#define SVR4_I_GETCLTIME (SVR4_STR|33)
|
||||||
|
#define SVR4_I_CANPUT (SVR4_STR|34)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following two ioctls are OS specific and
|
||||||
|
* undocumented.
|
||||||
|
*/
|
||||||
|
#define SVR4__I_BIND_RSVD (SVR4_STR|242)
|
||||||
|
#define SVR4__I_RELE_RSVD (SVR4_STR|243)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Service type definitions
|
||||||
|
*/
|
||||||
|
#define SVR4_T_COTS 1 /* Connection-orieted */
|
||||||
|
#define SVR4_T_COTS_ORD 2 /* Local connection-oriented */
|
||||||
|
#define SVR4_T_CLTS 3 /* Connectionless */
|
||||||
|
|
||||||
|
/* Struct passed for SVR4_I_STR */
|
||||||
|
struct svr4_strioctl {
|
||||||
|
u_long cmd;
|
||||||
|
int timeout;
|
||||||
|
int len;
|
||||||
|
char *buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bits for I_{G,S}ETSIG
|
||||||
|
*/
|
||||||
|
#define SVR4_S_INPUT 0x0001 /* any message on read queue no HIPRI */
|
||||||
|
#define SVR4_S_HIPRI 0x0002 /* high prio message on read queue */
|
||||||
|
#define SVR4_S_OUTPUT 0x0004 /* write queue has free space */
|
||||||
|
#define SVR4_S_MSG 0x0008 /* signal message in read queue head */
|
||||||
|
#define SVR4_S_ERROR 0x0010 /* error message in read queue head */
|
||||||
|
#define SVR4_S_HANGUP 0x0020 /* hangup message in read queue head */
|
||||||
|
#define SVR4_S_RDNORM 0x0040 /* normal message on read queue */
|
||||||
|
#define SVR4_S_WRNORM S_OUTPUT /* write queue has free space */
|
||||||
|
#define SVR4_S_RDBAND 0x0080 /* out of band message on read queue */
|
||||||
|
#define SVR4_S_WRBAND 0x0100 /* write queue has free space for oob */
|
||||||
|
#define SVR4_S_BANDURG 0x0200 /* generate SIGURG instead of SIGPOLL */
|
||||||
|
#define SVR4_S_ALLMASK 0x03ff /* all events mask */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our internal state for the stream
|
||||||
|
* For now we keep almost nothing... In the future we can keep more
|
||||||
|
* streams state.
|
||||||
|
*/
|
||||||
|
struct svr4_strm {
|
||||||
|
int s_family; /* socket family */
|
||||||
|
int s_cmd; /* last getmsg reply or putmsg request */
|
||||||
|
int s_afd; /* last accepted fd; [for fd_insert] */
|
||||||
|
int s_eventmask; /* state info from I_SETSIG et al */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following structures are determined empirically.
|
||||||
|
*/
|
||||||
|
struct svr4_strmcmd {
|
||||||
|
long cmd; /* command ? */
|
||||||
|
long len; /* Address len */
|
||||||
|
long offs; /* Address offset */
|
||||||
|
long pad[61];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_infocmd {
|
||||||
|
long cmd;
|
||||||
|
long tsdu;
|
||||||
|
long etsdu;
|
||||||
|
long cdata;
|
||||||
|
long ddata;
|
||||||
|
long addr;
|
||||||
|
long opt;
|
||||||
|
long tidu;
|
||||||
|
long serv;
|
||||||
|
long current;
|
||||||
|
long provider;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_strfdinsert {
|
||||||
|
struct svr4_strbuf ctl;
|
||||||
|
struct svr4_strbuf data;
|
||||||
|
long flags;
|
||||||
|
int fd;
|
||||||
|
int offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_netaddr_in {
|
||||||
|
u_short family;
|
||||||
|
u_short port;
|
||||||
|
u_long addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct svr4_netaddr_un {
|
||||||
|
u_short family;
|
||||||
|
char path[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SVR4_ADDROF(sc) (void *) (((char *) (sc)) + (sc)->offs)
|
||||||
|
#define SVR4_C_ADDROF(sc) (const void *) (((const char *) (sc)) + (sc)->offs)
|
||||||
|
|
||||||
|
struct svr4_strm *svr4_stream_get __P((struct file *fp));
|
||||||
|
|
||||||
|
#endif /* !_SVR4_STROPTS */
|
144
sys/svr4/svr4_syscall.h
Normal file
144
sys/svr4/svr4_syscall.h
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
/*
|
||||||
|
* System call numbers.
|
||||||
|
*
|
||||||
|
* DO NOT EDIT-- this file is automatically generated.
|
||||||
|
* created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SVR4_SYS_exit 1
|
||||||
|
#define SVR4_SYS_fork 2
|
||||||
|
#define SVR4_SYS_read 3
|
||||||
|
#define SVR4_SYS_write 4
|
||||||
|
#define SVR4_SYS_svr4_sys_open 5
|
||||||
|
#define SVR4_SYS_close 6
|
||||||
|
#define SVR4_SYS_svr4_sys_wait 7
|
||||||
|
#define SVR4_SYS_svr4_sys_creat 8
|
||||||
|
#define SVR4_SYS_link 9
|
||||||
|
#define SVR4_SYS_unlink 10
|
||||||
|
#define SVR4_SYS_svr4_sys_execv 11
|
||||||
|
#define SVR4_SYS_chdir 12
|
||||||
|
#define SVR4_SYS_svr4_sys_time 13
|
||||||
|
#define SVR4_SYS_svr4_sys_mknod 14
|
||||||
|
#define SVR4_SYS_chmod 15
|
||||||
|
#define SVR4_SYS_chown 16
|
||||||
|
#define SVR4_SYS_svr4_sys_break 17
|
||||||
|
#define SVR4_SYS_svr4_sys_stat 18
|
||||||
|
#define SVR4_SYS_lseek 19
|
||||||
|
#define SVR4_SYS_getpid 20
|
||||||
|
#define SVR4_SYS_setuid 23
|
||||||
|
#define SVR4_SYS_getuid 24
|
||||||
|
#define SVR4_SYS_svr4_sys_alarm 27
|
||||||
|
#define SVR4_SYS_svr4_sys_fstat 28
|
||||||
|
#define SVR4_SYS_svr4_sys_pause 29
|
||||||
|
#define SVR4_SYS_svr4_sys_utime 30
|
||||||
|
#define SVR4_SYS_svr4_sys_access 33
|
||||||
|
#define SVR4_SYS_svr4_sys_nice 34
|
||||||
|
#define SVR4_SYS_sync 36
|
||||||
|
#define SVR4_SYS_svr4_sys_kill 37
|
||||||
|
#define SVR4_SYS_svr4_sys_pgrpsys 39
|
||||||
|
#define SVR4_SYS_dup 41
|
||||||
|
#define SVR4_SYS_pipe 42
|
||||||
|
#define SVR4_SYS_svr4_sys_times 43
|
||||||
|
#define SVR4_SYS_setgid 46
|
||||||
|
#define SVR4_SYS_getgid 47
|
||||||
|
#define SVR4_SYS_svr4_sys_signal 48
|
||||||
|
#define SVR4_SYS_svr4_sys_msgsys 49
|
||||||
|
#define SVR4_SYS_svr4_sys_sysarch 50
|
||||||
|
#define SVR4_SYS_svr4_sys_ioctl 54
|
||||||
|
#define SVR4_SYS_svr4_sys_utssys 57
|
||||||
|
#define SVR4_SYS_fsync 58
|
||||||
|
#define SVR4_SYS_svr4_sys_execve 59
|
||||||
|
#define SVR4_SYS_umask 60
|
||||||
|
#define SVR4_SYS_chroot 61
|
||||||
|
#define SVR4_SYS_svr4_sys_fcntl 62
|
||||||
|
#define SVR4_SYS_svr4_sys_ulimit 63
|
||||||
|
#define SVR4_SYS_rmdir 79
|
||||||
|
#define SVR4_SYS_mkdir 80
|
||||||
|
#define SVR4_SYS_svr4_sys_getdents 81
|
||||||
|
#define SVR4_SYS_svr4_sys_getmsg 85
|
||||||
|
#define SVR4_SYS_svr4_sys_putmsg 86
|
||||||
|
#define SVR4_SYS_svr4_sys_poll 87
|
||||||
|
#define SVR4_SYS_svr4_sys_lstat 88
|
||||||
|
#define SVR4_SYS_symlink 89
|
||||||
|
#define SVR4_SYS_readlink 90
|
||||||
|
#define SVR4_SYS_getgroups 91
|
||||||
|
#define SVR4_SYS_setgroups 92
|
||||||
|
#define SVR4_SYS_fchmod 93
|
||||||
|
#define SVR4_SYS_fchown 94
|
||||||
|
#define SVR4_SYS_svr4_sys_sigprocmask 95
|
||||||
|
#define SVR4_SYS_svr4_sys_sigsuspend 96
|
||||||
|
#define SVR4_SYS_svr4_sys_sigaltstack 97
|
||||||
|
#define SVR4_SYS_svr4_sys_sigaction 98
|
||||||
|
#define SVR4_SYS_svr4_sys_sigpending 99
|
||||||
|
#define SVR4_SYS_svr4_sys_context 100
|
||||||
|
#define SVR4_SYS_svr4_sys_statvfs 103
|
||||||
|
#define SVR4_SYS_svr4_sys_fstatvfs 104
|
||||||
|
#define SVR4_SYS_svr4_sys_waitsys 107
|
||||||
|
#define SVR4_SYS_svr4_sys_hrtsys 109
|
||||||
|
#define SVR4_SYS_svr4_sys_pathconf 113
|
||||||
|
#define SVR4_SYS_svr4_sys_mmap 115
|
||||||
|
#define SVR4_SYS_mprotect 116
|
||||||
|
#define SVR4_SYS_munmap 117
|
||||||
|
#define SVR4_SYS_svr4_sys_fpathconf 118
|
||||||
|
#define SVR4_SYS_vfork 119
|
||||||
|
#define SVR4_SYS_fchdir 120
|
||||||
|
#define SVR4_SYS_readv 121
|
||||||
|
#define SVR4_SYS_writev 122
|
||||||
|
#define SVR4_SYS_svr4_sys_xstat 123
|
||||||
|
#define SVR4_SYS_svr4_sys_lxstat 124
|
||||||
|
#define SVR4_SYS_svr4_sys_fxstat 125
|
||||||
|
#define SVR4_SYS_svr4_sys_xmknod 126
|
||||||
|
#define SVR4_SYS_svr4_sys_setrlimit 128
|
||||||
|
#define SVR4_SYS_svr4_sys_getrlimit 129
|
||||||
|
#define SVR4_SYS_lchown 130
|
||||||
|
#define SVR4_SYS_svr4_sys_memcntl 131
|
||||||
|
#define SVR4_SYS_rename 134
|
||||||
|
#define SVR4_SYS_svr4_sys_uname 135
|
||||||
|
#define SVR4_SYS_setegid 136
|
||||||
|
#define SVR4_SYS_svr4_sys_sysconfig 137
|
||||||
|
#define SVR4_SYS_adjtime 138
|
||||||
|
#define SVR4_SYS_svr4_sys_systeminfo 139
|
||||||
|
#define SVR4_SYS_seteuid 141
|
||||||
|
#define SVR4_SYS_svr4_sys_fchroot 153
|
||||||
|
#define SVR4_SYS_svr4_sys_utimes 154
|
||||||
|
#define SVR4_SYS_svr4_sys_vhangup 155
|
||||||
|
#define SVR4_SYS_svr4_sys_gettimeofday 156
|
||||||
|
#define SVR4_SYS_getitimer 157
|
||||||
|
#define SVR4_SYS_setitimer 158
|
||||||
|
#define SVR4_SYS_svr4_sys_llseek 175
|
||||||
|
#define SVR4_SYS_svr4_sys_acl 185
|
||||||
|
#define SVR4_SYS_svr4_sys_auditsys 186
|
||||||
|
#define SVR4_SYS_nanosleep 199
|
||||||
|
#define SVR4_SYS_svr4_sys_facl 200
|
||||||
|
#define SVR4_SYS_setreuid 202
|
||||||
|
#define SVR4_SYS_setregid 203
|
||||||
|
#define SVR4_SYS_svr4_sys_resolvepath 209
|
||||||
|
#define SVR4_SYS_svr4_sys_getdents64 213
|
||||||
|
#define SVR4_SYS_svr4_sys_mmap64 214
|
||||||
|
#define SVR4_SYS_svr4_sys_stat64 215
|
||||||
|
#define SVR4_SYS_svr4_sys_lstat64 216
|
||||||
|
#define SVR4_SYS_svr4_sys_fstat64 217
|
||||||
|
#define SVR4_SYS_svr4_sys_statvfs64 218
|
||||||
|
#define SVR4_SYS_svr4_sys_fstatvfs64 219
|
||||||
|
#define SVR4_SYS_svr4_sys_setrlimit64 220
|
||||||
|
#define SVR4_SYS_svr4_sys_getrlimit64 221
|
||||||
|
#define SVR4_SYS_svr4_sys_creat64 224
|
||||||
|
#define SVR4_SYS_svr4_sys_open64 225
|
||||||
|
#define SVR4_SYS_svr4_sys_socket 230
|
||||||
|
#define SVR4_SYS_socketpair 231
|
||||||
|
#define SVR4_SYS_bind 232
|
||||||
|
#define SVR4_SYS_listen 233
|
||||||
|
#define SVR4_SYS_accept 234
|
||||||
|
#define SVR4_SYS_connect 235
|
||||||
|
#define SVR4_SYS_shutdown 236
|
||||||
|
#define SVR4_SYS_svr4_sys_recv 237
|
||||||
|
#define SVR4_SYS_recvfrom 238
|
||||||
|
#define SVR4_SYS_recvmsg 239
|
||||||
|
#define SVR4_SYS_svr4_sys_send 240
|
||||||
|
#define SVR4_SYS_sendmsg 241
|
||||||
|
#define SVR4_SYS_svr4_sys_sendto 242
|
||||||
|
#define SVR4_SYS_getpeername 243
|
||||||
|
#define SVR4_SYS_getsockname 244
|
||||||
|
#define SVR4_SYS_getsockopt 245
|
||||||
|
#define SVR4_SYS_setsockopt 246
|
||||||
|
#define SVR4_SYS_MAXSYSCALL 250
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue