⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proc_text

📁 实现模块的加载等实现。在LINUX操作系统下实现 操作系统实验程序之一
💻
字号:
#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 + -