History

binder: Split flat_binder_object

flat_binder_object is used for both handling binder objects and file descriptors, even though the two are mostly independent. Since we'll have more fixup objects in binder in the future, instead of extending flat_binder_object again, split out file descriptors to their own object while retaining backwards compatibility to existing user-space clients. All binder objects just share a header.

Martijn Coenen committed 9 years ago

Commit feba3901 parent 8fa8bea2 files · +137 −52Browse files

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

Unified · Split

include/uapi/linux/android/binder.h+28−3
@@ -48,6 +48,14 @@ typedef __u64 binder_size_t; · 47 unmodified lines
4848 typedef __u64 binder_uintptr_t;
4949 #endif
5050
51+/**
52+ * struct binder_object_header - header shared by all binder metadata objects.
53+ * @type: type of the object
54+ */
55+struct binder_object_header {
56+ __u32 type;
57+};
58+
5159 /*
5260 * This is the flattened representation of a Binder object for transfer
5361 * between processes. The 'offsets' supplied as part of a binder transaction
@@ -56,9 +64,8 @@ typedef __u64 binder_uintptr_t; · 2 unmodified lines
5664 * between processes.
5765 */
5866 struct flat_binder_object {
59− /* 8 bytes for large_flat_header. */
60− __u32 type;
61− __u32 flags;
67+ struct binder_object_header hdr;
68+ __u32 flags;
6269
6370 /* 8 bytes of data. */
6471 union {
@@ -70,6 +77,24 @@ struct flat_binder_object { · 5 unmodified lines
7077 binder_uintptr_t cookie;
7178 };
7279
80+/**
81+ * struct binder_fd_object - describes a filedescriptor to be fixed up.
82+ * @hdr: common header structure
83+ * @pad_flags: padding to remain compatible with old userspace code
84+ * @pad_binder: padding to remain compatible with old userspace code
85+ * @fd: file descriptor
86+ * @cookie: opaque data, used by user-space
87+ */
88+struct binder_fd_object {
89+ struct binder_object_header hdr;
90+ __u32 pad_flags;
91+ union {
92+ binder_uintptr_t pad_binder;
93+ __u32 fd;
94+ };
95+
96+ binder_uintptr_t cookie;
97+};
7398 /*
7499 * On 64-bit platforms where user code may run in 32-bits the driver must
75100 * translate the buffer (and local binder) addresses appropriately.