2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #include <linux/sched.h>
37 #include <linux/kernel.h>
39 static char message
[256]; /* keep it off the stack */
40 static DEFINE_SPINLOCK(xfs_err_lock
);
42 /* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */
43 #define XFS_MAX_ERR_LEVEL 7
44 #define XFS_ERR_MASK ((1 << 3) - 1)
45 static char *err_level
[XFS_MAX_ERR_LEVEL
+1] =
46 {KERN_EMERG
, KERN_ALERT
, KERN_CRIT
,
47 KERN_ERR
, KERN_WARNING
, KERN_NOTICE
,
48 KERN_INFO
, KERN_DEBUG
};
51 assfail(char *a
, char *f
, int l
)
53 printk("XFS assertion failed: %s, file: %s, line: %d\n", a
, f
, l
);
57 #if ((defined(DEBUG) || defined(INDUCE_IO_ERRROR)) && !defined(NO_WANT_RANDOM))
62 static unsigned long RandomValue
= 1;
63 /* cycles pseudo-randomly through all values between 1 and 2^31 - 2 */
64 register long rv
= RandomValue
;
70 rv
= 16807 * lo
- 2836 * hi
;
71 if( rv
<= 0 ) rv
+= 2147483647;
72 return( RandomValue
= rv
);
81 #endif /* DEBUG || INDUCE_IO_ERRROR || !NO_WANT_RANDOM */
84 cmn_err(register int level
, char *fmt
, ...)
91 level
&= XFS_ERR_MASK
;
92 if (level
> XFS_MAX_ERR_LEVEL
)
93 level
= XFS_MAX_ERR_LEVEL
;
94 spin_lock_irqsave(&xfs_err_lock
,flags
);
96 if (*fmt
== '!') fp
++;
97 len
= vsprintf(message
, fp
, ap
);
98 if (message
[len
-1] != '\n')
99 strcat(message
, "\n");
100 printk("%s%s", err_level
[level
], message
);
102 spin_unlock_irqrestore(&xfs_err_lock
,flags
);
104 if (level
== CE_PANIC
)
110 icmn_err(register int level
, char *fmt
, va_list ap
)
115 level
&= XFS_ERR_MASK
;
116 if(level
> XFS_MAX_ERR_LEVEL
)
117 level
= XFS_MAX_ERR_LEVEL
;
118 spin_lock_irqsave(&xfs_err_lock
,flags
);
119 len
= vsprintf(message
, fmt
, ap
);
120 if (message
[len
-1] != '\n')
121 strcat(message
, "\n");
122 spin_unlock_irqrestore(&xfs_err_lock
,flags
);
123 printk("%s%s", err_level
[level
], message
);
124 if (level
== CE_PANIC
)