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>
40 static char message
[256]; /* keep it off the stack */
41 static DEFINE_SPINLOCK(xfs_err_lock
);
43 /* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */
44 #define XFS_MAX_ERR_LEVEL 7
45 #define XFS_ERR_MASK ((1 << 3) - 1)
46 static char *err_level
[XFS_MAX_ERR_LEVEL
+1] =
47 {KERN_EMERG
, KERN_ALERT
, KERN_CRIT
,
48 KERN_ERR
, KERN_WARNING
, KERN_NOTICE
,
49 KERN_INFO
, KERN_DEBUG
};
52 assfail(char *a
, char *f
, int l
)
54 printk("XFS assertion failed: %s, file: %s, line: %d\n", a
, f
, l
);
58 #if ((defined(DEBUG) || defined(INDUCE_IO_ERRROR)) && !defined(NO_WANT_RANDOM))
63 static unsigned long RandomValue
= 1;
64 /* cycles pseudo-randomly through all values between 1 and 2^31 - 2 */
65 register long rv
= RandomValue
;
71 rv
= 16807 * lo
- 2836 * hi
;
72 if( rv
<= 0 ) rv
+= 2147483647;
73 return( RandomValue
= rv
);
82 #endif /* DEBUG || INDUCE_IO_ERRROR || !NO_WANT_RANDOM */
85 cmn_err(register int level
, char *fmt
, ...)
92 level
&= XFS_ERR_MASK
;
93 if (level
> XFS_MAX_ERR_LEVEL
)
94 level
= XFS_MAX_ERR_LEVEL
;
95 spin_lock_irqsave(&xfs_err_lock
,flags
);
97 if (*fmt
== '!') fp
++;
98 len
= vsprintf(message
, fp
, ap
);
99 if (message
[len
-1] != '\n')
100 strcat(message
, "\n");
101 printk("%s%s", err_level
[level
], message
);
103 spin_unlock_irqrestore(&xfs_err_lock
,flags
);
105 if (level
== CE_PANIC
)
111 icmn_err(register int level
, char *fmt
, va_list ap
)
116 level
&= XFS_ERR_MASK
;
117 if(level
> XFS_MAX_ERR_LEVEL
)
118 level
= XFS_MAX_ERR_LEVEL
;
119 spin_lock_irqsave(&xfs_err_lock
,flags
);
120 len
= vsprintf(message
, fmt
, ap
);
121 if (message
[len
-1] != '\n')
122 strcat(message
, "\n");
123 spin_unlock_irqrestore(&xfs_err_lock
,flags
);
124 printk("%s%s", err_level
[level
], message
);
125 if (level
== CE_PANIC
)