diff options
author | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
---|---|---|
committer | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
commit | 7c478bd95313f5f23a4c958a745db2134aa03244 (patch) | |
tree | c871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/lib/libc/port/sys | |
download | illumos-gate-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz |
OpenSolaris Launch
Diffstat (limited to 'usr/src/lib/libc/port/sys')
46 files changed, 3833 insertions, 0 deletions
diff --git a/usr/src/lib/libc/port/sys/_autofssys.c b/usr/src/lib/libc/port/sys/_autofssys.c new file mode 100644 index 0000000000..0f0ceb7312 --- /dev/null +++ b/usr/src/lib/libc/port/sys/_autofssys.c @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/fs/autofs.h> +#include <errno.h> + +int +_autofssys(enum autofssys_op op, void *arg) +{ + return (syscall(SYS_autofssys, op, arg, NULL, NULL, NULL, NULL)); +} diff --git a/usr/src/lib/libc/port/sys/acctctl.c b/usr/src/lib/libc/port/sys/acctctl.c new file mode 100644 index 0000000000..4dfa279e05 --- /dev/null +++ b/usr/src/lib/libc/port/sys/acctctl.c @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright (c) 1999-2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#ident "%Z%%M% %I% %E% SMI" + +#pragma weak acctctl = _acctctl + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> + +int +acctctl(int cmd, void *buf, size_t bufsz) +{ + return (syscall(SYS_acctctl, cmd, buf, bufsz)); +} diff --git a/usr/src/lib/libc/port/sys/bsd_signal.c b/usr/src/lib/libc/port/sys/bsd_signal.c new file mode 100644 index 0000000000..3e24c28c51 --- /dev/null +++ b/usr/src/lib/libc/port/sys/bsd_signal.c @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak bsd_signal = _bsd_signal + +#include "synonyms.h" +#include <sys/types.h> +#include <errno.h> +#include <signal.h> +#include <wait.h> + +/* + * Check for valid signal number + */ +#define CHECK_SIG(s, code) \ + if ((s) <= 0 || (s) >= NSIG || (s) == SIGKILL || (s) == SIGSTOP) { \ + errno = EINVAL; \ + return (code); \ + } + +void (* +bsd_signal(int sig, void(*func)(int)))(int) +{ + struct sigaction nact; + struct sigaction oact; + + CHECK_SIG(sig, SIG_ERR); + + nact.sa_handler = func; + nact.sa_flags = SA_RESTART; + (void) sigemptyset(&nact.sa_mask); + (void) sigaddset(&nact.sa_mask, sig); + + if (sigaction(sig, &nact, &oact) == -1) + return (SIG_ERR); + + return (oact.sa_handler); +} diff --git a/usr/src/lib/libc/port/sys/corectl.c b/usr/src/lib/libc/port/sys/corectl.c new file mode 100644 index 0000000000..67138b54fc --- /dev/null +++ b/usr/src/lib/libc/port/sys/corectl.c @@ -0,0 +1,130 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak core_set_options = _core_set_options +#pragma weak core_get_options = _core_get_options +#pragma weak core_set_global_content = _core_set_global_content +#pragma weak core_get_global_content = _core_get_global_content +#pragma weak core_set_global_path = _core_set_global_path +#pragma weak core_get_global_path = _core_get_global_path +#pragma weak core_set_default_content = _core_set_default_content +#pragma weak core_get_default_content = _core_get_default_content +#pragma weak core_set_default_path = _core_set_default_path +#pragma weak core_get_default_path = _core_get_default_path +#pragma weak core_set_process_content = _core_set_process_content +#pragma weak core_get_process_content = _core_get_process_content +#pragma weak core_set_process_path = _core_set_process_path +#pragma weak core_get_process_path = _core_get_process_path + +#include "synonyms.h" +#include <sys/corectl.h> +#include <sys/syscall.h> + +int +core_set_options(int options) +{ + return (syscall(SYS_corectl, CC_SET_OPTIONS, options)); +} + +int +core_get_options(void) +{ + return (syscall(SYS_corectl, CC_GET_OPTIONS)); +} + +int +core_set_global_content(const core_content_t *content) +{ + return (syscall(SYS_corectl, CC_SET_GLOBAL_CONTENT, content)); +} + +int +core_get_global_content(core_content_t *content) +{ + return (syscall(SYS_corectl, CC_GET_GLOBAL_CONTENT, content)); +} + +int +core_set_global_path(const char *buf, size_t bufsize) +{ + return (syscall(SYS_corectl, CC_SET_GLOBAL_PATH, buf, bufsize)); +} + +int +core_get_global_path(char *buf, size_t bufsize) +{ + return (syscall(SYS_corectl, CC_GET_GLOBAL_PATH, buf, bufsize)); +} + +int +core_set_default_content(const core_content_t *content) +{ + return (syscall(SYS_corectl, CC_SET_DEFAULT_CONTENT, content)); +} + +int +core_get_default_content(core_content_t *content) +{ + return (syscall(SYS_corectl, CC_GET_DEFAULT_CONTENT, content)); +} + +int +core_set_default_path(const char *buf, size_t bufsize) +{ + return (syscall(SYS_corectl, CC_SET_DEFAULT_PATH, buf, bufsize)); +} + +int +core_get_default_path(char *buf, size_t bufsize) +{ + return (syscall(SYS_corectl, CC_GET_DEFAULT_PATH, buf, bufsize)); +} + +int +core_set_process_content(const core_content_t *content, pid_t pid) +{ + return (syscall(SYS_corectl, CC_SET_PROCESS_CONTENT, content, pid)); +} + +int +core_get_process_content(core_content_t *content, pid_t pid) +{ + return (syscall(SYS_corectl, CC_GET_PROCESS_CONTENT, content, pid)); +} + +int +core_set_process_path(const char *buf, size_t bufsize, pid_t pid) +{ + return (syscall(SYS_corectl, CC_SET_PROCESS_PATH, buf, bufsize, pid)); +} + +int +core_get_process_path(char *buf, size_t bufsize, pid_t pid) +{ + return (syscall(SYS_corectl, CC_GET_PROCESS_PATH, buf, bufsize, pid)); +} diff --git a/usr/src/lib/libc/port/sys/exacctsys.c b/usr/src/lib/libc/port/sys/exacctsys.c new file mode 100644 index 0000000000..017545c262 --- /dev/null +++ b/usr/src/lib/libc/port/sys/exacctsys.c @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak getacct = _getacct +#pragma weak putacct = _putacct +#pragma weak wracct = _wracct + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/procset.h> + +size_t +getacct(idtype_t idtype, id_t id, void *buf, size_t bufsize) +{ + sysret_t rval; + int error; + + error = __systemcall(&rval, SYS_exacctsys, + 0, idtype, id, buf, bufsize, 0); + if (error) + (void) __set_errno(error); + return ((size_t)rval.sys_rval1); +} + +int +putacct(idtype_t idtype, id_t id, void *buf, size_t bufsize, int flags) +{ + return (syscall(SYS_exacctsys, 1, idtype, id, buf, bufsize, flags)); +} + +int +wracct(idtype_t idtype, id_t id, int flags) +{ + return (syscall(SYS_exacctsys, 2, idtype, id, NULL, 0, flags)); +} diff --git a/usr/src/lib/libc/port/sys/execl.c b/usr/src/lib/libc/port/sys/execl.c new file mode 100644 index 0000000000..cdfcb1508d --- /dev/null +++ b/usr/src/lib/libc/port/sys/execl.c @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * execl(name, arg0, arg1, ..., argn, 0) + * environment automatically passed. + */ + +#pragma weak execl = _execl + +#include "synonyms.h" +#include <alloca.h> +#include <malloc.h> +#include <stdarg.h> +#include <sys/types.h> +#include <unistd.h> + +/*VARARGS1*/ +int +execl(const char *name, const char *arg0, ...) +{ + char **argp; + va_list args; + char **argvec; + extern char **environ; + int err; + int nargs = 0; + char *nextarg; + + /* + * count the number of arguments in the variable argument list + * and allocate an argument vector for them on the stack, + * adding an extra element for a terminating null pointer + */ + + va_start(args, arg0); + while (va_arg(args, char *) != (char *)0) { + nargs++; + } + va_end(args); + + /* + * load the arguments in the variable argument list + * into the argument vector and add the terminating null pointer + */ + + va_start(args, arg0); + + /* workaround for bugid 1242839 */ + argvec = (char **)alloca((size_t)((nargs + 2) * sizeof (char *))); + argp = argvec; + *argp++ = (char *)arg0; + while ((nextarg = va_arg(args, char *)) != (char *)0) { + *argp++ = nextarg; + } + va_end(args); + *argp = (char *)0; + + /* + * call execve() + */ + + err = execve(name, argvec, environ); + return (err); +} diff --git a/usr/src/lib/libc/port/sys/execle.c b/usr/src/lib/libc/port/sys/execle.c new file mode 100644 index 0000000000..ecaa7965f4 --- /dev/null +++ b/usr/src/lib/libc/port/sys/execle.c @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * execle(file, arg1, arg2, ..., 0, envp) + */ + +#pragma weak execle = _execle + +#include "synonyms.h" +#include <sys/types.h> +#include <alloca.h> +#include <malloc.h> +#include <stdarg.h> +#include <unistd.h> + +/*VARARGS1*/ +int +execle(const char *file, const char *arg0, ...) +{ + char **argp; + va_list args; + char **argvec; + register char **environmentp; + int err; + int nargs = 0; + char *nextarg; + + /* + * count the number of arguments in the variable argument list + * and allocate an argument vector for them on the stack, + * adding space at the end for a terminating null pointer + */ + + va_start(args, arg0); + while (va_arg(args, char *) != (char *)0) { + nargs++; + } + + /* + * save the environment pointer, which is at the end of the + * variable argument list + */ + + environmentp = va_arg(args, char **); + va_end(args); + + /* + * load the arguments in the variable argument list + * into the argument vector, and add the terminating null pointer + */ + + va_start(args, arg0); + /* workaround for bugid 1242839 */ + argvec = (char **)alloca((size_t)((nargs + 2) * sizeof (char *))); + argp = argvec; + *argp++ = (char *)arg0; + while ((nextarg = va_arg(args, char *)) != (char *)0) { + *argp++ = nextarg; + } + va_end(args); + *argp = (char *)0; + + /* + * call execve() + */ + + err = execve(file, argvec, environmentp); + return (err); +} diff --git a/usr/src/lib/libc/port/sys/execv.c b/usr/src/lib/libc/port/sys/execv.c new file mode 100644 index 0000000000..8b5608f173 --- /dev/null +++ b/usr/src/lib/libc/port/sys/execv.c @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +/* + * execv(file, argv) + * + * where argv is a vector argv[0] ... argv[x], NULL + * last vector element must be NULL + * environment passed automatically + */ + +#pragma weak execv = _execv + +#include "synonyms.h" +#include <sys/types.h> +#include <unistd.h> + +int +execv(const char *file, char *const argv[]) +{ + extern char **environ; + return (execve(file, argv, environ)); +} diff --git a/usr/src/lib/libc/port/sys/fcntl.c b/usr/src/lib/libc/port/sys/fcntl.c new file mode 100644 index 0000000000..4c4b6f56f0 --- /dev/null +++ b/usr/src/lib/libc/port/sys/fcntl.c @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "synonyms.h" +#include <sys/param.h> +#include <sys/sockio.h> +#include <sys/filio.h> +#include <sys/file.h> +#include <sys/types.h> +#include <sys/fcntl.h> +#include <signal.h> +#include <sys/stat.h> +#include <sys/stropts.h> +#include <sys/socket.h> +#include <sys/stropts.h> +#include <sys/stream.h> +#include <sys/socketvar.h> +#include <sys/syscall.h> +#include <errno.h> +#include <stdio.h> +#include <stdarg.h> +#include <unistd.h> +#include <string.h> +#include <stdlib.h> +#include "libc.h" + +extern int __fcntl(int fd, int cmd, intptr_t arg); + +#if !defined(_LP64) +/* + * XXX these hacks are needed for X.25 which assumes that s_fcntl and + * s_ioctl exist in the socket library. + * There is no need for a _s_ioctl for other purposes. + */ +#pragma weak s_fcntl = _fcntl +#pragma weak _s_fcntl = _fcntl +#pragma weak s_ioctl = _s_ioctl + +int +_s_ioctl(int fd, int cmd, intptr_t arg) +{ + return (ioctl(fd, cmd, arg)); +} +/* End XXX */ +#endif /* _LP64 */ + +int +_fcntl(int fd, int cmd, ...) +{ + int res; + int pid; + intptr_t arg; + va_list ap; + + va_start(ap, cmd); + arg = va_arg(ap, intptr_t); + va_end(ap); + + switch (cmd) { + case F_SETOWN: + pid = (int)arg; + return (ioctl(fd, FIOSETOWN, &pid)); + + case F_GETOWN: + if (ioctl(fd, FIOGETOWN, &res) < 0) + return (-1); + return (res); + + default: + return (__fcntl(fd, cmd, arg)); + } +} diff --git a/usr/src/lib/libc/port/sys/fsmisc.c b/usr/src/lib/libc/port/sys/fsmisc.c new file mode 100644 index 0000000000..88415c5363 --- /dev/null +++ b/usr/src/lib/libc/port/sys/fsmisc.c @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak fchownat = _fchownat +#pragma weak renameat = _renameat +#pragma weak futimesat = _futimesat +#pragma weak unlinkat = _unlinkat + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/stat.h> +#include <sys/time.h> + +int +fchownat(int fd, const char *name, uid_t uid, gid_t gid, int flags) +{ + return (syscall(SYS_fsat, 4, fd, name, uid, gid, flags)); +} + +int +unlinkat(int fd, const char *name, int flags) +{ + return (syscall(SYS_fsat, 5, fd, name, flags)); +} + +int +futimesat(int fd, const char *name, const struct timeval *tv) +{ + return (syscall(SYS_fsat, 6, fd, name, tv)); +} + +int +renameat(int fromfd, const char *fromname, int tofd, const char *toname) +{ + return (syscall(SYS_fsat, 7, fromfd, fromname, tofd, toname)); +} diff --git a/usr/src/lib/libc/port/sys/fstatat.c b/usr/src/lib/libc/port/sys/fstatat.c new file mode 100644 index 0000000000..e919879073 --- /dev/null +++ b/usr/src/lib/libc/port/sys/fstatat.c @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#pragma weak fstatat64 = _fstatat64 +#else +#pragma weak fstatat = _fstatat +#endif + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/stat.h> + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 + +int +fstatat64(int fd, const char *name, struct stat64 *sb, int flags) +{ + return (syscall(SYS_fsat, 2, fd, name, sb, flags)); +} + +#else + +int +fstatat(int fd, const char *name, struct stat *sb, int flags) +{ + return (syscall(SYS_fsat, 3, fd, name, sb, flags)); +} + +#endif diff --git a/usr/src/lib/libc/port/sys/fsync.c b/usr/src/lib/libc/port/sys/fsync.c new file mode 100644 index 0000000000..d6827f60f3 --- /dev/null +++ b/usr/src/lib/libc/port/sys/fsync.c @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * fsync(int fd) + * + */ +#include "synonyms.h" +#include <sys/types.h> +#include "libc.h" +#include "sys/file.h" + +int +_fsync(int fd) +{ + return (__fdsync(fd, FSYNC)); +} diff --git a/usr/src/lib/libc/port/sys/getpeerucred.c b/usr/src/lib/libc/port/sys/getpeerucred.c new file mode 100644 index 0000000000..5712f12a33 --- /dev/null +++ b/usr/src/lib/libc/port/sys/getpeerucred.c @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak getpeerucred = _getpeerucred + +#include "synonyms.h" + +#include <sys/types.h> +#include <sys/syscall.h> +#include <ucred.h> +#include <sys/ucred.h> + +int +getpeerucred(int fd, ucred_t **ucp) +{ + ucred_t *uc = *ucp; + + if (uc == NULL) { + uc = _ucred_alloc(); + if (uc == NULL) + return (-1); + } + + if (syscall(SYS_ucredsys, UCREDSYS_GETPEERUCRED, fd, uc) != 0) { + if (*ucp == NULL) + ucred_free(uc); + return (-1); + } + *ucp = uc; + return (0); +} diff --git a/usr/src/lib/libc/port/sys/inst_sync.c b/usr/src/lib/libc/port/sys/inst_sync.c new file mode 100644 index 0000000000..2da71160b7 --- /dev/null +++ b/usr/src/lib/libc/port/sys/inst_sync.c @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright (c) 2000 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak inst_sync = _inst_sync + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/instance.h> + +int +inst_sync(char *pathname, int flags) +{ + return (syscall(SYS_inst_sync, pathname, flags)); +} diff --git a/usr/src/lib/libc/port/sys/issetugid.c b/usr/src/lib/libc/port/sys/issetugid.c new file mode 100644 index 0000000000..8043ca69e6 --- /dev/null +++ b/usr/src/lib/libc/port/sys/issetugid.c @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright (c) 2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak issetugid = _issetugid + +#include "synonyms.h" +#include <sys/syscall.h> +#include <unistd.h> + +int +issetugid(void) +{ + return (syscall(SYS_issetugid)); +} diff --git a/usr/src/lib/libc/port/sys/libc_link.c b/usr/src/lib/libc/port/sys/libc_link.c new file mode 100644 index 0000000000..2f57a799bf --- /dev/null +++ b/usr/src/lib/libc/port/sys/libc_link.c @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak link = _link + +#include "synonyms.h" +#include <stdlib.h> +#include <errno.h> +#include <unistd.h> +#include <limits.h> + +extern int __xpg4; /* defined in port/gen/xpg4.c; 0 if not xpg4/xpg4v2 */ + +extern int __link(const char *existing, const char *new); + +int +link(const char *existing, const char *new) +{ + int sz; + char linkbuf[PATH_MAX + 1]; + + /* + * XPG4v2 link() requires that the link count of a symbolic + * link target be updated rather than the link itself. This + * matches SunOS 4.x and other BSD based implementations. + * However, the SVR4 merge apparently introduced the change + * that allowed link(src, dest) when "src" was a symbolic link, + * to create "dest" as a hard link to "src". Hence, the link + * count of the symbolic link is updated rather than the target + * of the symbolic link. This latter behavior remains for + * non-XPG4 based environments. For a more detailed discussion, + * see bug 1256170. + */ + if (__xpg4 != 0) { + if ((sz = resolvepath(existing, linkbuf, PATH_MAX)) == -1) + return (-1); + linkbuf[sz] = '\0'; + existing = linkbuf; + } + return (__link(existing, new)); +} diff --git a/usr/src/lib/libc/port/sys/libc_open.c b/usr/src/lib/libc/port/sys/libc_open.c new file mode 100644 index 0000000000..1057c846a5 --- /dev/null +++ b/usr/src/lib/libc/port/sys/libc_open.c @@ -0,0 +1,175 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "synonyms.h" +#include <sys/mkdev.h> +#include <limits.h> +#include <stdarg.h> +#include <unistd.h> +#include <strings.h> +#include <sys/stat.h> +#include <sys/stropts.h> +#include <sys/stream.h> +#include <sys/ptms.h> + +#if !defined(_LP64) +extern int __open64(const char *fname, int oflag, mode_t mode); +#endif + +extern int __xpg4; /* defined in port/gen/xpg4.c; 0 if not xpg4/xpg4v2 */ + +extern int __open(const char *fname, int oflag, mode_t mode); + +static void push_module(int fd); +static int isptsfd(int fd); +static void itoa(int i, char *ptr); + +int +_open(const char *fname, int oflag, ...) +{ + mode_t mode; + int fd; + va_list ap; + + va_start(ap, oflag); + mode = va_arg(ap, mode_t); + va_end(ap); + + /* + * XPG4v2 requires that open of a slave pseudo terminal device + * provides the process with an interface that is identical to + * the terminal interface. For a more detailed discussion, + * see bugid 4025044. + */ + fd = __open(fname, oflag, mode); + if (__xpg4 != 0 && fd >= 0 && isptsfd(fd)) + push_module(fd); + return (fd); +} + +#if !defined(_LP64) +/* + * The 32-bit APIs to large files require this interposition. + * The 64-bit APIs just fall back to _open() above. + */ +int +_open64(const char *fname, int oflag, ...) +{ + mode_t mode; + int fd; + va_list ap; + + va_start(ap, oflag); + mode = va_arg(ap, mode_t); + va_end(ap); + + /* + * XPG4v2 requires that open of a slave pseudo terminal device + * provides the process with an interface that is identical to + * the terminal interface. For a more detailed discussion, + * see bugid 4025044. + */ + fd = __open64(fname, oflag, mode); + if (__xpg4 != 0 && fd >= 0 && isptsfd(fd)) + push_module(fd); + return (fd); +} +#endif /* !_LP64 */ + +/* + * Checks if the file matches an entry in the /dev/pts directory + */ +static int +isptsfd(int fd) +{ + static char buf[TTYNAME_MAX]; + struct stat64 fsb, stb; + + if (fstat64(fd, &fsb) != 0 || + (fsb.st_mode & S_IFMT) != S_IFCHR) + return (0); + + (void) strcpy(buf, "/dev/pts/"); + itoa(minor(fsb.st_rdev), buf+strlen(buf)); + + if (stat64(buf, &stb) != 0 || + (fsb.st_mode & S_IFMT) != S_IFCHR) + return (0); + + return (stb.st_rdev == fsb.st_rdev); +} + +/* + * Converts a number to a string (null terminated). + */ +static void +itoa(int i, char *ptr) +{ + int dig = 0; + int tempi; + + tempi = i; + do { + dig++; + tempi /= 10; + } while (tempi); + + ptr += dig; + *ptr = '\0'; + while (--dig >= 0) { + *(--ptr) = i % 10 + '0'; + i /= 10; + } +} + +/* + * Push modules to provide tty semantics + */ +static void +push_module(int fd) +{ + struct strioctl istr; + + istr.ic_cmd = PTSSTTY; + istr.ic_len = 0; + istr.ic_timout = 0; + istr.ic_dp = NULL; + if (ioctl(fd, I_STR, &istr) != -1) { + (void) ioctl(fd, __I_PUSH_NOCTTY, "ptem"); + (void) ioctl(fd, __I_PUSH_NOCTTY, "ldterm"); + (void) ioctl(fd, __I_PUSH_NOCTTY, "ttcompat"); + istr.ic_cmd = PTSSTTY; + istr.ic_len = 0; + istr.ic_timout = 0; + istr.ic_dp = NULL; + (void) ioctl(fd, I_STR, &istr); + } +} diff --git a/usr/src/lib/libc/port/sys/lockf.c b/usr/src/lib/libc/port/sys/lockf.c new file mode 100644 index 0000000000..f1bb62a12f --- /dev/null +++ b/usr/src/lib/libc/port/sys/lockf.c @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#include <sys/feature_tests.h> + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#define _lockf _lockf64 +#endif + +#include "synonyms.h" +#include <sys/types.h> +#include <unistd.h> +#include <errno.h> +#include <fcntl.h> + +int +_lockf(int fildes, int function, off_t size) +{ + struct flock l; + int rv; + + l.l_whence = 1; + if (size < 0) { + l.l_start = size; + l.l_len = -size; + } else { + l.l_start = (off_t)0; + l.l_len = size; + } + switch (function) { + case F_ULOCK: + l.l_type = F_UNLCK; + rv = fcntl(fildes, F_SETLK, &l); + break; + case F_LOCK: + l.l_type = F_WRLCK; + rv = fcntl(fildes, F_SETLKW, &l); + break; + case F_TLOCK: + l.l_type = F_WRLCK; + rv = fcntl(fildes, F_SETLK, &l); + break; + case F_TEST: + l.l_type = F_WRLCK; + rv = fcntl(fildes, F_GETLK, &l); + if (rv != -1) { + if (l.l_type == F_UNLCK) + return (0); + else { + errno = EAGAIN; + return (-1); + } + } + break; + default: + errno = EINVAL; + return (-1); + } + if (rv < 0) { + switch (errno) { + case EMFILE: + case ENOSPC: + case ENOLCK: + /* + * A deadlock error is given if we run out of resources, + * in compliance with /usr/group standards. + */ + errno = EDEADLK; + break; + default: + break; + } + } + return (rv); +} diff --git a/usr/src/lib/libc/port/sys/lwp.c b/usr/src/lib/libc/port/sys/lwp.c new file mode 100644 index 0000000000..9d97d3c6ee --- /dev/null +++ b/usr/src/lib/libc/port/sys/lwp.c @@ -0,0 +1,105 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak _private_lwp_mutex_lock = __lwp_mutex_lock +#pragma weak _lwp_mutex_lock = __lwp_mutex_lock +#pragma weak _lwp_mutex_trylock = __lwp_mutex_trylock +#pragma weak _lwp_sema_init = __lwp_sema_init +#pragma weak _lwp_sema_wait = __lwp_sema_wait +#pragma weak _lwp_suspend = __lwp_suspend +#if defined(__i386) || defined(__amd64) +#pragma weak _lwp_private = __lwp_private +#endif /* __i386 || __amd64 */ + +#include "synonyms.h" +#include "mtlib.h" +#include <sys/types.h> +#include <sys/time.h> +#include <errno.h> +#include <synch.h> +#include <sys/synch32.h> +#include <sys/lwp.h> + +extern int ___lwp_mutex_timedlock(mutex_t *, timespec_t *); +extern int ___lwp_sema_timedwait(lwp_sema_t *, timespec_t *, int); +extern int set_lock_byte(volatile uint8_t *); + +int +_lwp_mutex_lock(mutex_t *mp) +{ + if (set_lock_byte(&mp->mutex_lockw) == 0) + return (0); + return (___lwp_mutex_timedlock(mp, NULL)); +} + +int +_lwp_mutex_trylock(mutex_t *mp) +{ + if (set_lock_byte(&mp->mutex_lockw) == 0) + return (0); + return (EBUSY); +} + +int +_lwp_sema_init(lwp_sema_t *sp, int count) +{ + sp->sema_count = count; + sp->sema_waiters = 0; + sp->type = USYNC_PROCESS; + return (0); +} + +int +_lwp_sema_wait(lwp_sema_t *sp) +{ + return (___lwp_sema_timedwait(sp, NULL, 0)); +} + +#if defined(__i386) || defined(__amd64) +int +_lwp_private(int cmd, int which, void *sbase) +{ + extern int ___lwp_private(int, int, void *); + return (___lwp_private(cmd, which, sbase)); +} +#endif /* __i386 || __amd64 */ + +int +_lwp_suspend(lwpid_t lwpid) +{ + extern int ___lwp_suspend(lwpid_t); + return (___lwp_suspend(lwpid)); +} + +void +_halt(void) +{ + /*LINTED*/ + while (1) + continue; +} diff --git a/usr/src/lib/libc/port/sys/lwp_cond.c b/usr/src/lib/libc/port/sys/lwp_cond.c new file mode 100644 index 0000000000..82a990f169 --- /dev/null +++ b/usr/src/lib/libc/port/sys/lwp_cond.c @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak _lwp_cond_wait = __lwp_cond_wait +#pragma weak _lwp_cond_reltimedwait = __lwp_cond_reltimedwait +#pragma weak _lwp_cond_timedwait = __lwp_cond_timedwait + +#include "synonyms.h" +#include <sys/types.h> + +#include <time.h> +#include <errno.h> +#include <synch.h> +#include <sys/synch32.h> +#include <pthread.h> + +extern int ___lwp_cond_wait(lwp_cond_t *, lwp_mutex_t *, timespec_t *, int); +extern int ___lwp_mutex_timedlock(lwp_mutex_t *, timespec_t *); + +int +_lwp_cond_wait(cond_t *cv, mutex_t *mp) +{ + int error; + + error = ___lwp_cond_wait(cv, mp, NULL, 0); + if (mp->mutex_type & (PTHREAD_PRIO_INHERIT|PTHREAD_PRIO_PROTECT)) + (void) ___lwp_mutex_timedlock(mp, NULL); + else + (void) _lwp_mutex_lock(mp); + return (error); +} + +int +_lwp_cond_reltimedwait(cond_t *cv, mutex_t *mp, timespec_t *relts) +{ + int error; + + if (relts != NULL && + (relts->tv_sec < 0 || (ulong_t)relts->tv_nsec >= NANOSEC)) + return (EINVAL); + error = ___lwp_cond_wait(cv, mp, relts, 0); + if (mp->mutex_type & (PTHREAD_PRIO_INHERIT|PTHREAD_PRIO_PROTECT)) + (void) ___lwp_mutex_timedlock(mp, NULL); + else + (void) _lwp_mutex_lock(mp); + return (error); +} + +int +_lwp_cond_timedwait(cond_t *cv, mutex_t *mp, timespec_t *absts) +{ + extern void abstime_to_reltime(clockid_t, + const timespec_t *, timespec_t *); + timespec_t tslocal; + + abstime_to_reltime(CLOCK_REALTIME, absts, &tslocal); + return (_lwp_cond_reltimedwait(cv, mp, &tslocal)); +} diff --git a/usr/src/lib/libc/port/sys/lwp_rwlock.c b/usr/src/lib/libc/port/sys/lwp_rwlock.c new file mode 100644 index 0000000000..d164cc948b --- /dev/null +++ b/usr/src/lib/libc/port/sys/lwp_rwlock.c @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "synonyms.h" +#include <synch.h> +#include <time.h> +#include <errno.h> +#include <sys/syscall.h> + +#define SUBSYS_lwp_rwlock_rdlock 0 +#define SUBSYS_lwp_rwlock_wrlock 1 +#define SUBSYS_lwp_rwlock_tryrdlock 2 +#define SUBSYS_lwp_rwlock_trywrlock 3 +#define SUBSYS_lwp_rwlock_unlock 4 + +int +__lwp_rwlock_rdlock(rwlock_t *rwl, timespec_t *tsp) +{ + int rval; + + do { + rval = syscall(SYS_lwp_rwlock_sys, + SUBSYS_lwp_rwlock_rdlock, rwl, tsp); + } while (rval == -1 && errno == EINTR); + + return (rval == -1 ? errno : 0); +} + +int +__lwp_rwlock_wrlock(rwlock_t *rwl, timespec_t *tsp) +{ + int rval; + + do { + rval = syscall(SYS_lwp_rwlock_sys, + SUBSYS_lwp_rwlock_wrlock, rwl, tsp); + } while (rval == -1 && errno == EINTR); + + return (rval == -1 ? errno : 0); +} + +int +__lwp_rwlock_tryrdlock(rwlock_t *rwl) +{ + if (syscall(SYS_lwp_rwlock_sys, + SUBSYS_lwp_rwlock_tryrdlock, rwl) == -1) + return (errno); + return (0); +} + +int +__lwp_rwlock_trywrlock(rwlock_t *rwl) +{ + if (syscall(SYS_lwp_rwlock_sys, + SUBSYS_lwp_rwlock_trywrlock, rwl) == -1) + return (errno); + return (0); +} + +int +__lwp_rwlock_unlock(rwlock_t *rwl) +{ + if (syscall(SYS_lwp_rwlock_sys, SUBSYS_lwp_rwlock_unlock, rwl) == -1) + return (errno); + return (0); +} diff --git a/usr/src/lib/libc/port/sys/lwp_sigmask.c b/usr/src/lib/libc/port/sys/lwp_sigmask.c new file mode 100644 index 0000000000..c719cb267f --- /dev/null +++ b/usr/src/lib/libc/port/sys/lwp_sigmask.c @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "synonyms.h" +#include <signal.h> +#include <sys/syscall.h> + +int +__lwp_sigmask(int how, const sigset_t *set, sigset_t *oset) +{ + sysret_t rval; + uint_t mask0; + uint_t mask1; + + if (set) { + mask0 = set->__sigbits[0]; + mask1 = set->__sigbits[1]; + } else { + how = 0; + mask0 = mask1 = 0; + } + + (void) __systemcall(&rval, SYS_lwp_sigmask, how, mask0, mask1); + + if (oset) { + oset->__sigbits[0] = (uint_t)rval.sys_rval1; + oset->__sigbits[1] = (uint_t)rval.sys_rval2; + oset->__sigbits[2] = 0; + oset->__sigbits[3] = 0; + } + + return (0); +} diff --git a/usr/src/lib/libc/port/sys/meminfosys.c b/usr/src/lib/libc/port/sys/meminfosys.c new file mode 100644 index 0000000000..a2343aeaa2 --- /dev/null +++ b/usr/src/lib/libc/port/sys/meminfosys.c @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak meminfo = _meminfo + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/mman.h> + +/* + * meminfo() function call + */ +int +meminfo(const uint64_t *inaddr, int addr_count, const uint_t *info_req, + int info_count, uint64_t *outdata, uint_t *validity) +{ + struct meminfo minfo; + + minfo.mi_inaddr = inaddr; + minfo.mi_info_req = info_req; + minfo.mi_info_count = info_count; + minfo.mi_outdata = outdata; + minfo.mi_validity = validity; + + return (syscall(SYS_meminfosys, MISYS_MEMINFO, addr_count, &minfo)); +} diff --git a/usr/src/lib/libc/port/sys/msgsys.c b/usr/src/lib/libc/port/sys/msgsys.c new file mode 100644 index 0000000000..d2db4da376 --- /dev/null +++ b/usr/src/lib/libc/port/sys/msgsys.c @@ -0,0 +1,125 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#pragma weak msgctl = _msgctl +#pragma weak msgctl64 = _msgctl64 +#pragma weak msgget = _msgget +#pragma weak msgids = _msgids +#pragma weak msgsnap = _msgsnap + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/ipc_impl.h> +#include <sys/msg.h> +#include <sys/msg_impl.h> +#include <sys/syscall.h> +#include <errno.h> +#include <limits.h> + +int +msgget(key_t key, int msgflg) +{ + return (syscall(SYS_msgsys, MSGGET, key, msgflg)); +} + +int +msgctl(int msqid, int cmd, struct msqid_ds *buf) +{ + if (cmd == IPC_SET64 || cmd == IPC_STAT64) { + (void) __set_errno(EINVAL); + return (-1); + } + + return (syscall(SYS_msgsys, MSGCTL, msqid, cmd, buf)); +} + +int +msgctl64(int msqid, int cmd, struct msqid_ds64 *buf) +{ + if (cmd != IPC_SET64 && cmd != IPC_STAT64) { + (void) __set_errno(EINVAL); + return (-1); + } + + return (syscall(SYS_msgsys, MSGCTL, msqid, cmd, buf)); +} + +ssize_t +_msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) +{ + if (msgsz > INT_MAX) { + sysret_t rval; + int error; + + /* + * We have to use __systemcall here because in the + * 64-bit case, we need to return a long, while + * syscall() is doomed to return an int + */ + error = __systemcall(&rval, SYS_msgsys, MSGRCV, msqid, + msgp, msgsz, msgtyp, msgflg); + if (error) + (void) __set_errno(error); + return ((ssize_t)rval.sys_rval1); + } + return ((ssize_t)syscall(SYS_msgsys, MSGRCV, msqid, + msgp, msgsz, msgtyp, msgflg)); +} + +int +_msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) +{ + if (msgsz > INT_MAX) { + sysret_t rval; + int error; + + error = __systemcall(&rval, SYS_msgsys, MSGSND, msqid, + msgp, msgsz, msgflg); + if (error) + (void) __set_errno(error); + return ((int)rval.sys_rval1); + } + return (syscall(SYS_msgsys, MSGSND, msqid, msgp, msgsz, msgflg)); +} + +int +msgids(int *buf, uint_t nids, uint_t *pnids) +{ + return (syscall(SYS_msgsys, MSGIDS, buf, nids, pnids)); +} + +int +msgsnap(int msqid, void *buf, size_t bufsz, long msgtyp) +{ + return (syscall(SYS_msgsys, MSGSNAP, msqid, buf, bufsz, msgtyp)); +} diff --git a/usr/src/lib/libc/port/sys/nfssys.c b/usr/src/lib/libc/port/sys/nfssys.c new file mode 100644 index 0000000000..4c439339d3 --- /dev/null +++ b/usr/src/lib/libc/port/sys/nfssys.c @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak exportfs = _exportfs +#pragma weak nfs_getfh = _nfs_getfh +#pragma weak nfssvc = _nfssvc + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/types32.h> +#include <rpc/types.h> +#include <sys/vfs.h> +#include <nfs/nfs.h> +#include <nfs/export.h> +#include <nfs/nfssys.h> +#include "libc.h" + +int +exportfs(char *dir, struct exportdata *ep) +{ + struct exportfs_args ea; + + ea.dname = dir; + ea.uex = ep; + return (_nfssys(EXPORTFS, &ea)); +} + +int +nfs_getfh(char *path, fhandle_t *fhp) +{ + struct nfs_getfh_args nga; + + nga.fname = path; + nga.fhp = fhp; + return (_nfssys(NFS_GETFH, &nga)); +} + +int +nfssvc(int fd) +{ + struct nfs_svc_args nsa; + + nsa.fd = fd; + return (_nfssys(NFS_SVC, &nsa)); +} diff --git a/usr/src/lib/libc/port/sys/openat.c b/usr/src/lib/libc/port/sys/openat.c new file mode 100644 index 0000000000..5549abf5d9 --- /dev/null +++ b/usr/src/lib/libc/port/sys/openat.c @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#pragma weak openat64 = _openat64 +#else +#pragma weak openat = _openat +#endif + +#include "synonyms.h" +#include <stdarg.h> +#include <sys/types.h> +#include <sys/syscall.h> + +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 + +int +openat64(int fd, const char *name, int omode, ...) +{ + va_list ap; + mode_t cmode; + + va_start(ap, omode); + cmode = va_arg(ap, mode_t); + va_end(ap); + return (syscall(SYS_fsat, 1, fd, name, omode, cmode)); +} + +#else + +int +openat(int fd, const char *name, int omode, ...) +{ + va_list ap; + mode_t cmode; + + va_start(ap, omode); + cmode = va_arg(ap, mode_t); + va_end(ap); + return (syscall(SYS_fsat, 0, fd, name, omode, cmode)); +} + +#endif diff --git a/usr/src/lib/libc/port/sys/pgrpsys.c b/usr/src/lib/libc/port/sys/pgrpsys.c new file mode 100644 index 0000000000..d7ed0bfb26 --- /dev/null +++ b/usr/src/lib/libc/port/sys/pgrpsys.c @@ -0,0 +1,76 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak getpgrp = _getpgrp +#pragma weak setpgrp = _setpgrp +#pragma weak getsid = _getsid +#pragma weak setsid = _setsid +#pragma weak getpgid = _getpgid +#pragma weak setpgid = _setpgid +#pragma weak _private_setpgid = _setpgid + +#include "synonyms.h" +#include <sys/types.h> +#include <unistd.h> +#include <sys/syscall.h> + +pid_t +getpgrp(void) +{ + return ((pid_t)syscall(SYS_pgrpsys, 0)); +} + +pid_t +setpgrp(void) +{ + return ((pid_t)syscall(SYS_pgrpsys, 1)); +} + +pid_t +getsid(pid_t pid) +{ + return ((pid_t)syscall(SYS_pgrpsys, 2, pid)); +} + +pid_t +setsid(void) +{ + return ((pid_t)syscall(SYS_pgrpsys, 3)); +} + +pid_t +getpgid(pid_t pid) +{ + return ((pid_t)syscall(SYS_pgrpsys, 4, pid)); +} + +int +setpgid(pid_t pid, pid_t pgid) +{ + return (syscall(SYS_pgrpsys, 5, pid, pgid)); +} diff --git a/usr/src/lib/libc/port/sys/posix_sigwait.c b/usr/src/lib/libc/port/sys/posix_sigwait.c new file mode 100644 index 0000000000..3f2eb068da --- /dev/null +++ b/usr/src/lib/libc/port/sys/posix_sigwait.c @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "lint.h" +#include <sys/types.h> +#include <errno.h> +#include <signal.h> +#include "libc.h" + +/* + * POSIX.1c version of the sigwait. + * User gets it via static sigwait from header file. + */ +int +__posix_sigwait(const sigset_t *setp, int *signo) +{ + int nerrno = 0; + int oerrno = errno; + + errno = 0; + if ((*signo = _sigwait((sigset_t *)setp)) == -1) { + if (errno == 0) + errno = EINVAL; + else + nerrno = errno; + } + errno = oerrno; + return (nerrno); +} diff --git a/usr/src/lib/libc/port/sys/ppriv.c b/usr/src/lib/libc/port/sys/ppriv.c new file mode 100644 index 0000000000..6ab4add91e --- /dev/null +++ b/usr/src/lib/libc/port/sys/ppriv.c @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak setppriv = _setppriv +#pragma weak getppriv = _getppriv +#pragma weak setpflags = _setpflags +#pragma weak getpflags = _getpflags + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include "priv_private.h" +#include <priv.h> + +int +setppriv(priv_op_t op, priv_ptype_t type, const priv_set_t *pset) +{ + priv_data_t *d; + int set; + + LOADPRIVDATA(d); + + set = priv_getsetbyname(type); + + return (syscall(SYS_privsys, PRIVSYS_SETPPRIV, op, set, (void *)pset, + d->pd_setsize)); +} + +int +getppriv(priv_ptype_t type, priv_set_t *pset) +{ + priv_data_t *d; + int set; + + LOADPRIVDATA(d); + + set = priv_getsetbyname(type); + + return (syscall(SYS_privsys, PRIVSYS_GETPPRIV, 0, set, (void *)pset, + d->pd_setsize)); +} + +int +getprivinfo(priv_impl_info_t *buf, size_t bufsize) +{ + return (syscall(SYS_privsys, PRIVSYS_GETIMPLINFO, 0, 0, (void *)buf, + bufsize)); +} + +int +setpflags(uint_t flag, uint_t val) +{ + return (syscall(SYS_privsys, PRIVSYS_SETPFLAGS, (priv_op_t)flag, + (priv_ptype_t)(uintptr_t)val, 0, 0)); +} + +uint_t +getpflags(uint_t flag) +{ + return (syscall(SYS_privsys, PRIVSYS_GETPFLAGS, flag, 0, 0, 0)); +} diff --git a/usr/src/lib/libc/port/sys/psetsys.c b/usr/src/lib/libc/port/sys/psetsys.c new file mode 100644 index 0000000000..5de5d62591 --- /dev/null +++ b/usr/src/lib/libc/port/sys/psetsys.c @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak pset_create = _pset_create +#pragma weak pset_destroy = _pset_destroy +#pragma weak pset_assign = _pset_assign +#pragma weak pset_info = _pset_info +#pragma weak pset_bind = _pset_bind +#pragma weak pset_getloadavg = _pset_getloadavg +#pragma weak pset_list = _pset_list +#pragma weak pset_setattr = _pset_setattr +#pragma weak pset_getattr = _pset_getattr + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/procset.h> +#include <sys/processor.h> +#include <sys/pset.h> +#include <sys/param.h> +#include <sys/loadavg.h> + +int _pset(int, ...); + +/* subcode wrappers for _pset system call */ + +int +pset_create(psetid_t *npset) +{ + return (_pset(PSET_CREATE, npset)); +} + +int +pset_destroy(psetid_t pset) +{ + return (_pset(PSET_DESTROY, pset)); +} + +int +pset_assign(psetid_t pset, processorid_t cpu, psetid_t *opset) +{ + return (_pset(PSET_ASSIGN, pset, cpu, opset)); +} + +int +pset_assign_forced(psetid_t pset, processorid_t cpu, psetid_t *opset) +{ + return (_pset(PSET_ASSIGN_FORCED, pset, cpu, opset)); +} + +int +pset_info(psetid_t pset, int *type, uint_t *numcpus, processorid_t *cpulist) +{ + return (_pset(PSET_INFO, pset, type, numcpus, cpulist)); +} + +int +pset_bind(psetid_t pset, idtype_t idtype, id_t id, psetid_t *opset) +{ + return (_pset(PSET_BIND, pset, idtype, id, opset)); +} + +/* + * Get the per-processor-set load average. + */ +int +pset_getloadavg(psetid_t pset, double loadavg[], int nelem) +{ + int i, buf[LOADAVG_NSTATS]; + + if (nelem > LOADAVG_NSTATS) + nelem = LOADAVG_NSTATS; + + if (_pset(PSET_GETLOADAVG, pset, buf, nelem) == -1) + return (-1); + + for (i = 0; i < nelem; i++) + loadavg[i] = (double)buf[i] / FSCALE; + + return (nelem); +} + +int +pset_list(psetid_t *psetlist, uint_t *numpsets) +{ + return (_pset(PSET_LIST, psetlist, numpsets)); +} + +int +pset_setattr(psetid_t pset, uint_t attr) +{ + return (_pset(PSET_SETATTR, pset, attr)); +} + +int +pset_getattr(psetid_t pset, uint_t *attr) +{ + return (_pset(PSET_GETATTR, pset, attr)); +} diff --git a/usr/src/lib/libc/port/sys/rctlsys.c b/usr/src/lib/libc/port/sys/rctlsys.c new file mode 100644 index 0000000000..e47511ac2a --- /dev/null +++ b/usr/src/lib/libc/port/sys/rctlsys.c @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak setrctl = _setrctl +#pragma weak getrctl = _getrctl +#pragma weak rctllist = _rctllist +#pragma weak rctlctl = _rctlctl + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/rctl.h> + +int +getrctl(const char *name, rctlblk_t *old_rblk, rctlblk_t *new_rblk, + int flags) +{ + return (syscall(SYS_rctlsys, + 0, name, old_rblk, new_rblk, 0, flags)); +} + +int +setrctl(const char *name, rctlblk_t *old_rblk, rctlblk_t *new_rblk, + int flags) +{ + return (syscall(SYS_rctlsys, + 1, name, old_rblk, new_rblk, 0, flags)); +} + +size_t +rctllist(char *list_buf, size_t list_bufsz) +{ + sysret_t rval; + int error; + + error = __systemcall(&rval, SYS_rctlsys, 2, NULL, list_buf, NULL, + list_bufsz, 0); + + if (error) + (void) __set_errno(error); + return ((size_t)rval.sys_rval1); +} + +int +rctlctl(const char *name, rctlblk_t *rblk, int flags) +{ + return (syscall(SYS_rctlsys, 3, name, rblk, NULL, 0, flags)); +} diff --git a/usr/src/lib/libc/port/sys/sbrk.c b/usr/src/lib/libc/port/sys/sbrk.c new file mode 100644 index 0000000000..6942e663c3 --- /dev/null +++ b/usr/src/lib/libc/port/sys/sbrk.c @@ -0,0 +1,183 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak sbrk = _sbrk +#pragma weak brk = _brk + +#include "synonyms.h" +#include <synch.h> +#include <errno.h> +#include <sys/isa_defs.h> +#include <sys/types.h> +#include <sys/sysmacros.h> +#include <inttypes.h> +#include <unistd.h> +#include "mtlib.h" +#include "libc.h" + +extern int _end; +void *_nd = &_end; +mutex_t __sbrk_lock = DEFAULTMUTEX; + +extern int _brk_unlocked(void *); +void *_sbrk_unlocked(intptr_t); + +/* + * The break must always be at least 8-byte aligned + */ +#if (_MAX_ALIGNMENT < 8) +#define ALIGNSZ 8 +#else +#define ALIGNSZ _MAX_ALIGNMENT +#endif + +#define BRKALIGN(x) (caddr_t)P2ROUNDUP((uintptr_t)(x), ALIGNSZ) + +void * +sbrk(intptr_t addend) +{ + void *result; + + lmutex_lock(&__sbrk_lock); + result = _sbrk_unlocked(addend); + lmutex_unlock(&__sbrk_lock); + + return (result); +} + +/* + * _sbrk_unlocked() aligns the old break, adds the addend, aligns + * the new break, and calls _brk_unlocked() to set the new break. + * We must align the old break because _nd may begin life misaligned. + * The addend can be either positive or negative, so there are two + * overflow/underflow edge conditions to reject: + * + * - the addend is negative and brk + addend < 0. + * - the addend is positive and brk + addend > ULONG_MAX + */ +void * +_sbrk_unlocked(intptr_t addend) +{ + char *old_brk = BRKALIGN(_nd); + char *new_brk = BRKALIGN(old_brk + addend); + + if (!primary_link_map) { + errno = ENOTSUP; + return ((void *)-1); + } + if ((addend > 0 && new_brk < old_brk) || + (addend < 0 && new_brk > old_brk)) { + errno = ENOMEM; + return ((void *)-1); + } + if (_brk_unlocked(new_brk) != 0) + return ((void *)-1); + _nd = new_brk; + return (old_brk); +} + +/* + * _sbrk_grow_aligned() aligns the old break to a low_align boundry, + * adds min_size, aligns to a high_align boundry, and calls _brk_unlocked() + * to set the new break. The low_aligned-aligned value is returned, and + * the actual space allocated is returned through actual_size. + * + * Unlike sbrk(2), _sbrk_grow_aligned takes an unsigned size, and does + * not allow shrinking the heap. + */ +void * +_sbrk_grow_aligned(size_t min_size, size_t low_align, size_t high_align, + size_t *actual_size) +{ + uintptr_t old_brk; + uintptr_t ret_brk; + uintptr_t high_brk; + uintptr_t new_brk; + int brk_result; + + if (!primary_link_map) { + errno = ENOTSUP; + return ((void *)-1); + } + if ((low_align & (low_align - 1)) != 0 || + (high_align & (high_align - 1)) != 0) { + errno = EINVAL; + return ((void *)-1); + } + low_align = MAX(low_align, ALIGNSZ); + high_align = MAX(high_align, ALIGNSZ); + + lmutex_lock(&__sbrk_lock); + + old_brk = (uintptr_t)BRKALIGN(_nd); + ret_brk = P2ROUNDUP(old_brk, low_align); + high_brk = ret_brk + min_size; + new_brk = P2ROUNDUP(high_brk, high_align); + + /* + * Check for overflow + */ + if (ret_brk < old_brk || high_brk < ret_brk || new_brk < high_brk) { + lmutex_unlock(&__sbrk_lock); + errno = ENOMEM; + return ((void *)-1); + } + + if ((brk_result = _brk_unlocked((void *)new_brk)) == 0) + _nd = (void *)new_brk; + lmutex_unlock(&__sbrk_lock); + + if (brk_result != 0) + return ((void *)-1); + + if (actual_size != NULL) + *actual_size = (new_brk - ret_brk); + return ((void *)ret_brk); +} + +int +brk(void *new_brk) +{ + int result; + + if (!primary_link_map) { + errno = ENOTSUP; + return (-1); + } + /* + * Need to align this here; _brk_unlocked won't do it for us. + */ + new_brk = BRKALIGN(new_brk); + + lmutex_lock(&__sbrk_lock); + if ((result = _brk_unlocked(new_brk)) == 0) + _nd = new_brk; + lmutex_unlock(&__sbrk_lock); + + return (result); +} diff --git a/usr/src/lib/libc/port/sys/semsys.c b/usr/src/lib/libc/port/sys/semsys.c new file mode 100644 index 0000000000..8e6b35e4b3 --- /dev/null +++ b/usr/src/lib/libc/port/sys/semsys.c @@ -0,0 +1,147 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#pragma weak semctl = _semctl +#pragma weak semctl64 = _semctl64 +#pragma weak semget = _semget +#pragma weak semop = _semop +#pragma weak semids = _semids +#pragma weak semtimedop = _semtimedop + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/ipc_impl.h> +#include <sys/sem.h> +#include <sys/sem_impl.h> +#include <sys/syscall.h> +#include <stdarg.h> +#include <errno.h> + +union semun { + int val; + struct semid_ds *buf; + struct semid_ds64 *buf64; + ushort_t *array; +}; + +/* + * The kernel implementation of semsys expects an argument containing the + * value of the semun argument, but the Sparc compiler passes a pointer + * to it, since it is a union. So, we convert here and pass the value, + * but to keep the naive user from being penalized for the counterintuitive + * behaviour of the Sparc compiler, we ignore the union if it will not be + * used by the system call (to protect the caller from SIGSEGVs, e.g. + * semctl(semid, semnum, cmd, NULL); which would otherwise always result + * in a segmentation violation). We do this partly for consistency, since + * the ICL port did it. This all works just fine for the Intel compiler, + * which actually does pass the union by value. + */ +int +semctl(int semid, int semnum, int cmd, ...) +{ + uintptr_t arg; + va_list ap; + + switch (cmd) { + case SETVAL: + va_start(ap, cmd); + arg = (uintptr_t)va_arg(ap, union semun).val; + va_end(ap); + break; + case GETALL: + case SETALL: + va_start(ap, cmd); + arg = (uintptr_t)va_arg(ap, union semun).array; + va_end(ap); + break; + case IPC_STAT: + case IPC_SET: + va_start(ap, cmd); + arg = (uintptr_t)va_arg(ap, union semun).buf; + va_end(ap); + break; + case IPC_SET64: + case IPC_STAT64: + (void) __set_errno(EINVAL); + return (-1); + default: + arg = 0; + break; + } + + return (syscall(SYS_semsys, SEMCTL, semid, semnum, cmd, arg)); +} + +int +semctl64(int semid, int semnum, int cmd, ...) +{ + struct semid_ds64 *buf; + va_list ap; + + if (cmd != IPC_SET64 && cmd != IPC_STAT64) { + (void) __set_errno(EINVAL); + return (-1); + } + + va_start(ap, cmd); + buf = va_arg(ap, union semun).buf64; + va_end(ap); + + return (syscall(SYS_semsys, SEMCTL, semid, semnum, cmd, buf)); +} + +int +semget(key_t key, int nsems, int semflg) +{ + return (syscall(SYS_semsys, SEMGET, key, nsems, semflg)); +} + +int +semop(int semid, struct sembuf *sops, size_t nsops) +{ + return (syscall(SYS_semsys, SEMOP, semid, sops, nsops)); +} + +int +semids(int *buf, uint_t nids, uint_t *pnids) +{ + return (syscall(SYS_semsys, SEMIDS, buf, nids, pnids)); +} + +int +semtimedop(int semid, struct sembuf *sops, size_t nsops, + const timespec_t *timeout) +{ + return (syscall(SYS_semsys, SEMTIMEDOP, semid, sops, nsops, + timeout)); +} diff --git a/usr/src/lib/libc/port/sys/set_errno.c b/usr/src/lib/libc/port/sys/set_errno.c new file mode 100644 index 0000000000..2181b9ccb7 --- /dev/null +++ b/usr/src/lib/libc/port/sys/set_errno.c @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2000-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "lint.h" +#include <errno.h> +#include <sys/syscall.h> + +/* + * __set_errno() takes an error number, maps ERESTART into EINTR, and sets + * the global (or per-thread) errno. It returns the mapped error number. + * __set_errno(error) is designed to be used after calling __systemcall() + * and getting a non-zero error return value. (__systemcall() does not + * set errno and does not deal with ERESTART; it just returns the error + * number, if any, from the system call.) + */ +int +__set_errno(int error) +{ + if (error == ERESTART) + error = EINTR; + errno = error; + return (error); +} diff --git a/usr/src/lib/libc/port/sys/shmsys.c b/usr/src/lib/libc/port/sys/shmsys.c new file mode 100644 index 0000000000..c4b5d8edb1 --- /dev/null +++ b/usr/src/lib/libc/port/sys/shmsys.c @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#pragma weak shmat = _shmat +#pragma weak shmctl = _shmctl +#pragma weak shmctl64 = _shmctl64 +#pragma weak shmdt = _shmdt +#pragma weak shmget = _shmget +#pragma weak shmids = _shmids + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/ipc_impl.h> +#include <sys/shm.h> +#include <sys/shm_impl.h> +#include <sys/syscall.h> +#include <errno.h> + +void * +shmat(int shmid, const void *shmaddr, int shmflg) +{ + sysret_t rval; + int error; + + error = __systemcall(&rval, SYS_shmsys, SHMAT, shmid, shmaddr, shmflg); + if (error) + (void) __set_errno(error); + return ((void *)rval.sys_rval1); +} + +int +shmctl(int shmid, int cmd, struct shmid_ds *buf) +{ + if (cmd == IPC_SET64 || cmd == IPC_STAT64) { + (void) __set_errno(EINVAL); + return (-1); + } + return (syscall(SYS_shmsys, SHMCTL, shmid, cmd, buf)); +} + +int +shmctl64(int shmid, int cmd, struct shmid_ds64 *buf) +{ + if (cmd != IPC_SET64 && cmd != IPC_STAT64) { + (void) __set_errno(EINVAL); + return (-1); + } + return (syscall(SYS_shmsys, SHMCTL, shmid, cmd, buf)); +} + +int +shmdt(char *shmaddr) +{ + return (syscall(SYS_shmsys, SHMDT, shmaddr)); +} + +int +shmget(key_t key, size_t size, int shmflg) +{ + return (syscall(SYS_shmsys, SHMGET, key, size, shmflg)); +} + +int +shmids(int *buf, uint_t nids, uint_t *pnids) +{ + return (syscall(SYS_shmsys, SHMIDS, buf, nids, pnids)); +} diff --git a/usr/src/lib/libc/port/sys/siginterrupt.c b/usr/src/lib/libc/port/sys/siginterrupt.c new file mode 100644 index 0000000000..3f82478de8 --- /dev/null +++ b/usr/src/lib/libc/port/sys/siginterrupt.c @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak siginterrupt = _siginterrupt + +#include "synonyms.h" +#include <sys/types.h> +#include <errno.h> +#include <signal.h> + +int +siginterrupt(int sig, int flag) +{ + struct sigaction act; + + /* + * Check for valid signal number + */ + if (sig <= 0 || sig >= NSIG) { + errno = EINVAL; + return (-1); + } + + (void) sigaction(sig, NULL, &act); + if (flag) + act.sa_flags &= ~SA_RESTART; + else + act.sa_flags |= SA_RESTART; + return (sigaction(sig, &act, NULL)); +} diff --git a/usr/src/lib/libc/port/sys/signal.c b/usr/src/lib/libc/port/sys/signal.c new file mode 100644 index 0000000000..4cd406e6fd --- /dev/null +++ b/usr/src/lib/libc/port/sys/signal.c @@ -0,0 +1,232 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak signal = _signal +#pragma weak sighold = _sighold +#pragma weak sigrelse = _sigrelse +#pragma weak sigignore = _sigignore +#pragma weak sigset = _sigset + +#include "synonyms.h" +#include <sys/types.h> +#include <unistd.h> +#include <errno.h> +#include <signal.h> +#include <wait.h> + +/* + * Check for valid signal number as per SVID. + */ +#define CHECK_SIG(s, code) \ + if ((s) <= 0 || (s) >= NSIG || (s) == SIGKILL || (s) == SIGSTOP) { \ + errno = EINVAL; \ + return (code); \ + } + +/* + * Equivalent to stopdefault set in the kernel implementation (sig.c). + */ +#define STOPDEFAULT(s) \ + ((s) == SIGSTOP || (s) == SIGTSTP || (s) == SIGTTOU || (s) == SIGTTIN) + + +/* + * SVr3.x signal compatibility routines. They are now + * implemented as library routines instead of system + * calls. + */ + +void(* +signal(int sig, void(*func)(int)))(int) +{ + struct sigaction nact; + struct sigaction oact; + + CHECK_SIG(sig, SIG_ERR); + + nact.sa_handler = func; + nact.sa_flags = SA_RESETHAND|SA_NODEFER; + (void) sigemptyset(&nact.sa_mask); + + /* + * Pay special attention if sig is SIGCHLD and + * the disposition is SIG_IGN, per sysV signal man page. + */ + if (sig == SIGCHLD) { + nact.sa_flags |= SA_NOCLDSTOP; + if (func == SIG_IGN) + nact.sa_flags |= SA_NOCLDWAIT; + } + + if (STOPDEFAULT(sig)) + nact.sa_flags |= SA_RESTART; + + if (sigaction(sig, &nact, &oact) < 0) + return (SIG_ERR); + + return (oact.sa_handler); +} + +int +sighold(int sig) +{ + sigset_t set; + + CHECK_SIG(sig, -1); + + /* + * errno set on failure by either sigaddset or sigprocmask. + */ + (void) sigemptyset(&set); + if (sigaddset(&set, sig) < 0) + return (-1); + return (sigprocmask(SIG_BLOCK, &set, (sigset_t *)0)); +} + +int +sigrelse(int sig) +{ + sigset_t set; + + CHECK_SIG(sig, -1); + + /* + * errno set on failure by either sigaddset or sigprocmask. + */ + (void) sigemptyset(&set); + if (sigaddset(&set, sig) < 0) + return (-1); + return (sigprocmask(SIG_UNBLOCK, &set, (sigset_t *)0)); +} + +int +sigignore(int sig) +{ + struct sigaction act; + sigset_t set; + + CHECK_SIG(sig, -1); + + act.sa_handler = SIG_IGN; + act.sa_flags = 0; + (void) sigemptyset(&act.sa_mask); + + /* + * Pay special attention if sig is SIGCHLD and + * the disposition is SIG_IGN, per sysV signal man page. + */ + if (sig == SIGCHLD) { + act.sa_flags |= SA_NOCLDSTOP; + act.sa_flags |= SA_NOCLDWAIT; + } + + if (STOPDEFAULT(sig)) + act.sa_flags |= SA_RESTART; + + if (sigaction(sig, &act, (struct sigaction *)0) < 0) + return (-1); + + (void) sigemptyset(&set); + if (sigaddset(&set, sig) < 0) + return (-1); + return (sigprocmask(SIG_UNBLOCK, &set, (sigset_t *)0)); +} + +int +_sigpause(int sig) +{ + sigset_t set; + int rval; + + CHECK_SIG(sig, -1); + + /* + * sigpause() is defined to unblock the signal + * and not block it again on return. + * sigsuspend() restores the original signal set, + * so we have to unblock sig overtly. + */ + (void) sigprocmask(0, (sigset_t *)0, &set); + if (sigdelset(&set, sig) < 0) + return (-1); + rval = sigsuspend(&set); + (void) sigrelse(sig); + return (rval); +} + +void(* +sigset(int sig, void(*func)(int)))(int) +{ + struct sigaction nact; + struct sigaction oact; + sigset_t nset; + sigset_t oset; + int code; + + CHECK_SIG(sig, SIG_ERR); + + (void) sigemptyset(&nset); + if (sigaddset(&nset, sig) < 0) + return (SIG_ERR); + + if (func == SIG_HOLD) { + if (sigprocmask(SIG_BLOCK, &nset, &oset) < 0) + return (SIG_ERR); + if (sigaction(sig, (struct sigaction *)0, &oact) < 0) + return (SIG_ERR); + } else { + nact.sa_handler = func; + nact.sa_flags = 0; + (void) sigemptyset(&nact.sa_mask); + /* + * Pay special attention if sig is SIGCHLD and + * the disposition is SIG_IGN, per sysV signal man page. + */ + if (sig == SIGCHLD) { + nact.sa_flags |= SA_NOCLDSTOP; + if (func == SIG_IGN) + nact.sa_flags |= SA_NOCLDWAIT; + } + + if (STOPDEFAULT(sig)) + nact.sa_flags |= SA_RESTART; + + if (sigaction(sig, &nact, &oact) < 0) + return (SIG_ERR); + + if (sigprocmask(SIG_UNBLOCK, &nset, &oset) < 0) + return (SIG_ERR); + } + + if ((code = sigismember(&oset, sig)) < 0) + return (SIG_ERR); + else if (code == 1) + return (SIG_HOLD); + + return (oact.sa_handler); +} diff --git a/usr/src/lib/libc/port/sys/sigpending.c b/usr/src/lib/libc/port/sys/sigpending.c new file mode 100644 index 0000000000..9084a97506 --- /dev/null +++ b/usr/src/lib/libc/port/sys/sigpending.c @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak sigpending = _sigpending + +#include "synonyms.h" +#include <signal.h> +#include <sys/syscall.h> + +int +sigpending(sigset_t *set) +{ + return (syscall(SYS_sigpending, 1, set)); +} + +int +__sigfillset(sigset_t *set) +{ + return (syscall(SYS_sigpending, 2, set)); +} diff --git a/usr/src/lib/libc/port/sys/sigstack.c b/usr/src/lib/libc/port/sys/sigstack.c new file mode 100644 index 0000000000..9b147051b0 --- /dev/null +++ b/usr/src/lib/libc/port/sys/sigstack.c @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak sigstack = _sigstack + +#include "lint.h" +#include <sys/types.h> +#include <sys/ucontext.h> +#include <signal.h> +#include <errno.h> + +int +_sigstack(struct sigstack *nss, struct sigstack *oss) +{ + struct sigaltstack nalt; + struct sigaltstack oalt; + struct sigaltstack *naltp; + + if (nss) { + /* Assumes stack growth is down */ + nalt.ss_sp = (char *)nss->ss_sp - SIGSTKSZ; + nalt.ss_size = SIGSTKSZ; + nalt.ss_flags = 0; + naltp = &nalt; + } else + naltp = (struct sigaltstack *)0; + + if (sigaltstack(naltp, &oalt) < 0) + return (-1); + + if (oss) { + /* Assumes stack growth is down */ + oss->ss_sp = (char *)oalt.ss_sp + oalt.ss_size; + oss->ss_onstack = ((oalt.ss_flags & SS_ONSTACK) != 0); + } + return (0); +} diff --git a/usr/src/lib/libc/port/sys/tasksys.c b/usr/src/lib/libc/port/sys/tasksys.c new file mode 100644 index 0000000000..d93cf01cee --- /dev/null +++ b/usr/src/lib/libc/port/sys/tasksys.c @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright (c) 1999-2001 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak settaskid = _settaskid +#pragma weak gettaskid = _gettaskid +#pragma weak getprojid = _getprojid + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/task.h> +#include <errno.h> +#include <project.h> + +taskid_t +settaskid(projid_t project, uint_t flags) +{ + taskid_t newtaskid; + + while ((newtaskid = syscall(SYS_tasksys, 0, project, flags, NULL, 0)) + == -1 && errno == EINTR); + + return (newtaskid); +} + +taskid_t +gettaskid(void) +{ + return ((taskid_t)syscall(SYS_tasksys, 1, 0, 0, NULL, 0)); +} + +projid_t +getprojid(void) +{ + return ((projid_t)syscall(SYS_tasksys, 2, 0, 0, NULL, 0)); +} diff --git a/usr/src/lib/libc/port/sys/time.c b/usr/src/lib/libc/port/sys/time.c new file mode 100644 index 0000000000..ea95dd0fac --- /dev/null +++ b/usr/src/lib/libc/port/sys/time.c @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak time = _time +#pragma weak stime = _stime + +#include "synonyms.h" +#include <unistd.h> +#include <time.h> + +time_t +time(time_t *tloc) +{ + extern time_t __time(void); /* the raw system call */ + time_t rval; + + rval = __time(); + if (tloc) + *tloc = rval; + return (rval); +} + +int +stime(const time_t *tp) +{ + extern int __stime(time_t); /* the raw system call */ + + return (__stime(*tp)); +} diff --git a/usr/src/lib/libc/port/sys/time_util.c b/usr/src/lib/libc/port/sys/time_util.c new file mode 100644 index 0000000000..93a07aaee0 --- /dev/null +++ b/usr/src/lib/libc/port/sys/time_util.c @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> +#include <time.h> +#include <errno.h> + +/* + * This function is blatently stolen from the kernel. + * See the dissertation in the comments preceding the + * hrt2ts() function in: + * uts/common/os/timers.c + */ +void +hrt2ts(hrtime_t hrt, timespec_t *tsp) +{ + uint32_t sec, nsec, tmp; + + tmp = (uint32_t)(hrt >> 30); + sec = tmp - (tmp >> 2); + sec = tmp - (sec >> 5); + sec = tmp + (sec >> 1); + sec = tmp - (sec >> 6) + 7; + sec = tmp - (sec >> 3); + sec = tmp + (sec >> 1); + sec = tmp + (sec >> 3); + sec = tmp + (sec >> 4); + tmp = (sec << 7) - sec - sec - sec; + tmp = (tmp << 7) - tmp - tmp - tmp; + tmp = (tmp << 7) - tmp - tmp - tmp; + nsec = (uint32_t)hrt - (tmp << 9); + while (nsec >= NANOSEC) { + nsec -= NANOSEC; + sec++; + } + tsp->tv_sec = (time_t)sec; + tsp->tv_nsec = nsec; +} + +/* + * Convert absolute time to relative time. + * All *timedwait() system call traps expect relative time. + */ +void +abstime_to_reltime(clockid_t clock_id, + const timespec_t *abstime, timespec_t *reltime) +{ + extern int __clock_gettime(clockid_t, timespec_t *); + timespec_t now; + + if (clock_id == CLOCK_HIGHRES) + hrt2ts(gethrtime(), &now); + else + (void) __clock_gettime(clock_id, &now); + if (abstime->tv_nsec >= now.tv_nsec) { + reltime->tv_sec = abstime->tv_sec - now.tv_sec; + reltime->tv_nsec = abstime->tv_nsec - now.tv_nsec; + } else { + reltime->tv_sec = abstime->tv_sec - now.tv_sec - 1; + reltime->tv_nsec = abstime->tv_nsec - now.tv_nsec + NANOSEC; + } + /* + * If the absolute time has already passed, + * just set the relative time to zero. + */ + if (reltime->tv_sec < 0) { + reltime->tv_sec = 0; + reltime->tv_nsec = 0; + } + /* + * If the specified absolute time has a bad nanoseconds value, + * assign it to the relative time value. If the interface + * attempts to sleep, the bad value will be detected then. + * The SUSV3 Posix spec is very clear that such detection + * should not happen until an attempt to sleep is made. + */ + if ((ulong_t)abstime->tv_nsec >= NANOSEC) + reltime->tv_nsec = abstime->tv_nsec; +} diff --git a/usr/src/lib/libc/port/sys/ucontext.c b/usr/src/lib/libc/port/sys/ucontext.c new file mode 100644 index 0000000000..56d3984691 --- /dev/null +++ b/usr/src/lib/libc/port/sys/ucontext.c @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak getustack = _getustack +#pragma weak setustack = _setustack +#pragma weak _private_setustack = _setustack +#pragma weak __setcontext_syscall = __setcontext + +#include "synonyms.h" +#include <ucontext.h> +#include <sys/syscall.h> + +/* + * __getcontext() must be implemented in assembler, as opposed to + * the other members of the SYS_context family (see __getcontext.s) + * because we must be careful to get the precise context of the caller. + */ + +int +__setcontext(const ucontext_t *ucp) +{ + return (syscall(SYS_context, 1, ucp)); +} + +int +getustack(stack_t **spp) +{ + return (syscall(SYS_context, 2, spp)); +} + +int +setustack(stack_t *sp) +{ + return (syscall(SYS_context, 3, sp)); +} diff --git a/usr/src/lib/libc/port/sys/umount.c b/usr/src/lib/libc/port/sys/umount.c new file mode 100644 index 0000000000..c7c52d71dd --- /dev/null +++ b/usr/src/lib/libc/port/sys/umount.c @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * This file is created to make the trap value + * obsolete for umount() system call. This is an + * effort to support forcible unmount interface + * through umount2() system call. + */ + +#pragma weak umount = _umount + +#include "synonyms.h" +#include "libc.h" + +int +umount(const char *path) +{ + return (umount2(path, 0)); +} diff --git a/usr/src/lib/libc/port/sys/ustat.c b/usr/src/lib/libc/port/sys/ustat.c new file mode 100644 index 0000000000..312763bf11 --- /dev/null +++ b/usr/src/lib/libc/port/sys/ustat.c @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak ustat = _ustat + +#include "synonyms.h" +#include <sys/types.h> +#include <ustat.h> +#include <sys/utssys.h> + +extern int utssys(); + +int +ustat(dev_t dev, struct ustat *buf) +{ + if (utssys(buf, dev, UTS_USTAT) == -1) + return (-1); + return (0); +} diff --git a/usr/src/lib/libc/port/sys/zone.c b/usr/src/lib/libc/port/sys/zone.c new file mode 100644 index 0000000000..416313941f --- /dev/null +++ b/usr/src/lib/libc/port/sys/zone.c @@ -0,0 +1,201 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (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 + * or http://www.opensolaris.org/os/licensing. + * 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 + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#pragma weak getzoneid = _getzoneid +#pragma weak getzoneidbyname = _getzoneidbyname +#pragma weak getzonenamebyid = _getzonenamebyid + +#include "synonyms.h" +#include <sys/types.h> +#include <sys/syscall.h> +#include <sys/zone.h> +#include <sys/priv.h> +#include <zone.h> +#include <dlfcn.h> +#include <stdlib.h> +#include <errno.h> + +zoneid_t +zone_create(const char *name, const char *root, const priv_set_t *privs, + const char *rctls, size_t rctlsz, int *extended_error) +{ + zone_def zd; + + zd.zone_name = name; + zd.zone_root = root; + zd.zone_privs = privs; + zd.rctlbuf = rctls; + zd.rctlbufsz = rctlsz; + zd.extended_error = extended_error; + + return ((zoneid_t)syscall(SYS_zone, + ZONE_CREATE, &zd)); +} + +int +zone_boot(zoneid_t zoneid, const char *bootargs) +{ + return (syscall(SYS_zone, ZONE_BOOT, zoneid, bootargs)); +} + +int +zone_shutdown(zoneid_t zoneid) +{ + return (syscall(SYS_zone, ZONE_SHUTDOWN, zoneid)); +} + +int +zone_destroy(zoneid_t zoneid) +{ + return (syscall(SYS_zone, ZONE_DESTROY, zoneid)); +} + +ssize_t +zone_getattr(zoneid_t zoneid, int attr, void *valp, size_t size) +{ + sysret_t rval; + int error; + + error = __systemcall(&rval, SYS_zone, ZONE_GETATTR, zoneid, + attr, valp, size); + if (error) + (void) __set_errno(error); + return ((ssize_t)rval.sys_rval1); +} + +int +zone_enter(zoneid_t zoneid) +{ + return (syscall(SYS_zone, ZONE_ENTER, zoneid)); +} + +/* + * Get id (if any) for specified zone. + * + * Call the real zone_get_id() in libzonecfg.so.1 if it can be found. + * Otherwise, perform a stripped-down version of the function. + * Any changes in one version should probably be reflected in the other. + * + * This stripped-down version of the function only checks for active + * (booted) zones, by numeric id or name. + */ + +typedef int (*zone_get_id_t)(const char *, zoneid_t *); +static zone_get_id_t real_zone_get_id = NULL; + +int +zone_get_id(const char *str, zoneid_t *zip) +{ + zoneid_t zoneid; + char *cp; + + /* + * The first time we are called, attempt to dlopen() libzonecfg.so.1 + * and get a pointer to the real zone_get_id(). + * If we fail, set our pointer to -1 so we won't try again. + */ + if (real_zone_get_id == NULL) { + /* + * There's no harm in doing this more than once, even + * concurrently. We will get the same result each time, + * and the dynamic linker will single-thread the dlopen() + * with its own internal lock. The worst that can happen + * is that the handle gets a reference count greater than + * one, which doesn't matter since we never dlclose() + * the handle if we successfully find the symbol; the + * library just stays in the address space until exit(). + */ + void *dlhandle = dlopen("libzonecfg.so.1", RTLD_LAZY); + void *sym = (void *)(-1); + + if (dlhandle != NULL && + (sym = dlsym(dlhandle, "zone_get_id")) == NULL) { + sym = (void *)(-1); + (void) dlclose(dlhandle); + } + real_zone_get_id = (zone_get_id_t)sym; + } + + /* + * If we've successfully loaded it, call the real zone_get_id(). + * Otherwise, perform our stripped-down version of the code. + */ + if (real_zone_get_id != (zone_get_id_t)(-1)) + return (real_zone_get_id(str, zip)); + + /* first try looking for active zone by id */ + errno = 0; + zoneid = (zoneid_t)strtol(str, &cp, 0); + if (errno == 0 && cp != str && *cp == '\0' && + getzonenamebyid(zoneid, NULL, 0) != -1) { + *zip = zoneid; + return (0); + } + + /* then look for active zone by name */ + if ((zoneid = getzoneidbyname(str)) != -1) { + *zip = zoneid; + return (0); + } + + /* not an active zone, return error */ + return (-1); +} + +int +zone_list(zoneid_t *zonelist, uint_t *numzones) +{ + return (syscall(SYS_zone, ZONE_LIST, zonelist, numzones)); +} + +/* + * Underlying implementation for getzoneid and getzoneidbyname. + */ +static zoneid_t +zone_lookup(const char *name) +{ + return ((zoneid_t)syscall(SYS_zone, ZONE_LOOKUP, name)); +} + +zoneid_t +getzoneid(void) +{ + return (zone_lookup(NULL)); +} + +zoneid_t +getzoneidbyname(const char *zonename) +{ + return (zone_lookup(zonename)); +} + +ssize_t +getzonenamebyid(zoneid_t zoneid, char *buf, size_t buflen) +{ + return (zone_getattr(zoneid, ZONE_ATTR_NAME, buf, buflen)); +} |