0001
0002
0003
0004
0005
0006
0007 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0008 #include "debug.h"
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 void __ntfs_warning(const char *function, const struct super_block *sb,
0030 const char *fmt, ...)
0031 {
0032 struct va_format vaf;
0033 va_list args;
0034 int flen = 0;
0035
0036 #ifndef DEBUG
0037 if (!printk_ratelimit())
0038 return;
0039 #endif
0040 if (function)
0041 flen = strlen(function);
0042 va_start(args, fmt);
0043 vaf.fmt = fmt;
0044 vaf.va = &args;
0045 if (sb)
0046 pr_warn("(device %s): %s(): %pV\n",
0047 sb->s_id, flen ? function : "", &vaf);
0048 else
0049 pr_warn("%s(): %pV\n", flen ? function : "", &vaf);
0050 va_end(args);
0051 }
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 void __ntfs_error(const char *function, const struct super_block *sb,
0073 const char *fmt, ...)
0074 {
0075 struct va_format vaf;
0076 va_list args;
0077 int flen = 0;
0078
0079 #ifndef DEBUG
0080 if (!printk_ratelimit())
0081 return;
0082 #endif
0083 if (function)
0084 flen = strlen(function);
0085 va_start(args, fmt);
0086 vaf.fmt = fmt;
0087 vaf.va = &args;
0088 if (sb)
0089 pr_err("(device %s): %s(): %pV\n",
0090 sb->s_id, flen ? function : "", &vaf);
0091 else
0092 pr_err("%s(): %pV\n", flen ? function : "", &vaf);
0093 va_end(args);
0094 }
0095
0096 #ifdef DEBUG
0097
0098
0099 int debug_msgs = 0;
0100
0101 void __ntfs_debug(const char *file, int line, const char *function,
0102 const char *fmt, ...)
0103 {
0104 struct va_format vaf;
0105 va_list args;
0106 int flen = 0;
0107
0108 if (!debug_msgs)
0109 return;
0110 if (function)
0111 flen = strlen(function);
0112 va_start(args, fmt);
0113 vaf.fmt = fmt;
0114 vaf.va = &args;
0115 pr_debug("(%s, %d): %s(): %pV", file, line, flen ? function : "", &vaf);
0116 va_end(args);
0117 }
0118
0119
0120 void ntfs_debug_dump_runlist(const runlist_element *rl)
0121 {
0122 int i;
0123 const char *lcn_str[5] = { "LCN_HOLE ", "LCN_RL_NOT_MAPPED",
0124 "LCN_ENOENT ", "LCN_unknown " };
0125
0126 if (!debug_msgs)
0127 return;
0128 pr_debug("Dumping runlist (values in hex):\n");
0129 if (!rl) {
0130 pr_debug("Run list not present.\n");
0131 return;
0132 }
0133 pr_debug("VCN LCN Run length\n");
0134 for (i = 0; ; i++) {
0135 LCN lcn = (rl + i)->lcn;
0136
0137 if (lcn < (LCN)0) {
0138 int index = -lcn - 1;
0139
0140 if (index > -LCN_ENOENT - 1)
0141 index = 3;
0142 pr_debug("%-16Lx %s %-16Lx%s\n",
0143 (long long)(rl + i)->vcn, lcn_str[index],
0144 (long long)(rl + i)->length,
0145 (rl + i)->length ? "" :
0146 " (runlist end)");
0147 } else
0148 pr_debug("%-16Lx %-16Lx %-16Lx%s\n",
0149 (long long)(rl + i)->vcn,
0150 (long long)(rl + i)->lcn,
0151 (long long)(rl + i)->length,
0152 (rl + i)->length ? "" :
0153 " (runlist end)");
0154 if (!(rl + i)->length)
0155 break;
0156 }
0157 }
0158
0159 #endif