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 /* xfs_mount.h drags a lot of crap in, sorry.. */
25 #include "xfs_dmapi.h"
26 #include "xfs_mount.h"
28 static char message
[1024]; /* keep it off the stack */
29 static DEFINE_SPINLOCK(xfs_err_lock
);
31 /* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */
32 #define XFS_MAX_ERR_LEVEL 7
33 #define XFS_ERR_MASK ((1 << 3) - 1)
34 static const char * const err_level
[XFS_MAX_ERR_LEVEL
+1] =
35 {KERN_EMERG
, KERN_ALERT
, KERN_CRIT
,
36 KERN_ERR
, KERN_WARNING
, KERN_NOTICE
,
37 KERN_INFO
, KERN_DEBUG
};
40 cmn_err(register int level
, char *fmt
, ...)
47 level
&= XFS_ERR_MASK
;
48 if (level
> XFS_MAX_ERR_LEVEL
)
49 level
= XFS_MAX_ERR_LEVEL
;
50 spin_lock_irqsave(&xfs_err_lock
,flags
);
52 if (*fmt
== '!') fp
++;
53 len
= vsnprintf(message
, sizeof(message
), fp
, ap
);
54 if (len
>= sizeof(message
))
55 len
= sizeof(message
) - 1;
56 if (message
[len
-1] == '\n')
58 printk("%s%s\n", err_level
[level
], message
);
60 spin_unlock_irqrestore(&xfs_err_lock
,flags
);
61 BUG_ON(level
== CE_PANIC
);
74 level
&= XFS_ERR_MASK
;
75 if (level
> XFS_MAX_ERR_LEVEL
)
76 level
= XFS_MAX_ERR_LEVEL
;
78 spin_lock_irqsave(&xfs_err_lock
,flags
);
81 len
= sprintf(message
, "Filesystem \"%s\": ", mp
->m_fsname
);
84 * Skip the printk if we can't print anything useful
85 * due to an over-long device name.
87 if (len
>= sizeof(message
))
91 len
= vsnprintf(message
+ len
, sizeof(message
) - len
, fmt
, ap
);
92 if (len
>= sizeof(message
))
93 len
= sizeof(message
) - 1;
94 if (message
[len
-1] == '\n')
97 printk("%s%s\n", err_level
[level
], message
);
99 spin_unlock_irqrestore(&xfs_err_lock
,flags
);
101 BUG_ON(level
== CE_PANIC
);
105 assfail(char *expr
, char *file
, int line
)
107 printk("Assertion failed: %s, file: %s, line: %d\n", expr
, file
, line
);
112 xfs_hex_dump(void *p
, int length
)
114 print_hex_dump(KERN_ALERT
, "", DUMP_PREFIX_ADDRESS
, 16, 1, p
, length
, 1);