Proc-fs programming and proc-fs Programming

Source: Internet
Author: User

Proc-fs programming and proc-fs Programming

I. Introduction

The Proc file system is a pseudo-File System (Virtual File System) on Linux. It stores a series of special files in the running status of the current kernel, you can use these files to view the system hardware and currently running processes, or even change the running status of the kernel by changing some of these files.

Based on the particularity described above in the/proc file system, the files in it are also called virtual files and have some unique characteristics. To facilitate viewing and usage, these files are usually stored in different directories and even subdirectories by relevance, for example, the/proc/scsi directory stores information about all SCSI devices in the current system, and the/proc/N stores information about the processes currently running in the system, where N is a running process (as you can imagine, the related directory will disappear after a process ends ).


 Ii. API

http://oss.org.cn/ossdocs/gnu_linux/kernel-api/

1. add or delete directories or files of the basic proc file system

struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, struct proc_dir_entry *parent);struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, struct proc_dir_entry *parent);struct proc_dir_entry *proc_create(const char *name, mode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops)struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops, void *data);void remove_proc_entry(const char *name, struct proc_dir_entry *parent);

2. Add special proc files

1)/proc/net/

struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, struct proc_dir_entry *parent);void proc_net_remove(struct net *net, const char *name);struct proc_dir_entry *proc_net_fops_create(struct net *net, const char *name, mode_t mode, const struct file_operations *fops);

2)/proc/sys/

 

Iii. Instances

http://www.mamicode.com/info-detail-96547.html

 

Reference: http://www.chinaitlab.com/linux/administer/889804.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.