diff options
author | casper <none@none> | 2006-02-23 04:39:12 -0800 |
---|---|---|
committer | casper <none@none> | 2006-02-23 04:39:12 -0800 |
commit | 7c4dcc5546f9f002dfc2b95de47c90f00d07c066 (patch) | |
tree | 7e3a6d7a854319ac7ab26d01c3bb2f5bcefe59be | |
parent | a07094369b21309434206d9b3601d162693466fc (diff) | |
download | illumos-gate-7c4dcc5546f9f002dfc2b95de47c90f00d07c066.tar.gz |
PSARC/2006/107 mkstemps(3C)/mkdtemp(3C)
6386057 Add mkdtemp(3C)/mkstemps(3C)
22 files changed, 267 insertions, 155 deletions
diff --git a/usr/src/cmd/mktemp/mktemp.c b/usr/src/cmd/mktemp/mktemp.c index d7982b892b..93d5338ae2 100644 --- a/usr/src/cmd/mktemp/mktemp.c +++ b/usr/src/cmd/mktemp/mktemp.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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Create unique plain files or directories. @@ -31,10 +30,8 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <errno.h> #include <string.h> #include <locale.h> -#include <sys/stat.h> static void usage(void) @@ -45,38 +42,6 @@ usage(void) /* NOTREACHED */ } -static int -mktmpdir(char *tmpl) -{ - char *tx = strdup(tmpl); - int i; - - if (tx == NULL) { - perror("strdup"); - exit(1); - } - for (i = 0; i < 100; i++) { - if (*mktemp(tmpl) == '\0') - goto errout; - - if (mkdir(tmpl, 0700) == 0) { - free(tx); - return (0); - } - - /* All other errors won't be fixed by trying a different name */ - if (errno != EEXIST) - goto errout; - - /* Restore template for next try */ - (void) strcpy(tmpl, tx); - } -errout: - (void) strcpy(tmpl, tx); - free(tx); - return (-1); -} - int main(int argc, char **argv) { @@ -161,7 +126,7 @@ main(int argc, char **argv) } if (domkdir) { - if (mktmpdir(tmpl) != 0) { + if (mkdtemp(tmpl) == NULL) { if (!quiet) { (void) fprintf(stderr, gettext("mktemp: failed to create " diff --git a/usr/src/cmd/perl/5.6.1/i386/config.sh b/usr/src/cmd/perl/5.6.1/i386/config.sh index 1bb5274942..14bbaa5ca0 100644 --- a/usr/src/cmd/perl/5.6.1/i386/config.sh +++ b/usr/src/cmd/perl/5.6.1/i386/config.sh @@ -231,10 +231,10 @@ d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' -d_mkdtemp='undef' +d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' -d_mkstemps='undef' +d_mkstemps='define' d_mktime='define' d_mmap='define' d_modfl='undef' diff --git a/usr/src/cmd/perl/5.6.1/sparc/config.sh b/usr/src/cmd/perl/5.6.1/sparc/config.sh index 795d72ba4b..330a0e5893 100644 --- a/usr/src/cmd/perl/5.6.1/sparc/config.sh +++ b/usr/src/cmd/perl/5.6.1/sparc/config.sh @@ -231,10 +231,10 @@ d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' -d_mkdtemp='undef' +d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' -d_mkstemps='undef' +d_mkstemps='define' d_mktime='define' d_mmap='define' d_modfl='undef' diff --git a/usr/src/cmd/perl/5.8.4/i386/config.sh b/usr/src/cmd/perl/5.8.4/i386/config.sh index 2346fc6d92..e2dc8cd925 100644 --- a/usr/src/cmd/perl/5.8.4/i386/config.sh +++ b/usr/src/cmd/perl/5.8.4/i386/config.sh @@ -285,10 +285,10 @@ d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' -d_mkdtemp='undef' +d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' -d_mkstemps='undef' +d_mkstemps='define' d_mktime='define' d_mmap='define' d_modfl='define' diff --git a/usr/src/cmd/perl/5.8.4/sparc/config.sh b/usr/src/cmd/perl/5.8.4/sparc/config.sh index 6db44eb4d9..ec7da3581a 100644 --- a/usr/src/cmd/perl/5.8.4/sparc/config.sh +++ b/usr/src/cmd/perl/5.8.4/sparc/config.sh @@ -284,10 +284,10 @@ d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' -d_mkdtemp='undef' +d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' -d_mkstemps='undef' +d_mkstemps='define' d_mktime='define' d_mmap='define' d_modfl='define' diff --git a/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.6.1/5.11/i386/Config.pm b/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.6.1/5.11/i386/Config.pm index 9b418f0456..8d817c52b6 100644 --- a/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.6.1/5.11/i386/Config.pm +++ b/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.6.1/5.11/i386/Config.pm @@ -291,10 +291,10 @@ d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' -d_mkdtemp='undef' +d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' -d_mkstemps='undef' +d_mkstemps='define' d_mktime='define' d_mmap='define' d_modfl='undef' diff --git a/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.6.1/5.11/sparc/Config.pm b/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.6.1/5.11/sparc/Config.pm index 5d349ac502..88ab937076 100644 --- a/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.6.1/5.11/sparc/Config.pm +++ b/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.6.1/5.11/sparc/Config.pm @@ -291,10 +291,10 @@ d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' -d_mkdtemp='undef' +d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' -d_mkstemps='undef' +d_mkstemps='define' d_mktime='define' d_mmap='define' d_modfl='undef' diff --git a/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.8.4/5.11/i386/Config.pm b/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.8.4/5.11/i386/Config.pm index 55005697db..d00452855d 100644 --- a/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.8.4/5.11/i386/Config.pm +++ b/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.8.4/5.11/i386/Config.pm @@ -391,10 +391,10 @@ d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' -d_mkdtemp='undef' +d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' -d_mkstemps='undef' +d_mkstemps='define' d_mktime='define' d_mmap='define' d_modfl='define' diff --git a/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.8.4/5.11/sparc/Config.pm b/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.8.4/5.11/sparc/Config.pm index 2956766e49..3012988f9d 100644 --- a/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.8.4/5.11/sparc/Config.pm +++ b/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/config/5.8.4/5.11/sparc/Config.pm @@ -391,10 +391,10 @@ d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' -d_mkdtemp='undef' +d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' -d_mkstemps='undef' +d_mkstemps='define' d_mktime='define' d_mmap='define' d_modfl='define' diff --git a/usr/src/cmd/ssh/include/config.h b/usr/src/cmd/ssh/include/config.h index 74f1779587..477a8b5ab4 100644 --- a/usr/src/cmd/ssh/include/config.h +++ b/usr/src/cmd/ssh/include/config.h @@ -2,7 +2,7 @@ /* config.h.in. Generated from configure.ac by autoheader. */ /* $Id: acconfig.h,v 1.145 2002/09/26 00:38:48 tim Exp $ */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -969,6 +969,10 @@ extern "C" { /* Define if compiling in ON */ #define SUNW_SSH 1 +/* Define if you have mkstemp, mkstemps and mkdtemp */ +#define HAVE_MKDTEMP + + /* ******************* Shouldn't need to edit below this line ************** */ #ifdef __cplusplus diff --git a/usr/src/head/stdlib.h b/usr/src/head/stdlib.h index d652900fc2..0024698697 100644 --- a/usr/src/head/stdlib.h +++ b/usr/src/head/stdlib.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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -98,8 +97,10 @@ typedef long uid_t; /* (historical version) */ #ifdef __PRAGMA_REDEFINE_EXTNAME #pragma redefine_extname mkstemp mkstemp64 +#pragma redefine_extname mkstemps mkstemps64 #else /* __PRAGMA_REDEFINE_EXTNAME */ #define mkstemp mkstemp64 +#define mkstemps mkstemps64 #endif /* __PRAGMA_REDEFINE_EXTNAME */ #endif /* _FILE_OFFSET_BITS == 64 */ @@ -109,8 +110,10 @@ typedef long uid_t; /* (historical version) */ #ifdef __PRAGMA_REDEFINE_EXTNAME #pragma redefine_extname mkstemp64 mkstemp +#pragma redefine_extname mkstemps64 mkstemps #else /* __PRAGMA_REDEFINE_EXTNAME */ #define mkstemp64 mkstemp +#define mkstemps64 mkstemps #endif /* __PRAGMA_REDEFINE_EXTNAME */ #endif /* _LP64 && _LARGEFILE64_SOURCE */ @@ -166,11 +169,13 @@ extern void swab(const char *, char *, ssize_t); !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) extern int mkstemp(char *); +extern int mkstemps(char *, int); #endif /* defined(__EXTENSIONS__) ... */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ !defined(__PRAGMA_REDEFINE_EXTNAME)) extern int mkstemp64(char *); +extern int mkstemps64(char *, int); #endif /* _LARGEFILE64_SOURCE... */ #if defined(__EXTENSIONS__) || \ @@ -226,6 +231,7 @@ extern int getpw(uid_t, char *); extern int isatty(int); extern void *memalign(size_t, size_t); extern char *ttyname(int); +extern char *mkdtemp(char *); #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) extern char *lltostr(long long, char *); @@ -266,11 +272,13 @@ extern void swab(); !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) extern int mkstemp(); +extern int mkstemps(); #endif /* defined(__EXTENSIONS__) ... */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ !defined(__PRAGMA_REDEFINE_EXTNAME)) extern int mkstemp64(); +extern int mkstemps64(); #endif /* _LARGEFILE64_SOURCE... */ #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) @@ -320,6 +328,7 @@ extern int getpw(); extern int isatty(); extern void *memalign(); extern char *ttyname(); +extern char *mkdtemp(); #if defined(_LONGLONG_TYPE) extern char *lltostr(); diff --git a/usr/src/lib/common/inc/c_synonyms.h b/usr/src/lib/common/inc/c_synonyms.h index 1198df5292..06fa420471 100644 --- a/usr/src/lib/common/inc/c_synonyms.h +++ b/usr/src/lib/common/inc/c_synonyms.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. @@ -476,8 +475,10 @@ extern "C" { #define memset _memset #define mincore _mincore #define mkdir _mkdir +#define mkdtemp _mkdtemp #define mkfifo _mkfifo #define mkstemp _mkstemp +#define mkstemps _mkstemps #define mktemp _mktemp #define mlockall _mlockall #define mlock _mlock diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile index 6b4d219b8d..f5f2219db9 100644 --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -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. @@ -457,6 +456,7 @@ PORTGEN= \ malloc.o \ memalign.o \ mkdev.o \ + mkdtemp.o \ mkfifo.o \ mkstemp.o \ mktemp.o \ @@ -1046,7 +1046,7 @@ lint: $(LINTLIB):= SRCS=../port/llib-lc $(LINTLIB):= CPPFLAGS += -D_MSE_INT_H -$(LINTLIB):= LINTFLAGS64=-nvx -Xarch=amd64 +$(LINTLIB):= LINTFLAGS64=-nvx -Xarch=amd64 # object files that depend on inline template $(TIL:%=pics/%): $(LIBCBASE)/threads/amd64.il diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com index ed6944e5a3..4e9df745fc 100644 --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -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. @@ -489,6 +488,7 @@ PORTGEN= \ malloc.o \ memalign.o \ mkdev.o \ + mkdtemp.o \ mkfifo.o \ mkstemp.o \ mktemp.o \ diff --git a/usr/src/lib/libc/inc/synonyms.h b/usr/src/lib/libc/inc/synonyms.h index 5024e57757..b392b4140a 100644 --- a/usr/src/lib/libc/inc/synonyms.h +++ b/usr/src/lib/libc/inc/synonyms.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. @@ -58,6 +57,7 @@ extern "C" { #define lseek64 _lseek64 #define lstat64 _lstat64 #define mkstemp64 _mkstemp64 +#define mkstemps64 _mkstemps64 #define mmap64 _mmap64 #define openat64 _openat64 #define open64 _open64 @@ -563,9 +563,11 @@ extern "C" { #define memset _memset #define mincore _mincore #define mkdir _mkdir +#define mkdtemp _mkdtemp #define mkfifo _mkfifo #define mknod _mknod #define mkstemp _mkstemp +#define mkstemps _mkstemps #define mktemp _mktemp #define mlockall _mlockall #define mlock _mlock diff --git a/usr/src/lib/libc/port/gen/mkdtemp.c b/usr/src/lib/libc/port/gen/mkdtemp.c new file mode 100644 index 0000000000..9f6abff070 --- /dev/null +++ b/usr/src/lib/libc/port/gen/mkdtemp.c @@ -0,0 +1,67 @@ +/* + * 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 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * mkdtemp(3C) - create a directory with a unique name. + */ + +#pragma weak mkdtemp = _mkdtemp + +#include "synonyms.h" + +#include <alloca.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +char * +mkdtemp(char *template) +{ + char *t = alloca(strlen(template) + 1); + char *r; + + /* Save template */ + (void) strcpy(t, template); + for (; ; ) { + r = mktemp(template); + + if (*r == '\0') + return (NULL); + + if (mkdir(template, 0700) == 0) + return (r); + + /* Other errors indicate persistent conditions. */ + if (errno != EEXIST) + return (NULL); + + /* Reset template */ + (void) strcpy(template, t); + } +} diff --git a/usr/src/lib/libc/port/gen/mkstemp.c b/usr/src/lib/libc/port/gen/mkstemp.c index 9c35940f6c..368319201b 100644 --- a/usr/src/lib/libc/port/gen/mkstemp.c +++ b/usr/src/lib/libc/port/gen/mkstemp.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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T @@ -37,9 +36,13 @@ #if !defined(_LP64) && _FILE_OFFSET_BITS == 64 #pragma weak mkstemp64 = _mkstemp64 +#pragma weak mkstemps64 = _mkstemps64 #define _mkstemp _mkstemp64 +#define _mkstemps _mkstemps64 +#define libc_mkstemps libc_mkstemps64 /* prefer unique statics */ #else #pragma weak mkstemp = _mkstemp +#pragma weak mkstemps = _mkstemps #endif #include "synonyms.h" @@ -52,20 +55,26 @@ #include <sys/stat.h> #include <fcntl.h> +extern char *libc_mktemps(char *, int); -int -_mkstemp(char *as) +static int +libc_mkstemps(char *as, int slen) { int fd; + int len; char *tstr, *str, *mkret; if (as == NULL || *as == NULL) return (-1); - tstr = alloca(strlen(as) + 1); + len = (int)strlen(as); + tstr = alloca(len + 1); (void) strcpy(tstr, as); - str = tstr + (strlen(tstr) - 1); + if (slen < 0 || slen >= len) + return (-1); + + str = tstr + (len - 1 - slen); /* * The following for() loop is doing work. mktemp() will generate @@ -75,7 +84,7 @@ _mkstemp(char *as) for (; ; ) { if (*str == 'X') { /* If no trailing X's don't call mktemp. */ - mkret = mktemp(as); + mkret = libc_mktemps(as, slen); if (*mkret == '\0') { return (-1); } @@ -102,3 +111,15 @@ _mkstemp(char *as) (void) strcpy(as, tstr); } } + +int +_mkstemp(char *as) +{ + return (libc_mkstemps(as, 0)); +} + +int +_mkstemps(char *as, int slen) +{ + return (libc_mkstemps(as, slen)); +} diff --git a/usr/src/lib/libc/port/gen/mktemp.c b/usr/src/lib/libc/port/gen/mktemp.c index 1d5ccea75c..ff6c5b6be8 100644 --- a/usr/src/lib/libc/port/gen/mktemp.c +++ b/usr/src/lib/libc/port/gen/mktemp.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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -121,7 +120,7 @@ highbit(uint_t i) } char * -mktemp(char *as) +libc_mktemps(char *as, int slen) { /* statics are protected by this static mutex */ static mutex_t mktemp_lock = DEFAULTMUTEX; @@ -167,6 +166,9 @@ mktemp(char *as) /* count the X's */ xcnt = 0; len = (int)strlen(as); + if (slen >= len || slen < 0) + goto fail; + len -= slen; s = as + (len - 1); while ((len != 0) && (xcnt < XCNT) && (*s == 'X')) { xcnt++; @@ -249,3 +251,9 @@ fail: *as = '\0'; return (as); } + +char * +mktemp(char *template) +{ + return (libc_mktemps(template, 0)); +} diff --git a/usr/src/lib/libc/sparc/Makefile b/usr/src/lib/libc/sparc/Makefile index 0abf1da9ce..587a8d0306 100644 --- a/usr/src/lib/libc/sparc/Makefile +++ b/usr/src/lib/libc/sparc/Makefile @@ -1,10 +1,9 @@ -# + # 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. @@ -20,7 +19,7 @@ # 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. # # ident "%Z%%M% %I% %E% SMI" @@ -513,6 +512,7 @@ PORTGEN= \ malloc.o \ memalign.o \ mkdev.o \ + mkdtemp.o \ mkfifo.o \ mkstemp.o \ mktemp.o \ diff --git a/usr/src/lib/libc/sparcv9/Makefile b/usr/src/lib/libc/sparcv9/Makefile index 6e051be401..d2c0bd1f8c 100644 --- a/usr/src/lib/libc/sparcv9/Makefile +++ b/usr/src/lib/libc/sparcv9/Makefile @@ -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. @@ -475,6 +474,7 @@ PORTGEN= \ malloc.o \ memalign.o \ mkdev.o \ + mkdtemp.o \ mkfifo.o \ mkstemp.o \ mktemp.o \ diff --git a/usr/src/lib/libc/spec/gen.spec b/usr/src/lib/libc/spec/gen.spec index b3f08a4009..cf7993a61c 100644 --- a/usr/src/lib/libc/spec/gen.spec +++ b/usr/src/lib/libc/spec/gen.spec @@ -1,13 +1,12 @@ # -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # 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. @@ -1019,7 +1018,7 @@ end function _ftw weak ftw version SUNWprivate_1.1 -end +end function gconvert include <floatingpoint.h> @@ -1088,10 +1087,10 @@ version sparc=SYSVABI_1.3 i386=SYSVABI_1.3 sparcv9=SUNW_0.7 \ amd64=SUNW_0.7 end -function getextmntent +function getextmntent include <stdio.h>, <sys/mnttab.h> declaration int getextmntent(FILE *fp, struct extmnttab *mp, size_t len) -version SUNW_1.20 +version SUNW_1.20 exception $return != 0 end @@ -2014,6 +2013,18 @@ auxiliary sparc=/platform/$PLATFORM/lib/libc_psr.so.1 \ sparcv9=/platform/$PLATFORM/lib/sparcv9/libc_psr.so.1 end +function mkdtemp +include <stdlib.h> +declaration char *mkdtemp(char *template) +version SUNW_1.22.1 +exception $return == 0 +end + +function _mkdtemp +weak mkdtemp +version SUNW_1.22.1 +end + function mkfifo include <sys/types.h>, <sys/stat.h> declaration int mkfifo(const char *path, mode_t mode) @@ -2040,6 +2051,18 @@ weak mkstemp version SUNW_0.7 end +function mkstemps +include <stdlib.h> +declaration int mkstemps(char *template, int suffixlen) +version SUNW_1.22.1 +exception $return == -1 +end + +function _mkstemps +weak mkstemps +version SUNW_1.22.1 +end + function mktemp include <stdlib.h> declaration char *mktemp(char *template) @@ -2595,7 +2618,7 @@ function _readdir weak readdir version sparc=SYSVABI_1.3 i386=SYSVABI_1.3 sparcv9=SUNW_0.7 \ amd64=SUNW_0.7 -end +end # NOTE: The declarations of the various versions of readdir_r() # in <dirent.h> are hopelessly convoluted, so we can't declare @@ -2678,7 +2701,7 @@ end function resetmnttab include <stdio.h>, <sys/mnttab.h> declaration void resetmnttab(FILE *fp) -version SUNW_1.20 +version SUNW_1.20 end function rewind @@ -4202,7 +4225,7 @@ end function priv_set include <priv.h> -declaration int priv_set(priv_op_t, priv_ptype_t, ...) +declaration int priv_set(priv_op_t, priv_ptype_t, ...) version SUNW_1.22 exception $return != 0 errno ENOMEM EPERM EINVAL @@ -4215,7 +4238,7 @@ end function priv_str_to_set include <priv.h> -declaration priv_set_t *priv_str_to_set(const char *, const char *, const char **) +declaration priv_set_t *priv_str_to_set(const char *, const char *, const char **) version SUNW_1.22 exception $return == 0 errno ENOMEM EINVAL @@ -4261,7 +4284,7 @@ end function __priv_getsetbynum include <priv.h> -declaration const char *__priv_getsetbynum(int, void *) +declaration const char *__priv_getsetbynum(int, void *) version SUNW_1.22 exception $return == 0 errno EINVAL @@ -4273,7 +4296,7 @@ end function __priv_getbynum include <priv.h> -declaration const char *__priv_getbynum(int, void *) +declaration const char *__priv_getbynum(int, void *) version SUNW_1.22 exception $return == 0 errno EINVAL @@ -4281,7 +4304,7 @@ end function priv_getbynum include <priv.h> -declaration const char *priv_getbynum(int) +declaration const char *priv_getbynum(int) version SUNW_1.22 exception $return == 0 errno EINVAL @@ -4294,7 +4317,7 @@ end function priv_getsetbynum include <priv.h> -declaration const char *priv_getsetbynum(int) +declaration const char *priv_getsetbynum(int) version SUNW_1.22 exception $return == 0 errno EINVAL @@ -4307,7 +4330,7 @@ end function __priv_getsetbyname include <priv.h> -declaration int __priv_getsetbyname(const char *, void *) +declaration int __priv_getsetbyname(const char *, void *) version SUNW_1.22 exception $return == -1 errno EINVAL @@ -4315,7 +4338,7 @@ end function __priv_getbyname include <priv.h> -declaration int __priv_getbyname(const char *, void *) +declaration int __priv_getbyname(const char *, void *) version SUNW_1.22 exception $return == -1 errno EINVAL @@ -4323,7 +4346,7 @@ end function priv_getbyname include <priv.h> -declaration int priv_getbyname(const char *) +declaration int priv_getbyname(const char *) version SUNW_1.22 exception $return == -1 errno EINVAL @@ -4336,7 +4359,7 @@ end function priv_getsetbyname include <priv.h> -declaration int priv_getsetbyname(const char *) +declaration int priv_getsetbyname(const char *) version SUNW_1.22 exception $return == -1 errno EINVAL @@ -4349,7 +4372,7 @@ end function priv_gettext include <priv.h> -declaration char *priv_gettext(const char *) +declaration char *priv_gettext(const char *) version SUNW_1.22 exception $return == 0 end @@ -4361,7 +4384,7 @@ end function priv_allocset include <priv.h> -declaration priv_set_t *priv_allocset(void) +declaration priv_set_t *priv_allocset(void) version SUNW_1.22 exception $return == 0 errno ENOMEM @@ -4374,7 +4397,7 @@ end function priv_freeset include <priv.h> -declaration void priv_freeset(priv_set_t *) +declaration void priv_freeset(priv_set_t *) version SUNW_1.22 end @@ -4385,7 +4408,7 @@ end function priv_emptyset include <priv.h> -declaration void priv_emptyset(priv_set_t *) +declaration void priv_emptyset(priv_set_t *) version SUNW_1.22 end @@ -4396,7 +4419,7 @@ end function priv_fillset include <priv.h> -declaration void priv_fillset(priv_set_t *) +declaration void priv_fillset(priv_set_t *) version SUNW_1.22 end @@ -4407,7 +4430,7 @@ end function priv_isemptyset include <priv.h> -declaration boolean_t priv_isemptyset(const priv_set_t *) +declaration boolean_t priv_isemptyset(const priv_set_t *) version SUNW_1.22 end @@ -4418,7 +4441,7 @@ end function priv_isfullset include <priv.h> -declaration boolean_t priv_isfullset(const priv_set_t *) +declaration boolean_t priv_isfullset(const priv_set_t *) version SUNW_1.22 end @@ -4429,7 +4452,7 @@ end function priv_isequalset include <priv.h> -declaration boolean_t priv_isequalset(const priv_set_t *, const priv_set_t *) +declaration boolean_t priv_isequalset(const priv_set_t *, const priv_set_t *) version SUNW_1.22 end @@ -4440,7 +4463,7 @@ end function priv_issubset include <priv.h> -declaration boolean_t priv_issubset(const priv_set_t *, const priv_set_t *) +declaration boolean_t priv_issubset(const priv_set_t *, const priv_set_t *) version SUNW_1.22 end @@ -4451,7 +4474,7 @@ end function priv_intersect include <priv.h> -declaration void priv_intersect(const priv_set_t *, priv_set_t *) +declaration void priv_intersect(const priv_set_t *, priv_set_t *) version SUNW_1.22 end @@ -4462,7 +4485,7 @@ end function priv_union include <priv.h> -declaration void priv_union(const priv_set_t *, priv_set_t *) +declaration void priv_union(const priv_set_t *, priv_set_t *) version SUNW_1.22 end @@ -4473,7 +4496,7 @@ end function priv_inverse include <priv.h> -declaration void priv_inverse(priv_set_t *) +declaration void priv_inverse(priv_set_t *) version SUNW_1.22 end @@ -4484,7 +4507,7 @@ end function priv_addset include <priv.h> -declaration int priv_addset(priv_set_t *, const char *) +declaration int priv_addset(priv_set_t *, const char *) version SUNW_1.22 end @@ -4495,7 +4518,7 @@ end function priv_delset include <priv.h> -declaration int priv_delset(priv_set_t *, const char *) +declaration int priv_delset(priv_set_t *, const char *) version SUNW_1.22 end @@ -4506,7 +4529,7 @@ end function priv_copyset include <priv.h> -declaration void priv_copyset(const priv_set_t *, priv_set_t *) +declaration void priv_copyset(const priv_set_t *, priv_set_t *) version SUNW_1.22 end @@ -4517,7 +4540,7 @@ end function priv_ismember include <priv.h> -declaration boolean_t priv_ismember(const priv_set_t *, const char *) +declaration boolean_t priv_ismember(const priv_set_t *, const char *) version SUNW_1.22 end @@ -4528,7 +4551,7 @@ end function ucred_get include <ucred.h> -declaration ucred_t *ucred_get(pid_t pid) +declaration ucred_t *ucred_get(pid_t pid) version SUNW_1.22 end @@ -4545,7 +4568,7 @@ end function ucred_free include <ucred.h> -declaration void ucred_free(ucred_t *) +declaration void ucred_free(ucred_t *) version SUNW_1.22 end @@ -4556,7 +4579,7 @@ end function ucred_geteuid include <ucred.h> -declaration uid_t ucred_geteuid(const ucred_t *) +declaration uid_t ucred_geteuid(const ucred_t *) version SUNW_1.22 end @@ -4567,7 +4590,7 @@ end function ucred_getruid include <ucred.h> -declaration uid_t ucred_getruid(const ucred_t *) +declaration uid_t ucred_getruid(const ucred_t *) version SUNW_1.22 end @@ -4578,7 +4601,7 @@ end function ucred_getsuid include <ucred.h> -declaration uid_t ucred_getsuid(const ucred_t *) +declaration uid_t ucred_getsuid(const ucred_t *) version SUNW_1.22 end @@ -4589,7 +4612,7 @@ end function ucred_getegid include <ucred.h> -declaration gid_t ucred_getegid(const ucred_t *) +declaration gid_t ucred_getegid(const ucred_t *) version SUNW_1.22 end @@ -4600,7 +4623,7 @@ end function ucred_getrgid include <ucred.h> -declaration gid_t ucred_getrgid(const ucred_t *) +declaration gid_t ucred_getrgid(const ucred_t *) version SUNW_1.22 end @@ -4611,7 +4634,7 @@ end function ucred_getsgid include <ucred.h> -declaration gid_t ucred_getsgid(const ucred_t *) +declaration gid_t ucred_getsgid(const ucred_t *) version SUNW_1.22 end @@ -4622,7 +4645,7 @@ end function ucred_getgroups include <ucred.h> -declaration int ucred_getgroups(const ucred_t *, const gid_t **) +declaration int ucred_getgroups(const ucred_t *, const gid_t **) version SUNW_1.22 end @@ -4633,7 +4656,7 @@ end function ucred_getprivset include <ucred.h> -declaration const priv_set_t *ucred_getprivset(const ucred_t *, priv_ptype_t) +declaration const priv_set_t *ucred_getprivset(const ucred_t *, priv_ptype_t) version SUNW_1.22 end @@ -4644,7 +4667,7 @@ end function ucred_getpid include <ucred.h> -declaration pid_t ucred_getpid(const ucred_t *) +declaration pid_t ucred_getpid(const ucred_t *) version SUNW_1.22 end @@ -4655,7 +4678,7 @@ end function ucred_getprojid include <ucred.h> -declaration projid_t ucred_getprojid(const ucred_t *) +declaration projid_t ucred_getprojid(const ucred_t *) version SUNW_1.22 end @@ -4666,7 +4689,7 @@ end function ucred_getzoneid include <ucred.h> -declaration zoneid_t ucred_getzoneid(const ucred_t *) +declaration zoneid_t ucred_getzoneid(const ucred_t *) version SUNW_1.22 end @@ -4677,7 +4700,7 @@ end function ucred_getpflags include <ucred.h> -declaration uint_t ucred_getpflags(const ucred_t *, uint_t) +declaration uint_t ucred_getpflags(const ucred_t *, uint_t) version SUNW_1.22 end @@ -4686,7 +4709,7 @@ weak ucred_getpflags version SUNW_1.22 end -function zonept +function zonept include <stdlib.h> <sys/zone.h> declaration int zonept(int filedes, zoneid_t zoneid) version SUNWprivate_1.1 @@ -4834,7 +4857,7 @@ end function ucred_getauid include <ucred.h>, <bsm/audit.h> -declaration au_id_t ucred_getauid(const ucred_t *) +declaration au_id_t ucred_getauid(const ucred_t *) version SUNWprivate_1.1 end @@ -4845,7 +4868,7 @@ end function ucred_getasid include <ucred.h>, <bsm/audit.h> -declaration au_asid_t ucred_getasid(const ucred_t *) +declaration au_asid_t ucred_getasid(const ucred_t *) version SUNWprivate_1.1 end @@ -4856,7 +4879,7 @@ end function ucred_getamask include <ucred.h>, <bsm/audit.h> -declaration const au_mask_t *ucred_getamask(const ucred_t *) +declaration const au_mask_t *ucred_getamask(const ucred_t *) version SUNWprivate_1.1 end @@ -4867,7 +4890,7 @@ end function ucred_getatid include <ucred.h>, <bsm/audit.h> -declaration const au_tid64_addr_t *ucred_getatid(const ucred_t *) +declaration const au_tid64_addr_t *ucred_getatid(const ucred_t *) version SUNWprivate_1.1 end diff --git a/usr/src/lib/libc/spec/interface64.spec b/usr/src/lib/libc/spec/interface64.spec index fc7ff389c2..d164c9dd45 100644 --- a/usr/src/lib/libc/spec/interface64.spec +++ b/usr/src/lib/libc/spec/interface64.spec @@ -1,13 +1,12 @@ # -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # 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. @@ -236,6 +235,19 @@ arch sparc i386 version SUNW_1.1 end +function mkstemps64 +include <stdlib.h> +declaration int mkstemps64(char *template, int suffixlen) +arch sparc i386 +version SUNW_1.22.1 +end + +function _mkstemps64 +weak mkstemps64 +arch sparc i386 +version SUNW_1.22.1 +end + function mmap64 include <sys/types.h> include <sys/mman.h> @@ -418,7 +430,7 @@ arch sparc i386 version SUNW_1.1 end -function _statvfs64 +function _statvfs64 weak statvfs64 arch sparc i386 version SUNW_1.1 @@ -448,7 +460,7 @@ function tell64 include <unistd.h> declaration off64_t tell64(int) arch sparc i386 -version SUNW_1.1 +version SUNW_1.1 end function _tell64 |