1 /* 2 * Copyright (c) 2006-2023, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 */ 9 10 #ifndef __PROC_H__ 11 #define __PROC_H__ 12 13 #include <dfs_file.h> 14 #include <dfs_seq_file.h> 15 #include <dfs_vfs.h> 16 17 #ifdef __cplusplus 18 extern "C" 19 { 20 #endif 21 22 struct proc_dentry; 23 24 struct proc_ops 25 { 26 struct proc_dentry *(*lookup)(struct proc_dentry *parent, const char *name); 27 int (*readlink)(struct proc_dentry *dentry, char *buf, int len); 28 }; 29 30 struct proc_dentry 31 { 32 rt_uint32_t mode; 33 rt_atomic_t ref_count; 34 35 struct proc_dentry *parent; 36 struct dfs_vfs_node node; 37 38 const struct dfs_file_ops *fops; 39 const struct proc_ops *ops; 40 const struct dfs_seq_ops *seq_ops; 41 int (*single_show)(struct dfs_seq_file *seq, void *data); 42 43 int pid; 44 45 char *name; 46 void *data; 47 }; 48 49 struct proc_dentry *dfs_proc_find(const char *name); 50 51 struct proc_dentry *proc_mkdir_data(const char *name, mode_t mode, struct proc_dentry *parent, 52 const struct dfs_file_ops *fops, void *data); 53 struct proc_dentry *proc_mkdir_mode(const char *name, mode_t mode, struct proc_dentry *parent); 54 struct proc_dentry *proc_mkdir(const char *name, struct proc_dentry *parent); 55 56 struct proc_dentry *proc_create_data(const char *name, mode_t mode, struct proc_dentry *parent, 57 const struct dfs_file_ops *fops, void *data); 58 struct proc_dentry *proc_create_single_data(const char *name, mode_t mode, struct proc_dentry *parent, 59 int (*show)(struct dfs_seq_file *, void *), void *data); 60 61 struct proc_dentry *proc_symlink(const char *name, struct proc_dentry *parent, const char *dest); 62 63 struct proc_dentry *proc_acquire(struct proc_dentry *dentry); 64 void proc_release(struct proc_dentry *dentry); 65 66 void proc_remove(struct proc_dentry *dentry); 67 void proc_remove_dentry(const char *name, struct proc_dentry *parent); 68 69 int proc_pid(int pid); 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif 76