The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/jfs/jfs_debug.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  *   Copyright (c) International Business Machines Corp., 2000-2002
    3  *   Portions Copyright (c) Christoph Hellwig, 2001-2002
    4  *
    5  *   This program is free software;  you can redistribute it and/or modify
    6  *   it under the terms of the GNU General Public License as published by
    7  *   the Free Software Foundation; either version 2 of the License, or 
    8  *   (at your option) any later version.
    9  * 
   10  *   This program is distributed in the hope that it will be useful,
   11  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
   12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
   13  *   the GNU General Public License for more details.
   14  *
   15  *   You should have received a copy of the GNU General Public License
   16  *   along with this program;  if not, write to the Free Software 
   17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   18  */
   19 
   20 #include <linux/fs.h>
   21 #include <linux/ctype.h>
   22 #include <linux/module.h>
   23 #include <linux/proc_fs.h>
   24 #include <asm/uaccess.h>
   25 #include "jfs_incore.h"
   26 #include "jfs_filsys.h"
   27 #include "jfs_debug.h"
   28 
   29 #ifdef CONFIG_JFS_DEBUG
   30 void dump_mem(char *label, void *data, int length)
   31 {
   32         int i, j;
   33         int *intptr = data;
   34         char *charptr = data;
   35         char buf[10], line[80];
   36 
   37         printk("%s: dump of %d bytes of data at 0x%p\n\n", label, length,
   38                data);
   39         for (i = 0; i < length; i += 16) {
   40                 line[0] = 0;
   41                 for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
   42                         sprintf(buf, " %08x", intptr[i / 4 + j]);
   43                         strcat(line, buf);
   44                 }
   45                 buf[0] = ' ';
   46                 buf[2] = 0;
   47                 for (j = 0; (j < 16) && (i + j < length); j++) {
   48                         buf[1] =
   49                             isprint(charptr[i + j]) ? charptr[i + j] : '.';
   50                         strcat(line, buf);
   51                 }
   52                 printk("%s\n", line);
   53         }
   54 }
   55 #endif
   56 
   57 #ifdef PROC_FS_JFS /* see jfs_debug.h */
   58 
   59 static struct proc_dir_entry *base;
   60 #ifdef CONFIG_JFS_DEBUG
   61 extern read_proc_t jfs_txanchor_read;
   62 
   63 static int loglevel_read(char *page, char **start, off_t off,
   64                          int count, int *eof, void *data)
   65 {
   66         int len;
   67 
   68         len = sprintf(page, "%d\n", jfsloglevel);
   69 
   70         len -= off;
   71         *start = page + off;
   72 
   73         if (len > count)
   74                 len = count;
   75         else
   76                 *eof = 1;
   77 
   78         if (len < 0)
   79                 len = 0;
   80 
   81         return len;
   82 }
   83 
   84 static int loglevel_write(struct file *file, const char *buffer,
   85                         unsigned long count, void *data)
   86 {
   87         char c;
   88 
   89         if (get_user(c, buffer))
   90                 return -EFAULT;
   91 
   92         /* yes, I know this is an ASCIIism.  --hch */
   93         if (c < '' || c > '9')
   94                 return -EINVAL;
   95         jfsloglevel = c - '';
   96         return count;
   97 }
   98 #endif
   99 
  100 
  101 #ifdef CONFIG_JFS_STATISTICS
  102 extern read_proc_t jfs_lmstats_read;
  103 extern read_proc_t jfs_txstats_read;
  104 extern read_proc_t jfs_xtstat_read;
  105 extern read_proc_t jfs_mpstat_read;
  106 #endif
  107 
  108 static struct {
  109         const char      *name;
  110         read_proc_t     *read_fn;
  111         write_proc_t    *write_fn;
  112 } Entries[] = {
  113 #ifdef CONFIG_JFS_STATISTICS
  114         { "lmstats",    jfs_lmstats_read, },
  115         { "txstats",    jfs_txstats_read, },
  116         { "xtstat",     jfs_xtstat_read, },
  117         { "mpstat",     jfs_mpstat_read, },
  118 #endif
  119 #ifdef CONFIG_JFS_DEBUG
  120         { "TxAnchor",   jfs_txanchor_read, },
  121         { "loglevel",   loglevel_read, loglevel_write }
  122 #endif
  123 };
  124 #define NPROCENT        (sizeof(Entries)/sizeof(Entries[0]))
  125 
  126 void jfs_proc_init(void)
  127 {
  128         int i;
  129 
  130         if (!(base = proc_mkdir("jfs", proc_root_fs)))
  131                 return;
  132         base->owner = THIS_MODULE;
  133 
  134         for (i = 0; i < NPROCENT; i++) {
  135                 struct proc_dir_entry *p;
  136                 if ((p = create_proc_entry(Entries[i].name, 0, base))) {
  137                         p->read_proc = Entries[i].read_fn;
  138                         p->write_proc = Entries[i].write_fn;
  139                 }
  140         }
  141 }
  142 
  143 void jfs_proc_clean(void)
  144 {
  145         int i;
  146 
  147         if (base) {
  148                 for (i = 0; i < NPROCENT; i++)
  149                         remove_proc_entry(Entries[i].name, base);
  150                 remove_proc_entry("jfs", base);
  151         }
  152 }
  153 
  154 #endif /* PROC_FS_JFS */

Cache object: 8bb42bf13a837ef268ea0fc6fcfb4327


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.