proc.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef __PROC_H__
  10. #define __PROC_H__
  11. #include <dfs_file.h>
  12. #include <dfs_seq_file.h>
  13. #include <dfs_vfs.h>
  14. #ifdef __cplusplus
  15. extern "C"
  16. {
  17. #endif
  18. struct proc_dentry;
  19. struct proc_ops
  20. {
  21. struct proc_dentry *(*lookup)(struct proc_dentry *parent, const char *name);
  22. int (*readlink)(struct proc_dentry *dentry, char *buf, int len);
  23. };
  24. struct proc_dentry
  25. {
  26. rt_uint32_t mode;
  27. rt_atomic_t ref_count;
  28. struct proc_dentry *parent;
  29. struct dfs_vfs_node node;
  30. const struct dfs_file_ops *fops;
  31. const struct proc_ops *ops;
  32. const struct dfs_seq_ops *seq_ops;
  33. int (*single_show)(struct dfs_seq_file *seq, void *data);
  34. int pid;
  35. char *name;
  36. void *data;
  37. };
  38. struct proc_dentry *dfs_proc_find(const char *name);
  39. struct proc_dentry *proc_mkdir_data(const char *name, mode_t mode, struct proc_dentry *parent,
  40. const struct dfs_file_ops *fops, void *data);
  41. struct proc_dentry *proc_mkdir_mode(const char *name, mode_t mode, struct proc_dentry *parent);
  42. struct proc_dentry *proc_mkdir(const char *name, struct proc_dentry *parent);
  43. struct proc_dentry *proc_create_data(const char *name, mode_t mode, struct proc_dentry *parent,
  44. const struct dfs_file_ops *fops, void *data);
  45. struct proc_dentry *proc_create_single_data(const char *name, mode_t mode, struct proc_dentry *parent,
  46. int (*show)(struct dfs_seq_file *, void *), void *data);
  47. struct proc_dentry *proc_symlink(const char *name, struct proc_dentry *parent, const char *dest);
  48. struct proc_dentry *proc_acquire(struct proc_dentry *dentry);
  49. void proc_release(struct proc_dentry *dentry);
  50. void proc_remove(struct proc_dentry *dentry);
  51. void proc_remove_dentry(const char *name, struct proc_dentry *parent);
  52. int proc_pid(int pid);
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif