binder_internal.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_BINDER_INTERNAL_H
  3. #define _LINUX_BINDER_INTERNAL_H
  4. #include <linux/export.h>
  5. #include <linux/fs.h>
  6. #include <linux/list.h>
  7. #include <linux/miscdevice.h>
  8. #include <linux/mutex.h>
  9. #include <linux/refcount.h>
  10. #include <linux/stddef.h>
  11. #include <linux/types.h>
  12. #include <linux/uidgid.h>
  13. struct binder_context {
  14. struct binder_node *binder_context_mgr_node;
  15. struct mutex context_mgr_node_lock;
  16. kuid_t binder_context_mgr_uid;
  17. const char *name;
  18. };
  19. /**
  20. * struct binder_device - information about a binder device node
  21. * @hlist: list of binder devices (only used for devices requested via
  22. * CONFIG_ANDROID_BINDER_DEVICES)
  23. * @miscdev: information about a binder character device node
  24. * @context: binder context information
  25. * @binderfs_inode: This is the inode of the root dentry of the super block
  26. * belonging to a binderfs mount.
  27. */
  28. struct binder_device {
  29. struct hlist_node hlist;
  30. struct miscdevice miscdev;
  31. struct binder_context context;
  32. struct inode *binderfs_inode;
  33. refcount_t ref;
  34. };
  35. /**
  36. * binderfs_mount_opts - mount options for binderfs
  37. * @max: maximum number of allocatable binderfs binder devices
  38. * @stats_mode: enable binder stats in binderfs.
  39. */
  40. struct binderfs_mount_opts {
  41. int max;
  42. int stats_mode;
  43. };
  44. /**
  45. * binderfs_info - information about a binderfs mount
  46. * @ipc_ns: The ipc namespace the binderfs mount belongs to.
  47. * @control_dentry: This records the dentry of this binderfs mount
  48. * binder-control device.
  49. * @root_uid: uid that needs to be used when a new binder device is
  50. * created.
  51. * @root_gid: gid that needs to be used when a new binder device is
  52. * created.
  53. * @mount_opts: The mount options in use.
  54. * @device_count: The current number of allocated binder devices.
  55. * @proc_log_dir: Pointer to the directory dentry containing process-specific
  56. * logs.
  57. */
  58. struct binderfs_info {
  59. struct ipc_namespace *ipc_ns;
  60. struct dentry *control_dentry;
  61. kuid_t root_uid;
  62. kgid_t root_gid;
  63. struct binderfs_mount_opts mount_opts;
  64. int device_count;
  65. struct dentry *proc_log_dir;
  66. };
  67. extern const struct file_operations binder_fops;
  68. extern char *binder_devices_param;
  69. #ifdef CONFIG_ANDROID_BINDERFS
  70. extern bool is_binderfs_device(const struct inode *inode);
  71. extern struct dentry *binderfs_create_file(struct dentry *dir, const char *name,
  72. const struct file_operations *fops,
  73. void *data);
  74. extern void binderfs_remove_file(struct dentry *dentry);
  75. #else
  76. static inline bool is_binderfs_device(const struct inode *inode)
  77. {
  78. return false;
  79. }
  80. static inline struct dentry *binderfs_create_file(struct dentry *dir,
  81. const char *name,
  82. const struct file_operations *fops,
  83. void *data)
  84. {
  85. return NULL;
  86. }
  87. static inline void binderfs_remove_file(struct dentry *dentry) {}
  88. #endif
  89. #ifdef CONFIG_ANDROID_BINDERFS
  90. extern int __init init_binderfs(void);
  91. #else
  92. static inline int __init init_binderfs(void)
  93. {
  94. return 0;
  95. }
  96. #endif
  97. int binder_stats_show(struct seq_file *m, void *unused);
  98. DEFINE_SHOW_ATTRIBUTE(binder_stats);
  99. int binder_state_show(struct seq_file *m, void *unused);
  100. DEFINE_SHOW_ATTRIBUTE(binder_state);
  101. int binder_transactions_show(struct seq_file *m, void *unused);
  102. DEFINE_SHOW_ATTRIBUTE(binder_transactions);
  103. int binder_transaction_log_show(struct seq_file *m, void *unused);
  104. DEFINE_SHOW_ATTRIBUTE(binder_transaction_log);
  105. struct binder_transaction_log_entry {
  106. int debug_id;
  107. int debug_id_done;
  108. int call_type;
  109. int from_proc;
  110. int from_thread;
  111. int target_handle;
  112. int to_proc;
  113. int to_thread;
  114. int to_node;
  115. int data_size;
  116. int offsets_size;
  117. int return_error_line;
  118. uint32_t return_error;
  119. uint32_t return_error_param;
  120. char context_name[BINDERFS_MAX_NAME + 1];
  121. };
  122. struct binder_transaction_log {
  123. atomic_t cur;
  124. bool full;
  125. struct binder_transaction_log_entry entry[32];
  126. };
  127. extern struct binder_transaction_log binder_transaction_log;
  128. extern struct binder_transaction_log binder_transaction_log_failed;
  129. #endif /* _LINUX_BINDER_INTERNAL_H */