2 * Copyright 2000, International Business Machines Corporation and others.
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
11 * afs_warn.c - afs_warn
13 * Implements: afs_warn, afs_warnuser
15 #include <afsconfig.h>
16 #include "afs/param.h"
20 #include "afs/sysincludes.h" /* Standard vendor system headers */
24 #if !defined(AFS_LINUX20_ENV)
26 # if defined(AFS_SUN5_ENV)
27 # include <sys/varargs.h>
28 # elif defined(AFS_FBSD_ENV)
29 # include <machine/stdarg.h>
34 #include <netinet/in.h>
37 #include "h/hashing.h"
39 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
40 #include <netinet/in_var.h>
41 #endif /* ! AFS_HPUX110_ENV */
42 #endif /* !defined(UKERNEL) */
44 #include "afsincludes.h" /* Afs-based standard headers */
45 #include "afs/afs_stats.h" /* afs statistics */
47 #if defined(AFS_SUN5_ENV)
49 #include <inet/common.h>
50 #include <netinet/ip6.h>
54 #if defined(AFS_AIX_ENV)
55 #include <sys/fp_io.h>
58 #if defined(AFS_LINUX26_ENV)
59 # define afs_vprintf(fmt, ap) vprintk(fmt, ap)
60 #elif defined(AFS_SGI_ENV)
61 # define afs_vprintf(fmt, ap) icmn_err(CE_WARN, fmt, ap)
62 #elif (defined(AFS_DARWIN80_ENV) && !defined(AFS_DARWIN90_ENV)) || (defined(AFS_LINUX22_ENV))
64 afs_vprintf(const char *fmt
, va_list ap
)
68 vsnprintf(buf
, sizeof(buf
), fmt
, ap
);
72 # define afs_vprintf(fmt, ap) vprintf(fmt, ap)
77 afs_warn(fmt
, a
, b
, c
, d
, e
, f
, g
, h
, i
)
79 void *a
, *b
, *c
, *d
, *e
, *f
, *g
, *h
, *i
;
81 AFS_STATCNT(afs_warn
);
83 if (afs_showflags
& GAGCONSOLE
) {
86 /* cf. console_printf() in oncplus/kernext/nfs/serv/shared.c */
88 ("/dev/console", O_WRONLY
| O_NOCTTY
| O_NDELAY
, 0666, 0, FP_SYS
,
94 sprintf(buf
, fmt
, a
, b
, c
, d
, e
, f
, g
, h
, i
);
96 fp_write(fd
, buf
, len
, 0, UIO_SYSSPACE
, &count
);
101 #else /* AFS_AIX_ENV */
103 afs_vwarn(char *fmt
, va_list ap
)
105 afs_vprintf(fmt
, ap
);
110 afs_warn(char *fmt
, ...)
112 AFS_STATCNT(afs_warn
);
114 if (afs_showflags
& GAGCONSOLE
) {
122 #endif /* AFS_AIX_ENV */
127 afs_warnuser(fmt
, a
, b
, c
, d
, e
, f
, g
, h
, i
)
129 void *a
, *b
, *c
, *d
, *e
, *f
, *g
, *h
, *i
;
131 AFS_STATCNT(afs_warnuser
);
132 if (afs_showflags
& GAGUSER
) {
133 # ifdef AFS_GLOBAL_SUNLOCK
134 int haveGlock
= ISAFS_GLOCK();
135 /* drop GLOCK for uprintf */
138 # endif /* AFS_GLOBAL_SUNLOCK */
139 uprintf(fmt
, a
, b
, c
, d
, e
, f
, g
, h
, i
);
140 # ifdef AFS_GLOBAL_SUNLOCK
141 /* regain GLOCK we dropped for uprintf */
144 # endif /* AFS_GLOBAL_SUNLOCK */
147 #else /* AFS_AIX_ENV */
148 # ifdef AFS_WARNUSER_MARINER_ENV
150 afs_vwarnuser (char *fmt
, va_list ap
)
152 # ifdef AFS_GLOBAL_SUNLOCK
153 int haveGlock
= ISAFS_GLOCK();
154 /* gain GLOCK for mariner */
157 # endif /* AFS_GLOBAL_SUNLOCK */
163 /* mariner log the warning */
164 snprintf(buf
, sizeof(buf
), "warn$");
165 vsnprintf(buf
+strlen(buf
), sizeof(buf
)-strlen(buf
), fmt
, aq
);
166 afs_MarinerLog(buf
, NULL
);
170 # ifdef AFS_GLOBAL_SUNLOCK
171 /* drop GLOCK we got for mariner */
174 # endif /* AFS_GLOBAL_SUNLOCK */
176 # else /* AFS_WARNUSER_MARINER_ENV */
178 afs_vwarnuser (char *fmt
, va_list ap
)
180 # ifdef AFS_GLOBAL_SUNLOCK
181 int haveGlock
= ISAFS_GLOCK();
185 # endif /* AFS_GLOBAL_SUNLOCK */
187 afs_vprintf(fmt
, ap
);
189 # ifdef AFS_GLOBAL_SUNLOCK
190 /* regain GLOCK we dropped */
193 # endif /* AFS_GLOBAL_SUNLOCK */
195 # endif /* AFS_WARNUSER_MARINER_ENV */
198 afs_warnuser(char *fmt
, ...)
200 AFS_STATCNT(afs_warnuser
);
201 if (afs_showflags
& GAGUSER
) {
205 afs_vwarnuser(fmt
, ap
);
210 #endif /* AFS_AIX_ENV */
215 afs_warnall(fmt
, a
, b
, c
, d
, e
, f
, g
, h
, i
)
217 void *a
, *b
, *c
, *d
, *e
, *f
, *g
, *h
, *i
;
219 afs_warn(fmt
, a
, b
, c
, d
, e
, f
, g
, h
, i
);
220 afs_warnuser(fmt
, a
, b
, c
, d
, e
, f
, g
, h
, i
);
223 #else /* AFS_AIX_ENV */
224 /* On Linux both afs_warn and afs_warnuser go to the same
225 * place. Suppress one of them if we're running on Linux.
228 afs_warnall(char *fmt
, ...)
232 # ifdef AFS_LINUX20_ENV
233 AFS_STATCNT(afs_warn
);
234 if ((afs_showflags
& GAGCONSOLE
) || (afs_showflags
& GAGUSER
)) {
239 # else /* AFS_LINUX20_ENV */
240 AFS_STATCNT(afs_warn
);
241 if (afs_showflags
& GAGCONSOLE
) {
247 AFS_STATCNT(afs_warnuser
);
248 if (afs_showflags
& GAGUSER
) {
250 afs_vwarnuser(fmt
, ap
);
253 # endif /* AFS_LINUX20_ENV */
255 #endif /* AFS_AIX_ENV */