debug.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. /* All callers to xfs_cmn_err use CE_ALERT, so don't bother testing lvl */
  58. void
  59. xfs_cmn_err(
  60. int panic_tag,
  61. const char *lvl,
  62. struct xfs_mount *mp,
  63. const char *fmt,
  64. ...)
  65. {
  66. struct va_format vaf;
  67. va_list args;
  68. int do_panic = 0;
  69. if (xfs_panic_mask && (xfs_panic_mask & panic_tag)) {
  70. printk(KERN_ALERT "XFS: Transforming an alert into a BUG.");
  71. do_panic = 1;
  72. }
  73. va_start(args, fmt);
  74. vaf.fmt = fmt;
  75. vaf.va = &args;
  76. printk(KERN_ALERT "Filesystem %s: %pV", mp->m_fsname, &vaf);
  77. va_end(args);
  78. BUG_ON(do_panic);
  79. }
  80. void
  81. assfail(char *expr, char *file, int line)
  82. {
  83. printk(KERN_CRIT "Assertion failed: %s, file: %s, line: %d\n", expr,
  84. file, line);
  85. BUG();
  86. }
  87. void
  88. xfs_hex_dump(void *p, int length)
  89. {
  90. print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_ADDRESS, 16, 1, p, length, 1);
  91. }