Proc file system concept
Proc is a virtual file system used for Linux kernel space and user space communication. In Linux, Proc is not alone,SysfsIs a file system similar to/proc. It appears after proc, so it improves proc's disadvantages.
struct proc_dir_entry {const char *name;// virtual file namemode_t mode;// mode permissionsuid_t uid;// File's user idgid_t gid;// File's group idstruct inode_operations *proc_iops;// Inode operations functionsstruct file_operations *proc_fops;// File operations functionsstruct proc_dir_entry *parent;// Parent directory...read_proc_t *read_proc;// /proc read functionwrite_proc_t *write_proc;// /proc write functionvoid *data;// Pointer to private dataatomic_t count;// use count...};
struct proc_dir_entry *create_proc_entry( const char *name, mode_t mode, struct proc_dir_entry *parent );void remove_proc_entry( const char *name, struct proc_dir_entry *parent );
The parent parameter can be null (indicating the/proc root directory) or many other values, depending on where we want to put the file.
The following lists some other parent nodes that can be used.proc_dir_entry
And their location in the file system.
Proc_dir_entry |
Location in the file system |
proc_root_fs |
/proc |
proc_net |
/proc/net |
proc_bus |
/proc/bus |
proc_root_driver |
/* Create a directory in the proc filesystem */struct proc_dir_entry *proc_mkdir( const char *name, struct proc_dir_entry *parent );/* Create a symlink in the proc filesystem */struct proc_dir_entry *proc_symlink( const char *name, struct proc_dir_entry *parent, const char *dest );/* Create a proc_dir_entry with a read_proc_t in one call */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 ); |
The preceding editing is from the following URL:
Http://www.ibm.com/developerworks/cn/linux/l-proc.html