http://linux-ntfs.sourceforge.net/snapshots/ntfsprogs-200307311516.tar.bz2
[ntfsprogs.git] / libntfs / debug.c
1 /*
2  * debug.c - Debugging output functions. Part of the Linux-NTFS project.
3  *
4  * Copyright (c) 2002 Anton Altaparmakov
5  *
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.
10  *
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.
15  *
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
20  */
21
22 #include "debug.h"
23
24 #ifdef DEBUG
25 /**
26  * ntfs_debug_runlist_dump - Dump a runlist.
27  */
28 void ntfs_debug_runlist_dump(const runlist_element *rl)
29 {
30         int i = 0;
31         const char *lcn_str[5] = { "LCN_HOLE         ", "LCN_RL_NOT_MAPPED",
32                                    "LCN_ENOENT       ", "LCN_EINVAL       ",
33                                    "LCN_unknown      " };
34
35         Dputs("NTFS-fs DEBUG: Dumping runlist (values in hex):");
36         if (!rl) {
37                 Dputs("Run list not present.");
38                 return;
39         }
40         Dputs("VCN              LCN               Run length");
41         do {
42                 LCN lcn = (rl + i)->lcn;
43
44                 if (lcn < (LCN)0) {
45                         int index = -lcn - 1;
46
47                         if (index > -LCN_EINVAL - 1)
48                                 index = 4;
49                         Dprintf("%-16Lx %s %-16Lx%s\n", rl[i].vcn,
50                                         lcn_str[index], rl[i].length,
51                                         rl[i].length ? "" : " (runlist end)");
52                 } else
53                         Dprintf("%-16Lx %-16Lx  %-16Lx%s\n", rl[i].vcn,
54                                         rl[i].lcn, rl[i].length,
55                                         rl[i].length ? "" : " (runlist end)");
56         } while (rl[i++].length);
57 }
58
59 #endif
60