1 /** 2 * debug.c - Debugging output functions. Originated from the Linux-NTFS project. 3 * 4 * Copyright (c) 2002-2004 Anton Altaparmakov 5 * Copyright (c) 2004-2006 Szabolcs Szakacsits 6 * 7 * This program/include file is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as published 9 * by the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program/include file is distributed in the hope that it will be 13 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program (in the main directory of the NTFS-3G 19 * distribution in the file COPYING); if not, write to the Free Software 20 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 22 23 #ifdef HAVE_CONFIG_H 24 #include "config.h" 25 #endif 26 27 #ifdef HAVE_ERRNO_H 28 #include <errno.h> 29 #endif 30 31 #include "types.h" 32 #include "runlist.h" 33 #include "debug.h" 34 #include "logging.h" 35 36 #ifdef DEBUG 37 /** 38 * ntfs_debug_runlist_dump - Dump a runlist. 39 * @rl: 40 * 41 * Description... 42 * 43 * Returns: 44 */ 45 void ntfs_debug_runlist_dump(const runlist_element *rl) 46 { 47 int i = 0; 48 const char *lcn_str[5] = { "LCN_HOLE ", "LCN_RL_NOT_MAPPED", 49 "LCN_ENOENT ", "LCN_EINVAL ", 50 "LCN_unknown " }; 51 52 ntfs_log_debug("NTFS-fs DEBUG: Dumping runlist (values in hex):\n"); 53 if (!rl) { 54 ntfs_log_debug("Run list not present.\n"); 55 return; 56 } 57 ntfs_log_debug("VCN LCN Run length\n"); 58 do { 59 LCN lcn = (rl + i)->lcn; 60 61 if (lcn < (LCN)0) { 62 int idx = -lcn - 1; 63 64 if (idx > -LCN_EINVAL - 1) 65 idx = 4; 66 ntfs_log_debug("%-16lld %s %-16lld%s\n", 67 (long long)rl[i].vcn, lcn_str[idx], 68 (long long)rl[i].length, 69 rl[i].length ? "" : " (runlist end)"); 70 } else 71 ntfs_log_debug("%-16lld %-16lld %-16lld%s\n", 72 (long long)rl[i].vcn, (long long)rl[i].lcn, 73 (long long)rl[i].length, 74 rl[i].length ? "" : " (runlist end)"); 75 } while (rl[i++].length); 76 } 77 78 #endif 79 80