History

binder: Add support for file-descriptor arrays

This patch introduces a new binder_fd_array object, that allows us to support one or more file descriptors embedded in a buffer that is scatter-gathered.

Martijn Coenen committed 9 years ago

Commit def95c71 parent 79802402 files · +165 −0Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/android/binder.h+28−0
@@ -33,6 +33,7 @@ enum { · 32 unmodified lines
33 BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),33 BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
34 BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),34 BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
35 BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),35 BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
36 BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE),
36 BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE),37 BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE),
37};38};
38 39
@@ -129,6 +130,33 @@ enum { · 90 unmodified lines
129 BINDER_BUFFER_FLAG_HAS_PARENT = 0x01,130 BINDER_BUFFER_FLAG_HAS_PARENT = 0x01,
130};131};
131 132
133/* struct binder_fd_array_object - object describing an array of fds in a buffer
134 * @hdr: common header structure
135 * @num_fds: number of file descriptors in the buffer
136 * @parent: index in offset array to buffer holding the fd array
137 * @parent_offset: start offset of fd array in the buffer
138 *
139 * A binder_fd_array object represents an array of file
140 * descriptors embedded in a binder_buffer_object. It is
141 * different from a regular binder_buffer_object because it
142 * describes a list of file descriptors to fix up, not an opaque
143 * blob of memory, and hence the kernel needs to treat it differently.
144 *
145 * An example of how this would be used is with Android's
146 * native_handle_t object, which is a struct with a list of integers
147 * and a list of file descriptors. The native_handle_t struct itself
148 * will be represented by a struct binder_buffer_objct, whereas the
149 * embedded list of file descriptors is represented by a
150 * struct binder_fd_array_object with that binder_buffer_object as
151 * a parent.
152 */
153struct binder_fd_array_object {
154 struct binder_object_header hdr;
155 binder_size_t num_fds;
156 binder_size_t parent;
157 binder_size_t parent_offset;
158};
159
132/*160/*
133 * On 64-bit platforms where user code may run in 32-bits the driver must161 * On 64-bit platforms where user code may run in 32-bits the driver must
134 * translate the buffer (and local binder) addresses appropriately.162 * translate the buffer (and local binder) addresses appropriately.