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);
171 # ifdef AFS_GLOBAL_SUNLOCK
172 /* drop GLOCK we got for mariner */
175 # endif /* AFS_GLOBAL_SUNLOCK */
177 # else /* AFS_WARNUSER_MARINER_ENV */
179 afs_vwarnuser (char *fmt, va_list ap)
181 # ifdef AFS_GLOBAL_SUNLOCK
182 int haveGlock = ISAFS_GLOCK();
186 # endif /* AFS_GLOBAL_SUNLOCK */
188 afs_vprintf(fmt, ap);
190 # ifdef AFS_GLOBAL_SUNLOCK
191 /* regain GLOCK we dropped */
194 # endif /* AFS_GLOBAL_SUNLOCK */
196 # endif /* AFS_WARNUSER_MARINER_ENV */
199 afs_warnuser(char *fmt, ...)
201 AFS_STATCNT(afs_warnuser);
202 if (afs_showflags & GAGUSER) {
206 afs_vwarnuser(fmt, ap);
211 #endif /* AFS_AIX_ENV */
216 afs_warnall(fmt, a, b, c, d, e, f, g, h, i)
218 void *a, *b, *c, *d, *e, *f, *g, *h, *i;
220 afs_warn(fmt, a, b, c, d, e, f, g, h, i);
221 afs_warnuser(fmt, a, b, c, d, e, f, g, h, i);
224 #else /* AFS_AIX_ENV */
225 /* On Linux both afs_warn and afs_warnuser go to the same
226 * place. Suppress one of them if we're running on Linux.
229 afs_warnall(char *fmt, ...)
233 # ifdef AFS_LINUX20_ENV
234 AFS_STATCNT(afs_warn);
235 if ((afs_showflags & GAGCONSOLE) || (afs_showflags & GAGUSER)) {
240 # else /* AFS_LINUX20_ENV */
241 AFS_STATCNT(afs_warn);
242 if (afs_showflags & GAGCONSOLE) {
248 AFS_STATCNT(afs_warnuser);
249 if (afs_showflags & GAGUSER) {
251 afs_vwarnuser(fmt, ap);
254 # endif /* AFS_LINUX20_ENV */
256 #endif /* AFS_AIX_ENV */
259 * Log a warning when we encounter an ENOSPC error when writing to the cache
260 * partition. We should not normally encounter ENOSPC errors, since we limit
261 * our space usage according to the client config, which should be configured
262 * such that we never run out of space.
267 afs_warnuser("afs: Cache partition is FULL! This should not happen, and "
268 "can result in errors in userspace applications. To avoid "
269 "this, reduce the configured cache size so we do not run out "