/***************** * proc file system*****************/ (1) Characteristics of the /proc file system and description of /proc files The /proc file system is a special file system created by software. The kernel uses it to export information to the outside world. The /proc system only exists in memory and does not occupy external memory space. Each file under /proc is bound to a kernel function, which dynamically generates the file's contents when the user reads the file. You can also modify kernel parameters by writing /proc files File analysis under the /proc directory /proc/$pid Information directory about process $pid. Each process has a directory under /proc named after its process number. Example: $>strings -f /proc/[0-9]*/cmdline
(2) Implement a /proc file yourself The header file <linux/proc_fs.h> needs to be included, and the function is defined in /fs/proc/generic.c a. Create a file under /proc Call create_proc_read_entry to create a new file under /proc struct proc_dir_entry *create_proc_read_entry( const char *name, mode_t mode, struct proc_dir_entry *base, read_proc_t *read_proc, void * data) b. Uninstall files under /proc Use remove_proc_entry to uninstall proc files void remove_proc_entry( const char *name, struct proc_dir_entry *parent); c. Define a function that returns data When the process reads the /proc file, the kernel allocates a memory page (i.e. a memory block of PAGE_SIZE bytes), and the driver returns the data to be written to the user space through this memory page. typedef int (read_proc_t)(char *page, char **start, off_t off, int count, int *eof, void *data); Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: How to call the browser sharing function in Vue
>>: Detailed explanation of how to quickly operate MySQL database in nodejs environment
Table of contents 1. Current limiting algorithm 2...
Part 3: ❤Three ways to overlook backend data rece...
Preface: When you execute a SQL statement in MySQ...
Problem Description As we all know, the SQL to so...
Table of contents Preface Install Introduction Sw...
noscript definition and usage The noscript elemen...
Table of contents 1. Concept 1.1 What are errors ...
1. Introduction resolv.conf is the configuration ...
Use JS to implement object-oriented methods to ac...
Table of contents Environmental conditions Errors...
MySQL escape Escape means the original semantics ...
1. Find a suitable version of redis for docker Yo...
There are two ways to deploy Angular projects wit...
MySQL deployment Currently, the company deploys M...
This article example shares the specific code of ...