2 * debug.c - NTFS kernel debug support. Part of the Linux-NTFS project.
4 * Copyright (c) 2001-2004 Anton Altaparmakov
6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program/include file is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program (in the main directory of the Linux-NTFS
18 * distribution in the file COPYING); if not, write to the Free Software
19 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 * __ntfs_warning - output a warning to the syslog
26 * @function: name of function outputting the warning
27 * @sb: super block of mounted ntfs filesystem
28 * @fmt: warning string containing format specifications
29 * @...: a variable number of arguments specified in @fmt
31 * Outputs a warning to the syslog for the mounted ntfs filesystem described
34 * @fmt and the corresponding @... is printf style format string containing
35 * the warning string and the corresponding format arguments, respectively.
37 * @function is the name of the function from which __ntfs_warning is being
40 * Note, you should be using debug.h::ntfs_warning(@sb, @fmt, @...) instead
41 * as this provides the @function parameter automatically.
43 void __ntfs_warning(const char *function
, const struct super_block
*sb
,
51 if (!printk_ratelimit())
55 flen
= strlen(function
);
60 pr_warn("(device %s): %s(): %pV\n",
61 sb
->s_id
, flen
? function
: "", &vaf
);
63 pr_warn("%s(): %pV\n", flen
? function
: "", &vaf
);
68 * __ntfs_error - output an error to the syslog
69 * @function: name of function outputting the error
70 * @sb: super block of mounted ntfs filesystem
71 * @fmt: error string containing format specifications
72 * @...: a variable number of arguments specified in @fmt
74 * Outputs an error to the syslog for the mounted ntfs filesystem described
77 * @fmt and the corresponding @... is printf style format string containing
78 * the error string and the corresponding format arguments, respectively.
80 * @function is the name of the function from which __ntfs_error is being
83 * Note, you should be using debug.h::ntfs_error(@sb, @fmt, @...) instead
84 * as this provides the @function parameter automatically.
86 void __ntfs_error(const char *function
, const struct super_block
*sb
,
94 if (!printk_ratelimit())
98 flen
= strlen(function
);
103 pr_err("(device %s): %s(): %pV\n",
104 sb
->s_id
, flen
? function
: "", &vaf
);
106 pr_err("%s(): %pV\n", flen
? function
: "", &vaf
);
112 /* If 1, output debug messages, and if 0, don't. */
115 void __ntfs_debug(const char *file
, int line
, const char *function
,
116 const char *fmt
, ...)
118 struct va_format vaf
;
125 flen
= strlen(function
);
129 pr_debug("(%s, %d): %s(): %pV", file
, line
, flen
? function
: "", &vaf
);
133 /* Dump a runlist. Caller has to provide synchronisation for @rl. */
134 void ntfs_debug_dump_runlist(const runlist_element
*rl
)
137 const char *lcn_str
[5] = { "LCN_HOLE ", "LCN_RL_NOT_MAPPED",
138 "LCN_ENOENT ", "LCN_unknown " };
142 pr_debug("Dumping runlist (values in hex):\n");
144 pr_debug("Run list not present.\n");
147 pr_debug("VCN LCN Run length\n");
149 LCN lcn
= (rl
+ i
)->lcn
;
152 int index
= -lcn
- 1;
154 if (index
> -LCN_ENOENT
- 1)
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
? "" :
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
? "" :
168 if (!(rl
+ i
)->length
)