Can no longer be simplified
1#include <linux/module.h>2#include <linux/init.h>3 4#include <linux/seq_file.h>5#include <linux/fs.h>6#include <linux/proc_fs.h>7 void* Meng_seq_start (structseq_file*s,loff_t*POS)8 {9 if(*pos>1)Ten returnNULL; One returnPos; A } - - void* Meng_seq_next (structSeq_file*s,void*v,loff_t*POS) the { -(*pos) + +; - if(*pos>1) - returnNULL; + returnPos; - } + A voidMeng_seq_stop (structSeq_file*s,void*v) at { - } - Char*meng_seq_data[2]={"hello.\n","This meng seq proc file.\n"}; - - intMeng_seq_show (structSeq_file*s,void*v) - { inseq_printf (s,meng_seq_data[* (int*) (v)]); - return 0; to } + structSeq_operations meng_seq_ops={ -. start=Meng_seq_start, the. next=Meng_seq_next, *. stop=Meng_seq_stop, $. show=Meng_seq_showPanax Notoginseng }; - intMeng_seq_proc_seq_open (structInode*inode,structfile*file) the { + returnSeq_open (file,&meng_seq_ops); A } the + structFile_operations meng_seq_proc_ops= - { $. owner=This_module, $. open=Meng_seq_proc_seq_open, -. read=Seq_read, -. llseek=Seq_lseek, the. release=Seq_release - };Wuyi the - Wu intMeng_seq_proc_init (void) - { About structProc_dir_entry *entry=create_proc_entry ("Mengprocseq",0, NULL); $ if(Entry) -entry->proc_fops=&Meng_seq_proc_ops; - return 0; - } A + the voidMeng_seq_proc_exit (void) - { $Remove_proc_entry ("Mengprocseq", NULL); the } the the Module_init (meng_seq_proc_init); theModule_exit (Meng_seq_proc_exit);