diff options
author | raf <none@none> | 2006-12-12 21:33:45 -0800 |
---|---|---|
committer | raf <none@none> | 2006-12-12 21:33:45 -0800 |
commit | d4188195113bc7f546b026033c66ea3e12de0e02 (patch) | |
tree | db507e14c10cb79ec46942a49c2ce76a6f4489d0 /usr/src/lib/libbc/libc/sys | |
parent | 8dea286086b540419ab7594c626f1153fe6e99be (diff) | |
download | illumos-gate-d4188195113bc7f546b026033c66ea3e12de0e02.tar.gz |
6499491 libbc misuses <sys/syscall.h>
--HG--
rename : usr/src/lib/libbc/inc/include/sys/syscall.h => deleted_files/usr/src/lib/libbc/inc/include/sys/syscall.h
Diffstat (limited to 'usr/src/lib/libbc/libc/sys')
31 files changed, 617 insertions, 684 deletions
diff --git a/usr/src/lib/libbc/libc/sys/4.2/access.c b/usr/src/lib/libbc/libc/sys/4.2/access.c index d3a709483b..84c6ce7154 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/access.c +++ b/usr/src/lib/libbc/libc/sys/4.2/access.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,23 +18,23 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" #include "chkpath.h" -#include <syscall.h> +#include <sys/syscall.h> #include <unistd.h> #include <sys/param.h> -int access(path, mode) -char *path; -int mode; +int +access(char *path, int mode) { CHKNULL(path); - return(access_com(path, mode)); + return (access_com(path, mode)); } diff --git a/usr/src/lib/libbc/libc/sys/4.2/chkpath.h b/usr/src/lib/libbc/libc/sys/4.2/chkpath.h index 23bc3917d3..cb8c8f8b8e 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/chkpath.h +++ b/usr/src/lib/libbc/libc/sys/4.2/chkpath.h @@ -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 1995 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -31,11 +31,9 @@ #include <errno.h> #define CHKNULL(p) \ - if ((p) == (char *)0 || (p) == (char *) -1) { \ + if ((p) == (char *)0 || (p) == (char *)-1) { \ errno = EFAULT; \ return (-1); \ } else if (*(p) == 0) { \ p = "."; \ } - -extern int syscall(); diff --git a/usr/src/lib/libbc/libc/sys/4.2/creat.c b/usr/src/lib/libbc/libc/sys/4.2/creat.c index 3fd67c345e..a226b14cd8 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/creat.c +++ b/usr/src/lib/libbc/libc/sys/4.2/creat.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,28 +18,24 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" #include "chkpath.h" -#include <syscall.h> +#include <sys/syscall.h> #include <unistd.h> #include <errno.h> #include <sys/param.h> -extern int errno; - -int creat(path, mode) -char *path; -int mode; +int +creat(char *path, int mode) { CHKNULL(path); - return(creat_com(path, mode)); + return (creat_com(path, mode)); } - - diff --git a/usr/src/lib/libbc/libc/sys/4.2/read.c b/usr/src/lib/libbc/libc/sys/4.2/read.c index 1eaa42d661..905f542e93 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/read.c +++ b/usr/src/lib/libbc/libc/sys/4.2/read.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,9 +18,10 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -31,14 +31,12 @@ #include <stdio.h> #include <sys/types.h> #include <unistd.h> -#include <syscall.h> +#include <sys/syscall.h> /* * If reading from the utmp file, map the data to the SunOS 4.1 - * format on the fly. + * format on the fly. */ -extern int errno; - extern void to_utmp(char *, char *, int); int @@ -52,16 +50,16 @@ bc_read(int fd, char *buf, int size) { int fds, ret, off; char *nbuf; - + if (fd_get(fd) != -1) { /* we're reading utmp (utmpx, really) */ - size = getmodsize(size, sizeof (struct compat_utmp), + size = getmodsize(size, sizeof (struct compat_utmp), sizeof (struct utmpx)); if ((nbuf = (void *)malloc(size)) == NULL) { (void) fprintf(stderr, "read: malloc failed\n"); exit(-1); } - + if ((ret = _read(fd, nbuf, size)) == -1) { if (errno == EAGAIN) errno = EWOULDBLOCK; @@ -70,7 +68,7 @@ bc_read(int fd, char *buf, int size) } to_utmp(buf, nbuf, ret); - ret = getmodsize(ret, sizeof (struct utmpx), + ret = getmodsize(ret, sizeof (struct utmpx), sizeof (struct compat_utmp)); free(nbuf); return (ret); @@ -89,15 +87,15 @@ to_utmp(char *buf, char *nbuf, int len) struct compat_utmp *ut; struct utmpx *utx; - utx = (struct utmpx *) nbuf; - ut = (struct compat_utmp *) buf; + utx = (struct utmpx *)nbuf; + ut = (struct compat_utmp *)buf; while ((char *)utx < (nbuf + len)) { (void) strncpy(ut->ut_line, utx->ut_line, sizeof (ut->ut_line)); - (void) strncpy(ut->ut_name, utx->ut_user, sizeof (ut->ut_name)); - (void) strncpy(ut->ut_host, utx->ut_host, sizeof (ut->ut_host)); - ut->ut_time = utx->ut_tv.tv_sec; - utx++; - ut++; - } + (void) strncpy(ut->ut_name, utx->ut_user, sizeof (ut->ut_name)); + (void) strncpy(ut->ut_host, utx->ut_host, sizeof (ut->ut_host)); + ut->ut_time = utx->ut_tv.tv_sec; + utx++; + ut++; + } } diff --git a/usr/src/lib/libbc/libc/sys/4.2/readv.c b/usr/src/lib/libbc/libc/sys/4.2/readv.c index 75985299e9..60a746da24 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/readv.c +++ b/usr/src/lib/libbc/libc/sys/4.2/readv.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,26 +18,25 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" #include "../common/compat.h" #include <stdio.h> -#include <sys/errno.h> +#include <errno.h> #include <sys/types.h> #include <unistd.h> -#include <syscall.h> +#include <sys/syscall.h> #include <sys/uio.h> -extern int errno; - /* * If reading from the utmp file, map the data to the SunOS 4.1 - * format on the fly. + * format on the fly. */ extern void to_utmp(char *, char *, int); @@ -54,7 +52,7 @@ bc_readv(int fd, struct iovec *iov, int iovcnt) int fds, ret, off; int i, size, total = 0; char *nbuf; - + if (fd_get(fd) != -1) { /* we're reading utmp (utmpx really) */ for (i = 0; i < iovcnt; i++) { size = getmodsize(iov[i].iov_len, @@ -65,20 +63,20 @@ bc_readv(int fd, struct iovec *iov, int iovcnt) fprintf(stderr, "readv: malloc failed\n"); exit(-1); } - + if ((ret = _read(fd, nbuf, size)) == -1) { if (errno == EAGAIN) - errno = EWOULDBLOCK; + errno = EWOULDBLOCK; free(nbuf); return (-1); } - total += ret; - to_utmp(iov[i].iov_base, nbuf, ret); - ret = getmodsize(ret, sizeof (struct utmpx), + ret = getmodsize(ret, sizeof (struct utmpx), sizeof (struct compat_utmp)); + total += ret; + free(nbuf); } @@ -90,5 +88,4 @@ bc_readv(int fd, struct iovec *iov, int iovcnt) errno = EWOULDBLOCK; } return (ret); - } diff --git a/usr/src/lib/libbc/libc/sys/4.2/rename.c b/usr/src/lib/libbc/libc/sys/4.2/rename.c index 6b762dc450..bb381e3d13 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/rename.c +++ b/usr/src/lib/libbc/libc/sys/4.2/rename.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,21 +18,20 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" #include "chkpath.h" -#include <syscall.h> +#include <sys/syscall.h> -int rename(path1, path2) -char *path1, *path2; +int +rename(char *path1, char *path2) { - int ret; - char buf1[256]; char buf2[256]; CHKNULL(path1); @@ -44,19 +42,18 @@ char *path1, *path2; * to map the utmp or wtmp rename operation into * a rename of utmpx or wtmpx */ - if (strcmp(path1, "/var/adm/utmp") == 0 || - strcmp(path1, "/var/adm/wtmp") == 0 || - strcmp(path1, "/etc/utmp") == 0) { - if (strcmp(path1, "/etc/utmp") == 0 || - strcmp(path1,"/var/adm/utmp") == 0) - strcpy(buf1, "/var/adm/utmpx"); - else - strcpy(buf1, "/var/adm/wtmpx"); + if (strcmp(path1, "/etc/utmp") == 0 || + strcmp(path1, "/var/adm/utmp") == 0) { + path1 = "/var/adm/utmpx"; + strcpy(buf2, path2); + strcat(buf2, "x"); + path2 = buf2; + } else if (strcmp(path1, "/var/adm/wtmp") == 0) { + path1 = "/var/adm/wtmpx"; strcpy(buf2, path2); strcat(buf2, "x"); - ret = _syscall(SYS_rename, buf1, buf2); - } else - ret = _syscall(SYS_rename, path1, path2); + path2 = buf2; + } - return(ret); -} + return (_syscall(SYS_rename, path1, path2)); +} diff --git a/usr/src/lib/libbc/libc/sys/4.2/truncate.c b/usr/src/lib/libbc/libc/sys/4.2/truncate.c index 4e5981abbd..4cf30b8f26 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/truncate.c +++ b/usr/src/lib/libbc/libc/sys/4.2/truncate.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,42 +18,40 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" #include "chkpath.h" -#include <syscall.h> +#include <sys/syscall.h> #include <unistd.h> #include <errno.h> #include <sys/fcntl.h> #include <sys/param.h> -extern int errno; - -int truncate(path, length) -char *path; -off_t length; +int +truncate(char *path, off_t length) { - int fd, ret=0; + int fd, ret = 0; CHKNULL(path); if (strcmp(path, "/etc/mtab") == 0 || strcmp(path, "/etc/fstab") == 0) { errno = ENOENT; - return(-1); + return (-1); } if ((fd = open(path, O_WRONLY)) == -1) { - return(-1); + return (-1); } - + if (ftruncate(fd, length) == -1) { close(fd); - return(-1); + return (-1); } close(fd); - return(0); + return (0); } diff --git a/usr/src/lib/libbc/libc/sys/4.2/unlink.c b/usr/src/lib/libbc/libc/sys/4.2/unlink.c index a11e96e301..0a8d8a694c 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/unlink.c +++ b/usr/src/lib/libbc/libc/sys/4.2/unlink.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,40 +18,27 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> -#include <sys/errno.h> +#include "chkpath.h" +#include <sys/syscall.h> -int unlink(char *path) +int +unlink(char *path) { - int ret; - char buf[256]; - extern int errno; - char dot[2] = {'.','\n'}; + CHKNULL(path); - if (path == (char *) 0) { - errno = EFAULT; - return(-1); - } else if (strcmp(path, "") == 0) - path = dot; + if (strcmp(path, "/etc/utmp") == 0 || + strcmp(path, "/var/adm/utmp") == 0) + path = "/var/adm/utmpx"; + else if (strcmp(path, "/var/adm/wtmp") == 0) + path = "/var/adm/wtmpx"; - else if (strcmp(path, "/var/adm/utmp") == 0 || - strcmp(path, "/var/adm/wtmp") == 0 || - strcmp(path, "/etc/utmp") == 0) { - if (strcmp(path, "/etc/utmp") == 0 || - strcmp(path, "/var/adm/utmp") == 0) - strcpy(buf, "/var/adm/utmpx"); - else - strcpy(buf, "/var/adm/wtmpx"); - ret = _syscall(SYS_unlink, buf); - } else - ret = _syscall(SYS_unlink, path); - - return (ret); -} + return (_syscall(SYS_unlink, path)); +} diff --git a/usr/src/lib/libbc/libc/sys/4.2/writev.c b/usr/src/lib/libbc/libc/sys/4.2/writev.c index 4bfbbe0d33..2e54aa1439 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/writev.c +++ b/usr/src/lib/libbc/libc/sys/4.2/writev.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,9 +18,10 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -54,7 +54,7 @@ bc_writev(int fd, struct iovec *iov, int iovcnt) int nsize, total = 0; char *nbuf; int i; - + if (fd_get(fd) != -1) { /* writing utmp (utmpx, actually) */ for (i = 0; i < iovcnt; i++) { nsize = getmodsize(iov[i].iov_len, @@ -65,7 +65,7 @@ bc_writev(int fd, struct iovec *iov, int iovcnt) fprintf(stderr, "writev: malloc failed\n"); exit(-1); } - + (void) memset(nbuf, 0, nsize); ret = conv2utmpx(nbuf, iov[i].iov_base, iov[i].iov_len); @@ -77,16 +77,12 @@ bc_writev(int fd, struct iovec *iov, int iovcnt) return (-1); } - total += ret; - free(nbuf); - - ret = getmodsize(ret, sizeof (struct utmpx), - sizeof (struct compat_utmp)); + ret = getmodsize(ret, sizeof (struct utmpx), + sizeof (struct compat_utmp)); + total += ret; } - total = getmodsize(total, sizeof (struct utmpx), - sizeof (struct compat_utmp)); return (total); } @@ -94,6 +90,6 @@ bc_writev(int fd, struct iovec *iov, int iovcnt) if (errno == EAGAIN) errno = EWOULDBLOCK; } - + return (ret); } diff --git a/usr/src/lib/libbc/libc/sys/common/_access.c b/usr/src/lib/libbc/libc/sys/common/_access.c index 4ce2a1ca56..28737c88c0 100644 --- a/usr/src/lib/libbc/libc/sys/common/_access.c +++ b/usr/src/lib/libbc/libc/sys/common/_access.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,35 +18,34 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> #include <unistd.h> #include <sys/param.h> -int access_com(char *path, int mode) +int +access_com(char *path, int mode) { - int ret=0; - char buf[MAXPATHLEN+100]; - if (strcmp(path, "/etc/mtab") == 0 || strcmp(path, "/etc/fstab") == 0) { if (mode == W_OK || mode == X_OK) - return(-1); - else return(0); - } else if (strcmp(path, "/var/adm/utmp") == 0 || - strcmp(path, "/var/adm/wtmp") == 0) { - strcpy(buf, path); - strcat(buf, "x"); - return(_syscall(SYS_access, buf, mode)); - } else if (strcmp(path, "/etc/utmp") == 0) { - strcpy(buf, "/var/adm/utmpx"); - return(_syscall(SYS_access, buf, mode)); - } else - return(_syscall(SYS_access, path, mode)); + return (-1); + else + return (0); + } + + if (strcmp(path, "/etc/utmp") == 0 || + strcmp(path, "/var/adm/utmp") == 0) + path = "/var/adm/utmpx"; + else if (strcmp(path, "/var/adm/wtmp") == 0) + path = "/var/adm/wtmpx"; + + return (_syscall(SYS_access, path, mode)); } diff --git a/usr/src/lib/libbc/libc/sys/common/_creat.c b/usr/src/lib/libbc/libc/sys/common/_creat.c index 1f2181cc81..3a91013eb4 100644 --- a/usr/src/lib/libbc/libc/sys/common/_creat.c +++ b/usr/src/lib/libbc/libc/sys/common/_creat.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,48 +18,40 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> #include <unistd.h> #include <errno.h> #include <sys/param.h> #include "compat.h" /* for UTMPX_MAGIC_FLAG */ -extern int errno; - -int creat_com(char *path, int mode) +int +creat_com(char *path, int mode) { - int ret=0; - int fd, fd2; - char buf[MAXPATHLEN+100]; + int fd; if (strcmp(path, "/etc/mtab") == 0 || strcmp(path, "/etc/fstab") == 0) { errno = ENOENT; - return(-1); + return (-1); + } + if (strcmp(path, "/var/adm/wtmp") == 0) { + if ((fd = _syscall(SYS_creat, "/var/adm/wtmpx", mode)) >= 0) + fd_add(fd, UTMPX_MAGIC_FLAG); + return (fd); + } + if (strcmp(path, "/etc/utmp") == 0 || + strcmp(path, "/var/adm/utmp") == 0) { + if ((fd = _syscall(SYS_creat, "/var/adm/utmpx", mode)) >= 0) + fd_add(fd, UTMPX_MAGIC_FLAG); + return (fd); } - if (strcmp(path, "/var/adm/utmp") == 0 || - strcmp(path, "/var/adm/wtmp") == 0) { - strcpy(buf, path); - strcat(buf, "x"); - if ((fd = _syscall(SYS_creat, buf, mode)) >= 0) { - fd2 = UTMPX_MAGIC_FLAG; - fd_add(fd, fd2); - } - return(fd); - } else if (strcmp(path, "/etc/utmp") == 0) { - strcpy(buf, "/var/adm/utmpx"); - if ((fd = _syscall(SYS_creat, buf, mode)) >= 0) { - fd2 = UTMPX_MAGIC_FLAG; - fd_add(fd, fd2); - } - return(fd); - } else - return(_syscall(SYS_creat, path, mode)); + return (_syscall(SYS_creat, path, mode)); } diff --git a/usr/src/lib/libbc/libc/sys/common/_open.c b/usr/src/lib/libbc/libc/sys/common/_open.c index 8625c37156..139135e32a 100644 --- a/usr/src/lib/libbc/libc/sys/common/_open.c +++ b/usr/src/lib/libbc/libc/sys/common/_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. @@ -19,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -30,7 +30,7 @@ #include <fcntl.h> #include <string.h> #include <mntent.h> -#include <syscall.h> +#include <sys/syscall.h> #include <sys/param.h> #include <sys/sysmacros.h> #include <sys/types.h> @@ -107,30 +107,34 @@ open_com(char *path, int flags, int mode) return (_syscall(SYS_open, locbuf, nflags, mode)); } - if (strcmp(path, "/etc/mtab") == 0) { + if (strcmp(path, "/etc/mtab") == 0) return (open_mnt("/etc/mnttab", "mtab", nflags, mode)); - } else if (strcmp(path, "/etc/fstab") == 0) { + + if (strcmp(path, "/etc/fstab") == 0) return (open_mnt("/etc/vfstab", "fstab", nflags, mode)); - } else if (strcmp(path, "/etc/printcap") == 0) { - if ((fd = _syscall(SYS_open, path, - nflags, mode)) != -1) - return (fd); - return (open_printcap()); - } else if (strcmp(path, "/etc/utmp") == 0 || - strcmp(path, "/var/adm/wtmp") == 0) { - char buf[MAXPATHLEN+100]; - if (strcmp(path, "/etc/utmp") == 0) - strcpy(buf, "/var/adm/utmpx"); - else - strcpy(buf, "/var/adm/wtmpx"); - if ((fd = _syscall(SYS_open, buf, - nflags, mode)) == -1) - return (-1); - fd2 = UTMPX_MAGIC_FLAG; - fd_add(fd, fd2); + + if (strcmp(path, "/etc/printcap") == 0) { + if ((fd = _syscall(SYS_open, path, nflags, mode)) >= 0) return (fd); - } else - return (_syscall(SYS_open, path, nflags, mode)); + return (open_printcap()); + } + + if (strcmp(path, "/etc/utmp") == 0 || + strcmp(path, "/var/adm/utmp") == 0) { + fd = _syscall(SYS_open, "/var/adm/utmpx", nflags, mode); + if (fd >= 0) + fd_add(fd, UTMPX_MAGIC_FLAG); + return (fd); + } + + if (strcmp(path, "/var/adm/wtmp") == 0) { + fd = _syscall(SYS_open, "/var/adm/wtmpx", nflags, mode); + if (fd >= 0) + fd_add(fd, UTMPX_MAGIC_FLAG); + return (fd); + } + + return (_syscall(SYS_open, path, nflags, mode)); } int @@ -160,12 +164,13 @@ open_mnt(char *fname, char *tname, int flags, int mode) fclose(fd_out); return (-1); } - } else /* processing vfstab */ + } else { /* processing vfstab */ if (putfline(line, fd_out) == -1) { fclose(fd_in); fclose(fd_out); return (-1); } + } } if (feof(fd_in)) { @@ -185,7 +190,6 @@ open_mnt(char *fname, char *tname, int flags, int mode) } } - int getmntline(char *lp, FILE *fp) { @@ -237,8 +241,8 @@ putmline(char *line, FILE *fp) if (!devnumstr) { /* no device number on this line */ fprintf(fp, "%s %s %s %s %d %d\n", - mnt.mnt_fsname, mnt.mnt_dir, mnt.mnt_type, - mnt.mnt_opts, mnt.mnt_freq, mnt.mnt_passno); + mnt.mnt_fsname, mnt.mnt_dir, mnt.mnt_type, + mnt.mnt_opts, mnt.mnt_freq, mnt.mnt_passno); } else { /* found the device number, convert it to 4.x format */ devnum = strtol(&devnumstr[1], (char **)NULL, 16); @@ -247,9 +251,9 @@ putmline(char *line, FILE *fp) devnum = cmpdev(devnum); fprintf(fp, "%s %s %s %s%4x%s %d %d\n", - mnt.mnt_fsname, mnt.mnt_dir, mnt.mnt_type, - mnt.mnt_opts, devnum, remainder ? remainder : "", - mnt.mnt_freq, mnt.mnt_passno); + mnt.mnt_fsname, mnt.mnt_dir, mnt.mnt_type, + mnt.mnt_opts, devnum, remainder ? remainder : "", + mnt.mnt_freq, mnt.mnt_passno); } return (0); @@ -282,13 +286,12 @@ putfline(char *line, FILE *fp) } fprintf(fp, "%s %s %s %s %d %d\n", - mnt.mnt_fsname, mnt.mnt_dir, mnt.mnt_type, - mnt.mnt_opts, mnt.mnt_freq, mnt.mnt_passno); + mnt.mnt_fsname, mnt.mnt_dir, mnt.mnt_type, + mnt.mnt_opts, mnt.mnt_freq, mnt.mnt_passno); return (0); } - FILE * _fopen(char *file, char *mode) { @@ -361,7 +364,6 @@ open_printcap(void) return (tmp_file); } - static void getPrinterInfo(char *printerName, FILE *fd) { diff --git a/usr/src/lib/libbc/libc/sys/common/_stat.c b/usr/src/lib/libbc/libc/sys/common/_stat.c index cdbab6d0ed..b9c1ab3580 100644 --- a/usr/src/lib/libbc/libc/sys/common/_stat.c +++ b/usr/src/lib/libbc/libc/sys/common/_stat.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,9 +18,10 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -60,7 +60,7 @@ struct n_stat { long st_blocks; char st_fstype[ST_FSTYPSZ]; long st_pad4[8]; /* expansion area */ - + }; static void cpstatbuf(struct stat *, struct n_stat *); @@ -76,19 +76,19 @@ bc_fstat(int fd, struct stat *buf) { int ret; struct n_stat nb; - extern int errno; + extern int errno; if (buf == 0) { errno = EFAULT; return (-1); } - + if ((ret = _syscall(SYS_fstat, fd, &nb)) == -1) return (ret); cpstatbuf(buf, &nb); if (fd_get(fd) != -1) { - buf->st_size = getmodsize(buf->st_size, + buf->st_size = getmodsize(buf->st_size, sizeof (struct utmpx), sizeof(struct compat_utmp)); } @@ -117,39 +117,48 @@ stat_com(int sysnum, char *path, struct stat *buf) */ ret = stat_com(sysnum, "/etc/mnttab", buf); return(ret); - } else if (strcmp(path, "/etc/fstab") == 0) { + } + if (strcmp(path, "/etc/fstab") == 0) { fd = open_mnt("/etc/vfstab", "fstab", O_RDONLY); - ret = fstat(fd, buf); - close(fd); - return(ret); - } else if (strcmp(path, "/var/adm/utmp") == 0 || - strcmp(path, "/var/adm/wtmp") == 0 || - strcmp(path, "/etc/utmp") == 0) { - char pathx[MAXPATHLEN+100]; - if (strcmp(path, "/etc/utmp") == 0) - strcpy(pathx, "/var/adm/utmpx"); + if (fd < 0) + ret = -1; else { - strcpy(pathx, path); - strcat(pathx, "x"); + ret = fstat(fd, buf); + close(fd); } - if ((ret = _syscall(sysnum, pathx, &nb)) == -1) - return(-1); - else { - buf->st_size = getmodsize(buf->st_size, - sizeof(struct compat_utmp), sizeof(struct utmpx)); + return(ret); + } + if (strcmp(path, "/etc/utmp") == 0 || + strcmp(path, "/var/adm/utmp") == 0) { + if ((ret = _syscall(sysnum, "/var/adm/utmpx", &nb)) != -1) { cpstatbuf(buf, &nb); - return(ret); + buf->st_size = getmodsize(buf->st_size, + sizeof(struct utmpx), sizeof(struct compat_utmp)); } - } else if (_strstr(path, "/lib/locale/") != 0) { - fd = open(path, O_RDONLY); - ret = fstat(fd, buf); - close(fd); return(ret); - } else { - if ((ret = _syscall(sysnum, path, &nb)) != -1) + } + if (strcmp(path, "/var/adm/wtmp") == 0) { + if ((ret = _syscall(sysnum, "/var/adm/wtmpx", &nb)) != -1) { cpstatbuf(buf, &nb); + buf->st_size = getmodsize(buf->st_size, + sizeof(struct utmpx), sizeof(struct compat_utmp)); + } + return(ret); + } + if (_strstr(path, "/lib/locale/") != 0) { + fd = open(path, O_RDONLY); + if (fd < 0) + ret = -1; + else { + ret = fstat(fd, buf); + close(fd); + } return(ret); } + + if ((ret = _syscall(sysnum, path, &nb)) != -1) + cpstatbuf(buf, &nb); + return(ret); } diff --git a/usr/src/lib/libbc/libc/sys/common/close.c b/usr/src/lib/libbc/libc/sys/common/close.c index 2cdc0b74ba..ed9a5ae703 100644 --- a/usr/src/lib/libbc/libc/sys/common/close.c +++ b/usr/src/lib/libbc/libc/sys/common/close.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,24 +18,25 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> int close(int fd) { - return(bc_close(fd)); + return (bc_close(fd)); } int bc_close(int fd) { fd_rem(fd); - return(_syscall(SYS_close, fd)); -} + return (_syscall(SYS_close, fd)); +} diff --git a/usr/src/lib/libbc/libc/sys/common/dup.c b/usr/src/lib/libbc/libc/sys/common/dup.c index 57403687af..3445f278b2 100644 --- a/usr/src/lib/libbc/libc/sys/common/dup.c +++ b/usr/src/lib/libbc/libc/sys/common/dup.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,26 +18,26 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> - +#include <sys/syscall.h> -int dup(fd) -int fd; +int +dup(int fd) { int ret, fds; if ((ret = _syscall(SYS_dup, fd)) == -1) - return(-1); + return (-1); - if ((fds = fd_get(fd)) != -1) + if ((fds = fd_get(fd)) != -1) fd_add(ret, fds); - return(ret); + return (ret); } diff --git a/usr/src/lib/libbc/libc/sys/common/dup2.c b/usr/src/lib/libbc/libc/sys/common/dup2.c index 1c78240bc6..8a314ecd91 100644 --- a/usr/src/lib/libbc/libc/sys/common/dup2.c +++ b/usr/src/lib/libbc/libc/sys/common/dup2.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 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -28,52 +28,51 @@ #include <fcntl.h> #include <unistd.h> -#include <syscall.h> -#include <sys/errno.h> +#include <sys/syscall.h> +#include <errno.h> -#define OPEN_MAX 20 /* Taken from SVR4 limits.h */ +#define OPEN_MAX 20 /* Taken from SVR4 limits.h */ -int dup2(fildes, fildes2) -int fildes, /* file descriptor to be duplicated */ - fildes2; /* desired file descriptor */ +int +dup2( + int fildes, /* file descriptor to be duplicated */ + int fildes2) /* desired file descriptor */ { - int tmperrno; /* local work area */ - register int open_max; /* max open files */ - extern int errno; /* system error indicator */ - int ret; /* return value */ - int fds; /* duplicate files descriptor */ - - if ((open_max = ulimit(4, 0)) < 0) - open_max = OPEN_MAX; /* take a guess */ + int tmperrno; /* local work area */ + int open_max; /* max open files */ + int ret; /* return value */ + int fds; /* duplicate files descriptor */ - /* Be sure fildes is valid and open */ - if (fcntl(fildes, F_GETFL, 0) == -1) { - errno = EBADF; - return (-1); - } + if ((open_max = ulimit(4, 0)) < 0) + open_max = OPEN_MAX; /* take a guess */ - /* Be sure fildes2 is in valid range */ - if (fildes2 < 0 || fildes2 >= open_max) { - errno = EBADF; - return (-1); - } + /* Be sure fildes is valid and open */ + if (fcntl(fildes, F_GETFL, 0) == -1) { + errno = EBADF; + return (-1); + } - /* Check if file descriptors are equal */ - if (fildes == fildes2) { - /* open and equal so no dup necessary */ - return (fildes2); - } - /* Close in case it was open for another file */ - /* Must save and restore errno in case file was not open */ - tmperrno = errno; - close(fildes2); - errno = tmperrno; + /* Be sure fildes2 is in valid range */ + if (fildes2 < 0 || fildes2 >= open_max) { + errno = EBADF; + return (-1); + } - /* Do the dup */ - if ((ret = fcntl(fildes, F_DUPFD, fildes2)) != -1) { - if ((fds = fd_get(fildes)) != -1) - fd_add(fildes2, fds); - } - return(ret); + /* Check if file descriptors are equal */ + if (fildes == fildes2) { + /* open and equal so no dup necessary */ + return (fildes2); + } + /* Close in case it was open for another file */ + /* Must save and restore errno in case file was not open */ + tmperrno = errno; + close(fildes2); + errno = tmperrno; + /* Do the dup */ + if ((ret = fcntl(fildes, F_DUPFD, fildes2)) != -1) { + if ((fds = fd_get(fildes)) != -1) + fd_add(fildes2, fds); + } + return (ret); } diff --git a/usr/src/lib/libbc/libc/sys/common/fsync.c b/usr/src/lib/libbc/libc/sys/common/fsync.c index 97a0bcaa1a..7b94aee592 100644 --- a/usr/src/lib/libbc/libc/sys/common/fsync.c +++ b/usr/src/lib/libbc/libc/sys/common/fsync.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,22 +18,20 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> +#define FSYNC 0x10 /* Solaris definition, not SunOS4.x */ int fsync(int fd) { - int ret; - - if ((ret = _syscall(SYS_fsync, fd)) == -1) - return (-1); - return (ret); + return (_syscall(SYS_fdsync, fd, FSYNC)); } diff --git a/usr/src/lib/libbc/libc/sys/common/ftruncate.c b/usr/src/lib/libbc/libc/sys/common/ftruncate.c index ab66775508..6ebdcdb8ed 100644 --- a/usr/src/lib/libbc/libc/sys/common/ftruncate.c +++ b/usr/src/lib/libbc/libc/sys/common/ftruncate.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,20 +18,21 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> #include <sys/types.h> /* The following are from SVR4 sys/fcntl.h */ -#define F_FREESP 11 /* Free file space */ -#define F_WRLCK 02 /* Write Lock */ +#define F_FREESP 11 /* Free file space */ +#define F_WRLCK 02 /* Write Lock */ /* lock structure from SVR4. */ struct fl { @@ -45,18 +45,19 @@ struct fl { long pad[4]; }; -int ftruncate(int fd, off_t length) +int +ftruncate(int fd, off_t length) { struct fl lck; lck.l_whence = 0; /* offset l_start from beginning of file */ - lck.l_start = length; + lck.l_start = length; lck.l_type = F_WRLCK; /* setting a write lock */ lck.l_len = 0L; if (_syscall(SYS_fcntl, fd, F_FREESP, (int)&lck) == -1) return (-1); - else + else return (0); -} +} diff --git a/usr/src/lib/libbc/libc/sys/common/lseek.c b/usr/src/lib/libbc/libc/sys/common/lseek.c index 9476093725..17bbd92c1c 100644 --- a/usr/src/lib/libbc/libc/sys/common/lseek.c +++ b/usr/src/lib/libbc/libc/sys/common/lseek.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,22 +18,22 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" #include "compat.h" #include <errno.h> -#include <syscall.h> +#include <sys/syscall.h> #include <sys/types.h> #include <unistd.h> -extern int errno; - -off_t lseek(int fd, off_t offset, int whence) +off_t +lseek(int fd, off_t offset, int whence) { int off, ret; @@ -43,15 +42,13 @@ off_t lseek(int fd, off_t offset, int whence) return (-1); } if (fd_get(fd) != -1) { - off = getmodsize(offset, sizeof(struct utmpx), - sizeof(struct compat_utmp)); - if ((ret = _syscall(SYS_lseek, fd, off, whence)) == -1) - return(-1); - - ret = getmodsize(ret, sizeof(struct compat_utmp), - sizeof(struct utmpx)); + off = getmodsize(offset, sizeof (struct compat_utmp), + sizeof (struct utmpx)); + if ((ret = _syscall(SYS_lseek, fd, off, whence)) != -1) + ret = getmodsize(ret, sizeof (struct utmpx), + sizeof (struct compat_utmp)); return (ret); - } - else + } else { return (_syscall(SYS_lseek, fd, offset, whence)); + } } diff --git a/usr/src/lib/libbc/libc/sys/common/mincore.c b/usr/src/lib/libbc/libc/sys/common/mincore.c index e35bbd71d3..61cacd144c 100644 --- a/usr/src/lib/libbc/libc/sys/common/mincore.c +++ b/usr/src/lib/libbc/libc/sys/common/mincore.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 1991 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -28,28 +28,25 @@ /* mincore.c SMI 12/14/90 */ #include <errno.h> -#include <syscall.h> +#include <sys/syscall.h> #include <sys/types.h> #include <unistd.h> -#define INCORE 1; /* return only the incore status bit */ - -extern int errno; +#define INCORE 1; /* return only the incore status bit */ -int mincore(addr, len, vec) -caddr_t addr; -int len; -char *vec; +int +mincore(caddr_t addr, int len, char *vec) { int i; - if (len <0) { + if (len < 0) { errno = EINVAL; - return(-1); + return (-1); } - - if(_syscall(SYS_mincore, addr, len, vec) == 0) { - for (i=0; i< len/getpagesize(); i++) { + + if (_syscall(SYS_mincore, addr, len, vec) == 0) { + len /= getpagesize(); + for (i = 0; i < len; i++) { vec[i] &= INCORE; } } diff --git a/usr/src/lib/libbc/libc/sys/common/msgsys.c b/usr/src/lib/libbc/libc/sys/common/msgsys.c index 0b56312e00..de9f1c5f18 100644 --- a/usr/src/lib/libbc/libc/sys/common/msgsys.c +++ b/usr/src/lib/libbc/libc/sys/common/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,21 +18,22 @@ * * CDDL HEADER END */ + /* - * Copyright 1993 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ +/* Copyright (c) 1984 AT&T */ +/* All Rights Reserved */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/ipc.h> -#include <sys/msg.h> +#include <sys/syscall.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/msg.h> /* msgsys dispatch argument */ @@ -57,13 +57,15 @@ msgctl(int msqid, int cmd, struct msqid_ds *buf) int msgrcv(int msqid, struct msgbuf *msgp, int msgsz, long msgtyp, int msgflg) { - return (_syscall(SYS_msgsys, MSGRCV, msqid, msgp, msgsz, msgtyp, msgflg)); + return (_syscall(SYS_msgsys, MSGRCV, + msqid, msgp, msgsz, msgtyp, msgflg)); } int msgsnd(int msqid, struct msgbuf *msgp, int msgsz, int msgflg) { - return (_syscall(SYS_msgsys, MSGSND, msqid, msgp, msgsz, msgflg)); + return (_syscall(SYS_msgsys, MSGSND, + msqid, msgp, msgsz, msgflg)); } int @@ -79,33 +81,32 @@ msgsys(int sysnum, ...) int msgsz; long msgtyp; - va_start(ap, sysnum); switch (sysnum) { case MSGGET: - key=va_arg(ap, key_t); - msgflag=va_arg(ap, int); + key = va_arg(ap, key_t); + msgflag = va_arg(ap, int); va_end(ap); return (msgget(key, msgflag)); case MSGCTL: - msqid=va_arg(ap, int); - cmd=va_arg(ap, int); - buf=va_arg(ap, struct msqid_ds *); + msqid = va_arg(ap, int); + cmd = va_arg(ap, int); + buf = va_arg(ap, struct msqid_ds *); va_end(ap); return (msgctl(msqid, cmd, buf)); case MSGRCV: - msqid=va_arg(ap, int); - msgp=va_arg(ap, struct msgbuf *); - msgsz=va_arg(ap, int); - msgtyp=va_arg(ap, long); - msgflg=va_arg(ap, int); + msqid = va_arg(ap, int); + msgp = va_arg(ap, struct msgbuf *); + msgsz = va_arg(ap, int); + msgtyp = va_arg(ap, long); + msgflg = va_arg(ap, int); va_end(ap); return (msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)); case MSGSND: - msqid=va_arg(ap, int); - msgp=va_arg(ap, struct msgbuf *); - msgsz=va_arg(ap, int); - msgflg=va_arg(ap, int); + msqid = va_arg(ap, int); + msgp = va_arg(ap, struct msgbuf *); + msgsz = va_arg(ap, int); + msgflg = va_arg(ap, int); va_end(ap); return (msgsnd(msqid, msgp, msgsz, msgflg)); } diff --git a/usr/src/lib/libbc/libc/sys/common/semsys.c b/usr/src/lib/libbc/libc/sys/common/semsys.c index 5f7f79a958..5b3a4d84df 100644 --- a/usr/src/lib/libbc/libc/sys/common/semsys.c +++ b/usr/src/lib/libbc/libc/sys/common/semsys.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,26 +18,27 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ +/* Copyright (c) 1984 AT&T */ +/* All Rights Reserved */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/ipc.h> -#include <sys/sem.h> +#include <sys/syscall.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/sem.h> /* semsys dispatch argument */ -#define SEMCTL 0 -#define SEMGET 1 -#define SEMOP 2 +#define SEMCTL 0 +#define SEMGET 1 +#define SEMOP 2 int semctl(int semid, int semnum, int cmd, union semun *arg) @@ -52,13 +52,15 @@ semctl(int semid, int semnum, int cmd, union semun *arg) case SETVAL: case GETALL: case SETALL: - return (_syscall(SYS_semsys,SEMCTL,semid,semnum,cmd,arg->val)); + return (_syscall(SYS_semsys, SEMCTL, + semid, semnum, cmd, arg->val)); case IPC_RMID: cmd += 10; /* fall-through */ default: - return (_syscall(SYS_semsys,SEMCTL,semid,semnum,cmd,0)); + return (_syscall(SYS_semsys, SEMCTL, + semid, semnum, cmd, 0)); } } @@ -89,24 +91,24 @@ semsys(int sysnum, ...) va_start(ap, sysnum); switch (sysnum) { case SEMCTL: - semid=va_arg(ap, int); - semnum=va_arg(ap, int); - cmd=va_arg(ap, int); - val=va_arg(ap, int); + semid = va_arg(ap, int); + semnum = va_arg(ap, int); + cmd = va_arg(ap, int); + val = va_arg(ap, int); if ((cmd == IPC_STAT) || (cmd == IPC_SET) || (cmd == IPC_RMID)) cmd += 10; va_end(ap); return (_syscall(SYS_semsys, SEMCTL, semid, semnum, cmd, val)); case SEMGET: - key=va_arg(ap, key_t); - nsems=va_arg(ap, int); - semflg=va_arg(ap, int); + key = va_arg(ap, key_t); + nsems = va_arg(ap, int); + semflg = va_arg(ap, int); va_end(ap); return (semget(key, nsems, semflg)); case SEMOP: - semid=va_arg(ap, int); - sops=va_arg(ap, struct sembuf *); - nsops=va_arg(ap, int); + semid = va_arg(ap, int); + sops = va_arg(ap, struct sembuf *); + nsops = va_arg(ap, int); va_end(ap); return (semop(semid, sops, nsops)); } diff --git a/usr/src/lib/libbc/libc/sys/common/shmsys.c b/usr/src/lib/libbc/libc/sys/common/shmsys.c index 6d99c334e6..2ae18dbe30 100644 --- a/usr/src/lib/libbc/libc/sys/common/shmsys.c +++ b/usr/src/lib/libbc/libc/sys/common/shmsys.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,29 +18,30 @@ * * CDDL HEADER END */ + /* - * Copyright 1991 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ +/* Copyright (c) 1984 AT&T */ +/* All Rights Reserved */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/ipc.h> -#include <sys/shm.h> -#include <errno.h> +#include <sys/syscall.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <errno.h> /* shmsys dispatch argument */ #define SHMAT 0 #define SHMCTL 1 #define SHMDT 2 -#define SHMGET 3 +#define SHMGET 3 struct shmid_sv { struct ipc_perm shm_perm; @@ -57,7 +57,7 @@ struct shmid_sv { time_t shm_dtime; time_t shm_ctime; }; - + char * shmat(int shmid, char *shmaddr, int shmflg) @@ -110,7 +110,6 @@ shmctl(int shmid, int cmd, struct shmid_ds *buf) int shmdt(char *shmaddr) { - return (_syscall(SYS_shmsys, SHMDT, shmaddr)); } @@ -123,7 +122,7 @@ shmget(key_t key, int size, int shmflg) int shmsys(int sysnum, ...) { - va_list ap; + va_list ap; int shmid, shmflg, cmd, size; char *shmaddr; struct shmid_ds *buf; @@ -132,27 +131,27 @@ shmsys(int sysnum, ...) va_start(ap, sysnum); switch (sysnum) { case SHMAT: - shmid=va_arg(ap, int); - shmaddr=va_arg(ap, char *); - shmflg=va_arg(ap, int); - va_end(ap); - return ((int)shmat(shmid, shmaddr, shmflg)); + shmid = va_arg(ap, int); + shmaddr = va_arg(ap, char *); + shmflg = va_arg(ap, int); + va_end(ap); + return ((int)shmat(shmid, shmaddr, shmflg)); case SHMCTL: - shmid=va_arg(ap, int); - cmd=va_arg(ap, int); - buf=va_arg(ap, struct shmid_ds *); - va_end(ap); - return (shmctl(shmid, cmd, buf)); + shmid = va_arg(ap, int); + cmd = va_arg(ap, int); + buf = va_arg(ap, struct shmid_ds *); + va_end(ap); + return (shmctl(shmid, cmd, buf)); case SHMDT: - shmaddr=va_arg(ap, char *); - va_end(ap); - return (shmdt(shmaddr)); + shmaddr = va_arg(ap, char *); + va_end(ap); + return (shmdt(shmaddr)); case SHMGET: - key=va_arg(ap, key_t); - size=va_arg(ap, int); - shmflg=va_arg(ap, int); - va_end(ap); - return (shmget(key, size, shmflg)); + key = va_arg(ap, key_t); + size = va_arg(ap, int); + shmflg = va_arg(ap, int); + va_end(ap); + return (shmget(key, size, shmflg)); } va_end(ap); return (-1); diff --git a/usr/src/lib/libbc/libc/sys/common/syscall.c b/usr/src/lib/libbc/libc/sys/common/syscall.c index e81069a2fd..f5ebad51de 100644 --- a/usr/src/lib/libbc/libc/sys/common/syscall.c +++ b/usr/src/lib/libbc/libc/sys/common/syscall.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 1995 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -32,19 +32,19 @@ #include <sys/syscall.h> #include "xsyscall.h" -/* +/* * Array of SVR4 system call numbers. The 4.1 numbers are mapped * to their SVR4/5.0 equivalents before trapping into the kernel. */ -int syscallnum[190] = { SYS_syscall, SYS_exit, SYS_fork, +int syscallnum[190] = { SYS_syscall, SYS_exit, SYS_fork1, SYS_read, SYS_write, SYS_open, SYS_close, -1, SYS_creat, SYS_link, SYS_unlink, -1, SYS_chdir, 0, SYS_mknod, SYS_chmod, SYS_lchown, 0, 0, SYS_lseek, SYS_getpid, 0, 0, - 0, SYS_getuid, 0, SYS_ptrace, - 0, 0, 0, 0, + 0, SYS_getuid, 0, 0, + 0, 0, 0, 0, 0, 0, SYS_access, 0, 0, SYS_sync, SYS_kill, SYS_stat, 0, SYS_lstat, SYS_dup, SYS_pipe, @@ -52,7 +52,7 @@ int syscallnum[190] = { SYS_syscall, SYS_exit, SYS_fork, SYS_getgid, 0, 0, 0, SYS_acct, 0, -1, SYS_ioctl, -1 /*reboot*/, 0, SYS_symlink, SYS_readlink, - SYS_execve, SYS_umask, SYS_chroot, SYS_fstat, + SYS_execve, SYS_umask, SYS_chroot, SYS_fstat, 0, -1/*getpagesize*/,-1, 0, 0, 0, -1, -1, SYS_mmap, -1, SYS_munmap, SYS_mprotect, @@ -61,9 +61,9 @@ int syscallnum[190] = { SYS_syscall, SYS_exit, SYS_fork, SYS_setitimer, 0, -1 /*swapon*/, SYS_getitimer, -1/*gethostname*/,-1/*sethostname*/,-1/*getdtablesize*/,-1/*dup2*/, -1/*getdopt*/, SYS_fcntl, -1 /*select*/, -1 /*setdopt*/, - SYS_fsync, -1 /*setprio*/, -1 /*socket*/, -1 /*connect*/, + SYS_fdsync, -1 /*setprio*/, -1 /*socket*/, -1 /*connect*/, -1 /*accept*/, -1 /*getprio*/, -1 /*send*/, -1 /*recv*/, - 0, -1 /*bind*/, -1 /*setsockopt*/,-1 /*listen*/, + 0, -1 /*bind*/, -1 /*setsockopt*/,-1 /*listen*/, 0, -1 /*sigvec*/, -1 /*sigblock*/, -1 /*sigsetmask*/, -1 /*sigpause*/, -1 /*sigstack*/, -1 /*recvmsg*/, -1 /*sendmsg*/, -1 /*vtrace*/, SYS_gettimeofday, -1 /*getrusage*/, -1 /*getsockopt*/, @@ -72,7 +72,7 @@ int syscallnum[190] = { SYS_syscall, SYS_exit, SYS_fork, -1 /*getregid*/, SYS_rename, -1 /*truncate*/, -1 /*ftruncate*/, -1 /*flock*/, 0, -1 /*sendto*/, -1 /*shutdown*/, -1 /*socketpair*/,SYS_mkdir, SYS_rmdir, SYS_utimes, - 0, SYS_adjtime, -1 /*getpeername*/,-1 /*gethostid*/, + 0, SYS_adjtime, -1 /*getpeername*/,-1 /*gethostid*/, 0, SYS_getrlimit, SYS_setrlimit, -1 /*killpg*/, 0, 0, 0, -1/*getsockname*/, SYS_getmsg, SYS_putmsg, SYS_poll, 0, @@ -82,9 +82,9 @@ int syscallnum[190] = { SYS_syscall, SYS_exit, SYS_fork, SYS_mount, -1/*ustat*/, SYS_semsys, SYS_msgsys, SYS_shmsys, -1 /*auditsys*/, -1 /*rfsys*/, SYS_getdents, -1 /*setsid*/, SYS_fchdir, SYS_fchroot, -1 /*vpixsys*/, - -1 /*aioread*/, -1 /*aiowrite*/, -1 /*aiocancel*/, SYS_sigpending, + -1 /*aioread*/, -1 /*aiowrite*/, -1 /*aiocancel*/, SYS_sigpending, 0, -1 /*setpgid*/, SYS_pathconf, SYS_uname, -}; +}; int syscall(int sysnum, ...) @@ -96,7 +96,7 @@ syscall(int sysnum, ...) va_start(ap, sysnum); switch(sysnum) { - case XSYS_read: + case XSYS_read: i1 = va_arg(ap, int); c1 = va_arg(ap, char *); i2 = va_arg(ap, int); @@ -108,7 +108,7 @@ syscall(int sysnum, ...) i2 = va_arg(ap, int); va_end(ap); return (bc_write(i1, c1, i2)); - case XSYS_readv: + case XSYS_readv: i1 = va_arg(ap, int); c1 = va_arg(ap, char *); i2 = va_arg(ap, int); @@ -120,7 +120,7 @@ syscall(int sysnum, ...) i2 = va_arg(ap, int); va_end(ap); return (bc_writev(i1, c1, i2)); - case XSYS_open: + case XSYS_open: c1 = va_arg(ap, char *); i1 = va_arg(ap, int); i2 = va_arg(ap, int); @@ -129,7 +129,7 @@ syscall(int sysnum, ...) return (bc_open(c1, i1, i2)); else return (bc_open(c1, i1)); - case XSYS_close: + case XSYS_close: i1 = va_arg(ap, int); va_end(ap); return (bc_close(i1)); @@ -147,13 +147,13 @@ syscall(int sysnum, ...) c4 = va_arg(ap, char *); va_end(ap); return (_select(i1, c1, c2, c3, c4)); - case XSYS_ioctl : + case XSYS_ioctl : i1 = va_arg(ap, int); i2 = va_arg(ap, int); c1 = va_arg(ap, char *); va_end(ap); return (bc_ioctl(i1, i2, c1)); - case XSYS_stat: + case XSYS_stat: c1 = va_arg(ap, char *); c2 = va_arg(ap, char *); va_end(ap); @@ -163,23 +163,23 @@ syscall(int sysnum, ...) c2 = va_arg(ap, char *); va_end(ap); return (bc_lstat(c1, c2)); - case XSYS_fstat: + case XSYS_fstat: i1 = va_arg(ap, int); c1 = va_arg(ap, char *); va_end(ap); return (bc_fstat(i1, c1)); - case XSYS_getdents: + case XSYS_getdents: i1 = va_arg(ap, int); c1 = va_arg(ap, char *); i2 = va_arg(ap, int); va_end(ap); return (bc_getdents(i1, c1, i2)); - case XSYS_kill: + case XSYS_kill: i1 = va_arg(ap, int); i2 = va_arg(ap, int); va_end(ap); return (bc_kill(i1, i2)); - case XSYS_mount: + case XSYS_mount: c1 = va_arg(ap, char *); c2 = va_arg(ap, char *); i1 = va_arg(ap, int); @@ -191,7 +191,7 @@ syscall(int sysnum, ...) c1 = va_arg(ap, char *); va_end(ap); return (bc_getrlimit(i1, c1)); - case XSYS_setrlimit: + case XSYS_setrlimit: i1 = va_arg(ap, int); c1 = va_arg(ap, char *); va_end(ap); @@ -200,21 +200,21 @@ syscall(int sysnum, ...) c1 = va_arg(ap, char *); va_end(ap); return (bc_uname(c1)); - case XSYS_creat: + case XSYS_creat: c1 = va_arg(ap, char *); i1 = va_arg(ap, int); va_end(ap); return (creat(c1, i1)); - case XSYS_unmount: + case XSYS_unmount: c1 = va_arg(ap, char *); va_end(ap); return (umount(c1)); - case XSYS_link: + case XSYS_link: c1 = va_arg(ap, char *); c2 = va_arg(ap, char *); va_end(ap); return (link(c1, c2)); - case XSYS_unlink: + case XSYS_unlink: c1 = va_arg(ap, char *); va_end(ap); return (unlink(c1)); @@ -222,35 +222,35 @@ syscall(int sysnum, ...) c1 = va_arg(ap, char *); va_end(ap); return (chdir(c1)); - case XSYS_mknod: + case XSYS_mknod: c1 = va_arg(ap, char *); i1 = va_arg(ap, int); i2 = va_arg(ap, int); va_end(ap); return (mknod(c1, i1, i2)); - case XSYS_chmod: + case XSYS_chmod: c1 = va_arg(ap, char *); i1 = va_arg(ap, int); va_end(ap); return (chmod(c1, i1)); - case XSYS_chown: + case XSYS_chown: c1 = va_arg(ap, char *); i1 = va_arg(ap, int); i2 = va_arg(ap, int); va_end(ap); return (chown(c1, i1, i2)); - case XSYS_lseek: + case XSYS_lseek: i1 = va_arg(ap, int); i2 = va_arg(ap, int); i3 = va_arg(ap, int); va_end(ap); return (lseek(i1, i2, i3)); - case XSYS_access: + case XSYS_access: c1 = va_arg(ap, char *); i1 = va_arg(ap, int); va_end(ap); return (access(c1, i1)); - case XSYS_dup: + case XSYS_dup: i1 = va_arg(ap, int); va_end(ap); return (dup(i1)); @@ -259,42 +259,42 @@ syscall(int sysnum, ...) i2 = va_arg(ap, int); va_end(ap); return (dup(i1, i2)); - case XSYS_pipe: + case XSYS_pipe: c1 = (char *)va_arg(ap, int *); va_end(ap); return (pipe(c1)); - case XSYS_symlink: + case XSYS_symlink: c1 = va_arg(ap, char *); c2 = va_arg(ap, char *); va_end(ap); return (symlink(c1, c2)); - case XSYS_readlink: + case XSYS_readlink: c1 = va_arg(ap, char *); c2 = va_arg(ap, char *); i1 = va_arg(ap, int); va_end(ap); return (readlink(c1, c2, i1)); - case XSYS_execve: + case XSYS_execve: c1 = va_arg(ap, char *); c2 = (char *)va_arg(ap, char **); c3 = (char *)va_arg(ap, char **); va_end(ap); return (execve(c1, c2, c3)); - case XSYS_chroot: + case XSYS_chroot: c1 = va_arg(ap, char *); va_end(ap); return (chroot(c1)); - case XSYS_getgroups: + case XSYS_getgroups: i1 = va_arg(ap, int); c1 = (char *)va_arg(ap, int *); va_end(ap); return (getgroups(i1, c1)); - case XSYS_setgroups: + case XSYS_setgroups: i1 = va_arg(ap, int); c1 = (char *)va_arg(ap, int *); va_end(ap); return (setgroups(i1, c1)); - case XSYS_fsync: + case XSYS_fsync: i1 = va_arg(ap, int); va_end(ap); return (fsync(i1)); @@ -308,26 +308,26 @@ syscall(int sysnum, ...) c2 = va_arg(ap, char *); va_end(ap); return (settimeofday(c1, c2)); - case XSYS_rename: + case XSYS_rename: c1 = va_arg(ap, char *); c2 = va_arg(ap, char *); va_end(ap); return (rename(c1, c2)); - case XSYS_mkdir: + case XSYS_mkdir: c1 = va_arg(ap, char *); i1 = va_arg(ap, int); va_end(ap); return (mkdir(c1, i1)); - case XSYS_rmdir: + case XSYS_rmdir: c1 = va_arg(ap, char *); va_end(ap); return (rmdir(c1)); - case XSYS_statfs: + case XSYS_statfs: c1 = va_arg(ap, char *); c2 = va_arg(ap, char *); va_end(ap); return (statfs(c1, c2)); - case XSYS_fstatfs: + case XSYS_fstatfs: i1 = va_arg(ap, int); c1 = va_arg(ap, char *); va_end(ap); @@ -341,7 +341,7 @@ syscall(int sysnum, ...) case XSYS_getdtablesize: va_end(ap); return (getdtablesize()); - case XSYS_pathconf: + case XSYS_pathconf: c1 = va_arg(ap, char *); i1 = va_arg(ap, int); va_end(ap); @@ -356,22 +356,22 @@ syscall(int sysnum, ...) i1 = va_arg(ap, int); va_end(ap); return (sethostname(c1, i1)); - case XSYS_setreuid: + case XSYS_setreuid: i1 = va_arg(ap, int); i2 = va_arg(ap, int); va_end(ap); return (setreuid(i1, i2)); - case XSYS_setregid: + case XSYS_setregid: i1 = va_arg(ap, int); i2 = va_arg(ap, int); va_end(ap); return (setregid(i1, i2)); - case XSYS_getpriority: + case XSYS_getpriority: i1 = va_arg(ap, int); i2 = va_arg(ap, int); va_end(ap); return (getpriority(i1, i2)); - case XSYS_setpriority: + case XSYS_setpriority: i1 = va_arg(ap, int); i2 = va_arg(ap, int); i3 = va_arg(ap, int); @@ -424,7 +424,7 @@ syscall(int sysnum, ...) i2 = va_arg(ap, int); va_end(ap); return (setpgid(i1, i2)); - case XSYS_ptrace: + case XSYS_ptrace: i1 = va_arg(ap, int); i2 = va_arg(ap, int); i3 = va_arg(ap, int); @@ -432,7 +432,7 @@ syscall(int sysnum, ...) i4 = va_arg(ap, int); c2 = va_arg(ap, char *); va_end(ap); - return (ptrace(i1, i2, i3, c1, i4, c2)); + return (ptrace(i1, i2, i3, c1, i4, c2)); #ifdef S5EMUL case XSYS_getpgrp: va_end(ap); @@ -465,7 +465,7 @@ syscall(int sysnum, ...) i2 = va_arg(ap, int); va_end(ap); return (flock(i1, i2)); - + /* the following system calls are now implemented in * libsocket */ case XSYS_accept: @@ -595,32 +595,32 @@ syscall(int sysnum, ...) /* The following can directly go through syscall */ case XSYS_acct: - case XSYS_adjtime: - case XSYS_exit: - case XSYS_fchdir: - case XSYS_fchmod: - case XSYS_fchown: + case XSYS_adjtime: + case XSYS_exit: + case XSYS_fchdir: + case XSYS_fchmod: + case XSYS_fchown: case XSYS_fchroot: - case XSYS_fork: - case XSYS_getgid: + case XSYS_fork: + case XSYS_getgid: case XSYS_getitimer: case XSYS_getmsg: - case XSYS_getpid: - case XSYS_getuid: - case XSYS_mincore: - case XSYS_mprotect: - case XSYS_munmap: - case XSYS_putmsg: - case XSYS_poll: - case XSYS_profil: + case XSYS_getpid: + case XSYS_getuid: + case XSYS_mincore: + case XSYS_mprotect: + case XSYS_munmap: + case XSYS_putmsg: + case XSYS_poll: + case XSYS_profil: case XSYS_setitimer: - case XSYS_sync: - case XSYS_umask: + case XSYS_sync: + case XSYS_umask: case XSYS_utimes: case XSYS_semsys: - case XSYS_msgsys: - case XSYS_shmsys: - case XSYS_mmap: + case XSYS_msgsys: + case XSYS_shmsys: + case XSYS_mmap: case XSYS_vhangup: ret_val = _syscall(syscallnum[sysnum], ap); va_end(ap); @@ -631,13 +631,13 @@ syscall(int sysnum, ...) case XSYS_aiocancel: case XSYS_swapon: case XSYS_async_daemon: - case XSYS_getfh: + case XSYS_getfh: case XSYS_nfssvc: - case XSYS_exportfs: - case XSYS_auditsys: - case XSYS_vpixsys: + case XSYS_exportfs: + case XSYS_auditsys: + case XSYS_vpixsys: case XSYS_quotactl: - case XSYS_getdopt: + case XSYS_getdopt: case XSYS_setdopt: case XSYS_ustat: case XSYS_vtrace: diff --git a/usr/src/lib/libbc/libc/sys/sys5/access.c b/usr/src/lib/libbc/libc/sys/sys5/access.c index 54fcbf170c..7354450bd1 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/access.c +++ b/usr/src/lib/libbc/libc/sys/sys5/access.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,21 +18,20 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> #include <unistd.h> #include <sys/param.h> -int access(path, mode) -char *path; -int mode; +int +access(char *path, int mode) { - return(access_com(path, mode)); + return (access_com(path, mode)); } - diff --git a/usr/src/lib/libbc/libc/sys/sys5/read.c b/usr/src/lib/libbc/libc/sys/sys5/read.c index 35262a4f34..a52f3f3cae 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/read.c +++ b/usr/src/lib/libbc/libc/sys/sys5/read.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,9 +18,10 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -30,11 +30,11 @@ #include <stdio.h> #include <sys/types.h> #include <unistd.h> -#include <syscall.h> +#include <sys/syscall.h> /* * If reading from the utmp file, map the data to the SunOS 4.1 - * format on the fly. + * format on the fly. */ extern void to_utmp(char *, char *, int); @@ -50,16 +50,16 @@ bc_read(int fd, char *buf, int size) { int ret, off; char *nbuf; - + if (fd_get(fd) != -1) { /* we're reading utmp (utmpx, really) */ - size = getmodsize(size, sizeof (struct compat_utmp), + size = getmodsize(size, sizeof (struct compat_utmp), sizeof (struct utmpx)); if ((nbuf = (void *)malloc(size)) == NULL) { (void) fprintf(stderr, "read: malloc failed\n"); exit(-1); } - + if ((ret = _read(fd, nbuf, size)) == -1) { free(nbuf); return (-1); @@ -67,7 +67,7 @@ bc_read(int fd, char *buf, int size) to_utmp(buf, nbuf, ret); - ret = getmodsize(ret, sizeof (struct utmpx), + ret = getmodsize(ret, sizeof (struct utmpx), sizeof (struct compat_utmp)); free(nbuf); return (ret); @@ -82,15 +82,15 @@ to_utmp(char *buf, char *nbuf, int len) struct compat_utmp *ut; struct utmpx *utx; - utx = (struct utmpx *) nbuf; - ut = (struct compat_utmp *) buf; + utx = (struct utmpx *)nbuf; + ut = (struct compat_utmp *)buf; while ((char *)utx < (nbuf + len)) { (void) strncpy(ut->ut_line, utx->ut_line, sizeof (ut->ut_line)); - (void) strncpy(ut->ut_name, utx->ut_user, sizeof (ut->ut_name)); - (void) strncpy(ut->ut_host, utx->ut_host, sizeof (ut->ut_host)); - ut->ut_time = utx->ut_tv.tv_sec; - utx++; - ut++; - } + (void) strncpy(ut->ut_name, utx->ut_user, sizeof (ut->ut_name)); + (void) strncpy(ut->ut_host, utx->ut_host, sizeof (ut->ut_host)); + ut->ut_time = utx->ut_tv.tv_sec; + utx++; + ut++; + } } diff --git a/usr/src/lib/libbc/libc/sys/sys5/readv.c b/usr/src/lib/libbc/libc/sys/sys5/readv.c index eb203eb067..67323be984 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/readv.c +++ b/usr/src/lib/libbc/libc/sys/sys5/readv.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,9 +18,10 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -30,12 +30,12 @@ #include <stdio.h> #include <sys/types.h> #include <unistd.h> -#include <syscall.h> +#include <sys/syscall.h> #include <sys/uio.h> /* * If reading from the utmp file, map the data to the SunOS 4.1 - * format on the fly. + * format on the fly. */ extern void to_utmp(char *, char *, int); @@ -51,7 +51,7 @@ bc_readv(int fd, struct iovec *iov, int iovcnt) int ret, off; int i, size, total = 0; char *nbuf; - + if (fd_get(fd) != -1) { for (i = 0; i < iovcnt; i++) { size = getmodsize(iov[i].iov_len, @@ -62,18 +62,17 @@ bc_readv(int fd, struct iovec *iov, int iovcnt) fprintf(stderr, "readv: malloc failed\n"); exit(-1); } - + if ((ret = _read(fd, nbuf, size)) == -1) { free(nbuf); return (-1); } - total += ret; - to_utmp(iov[i].iov_base, nbuf, ret); - ret = getmodsize(ret, sizeof (struct utmpx), + ret = getmodsize(ret, sizeof (struct utmpx), sizeof (struct compat_utmp)); + total += ret; free(nbuf); } diff --git a/usr/src/lib/libbc/libc/sys/sys5/rename.c b/usr/src/lib/libbc/libc/sys/sys5/rename.c index b1d99b5fbb..79b975f975 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/rename.c +++ b/usr/src/lib/libbc/libc/sys/sys5/rename.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,35 +18,33 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> -int rename(path1, path2) -char *path1, *path2; +int +rename(char *path1, char *path2) { - int ret; - char buf1[256]; char buf2[256]; - if (strcmp(path1, "/var/adm/utmp") == 0 || - strcmp(path1, "/var/adm/wtmp") == 0 || - strcmp(path1, "/etc/utmp") == 0) { - if (strcmp(path1, "/etc/utmp") == 0 || - strcmp(path1, "/var/adm/utmp") == 0) - strcpy(path1, "/var/adm/utmpx"); - else - strcpy(path1, "/var/adm/wtmpx"); + if (strcmp(path1, "/etc/utmp") == 0 || + strcmp(path1, "/var/adm/utmp") == 0) { + path1 = "/var/adm/utmpx"; + strcpy(buf2, path2); + strcat(buf2, "x"); + path2 = buf2; + } else if (strcmp(path1, "/var/adm/wtmp") == 0) { + path1 = "/var/adm/wtmpx"; strcpy(buf2, path2); strcat(buf2, "x"); - ret = _syscall(SYS_rename, buf1, buf2); - } else - ret = _syscall(SYS_rename, path1, path2); + path2 = buf2; + } - return(ret); -} + return (_syscall(SYS_rename, path1, path2)); +} diff --git a/usr/src/lib/libbc/libc/sys/sys5/truncate.c b/usr/src/lib/libbc/libc/sys/sys5/truncate.c index 20d4e123e0..b322965d91 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/truncate.c +++ b/usr/src/lib/libbc/libc/sys/sys5/truncate.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,39 +18,37 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> #include <unistd.h> #include <errno.h> #include <sys/fcntl.h> #include <sys/param.h> -extern int errno; - -int truncate(path, length) -char *path; -off_t length; +int +truncate(char *path, off_t length) { - int fd, ret=0; + int fd, ret = 0; if (strcmp(path, "/etc/mtab") == 0 || strcmp(path, "/etc/fstab") == 0) { errno = ENOENT; - return(-1); + return (-1); } if ((fd = open(path, O_WRONLY)) == -1) { - return(-1); + return (-1); } - + if (ftruncate(fd, length) == -1) { close(fd); - return(-1); + return (-1); } close(fd); - return(0); + return (0); } diff --git a/usr/src/lib/libbc/libc/sys/sys5/unlink.c b/usr/src/lib/libbc/libc/sys/sys5/unlink.c index db378d4ccc..36dc087d9f 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/unlink.c +++ b/usr/src/lib/libbc/libc/sys/sys5/unlink.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,32 +18,24 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" -#include <syscall.h> +#include <sys/syscall.h> -int unlink(path) -char *path; +int +unlink(char *path) { - int ret; - char buf[256]; + if (strcmp(path, "/etc/utmp") == 0 || + strcmp(path, "/var/adm/utmp") == 0) + path = "/var/adm/utmpx"; + else if (strcmp(path, "/var/adm/wtmp") == 0) + path = "/var/adm/wtmpx"; - if (strcmp(path, "/var/adm/utmp") == 0 || - strcmp(path, "/var/adm/wtmp") == 0 || - strcmp(path, "/etc/utmp") == 0) { - if (strcmp(path, "/etc/utmp") == 0 || - strcmp(path, "/var/adm/utmp") == 0) - strcpy(buf, "/var/adm/utmpx"); - else - strcpy(buf, "/var/adm/wtmpx"); - ret = _syscall(SYS_unlink, buf); - } else - ret = _syscall(SYS_unlink, path); - - return(ret); -} + return (_syscall(SYS_unlink, path)); +} diff --git a/usr/src/lib/libbc/libc/sys/sys5/writev.c b/usr/src/lib/libbc/libc/sys/sys5/writev.c index fe9371ce58..a833f4e3a2 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/writev.c +++ b/usr/src/lib/libbc/libc/sys/sys5/writev.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,9 +18,10 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" @@ -51,7 +51,7 @@ bc_writev(int fd, struct iovec *iov, int iovcnt) int nsize, total = 0; char *nbuf; int i; - + if (fd_get(fd) != -1) { for (i = 0; i < iovcnt; i++) { nsize = getmodsize(iov[i].iov_len, @@ -62,7 +62,7 @@ bc_writev(int fd, struct iovec *iov, int iovcnt) fprintf(stderr, "writev: malloc failed\n"); exit(-1); } - + (void) memset(nbuf, 0, nsize); ret = conv2utmpx(nbuf, iov[i].iov_base, iov[i].iov_len); @@ -72,17 +72,13 @@ bc_writev(int fd, struct iovec *iov, int iovcnt) return (-1); } - total += ret; - free(nbuf); - - ret = getmodsize(ret, sizeof (struct utmpx), + + ret = getmodsize(ret, sizeof (struct utmpx), sizeof (struct compat_utmp)); + total += ret; } - total = getmodsize(total, sizeof (struct utmpx), - sizeof (struct compat_utmp)); return (total); - } return (_writev(fd, iov, iovcnt)); |