diff options
Diffstat (limited to 'usr/src/lib/libc/port/sys')
-rw-r--r-- | usr/src/lib/libc/port/sys/fsync.c | 50 | ||||
-rw-r--r-- | usr/src/lib/libc/port/sys/libc_fcntl.c (renamed from usr/src/lib/libc/port/sys/fcntl.c) | 40 | ||||
-rw-r--r-- | usr/src/lib/libc/port/sys/libc_open.c | 73 | ||||
-rw-r--r-- | usr/src/lib/libc/port/sys/lockf.c | 13 | ||||
-rw-r--r-- | usr/src/lib/libc/port/sys/msgsys.c | 13 | ||||
-rw-r--r-- | usr/src/lib/libc/port/sys/openat.c | 34 | ||||
-rw-r--r-- | usr/src/lib/libc/port/sys/sharefs.c | 5 | ||||
-rw-r--r-- | usr/src/lib/libc/port/sys/signal.c | 10 |
8 files changed, 106 insertions, 132 deletions
diff --git a/usr/src/lib/libc/port/sys/fsync.c b/usr/src/lib/libc/port/sys/fsync.c deleted file mode 100644 index b0278f3d95..0000000000 --- a/usr/src/lib/libc/port/sys/fsync.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * 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 2007 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) - * fdatasync(int fd) - */ -#include "synonyms.h" -#include "libc.h" -#include <sys/file.h> - -int -_fsync(int fd) -{ - return (__fdsync(fd, FSYNC)); -} - -int -_fdatasync(int fd) -{ - return (__fdsync(fd, FDSYNC)); -} diff --git a/usr/src/lib/libc/port/sys/fcntl.c b/usr/src/lib/libc/port/sys/libc_fcntl.c index 4c4b6f56f0..b474123486 100644 --- a/usr/src/lib/libc/port/sys/fcntl.c +++ b/usr/src/lib/libc/port/sys/libc_fcntl.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -35,7 +35,7 @@ #include <sys/filio.h> #include <sys/file.h> #include <sys/types.h> -#include <sys/fcntl.h> +#include <fcntl.h> #include <signal.h> #include <sys/stat.h> #include <sys/stropts.h> @@ -52,28 +52,36 @@ #include <stdlib.h> #include "libc.h" -extern int __fcntl(int fd, int cmd, intptr_t arg); +/* + * We must be careful to call only functions that are private + * to libc here, to avoid invoking the dynamic linker. + * This is important because _private_fcntl() is called from + * posix_spawn() after vfork() and we must never invoke the + * dynamic linker in a vfork() child. + */ + +extern int _private_ioctl(int, int, ...); +extern int __fcntl_syscall(int fd, int cmd, ...); #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. + * There is no need for _s_ioctl for other purposes. */ -#pragma weak s_fcntl = _fcntl -#pragma weak _s_fcntl = _fcntl +#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)); + return (_private_ioctl(fd, cmd, arg)); } -/* End XXX */ #endif /* _LP64 */ +#pragma weak _private_fcntl = __fcntl int -_fcntl(int fd, int cmd, ...) +__fcntl(int fd, int cmd, ...) { int res; int pid; @@ -87,14 +95,14 @@ _fcntl(int fd, int cmd, ...) switch (cmd) { case F_SETOWN: pid = (int)arg; - return (ioctl(fd, FIOSETOWN, &pid)); + return (_private_ioctl(fd, FIOSETOWN, &pid)); case F_GETOWN: - if (ioctl(fd, FIOGETOWN, &res) < 0) + if (_private_ioctl(fd, FIOGETOWN, &res) < 0) return (-1); return (res); default: - return (__fcntl(fd, cmd, arg)); + return (__fcntl_syscall(fd, cmd, arg)); } } diff --git a/usr/src/lib/libc/port/sys/libc_open.c b/usr/src/lib/libc/port/sys/libc_open.c index 0ed9b559a3..1a9cc4a017 100644 --- a/usr/src/lib/libc/port/sys/libc_open.c +++ b/usr/src/lib/libc/port/sys/libc_open.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -21,7 +20,7 @@ */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -41,21 +40,29 @@ #include <sys/stropts.h> #include <sys/stream.h> #include <sys/ptms.h> +#include "libc.h" #if !defined(_LP64) -extern int __open64(const char *fname, int oflag, mode_t mode); +extern int __open64_syscall(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); +extern int __open_syscall(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); +/* + * We must be careful to call only functions that are private + * to libc here, to avoid invoking the dynamic linker. + * This is important because _private_open() and _private_open64() + * are called from posix_spawn() after vfork() and we must never + * invoke the dynamic linker in a vfork() child. + */ + +#pragma weak _private_open = __open int -_open(const char *fname, int oflag, ...) +__open(const char *fname, int oflag, ...) { mode_t mode; int fd; @@ -71,8 +78,8 @@ _open(const char *fname, int oflag, ...) * the terminal interface. For a more detailed discussion, * see bugid 4025044. */ - fd = __open(fname, oflag, mode); - if (__xpg4 != 0 && fd >= 0 && isptsfd(fd)) + fd = __open_syscall(fname, oflag, mode); + if (libc__xpg4 != 0 && fd >= 0 && isptsfd(fd)) push_module(fd); return (fd); } @@ -80,10 +87,11 @@ _open(const char *fname, int oflag, ...) #if !defined(_LP64) /* * The 32-bit APIs to large files require this interposition. - * The 64-bit APIs just fall back to _open() above. + * The 64-bit APIs just fall back to __open() above. */ +#pragma weak _private_open64 = __open64 int -_open64(const char *fname, int oflag, ...) +__open64(const char *fname, int oflag, ...) { mode_t mode; int fd; @@ -99,8 +107,8 @@ _open64(const char *fname, int oflag, ...) * the terminal interface. For a more detailed discussion, * see bugid 4025044. */ - fd = __open64(fname, oflag, mode); - if (__xpg4 != 0 && fd >= 0 && isptsfd(fd)) + fd = __open64_syscall(fname, oflag, mode); + if (libc__xpg4 != 0 && fd >= 0 && isptsfd(fd)) push_module(fd); return (fd); } @@ -113,15 +121,31 @@ _open64(const char *fname, int oflag, ...) static int isptsfd(int fd) { +#if defined(_LP64) +#define _private_stat64 _private_stat +#define _private_fstat64 _private_fstat +#endif + extern int _private_stat64(const char *, struct stat64 *); + extern int _private_fstat64(int, struct stat64 *); char buf[TTYNAME_MAX]; + char *str1 = buf; + const char *str2 = "/dev/pts/"; struct stat64 fsb, stb; int oerrno = errno; int rval = 0; - if (fstat64(fd, &fsb) == 0 && S_ISCHR(fsb.st_mode)) { - (void) strcpy(buf, "/dev/pts/"); - itoa(minor(fsb.st_rdev), buf+strlen(buf)); - if (stat64(buf, &stb) == 0) + if (_private_fstat64(fd, &fsb) == 0 && S_ISCHR(fsb.st_mode)) { + /* + * Do this without strcpy() or strlen(), + * to avoid invoking the dynamic linker. + */ + while (*str2 != '\0') + *str1++ = *str2++; + /* + * Inline version of minor(dev), to avoid the dynamic linker. + */ + itoa(fsb.st_rdev & MAXMIN, str1); + if (_private_stat64(buf, &stb) == 0) rval = (stb.st_rdev == fsb.st_rdev); } errno = oerrno; @@ -157,6 +181,7 @@ itoa(int i, char *ptr) static void push_module(int fd) { + extern int _private_ioctl(int, int, ...); struct strioctl istr; int oerrno = errno; @@ -164,15 +189,15 @@ push_module(int fd) 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"); + if (_private_ioctl(fd, I_STR, &istr) != -1) { + (void) _private_ioctl(fd, __I_PUSH_NOCTTY, "ptem"); + (void) _private_ioctl(fd, __I_PUSH_NOCTTY, "ldterm"); + (void) _private_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); + (void) _private_ioctl(fd, I_STR, &istr); } errno = oerrno; } diff --git a/usr/src/lib/libc/port/sys/lockf.c b/usr/src/lib/libc/port/sys/lockf.c index f1bb62a12f..eb6d41bcdf 100644 --- a/usr/src/lib/libc/port/sys/lockf.c +++ b/usr/src/lib/libc/port/sys/lockf.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -29,11 +29,10 @@ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - #include <sys/feature_tests.h> #if !defined(_LP64) && _FILE_OFFSET_BITS == 64 -#define _lockf _lockf64 +#define __lockf __lockf64 #endif #include "synonyms.h" @@ -43,7 +42,7 @@ #include <fcntl.h> int -_lockf(int fildes, int function, off_t size) +__lockf(int fildes, int function, off_t size) { struct flock l; int rv; diff --git a/usr/src/lib/libc/port/sys/msgsys.c b/usr/src/lib/libc/port/sys/msgsys.c index d2db4da376..966bcc6975 100644 --- a/usr/src/lib/libc/port/sys/msgsys.c +++ b/usr/src/lib/libc/port/sys/msgsys.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -29,7 +29,6 @@ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - #pragma weak msgctl = _msgctl #pragma weak msgctl64 = _msgctl64 #pragma weak msgget = _msgget @@ -75,7 +74,7 @@ msgctl64(int msqid, int cmd, struct msqid_ds64 *buf) } ssize_t -_msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) +__msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) { if (msgsz > INT_MAX) { sysret_t rval; @@ -97,7 +96,7 @@ _msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) } int -_msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) +__msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) { if (msgsz > INT_MAX) { sysret_t rval; diff --git a/usr/src/lib/libc/port/sys/openat.c b/usr/src/lib/libc/port/sys/openat.c index 5549abf5d9..483a88a948 100644 --- a/usr/src/lib/libc/port/sys/openat.c +++ b/usr/src/lib/libc/port/sys/openat.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,19 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 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> @@ -40,29 +34,29 @@ #if !defined(_LP64) && _FILE_OFFSET_BITS == 64 int -openat64(int fd, const char *name, int omode, ...) +__openat64(int fd, const char *name, int oflag, ...) { va_list ap; - mode_t cmode; + mode_t mode; - va_start(ap, omode); - cmode = va_arg(ap, mode_t); + va_start(ap, oflag); + mode = va_arg(ap, mode_t); va_end(ap); - return (syscall(SYS_fsat, 1, fd, name, omode, cmode)); + return (syscall(SYS_fsat, 1, fd, name, oflag, mode)); } #else int -openat(int fd, const char *name, int omode, ...) +__openat(int fd, const char *name, int oflag, ...) { va_list ap; - mode_t cmode; + mode_t mode; - va_start(ap, omode); - cmode = va_arg(ap, mode_t); + va_start(ap, oflag); + mode = va_arg(ap, mode_t); va_end(ap); - return (syscall(SYS_fsat, 0, fd, name, omode, cmode)); + return (syscall(SYS_fsat, 0, fd, name, oflag, mode)); } #endif diff --git a/usr/src/lib/libc/port/sys/sharefs.c b/usr/src/lib/libc/port/sys/sharefs.c index 241790aad6..42e0db738a 100644 --- a/usr/src/lib/libc/port/sys/sharefs.c +++ b/usr/src/lib/libc/port/sys/sharefs.c @@ -18,15 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#pragma weak _sharefs = __sharefs - #include "synonyms.h" #include <sys/types.h> #include <sys/types32.h> diff --git a/usr/src/lib/libc/port/sys/signal.c b/usr/src/lib/libc/port/sys/signal.c index 4cd406e6fd..757dedd70b 100644 --- a/usr/src/lib/libc/port/sys/signal.c +++ b/usr/src/lib/libc/port/sys/signal.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -158,7 +158,7 @@ sigignore(int sig) } int -_sigpause(int sig) +__sigpause(int sig) { sigset_t set; int rval; |