?? proc_text
字號:
#define __NO_VERSION#define __KERNEL__#define MODULE#include <linux/kernel.h>#include <linux/module.h>#include <linux/sched.h>#include <linux/proc_fs.h>#include <asm/uaccess.h>#define STRINGLEN 1024#define NAMELEN 50#define IDLEN 10 struct person_information{ char name[NAMELEN]; char id[IDLEN]; }struct person_information global_buffer[STRINGLEN];struct proc_dir_entry *student_dir;int rec_count=0; int proc_read_information(char *page,char **start,off_t off,int count,int *eof, void *data){ int len=0; MOD_INC_USE_COUNT; int i=0; while(rec_count) { len=len+sprintf(page,"name is %s, id is %s \n",global_buffer[i].name, global_buffer[i].id`); i++; } MOD_DEC_USE_COUNT; return 0;} int proc_write_student(struct file *file,const char *buffer.unsigned long count, void *data){ int len=0; MOD_INC_COUNT; char op=fgetc(fp); if(op=='S') { count++; global_buffer[count].name=fgetc(fp); global_buffer[count].id=fgetc(fp); } else if(op=='D') { char name=fgetc(fp); char } } int init_module(){ example_dir=proc_mkdir("proc_text",NULL); example_dir->owner=THIS_MODULE; student_file=create_proc_entry("student",0644,example_dir); strcpy(global_buffer,"student"); student_file->read_proc=proc_read_student; student_file->write_proc=proc_write_student; student_file->owner=THIS_MODULE; return 0;}void cleanup_module(){ remove_proc_entry("student",example_dir); remove_proc_entry("proc_text",NULL);}MODULE_LICENSE("GPL");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -