1 0Sstevel@tonic-gate /*
2 0Sstevel@tonic-gate * CDDL HEADER START
3 0Sstevel@tonic-gate *
4 0Sstevel@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.
7 0Sstevel@tonic-gate *
8 0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
10 0Sstevel@tonic-gate * See the License for the specific language governing permissions
11 0Sstevel@tonic-gate * and limitations under the License.
12 0Sstevel@tonic-gate *
13 0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
14 0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
16 0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
17 0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
18 0Sstevel@tonic-gate *
19 0Sstevel@tonic-gate * CDDL HEADER END
20 0Sstevel@tonic-gate */
21 0Sstevel@tonic-gate /*
22 *9268SJerry.Gilliam@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 0Sstevel@tonic-gate * Use is subject to license terms.
24 0Sstevel@tonic-gate */
25 0Sstevel@tonic-gate
26 0Sstevel@tonic-gate #include <stdio.h>
27 0Sstevel@tonic-gate #include <stdlib.h>
28 0Sstevel@tonic-gate #include <stdarg.h>
29 0Sstevel@tonic-gate #include <sys/modctl.h>
30 0Sstevel@tonic-gate #include <errno.h>
31 0Sstevel@tonic-gate
32 *9268SJerry.Gilliam@Sun.COM /*PRINTFLIKE1*/
33 0Sstevel@tonic-gate void
error(char * fmt,...)34 0Sstevel@tonic-gate error(char *fmt, ...)
35 0Sstevel@tonic-gate {
36 0Sstevel@tonic-gate va_list args;
37 0Sstevel@tonic-gate
38 0Sstevel@tonic-gate int error;
39 0Sstevel@tonic-gate
40 0Sstevel@tonic-gate error = errno;
41 0Sstevel@tonic-gate
42 0Sstevel@tonic-gate va_start(args, fmt);
43 0Sstevel@tonic-gate (void) vfprintf(stderr, fmt, args);
44 0Sstevel@tonic-gate (void) fprintf(stderr, ": ");
45 0Sstevel@tonic-gate if (errno == ENOSPC)
46 0Sstevel@tonic-gate (void) fprintf(stderr,
47 0Sstevel@tonic-gate "Out of memory or no room in system tables\n");
48 0Sstevel@tonic-gate else
49 0Sstevel@tonic-gate perror("");
50 0Sstevel@tonic-gate va_end(args);
51 0Sstevel@tonic-gate exit(error);
52 0Sstevel@tonic-gate }
53 0Sstevel@tonic-gate
54 *9268SJerry.Gilliam@Sun.COM /*PRINTFLIKE1*/
55 0Sstevel@tonic-gate void
fatal(char * fmt,...)56 0Sstevel@tonic-gate fatal(char *fmt, ...)
57 0Sstevel@tonic-gate {
58 0Sstevel@tonic-gate va_list args;
59 0Sstevel@tonic-gate
60 0Sstevel@tonic-gate va_start(args, fmt);
61 0Sstevel@tonic-gate (void) vfprintf(stderr, fmt, args);
62 0Sstevel@tonic-gate va_end(args);
63 0Sstevel@tonic-gate exit(-1);
64 0Sstevel@tonic-gate }
65