misc.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/kernel.h>
  3. #include "ubifs.h"
  4. /* Normal UBIFS messages */
  5. void ubifs_msg(const struct ubifs_info *c, const char *fmt, ...)
  6. {
  7. struct va_format vaf;
  8. va_list args;
  9. va_start(args, fmt);
  10. vaf.fmt = fmt;
  11. vaf.va = &args;
  12. pr_notice("UBIFS (ubi%d:%d): %pV\n",
  13. c->vi.ubi_num, c->vi.vol_id, &vaf);
  14. va_end(args);
  15. } \
  16. /* UBIFS error messages */
  17. void ubifs_err(const struct ubifs_info *c, const char *fmt, ...)
  18. {
  19. struct va_format vaf;
  20. va_list args;
  21. va_start(args, fmt);
  22. vaf.fmt = fmt;
  23. vaf.va = &args;
  24. pr_err("UBIFS error (ubi%d:%d pid %d): %ps: %pV\n",
  25. c->vi.ubi_num, c->vi.vol_id, current->pid,
  26. __builtin_return_address(0),
  27. &vaf);
  28. va_end(args);
  29. } \
  30. /* UBIFS warning messages */
  31. void ubifs_warn(const struct ubifs_info *c, const char *fmt, ...)
  32. {
  33. struct va_format vaf;
  34. va_list args;
  35. va_start(args, fmt);
  36. vaf.fmt = fmt;
  37. vaf.va = &args;
  38. pr_warn("UBIFS warning (ubi%d:%d pid %d): %ps: %pV\n",
  39. c->vi.ubi_num, c->vi.vol_id, current->pid,
  40. __builtin_return_address(0),
  41. &vaf);
  42. va_end(args);
  43. }
  44. static char *assert_names[] = {
  45. [ASSACT_REPORT] = "report",
  46. [ASSACT_RO] = "read-only",
  47. [ASSACT_PANIC] = "panic",
  48. };
  49. const char *ubifs_assert_action_name(struct ubifs_info *c)
  50. {
  51. return assert_names[c->assert_action];
  52. }