Blame view

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