freebsd: CM changes targeting RELENG_8
[openafs.git] / src / afs / afs_warn.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * afs_warn.c - afs_warn
12  *
13  * Implements: afs_warn, afs_warnuser
14  */
15 #include <afsconfig.h>
16 #include "afs/param.h"
17
18
19 #include "afs/stds.h"
20 #include "afs/sysincludes.h"    /* Standard vendor system headers */
21
22 #if !defined(UKERNEL)
23 #if !defined(AFS_LINUX20_ENV)
24 #include <net/if.h>
25 #include "stdarg.h"
26 #endif
27 #include <netinet/in.h>
28
29 #ifdef AFS_SGI62_ENV
30 #include "h/hashing.h"
31 #endif
32 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN60_ENV)
33 #include <netinet/in_var.h>
34 #endif /* ! AFS_HPUX110_ENV */
35 #endif /* !defined(UKERNEL) */
36
37 #include "afsincludes.h"        /* Afs-based standard headers */
38 #include "afs/afs_stats.h"      /* afs statistics */
39
40 #if     defined(AFS_SUN56_ENV)
41 #include <inet/led.h>
42 #include <inet/common.h>
43 #if     defined(AFS_SUN58_ENV)
44 #include <netinet/ip6.h>
45 #endif
46 #include <inet/ip.h>
47 #endif
48
49 #if     defined(AFS_AIX_ENV)
50 #include <sys/fp_io.h>
51 #endif
52
53 #if defined(AFS_LINUX26_ENV)
54 # define afs_vprintf(fmt, ap) vprintk(fmt, ap)
55 #elif (defined(AFS_DARWIN80_ENV) && !defined(AFS_DARWIN90_ENV)) || (defined(AFS_LINUX22_ENV))
56 static_inline void afs_vprintf(const char *fmt, va_list ap) {
57         char buf[256];
58
59         vsnprintf(buf, sizeof(buf), fmt, ap);
60         printf(buf);
61 }
62 #else
63 # define afs_vprintf(fmt, ap) vprintf(fmt, ap)
64 #endif
65
66 #ifdef AFS_AIX_ENV
67 void
68 afs_warn(fmt, a, b, c, d, e, f, g, h, i)
69     char *fmt;
70     void *a, *b, *c, *d, *e, *f, *g, *h, *i;
71 #else
72 void
73 afs_warn(char *fmt, ...)
74 #endif
75 {
76     AFS_STATCNT(afs_warn);
77
78     if (afs_showflags & GAGCONSOLE) {
79 #if defined(AFS_AIX_ENV)
80         struct file *fd;
81
82         /* cf. console_printf() in oncplus/kernext/nfs/serv/shared.c */
83         if (fp_open
84             ("/dev/console", O_WRONLY | O_NOCTTY | O_NDELAY, 0666, 0, FP_SYS,
85              &fd) == 0) {
86             char buf[1024];
87             ssize_t len;
88             ssize_t count;
89
90             sprintf(buf, fmt, a, b, c, d, e, f, g, h, i);
91             len = strlen(buf);
92             fp_write(fd, buf, len, 0, UIO_SYSSPACE, &count);
93             fp_close(fd);
94         }
95 #else
96         va_list ap;
97
98         va_start(ap, fmt);
99         afs_vprintf(fmt, ap);
100         va_end(ap);
101 #endif
102     }
103 }
104
105 #ifdef AFS_AIX_ENV
106 void
107 afs_warnuser(fmt, a, b, c, d, e, f, g, h, i)
108     char *fmt;
109     void *a, *b, *c, *d, *e, *f, *g, *h, *i;
110 #else
111 void
112 afs_warnuser(char *fmt, ...)
113 #endif
114 {
115     AFS_STATCNT(afs_warnuser);
116     if (afs_showflags & GAGUSER) {
117 #if !defined(AFS_AIX_ENV)
118         va_list ap;
119 #endif
120 #ifdef AFS_GLOBAL_SUNLOCK
121         int haveGlock = ISAFS_GLOCK();
122         if (haveGlock)
123             AFS_GUNLOCK();
124 #endif /* AFS_GLOBAL_SUNLOCK */
125
126 #if defined(AFS_AIX_ENV)
127         uprintf(fmt, a, b, c, d, e, f, g, h, i);
128 #else
129
130         va_start(ap, fmt);
131         afs_vprintf(fmt, ap);
132         va_end(ap);
133 #endif
134
135 #ifdef AFS_GLOBAL_SUNLOCK
136         if (haveGlock)
137             AFS_GLOCK();
138 #endif /* AFS_GLOBAL_SUNLOCK */
139     }
140 }