2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 static char message[1024]; /* keep it off the stack */
22 static DEFINE_SPINLOCK(xfs_err_lock);
24 /* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */
25 #define XFS_MAX_ERR_LEVEL 7
26 #define XFS_ERR_MASK ((1 << 3) - 1)
27 static const char * const err_level[XFS_MAX_ERR_LEVEL+1] =
28 {KERN_EMERG, KERN_ALERT, KERN_CRIT,
29 KERN_ERR, KERN_WARNING, KERN_NOTICE,
30 KERN_INFO, KERN_DEBUG};
33 cmn_err(register int level, char *fmt, ...)
40 level &= XFS_ERR_MASK;
41 if (level > XFS_MAX_ERR_LEVEL)
42 level = XFS_MAX_ERR_LEVEL;
43 spin_lock_irqsave(&xfs_err_lock,flags);
45 if (*fmt == '!') fp++;
46 len = vsnprintf(message, sizeof(message), fp, ap);
47 if (len >= sizeof(message))
48 len = sizeof(message) - 1;
49 if (message[len-1] == '\n')
51 printk("%s%s\n", err_level[level], message);
53 spin_unlock_irqrestore(&xfs_err_lock,flags);
54 BUG_ON(level == CE_PANIC);
58 icmn_err(register int level, char *fmt, va_list ap)
63 level &= XFS_ERR_MASK;
64 if(level > XFS_MAX_ERR_LEVEL)
65 level = XFS_MAX_ERR_LEVEL;
66 spin_lock_irqsave(&xfs_err_lock,flags);
67 len = vsnprintf(message, sizeof(message), fmt, ap);
68 if (len >= sizeof(message))
69 len = sizeof(message) - 1;
70 if (message[len-1] == '\n')
72 printk("%s%s\n", err_level[level], message);
73 spin_unlock_irqrestore(&xfs_err_lock,flags);
74 BUG_ON(level == CE_PANIC);
78 assfail(char *expr, char *file, int line)
80 printk("Assertion failed: %s, file: %s, line: %d\n", expr, file, line);
85 xfs_hex_dump(void *p, int length)
87 print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);