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