debug.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * linux/fs/9p/debug.h - V9FS Debug Definitions
  3. *
  4. * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
  5. * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to:
  19. * Free Software Foundation
  20. * 51 Franklin Street, Fifth Floor
  21. * Boston, MA 02111-1301 USA
  22. *
  23. */
  24. #define DEBUG_ERROR (1<<0)
  25. #define DEBUG_CURRENT (1<<1)
  26. #define DEBUG_9P (1<<2)
  27. #define DEBUG_VFS (1<<3)
  28. #define DEBUG_CONV (1<<4)
  29. #define DEBUG_MUX (1<<5)
  30. #define DEBUG_TRANS (1<<6)
  31. #define DEBUG_SLABS (1<<7)
  32. #define DEBUG_FCALL (1<<8)
  33. #define DEBUG_DUMP_PKT 0
  34. extern int v9fs_debug_level;
  35. #define dprintk(level, format, arg...) \
  36. do { \
  37. if((v9fs_debug_level & level)==level) \
  38. printk(KERN_NOTICE "-- %s (%d): " \
  39. format , __FUNCTION__, current->pid , ## arg); \
  40. } while(0)
  41. #define eprintk(level, format, arg...) \
  42. do { \
  43. printk(level "v9fs: %s (%d): " \
  44. format , __FUNCTION__, current->pid , ## arg); \
  45. } while(0)
  46. #if DEBUG_DUMP_PKT
  47. static inline void dump_data(const unsigned char *data, unsigned int datalen)
  48. {
  49. int i, n;
  50. char buf[5*8];
  51. n = 0;
  52. i = 0;
  53. while (i < datalen) {
  54. n += snprintf(buf+n, sizeof(buf)-n, "%02x", data[i++]);
  55. if (i%4 == 0)
  56. n += snprintf(buf+n, sizeof(buf)-n, " ");
  57. if (i%16 == 0) {
  58. dprintk(DEBUG_ERROR, "%s\n", buf);
  59. n = 0;
  60. }
  61. }
  62. dprintk(DEBUG_ERROR, "%s\n", buf);
  63. }
  64. #else /* DEBUG_DUMP_PKT */
  65. static inline void dump_data(const unsigned char *data, unsigned int datalen)
  66. {
  67. }
  68. #endif /* DEBUG_DUMP_PKT */