sysent.c revision 5eaceb49d5b95dd7910af115172887f8dbddfb4c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* ONC_PLUS EXTRACT START */
/*
* Copyright 2012 Milan Jurik. All rights reserved.
* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* ONC_PLUS EXTRACT END */
#include <sys/systrace.h>
#include <sys/int_types.h>
#include <sys/sendfile.h>
struct hrtsysa;
struct mmaplf32a;
/* ONC_PLUS EXTRACT START */
/*
* This table is the switch used to transfer to the appropriate
* routine for processing a system call. Each row contains the
* number of arguments expected, a switch that tells systrap()
* in trap.c whether a setjmp() is not necessary, and a pointer
* to the routine.
*/
/* ONC_PLUS EXTRACT END */
int access(char *, int);
int alarm(int);
int chdir(char *);
int chmod(char *, int);
int chroot(char *);
int cladm(int, int, void *);
int close(int);
int exece(const char *, const char **, const char **);
int faccessat(int, char *, int, int);
int fchmodat(int, char *, int, int);
int fdsync(int, int);
int ucredsys(int, int, void *);
int getloadavg(int *, int);
int rusagesys(int, void *, void *, void *, void *);
int getpagesizes(int, size_t *, int);
#endif /* __i386 || __amd64 */
int kill();
int labelsys(int, void *, void *, void *, void *, void *);
int link(char *, char *);
int linkat(int, char *, int, char *, int);
int lgrpsys(int, long, void *);
int nice(int);
int nullsys();
int open(char *, int, int);
int openat(int, char *, int, int);
int pause();
long pcsample(void *, long);
int rename(char *, char *);
int renameat(int, char *, int, char *);
void rexit(int);
int semsys();
int setpgrp(int, int, int);
int sigsuspend(sigset_t);
int sigpending(int, sigset_t *);
int getsetcontext(int, void *);
int syssync();
int sysacct(char *);
long ulimit(int, long);
int getrlimit32(int, struct rlimit32 *);
int setrlimit32(int, struct rlimit32 *);
int umask(int);
int umount2(char *, int);
int unlink(char *);
int unlinkat(int, char *, int);
int rmdir(char *);
int mkdir(char *, int);
int mkdirat(int, char *, int);
int getdents32(int, void *, size_t);
int sysfs(int, long, long);
int uadmin();
int symlink(char *, char *);
int symlinkat(char *, int, char *);
int resolvepath(char *, char *, size_t);
int fchdir(int);
int fchmod(int, int);
#endif
int acl(const char *, int, int, void *);
int facl(int, int, int, void *);
int sigsendsys(procset_t *, int);
long sysconfig(int);
long systeminfo(int, char *, long);
#ifdef __sparc
#endif
void syslwp_exit();
int syslwp_suspend(id_t);
int syslwp_continue(id_t);
int syslwp_private(int, int, uintptr_t);
int lwp_detach(id_t);
int lwp_info(timestruc_t *);
int lwp_self();
int yield();
int lwp_mutex_wakeup(lwp_mutex_t *, int);
int lwp_mutex_unlock(lwp_mutex_t *);
int lwp_sema_post(lwp_sema_t *);
int lwp_sema_trywait(lwp_sema_t *);
int lwp_cond_signal(lwp_cond_t *);
int lwp_cond_broadcast(lwp_cond_t *);
long pathconf(char *, int);
long fpathconf(int, int);
int p_online(processorid_t, int);
/*
* POSIX .4 system calls *
*/
int timer_delete(timer_t);
int timer_getoverrun(timer_t);
int getdents64(int, void *, size_t);
int fstatvfs64(int, struct statvfs64 *);
int setrlimit64(int, struct rlimit64 *);
int getrlimit64(int, struct rlimit64 *);
int open64(char *, int, int);
int openat64(int, char *, int, int);
/*
* NTP syscalls
*/
int ntp_gettime(struct ntptimeval *);
int ntp_adjtime(struct timex *);
/*
* ++++++++++++++++++++++++
* ++ SunOS4.1 Buyback ++
* ++++++++++++++++++++++++
*
* fchroot, vhangup, gettimeofday
*/
int fchroot(int);
int vhangup();
int gettimeofday(struct timeval *);
long zone();
int so_socket(int, int, int, char *, int);
int so_socketpair(int[2]);
int listen(int, int, int);
int shutdown(int, int, int);
int getsockopt(int, int, int, void *, socklen_t *, int);
int setsockopt(int, int, int, void *, socklen_t *, int);
int sockconfig(int, void *, void *, void *, void *);
/*
* Sysent initialization macros.
* These take the name string of the system call even though that isn't
* currently used in the sysent entry. This might be useful someday.
*
* Initialization macro for system calls which take their args in the C style.
* These system calls return the longlong_t return value and must call
* set_errno() to return an error. For SPARC, narg must be at most six.
* For more args, use the SYSENT_AP() routine.
*
* We are able to return two distinct values to userland via the rval_t.
* At this time, that corresponds to one 64-bit quantity, or two 32-bit
* quantities. The kernel does not currently need to return two 64-bit
* values, or one 128 bit value(!), but we may do one day, so the calling
* sequence between userland and the kernel should permit it.
*
* The interpretation of rval_t is provided by the sy_flags field
* which is used to determine how to arrange the results in registers
* (or on the stack) for return userland.
*/
/* returns a 64-bit quantity for both ABIs */
/* returns one 32-bit value for both ABIs: r_val1 */
/* returns 2 32-bit values: r_val1 & r_val2 */
/*
* Initialization macro for system calls which take their args in the standard
* Unix style of a pointer to the arg structure and a pointer to the rval_t.
*
* Deprecated wherever possible (slower on some architectures, and trickier
* to maintain two flavours).
*/
/*
* Conditional constructors to build the tables without #ifdef clutter
*/
#if defined(_LP64)
#define IF_LP64(true, false) true
#else
#define IF_LP64(true, false) false
#endif
#if defined(__sparc)
#define IF_sparc(true, false) true
#else
#define IF_sparc(true, false) false
#endif
#define IF_i386(true, false) true
#else
#define IF_i386(true, false) false
#endif
#define IF_x86(true, false) true
#else
#define IF_x86(true, false) false
#endif
#define IF_386_ABI(true, false) true
#else
#define IF_386_ABI(true, false) false
#endif
/*
* Define system calls that return a native 'long' quantity i.e. a 32-bit
* or 64-bit integer - depending on how the kernel is itself compiled
* e.g. read(2) returns 'ssize_t' in the kernel and in userland.
*/
/*
* Initialization macro for loadable native system calls.
*/
#define SYSENT_LOADABLE() \
/* ONC_PLUS EXTRACT END */
/*
* Initialization macro for loadable 32-bit compatibility system calls.
*/
#define SYSENT_LOADABLE32() SYSENT_LOADABLE()
/* ONC_PLUS EXTRACT START */
/*
* Native sysent table.
*/
{
/* ONC_PLUS EXTRACT END */
/* 0 */ IF_LP64(
SYSENT_NOSYS(),
/* 19 */ IF_LP64(
/* 35 */ IF_LP64(
SYSENT_NOSYS(),
/* 38 */ IF_LP64(
SYSENT_NOSYS(),
/* 50 */ IF_x86(
SYSENT_LOADABLE()), /* (was sys3b) */
/* 57 */ IF_LP64(
/* 67 */ IF_LP64(
SYSENT_NOSYS(),
/* 69 */ IF_LP64(
SYSENT_NOSYS(),
/* 81 */ IF_LP64(
/* ONC_PLUS EXTRACT START */
/* ONC_PLUS EXTRACT END */
/* 109 */ IF_x86(
SYSENT_LOADABLE()),
/* 115 */ IF_LP64(
/* 128 */ IF_LP64(
/* 129 */ IF_LP64(
/* 166 */ IF_x86(
SYSENT_NOSYS()),
/*
* The 64-bit C library maps llseek() to lseek(), so this
* is needed as a native syscall only on the 32-bit kernel.
*/
/* 175 */ IF_LP64(
SYSENT_NOSYS(),
/* 208 */ IF_sparc(
SYSENT_NOSYS()),
/*
* Syscalls 213-225: 32-bit system call support for large files.
*
* (The 64-bit C library transparently maps these system calls
* back to their native versions, so almost all of them are only
* needed as native syscalls on the 32-bit kernel).
*/
/* 213 */ IF_LP64(
SYSENT_NOSYS(),
/* 214 */ IF_LP64(
SYSENT_NOSYS(),
/* 215 */ IF_LP64(
SYSENT_NOSYS(),
/* 216 */ IF_LP64(
SYSENT_NOSYS(),
/* 217 */ IF_LP64(
SYSENT_NOSYS(),
/* 218 */ IF_LP64(
SYSENT_NOSYS(),
/* 219 */ IF_LP64(
SYSENT_NOSYS(),
/* 220 */ IF_LP64(
SYSENT_NOSYS(),
/* 221 */ IF_LP64(
SYSENT_NOSYS(),
/* 222 */ IF_LP64(
SYSENT_NOSYS(),
/* 223 */ IF_LP64(
SYSENT_NOSYS(),
/* 225 */ IF_LP64(
SYSENT_NOSYS(),
/* ONC_PLUS EXTRACT START */
};
/* ONC_PLUS EXTRACT END */
#ifdef _SYSCALL32_IMPL
extern int ulimit32(int, int);
extern int open32(char *, int, int);
extern int openat32(int, char *, int, int);
extern int fstatat64_32(int, char *, struct stat64_32 *, int);
extern int lstat64_32(char *, struct stat64_32 *);
extern int fstat64_32(int, struct stat64_32 *);
int32_t *);
int32_t);
extern int getsetcontext32(int, void *);
extern int fstatvfs32(int, struct statvfs32 *);
extern int statvfs64_32(char *, struct statvfs64_32 *);
extern int fstatvfs64_32(int, struct statvfs64_32 *);
extern int getpagesizes32(int, size32_t *, int);
extern int ucredsys32(int, int, caddr32_t);
/* ONC_PLUS EXTRACT START */
/*
* sysent table for ILP32 processes running on
* a LP64 kernel.
*/
{
/* ONC_PLUS EXTRACT END */
/* 50 */ IF_386_ABI(
SYSENT_LOADABLE32()), /* (was sys3b) */
/* ONC_PLUS EXTRACT START */
/* ONC_PLUS EXTRACT END */
/* 109 */ IF_x86(
/* 166 */ IF_x86(
SYSENT_NOSYS()),
/* 208 */ SYSENT_LOADABLE32(),
/*
* Syscalls 213-225: 32-bit system call support for large files.
*/
/* ONC_PLUS EXTRACT START */
};
/* ONC_PLUS EXTRACT END */
#endif /* _SYSCALL32_IMPL */
/*
* Space allocated and initialized in init_syscallnames().
*/
char **syscallnames;
/*ARGSUSED*/
void
{}
/*ARGSUSED*/
{
proc_t *p;
/*
* We want to explicitly allow DTrace consumers to stop a process
* before it actually executes the meat of the syscall.
*/
mutex_enter(&p->p_lock);
curthread->t_dtrace_stop = 0;
stop(PR_REQUESTED, 0);
}
mutex_exit(&p->p_lock);
rval = -1;
return (rval);
}
#ifdef _SYSCALL32_IMPL
/*ARGSUSED*/
{
proc_t *p;
/*
* We want to explicitly allow DTrace consumers to stop a process
* before it actually executes the meat of the syscall.
*/
mutex_enter(&p->p_lock);
curthread->t_dtrace_stop = 0;
stop(PR_REQUESTED, 0);
}
mutex_exit(&p->p_lock);
rval = -1;
return (rval);
}
#endif
void
dtrace_systrace_rtt(void)
{
if (get_udatamodel() == DATAMODEL_NATIVE) {
if (systrace_sysent == NULL)
return;
#ifdef _SYSCALL32_IMPL
} else {
if (systrace_sysent32 == NULL)
return;
#endif
}
(*systrace_probe)(id, 0, 0, 0, 0, 0, 0);
}