debug.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  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.
  8. *
  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.
  13. *
  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
  17. */
  18. #include <xfs.h>
  19. #include "debug.h"
  20. /* xfs_mount.h drags a lot of crap in, sorry.. */
  21. #include "xfs_sb.h"
  22. #include "xfs_inum.h"
  23. #include "xfs_ag.h"
  24. #include "xfs_mount.h"
  25. #include "xfs_error.h"
  26. void
  27. cmn_err(
  28. const char *lvl,
  29. const char *fmt,
  30. ...)
  31. {
  32. struct va_format vaf;
  33. va_list args;
  34. va_start(args, fmt);
  35. vaf.fmt = fmt;
  36. vaf.va = &args;
  37. printk("%s%pV", lvl, &vaf);
  38. va_end(args);
  39. BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0);
  40. }
  41. void
  42. xfs_fs_cmn_err(
  43. const char *lvl,
  44. struct xfs_mount *mp,
  45. const char *fmt,
  46. ...)
  47. {
  48. struct va_format vaf;
  49. va_list args;
  50. va_start(args, fmt);
  51. vaf.fmt = fmt;
  52. vaf.va = &args;
  53. printk("%sFilesystem %s: %pV", lvl, mp->m_fsname, &vaf);
  54. va_end(args);
  55. BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0);
  56. }
  57. void
  58. assfail(char *expr, char *file, int line)
  59. {
  60. printk(KERN_CRIT "Assertion failed: %s, file: %s, line: %d\n", expr,
  61. file, line);
  62. BUG();
  63. }
  64. void
  65. xfs_hex_dump(void *p, int length)
  66. {
  67. print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_ADDRESS, 16, 1, p, length, 1);
  68. }