10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*9268SJerry.Gilliam@Sun.COM * Common Development and Distribution License (the "License").
6*9268SJerry.Gilliam@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*9268SJerry.Gilliam@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <stdio.h>
270Sstevel@tonic-gate #include <stdlib.h>
280Sstevel@tonic-gate #include <stdarg.h>
290Sstevel@tonic-gate #include <sys/modctl.h>
300Sstevel@tonic-gate #include <errno.h>
310Sstevel@tonic-gate
32*9268SJerry.Gilliam@Sun.COM /*PRINTFLIKE1*/
330Sstevel@tonic-gate void
error(char * fmt,...)340Sstevel@tonic-gate error(char *fmt, ...)
350Sstevel@tonic-gate {
360Sstevel@tonic-gate va_list args;
370Sstevel@tonic-gate
380Sstevel@tonic-gate int error;
390Sstevel@tonic-gate
400Sstevel@tonic-gate error = errno;
410Sstevel@tonic-gate
420Sstevel@tonic-gate va_start(args, fmt);
430Sstevel@tonic-gate (void) vfprintf(stderr, fmt, args);
440Sstevel@tonic-gate (void) fprintf(stderr, ": ");
450Sstevel@tonic-gate if (errno == ENOSPC)
460Sstevel@tonic-gate (void) fprintf(stderr,
470Sstevel@tonic-gate "Out of memory or no room in system tables\n");
480Sstevel@tonic-gate else
490Sstevel@tonic-gate perror("");
500Sstevel@tonic-gate va_end(args);
510Sstevel@tonic-gate exit(error);
520Sstevel@tonic-gate }
530Sstevel@tonic-gate
54*9268SJerry.Gilliam@Sun.COM /*PRINTFLIKE1*/
550Sstevel@tonic-gate void
fatal(char * fmt,...)560Sstevel@tonic-gate fatal(char *fmt, ...)
570Sstevel@tonic-gate {
580Sstevel@tonic-gate va_list args;
590Sstevel@tonic-gate
600Sstevel@tonic-gate va_start(args, fmt);
610Sstevel@tonic-gate (void) vfprintf(stderr, fmt, args);
620Sstevel@tonic-gate va_end(args);
630Sstevel@tonic-gate exit(-1);
640Sstevel@tonic-gate }
65