Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  *   Copyright (C) International Business Machines Corp., 2000-2004
  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 PROC_FS_JFS /* see jfs_debug.h */
 30 
 31 static struct proc_dir_entry *base;
 32 #ifdef CONFIG_JFS_DEBUG
 33 static int loglevel_read(char *page, char **start, off_t off,
 34                          int count, int *eof, void *data)
 35 {
 36         int len;
 37 
 38         len = sprintf(page, "%d\n", jfsloglevel);
 39 
 40         len -= off;
 41         *start = page + off;
 42 
 43         if (len > count)
 44                 len = count;
 45         else
 46                 *eof = 1;
 47 
 48         if (len < 0)
 49                 len = 0;
 50 
 51         return len;
 52 }
 53 
 54 static int loglevel_write(struct file *file, const char __user *buffer,
 55                         unsigned long count, void *data)
 56 {
 57         char c;
 58 
 59         if (get_user(c, buffer))
 60                 return -EFAULT;
 61 
 62         /* yes, I know this is an ASCIIism.  --hch */
 63         if (c < '' || c > '9')
 64                 return -EINVAL;
 65         jfsloglevel = c - '';
 66         return count;
 67 }
 68 #endif
 69 
 70 static struct {
 71         const char      *name;
 72         read_proc_t     *read_fn;
 73         write_proc_t    *write_fn;
 74 } Entries[] = {
 75 #ifdef CONFIG_JFS_STATISTICS
 76         { "lmstats",    jfs_lmstats_read, },
 77         { "txstats",    jfs_txstats_read, },
 78         { "xtstat",     jfs_xtstat_read, },
 79         { "mpstat",     jfs_mpstat_read, },
 80 #endif
 81 #ifdef CONFIG_JFS_DEBUG
 82         { "TxAnchor",   jfs_txanchor_read, },
 83         { "loglevel",   loglevel_read, loglevel_write }
 84 #endif
 85 };
 86 #define NPROCENT        ARRAY_SIZE(Entries)
 87 
 88 void jfs_proc_init(void)
 89 {
 90         int i;
 91 
 92         if (!(base = proc_mkdir("jfs", proc_root_fs)))
 93                 return;
 94         base->owner = THIS_MODULE;
 95 
 96         for (i = 0; i < NPROCENT; i++) {
 97                 struct proc_dir_entry *p;
 98                 if ((p = create_proc_entry(Entries[i].name, 0, base))) {
 99                         p->read_proc = Entries[i].read_fn;
100                         p->write_proc = Entries[i].write_fn;
101                 }
102         }
103 }
104 
105 void jfs_proc_clean(void)
106 {
107         int i;
108 
109         if (base) {
110                 for (i = 0; i < NPROCENT; i++)
111                         remove_proc_entry(Entries[i].name, base);
112                 remove_proc_entry("jfs", proc_root_fs);
113         }
114 }
115 
116 #endif /* PROC_FS_JFS */
117 
  This page was automatically generated by the LXR engine.