1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22#include "debug.h"
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43void __ntfs_warning(const char *function, const struct super_block *sb,
44 const char *fmt, ...)
45{
46 struct va_format vaf;
47 va_list args;
48 int flen = 0;
49
50#ifndef DEBUG
51 if (!printk_ratelimit())
52 return;
53#endif
54 if (function)
55 flen = strlen(function);
56 va_start(args, fmt);
57 vaf.fmt = fmt;
58 vaf.va = &args;
59 if (sb)
60 pr_warn("(device %s): %s(): %pV\n",
61 sb->s_id, flen ? function : "", &vaf);
62 else
63 pr_warn("%s(): %pV\n", flen ? function : "", &vaf);
64 va_end(args);
65}
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86void __ntfs_error(const char *function, const struct super_block *sb,
87 const char *fmt, ...)
88{
89 struct va_format vaf;
90 va_list args;
91 int flen = 0;
92
93#ifndef DEBUG
94 if (!printk_ratelimit())
95 return;
96#endif
97 if (function)
98 flen = strlen(function);
99 va_start(args, fmt);
100 vaf.fmt = fmt;
101 vaf.va = &args;
102 if (sb)
103 pr_err("(device %s): %s(): %pV\n",
104 sb->s_id, flen ? function : "", &vaf);
105 else
106 pr_err("%s(): %pV\n", flen ? function : "", &vaf);
107 va_end(args);
108}
109
110#ifdef DEBUG
111
112
113int debug_msgs = 0;
114
115void __ntfs_debug(const char *file, int line, const char *function,
116 const char *fmt, ...)
117{
118 struct va_format vaf;
119 va_list args;
120 int flen = 0;
121
122 if (!debug_msgs)
123 return;
124 if (function)
125 flen = strlen(function);
126 va_start(args, fmt);
127 vaf.fmt = fmt;
128 vaf.va = &args;
129 pr_debug("(%s, %d): %s(): %pV", file, line, flen ? function : "", &vaf);
130 va_end(args);
131}
132
133
134void ntfs_debug_dump_runlist(const runlist_element *rl)
135{
136 int i;
137 const char *lcn_str[5] = { "LCN_HOLE ", "LCN_RL_NOT_MAPPED",
138 "LCN_ENOENT ", "LCN_unknown " };
139
140 if (!debug_msgs)
141 return;
142 pr_debug("Dumping runlist (values in hex):\n");
143 if (!rl) {
144 pr_debug("Run list not present.\n");
145 return;
146 }
147 pr_debug("VCN LCN Run length\n");
148 for (i = 0; ; i++) {
149 LCN lcn = (rl + i)->lcn;
150
151 if (lcn < (LCN)0) {
152 int index = -lcn - 1;
153
154 if (index > -LCN_ENOENT - 1)
155 index = 3;
156 pr_debug("%-16Lx %s %-16Lx%s\n",
157 (long long)(rl + i)->vcn, lcn_str[index],
158 (long long)(rl + i)->length,
159 (rl + i)->length ? "" :
160 " (runlist end)");
161 } else
162 pr_debug("%-16Lx %-16Lx %-16Lx%s\n",
163 (long long)(rl + i)->vcn,
164 (long long)(rl + i)->lcn,
165 (long long)(rl + i)->length,
166 (rl + i)->length ? "" :
167 " (runlist end)");
168 if (!(rl + i)->length)
169 break;
170 }
171}
172
173#endif
174