1 /**
   2  * debug.c - Debugging output functions. Part of the Linux-NTFS project.
   3  *
   4  * Copyright (c) 2002-2004 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 #ifdef HAVE_CONFIG_H
  23 #include "config.h"
  24 #endif
  25 
  26 #ifdef HAVE_ERRNO_H
  27 #include <errno.h>
  28 #endif
  29 
  30 #include "compat.h"
  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("%-16llx %s %-16llx%s\n", rl[i].vcn, lcn_str[idx], rl[i].length, rl[i].length ? "" : " (runlist end)");
  67                 } else
  68                         ntfs_log_debug("%-16llx %-16llx  %-16llx%s\n", rl[i].vcn, rl[i].lcn, rl[i].length, rl[i].length ? "" : " (runlist end)");
  69         } while (rl[i++].length);
  70 }
  71 
  72 #endif
  73