2121#include <linux/ctype.h>
2222#include <linux/module.h>
2323#include <linux/proc_fs.h>
24+ #include <linux/seq_file.h>
2425#include <asm/uaccess.h>
2526#include "jfs_incore.h"
2627#include "jfs_filsys.h"
3031
3132static struct proc_dir_entry * base ;
3233#ifdef CONFIG_JFS_DEBUG
33- static int loglevel_read (char * page , char * * start , off_t off ,
34- int count , int * eof , void * data )
34+ static int jfs_loglevel_proc_show (struct seq_file * m , void * v )
3535{
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 ;
36+ seq_printf (m , "%d\n" , jfsloglevel );
37+ return 0 ;
38+ }
5039
51- return len ;
40+ static int jfs_loglevel_proc_open (struct inode * inode , struct file * file )
41+ {
42+ return single_open (file , jfs_loglevel_proc_show , NULL );
5243}
5344
54- static int loglevel_write (struct file * file , const char __user * buffer ,
55- unsigned long count , void * data )
45+ static ssize_t jfs_loglevel_proc_write (struct file * file ,
46+ const char __user * buffer , size_t count , loff_t * ppos )
5647{
5748 char c ;
5849
@@ -65,22 +56,30 @@ static int loglevel_write(struct file *file, const char __user *buffer,
6556 jfsloglevel = c - '0' ;
6657 return count ;
6758}
59+
60+ static const struct file_operations jfs_loglevel_proc_fops = {
61+ .owner = THIS_MODULE ,
62+ .open = jfs_loglevel_proc_open ,
63+ .read = seq_read ,
64+ .llseek = seq_lseek ,
65+ .release = single_release ,
66+ .write = jfs_loglevel_proc_write ,
67+ };
6868#endif
6969
7070static struct {
7171 const char * name ;
72- read_proc_t * read_fn ;
73- write_proc_t * write_fn ;
72+ const struct file_operations * proc_fops ;
7473} Entries [] = {
7574#ifdef CONFIG_JFS_STATISTICS
76- { "lmstats" , jfs_lmstats_read , },
77- { "txstats" , jfs_txstats_read , },
78- { "xtstat" , jfs_xtstat_read , },
79- { "mpstat" , jfs_mpstat_read , },
75+ { "lmstats" , & jfs_lmstats_proc_fops , },
76+ { "txstats" , & jfs_txstats_proc_fops , },
77+ { "xtstat" , & jfs_xtstat_proc_fops , },
78+ { "mpstat" , & jfs_mpstat_proc_fops , },
8079#endif
8180#ifdef CONFIG_JFS_DEBUG
82- { "TxAnchor" , jfs_txanchor_read , },
83- { "loglevel" , loglevel_read , loglevel_write }
81+ { "TxAnchor" , & jfs_txanchor_proc_fops , },
82+ { "loglevel" , & jfs_loglevel_proc_fops }
8483#endif
8584};
8685#define NPROCENT ARRAY_SIZE(Entries)
@@ -93,13 +92,8 @@ void jfs_proc_init(void)
9392 return ;
9493 base -> owner = THIS_MODULE ;
9594
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- }
95+ for (i = 0 ; i < NPROCENT ; i ++ )
96+ proc_create (Entries [i ].name , 0 , base , Entries [i ].proc_fops );
10397}
10498
10599void jfs_proc_clean (void )
0 commit comments