/***************** * 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
Intersection Selector The intersection selector i...
We deal with Linux servers every day, especially ...
Table of contents Written in front Two-way encryp...
I see many novice students doing front-end develop...
Table of contents 1. Knowledge description of the...
I just bought an Alibaba Cloud host and couldn’t ...
SQL (Structured Query Language) statement, that i...
After installing Navicat The following error may ...
The first tutorial for installing MySQL-5.7.19 ve...
1. Introduction MySQL Group Replication (MGR for ...
1. What is a calculated attribute? In plain words...
illustrate In front-end development, you often en...
First, let’s take a look at a CSS carousel animat...
1. useState: Let functional components have state...
A Thorough Analysis of HTML (14) Special Characte...