debug.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. *
  4. * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
  5. *
  6. * Useful functions for debugging.
  7. *
  8. */
  9. // clang-format off
  10. #ifndef _LINUX_NTFS3_DEBUG_H
  11. #define _LINUX_NTFS3_DEBUG_H
  12. struct super_block;
  13. struct inode;
  14. #ifndef Add2Ptr
  15. #define Add2Ptr(P, I) ((void *)((u8 *)(P) + (I)))
  16. #define PtrOffset(B, O) ((size_t)((size_t)(O) - (size_t)(B)))
  17. #endif
  18. #ifdef CONFIG_PRINTK
  19. __printf(2, 3)
  20. void ntfs_printk(const struct super_block *sb, const char *fmt, ...);
  21. __printf(2, 3)
  22. void ntfs_inode_printk(struct inode *inode, const char *fmt, ...);
  23. #else
  24. static inline __printf(2, 3)
  25. void ntfs_printk(const struct super_block *sb, const char *fmt, ...)
  26. {
  27. }
  28. static inline __printf(2, 3)
  29. void ntfs_inode_printk(struct inode *inode, const char *fmt, ...)
  30. {
  31. }
  32. #endif
  33. /*
  34. * Logging macros. Thanks Joe Perches <joe@perches.com> for implementation.
  35. */
  36. #define ntfs_err(sb, fmt, ...) ntfs_printk(sb, KERN_ERR fmt, ##__VA_ARGS__)
  37. #define ntfs_warn(sb, fmt, ...) ntfs_printk(sb, KERN_WARNING fmt, ##__VA_ARGS__)
  38. #define ntfs_info(sb, fmt, ...) ntfs_printk(sb, KERN_INFO fmt, ##__VA_ARGS__)
  39. #define ntfs_notice(sb, fmt, ...) \
  40. ntfs_printk(sb, KERN_NOTICE fmt, ##__VA_ARGS__)
  41. #define ntfs_inode_err(inode, fmt, ...) \
  42. ntfs_inode_printk(inode, KERN_ERR fmt, ##__VA_ARGS__)
  43. #define ntfs_inode_warn(inode, fmt, ...) \
  44. ntfs_inode_printk(inode, KERN_WARNING fmt, ##__VA_ARGS__)
  45. #endif /* _LINUX_NTFS3_DEBUG_H */
  46. // clang-format on