| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* rust_binder_internal.h |
| 3 |
* |
| 4 |
* This file contains internal data structures used by Rust Binder. Mostly, |
| 5 |
* these are type definitions used only by binderfs or things that Rust Binder |
| 6 |
* define and export to binderfs. |
| 7 |
* |
| 8 |
* It does not include things exported by binderfs to Rust Binder since this |
| 9 |
* file is not included as input to bindgen. |
| 10 |
* |
| 11 |
* Copyright (C) 2025 Google LLC. |
| 12 |
*/ |
| 13 |
|
| 14 |
#ifndef _LINUX_RUST_BINDER_INTERNAL_H |
| 15 |
#define _LINUX_RUST_BINDER_INTERNAL_H |
| 16 |
|
| 17 |
#define RUST_BINDERFS_SUPER_MAGIC 0x6c6f6f71 |
| 18 |
|
| 19 |
#include <linux/seq_file.h> |
| 20 |
#include <uapi/linux/android/binder.h> |
| 21 |
#include <uapi/linux/android/binderfs.h> |
| 22 |
|
| 23 |
/* |
| 24 |
* The internal data types in the Rust Binder driver are opaque to C, so we use |
| 25 |
* void pointer typedefs for these types. |
| 26 |
*/ |
| 27 |
typedef void *rust_binder_context; |
| 28 |
|
| 29 |
/** |
| 30 |
* struct binder_device - information about a binder device node |
| 31 |
* @minor: the minor number used by this device |
| 32 |
* @ctx: the Rust Context used by this device, or null for binder-control |
| 33 |
* |
| 34 |
* This is used as the private data for files directly in binderfs, but not |
| 35 |
* files in the binder_logs subdirectory. This struct owns a refcount on `ctx` |
| 36 |
* and the entry for `minor` in `binderfs_minors`. For binder-control `ctx` is |
| 37 |
* null. |
| 38 |
*/ |
| 39 |
struct binder_device { |
| 40 |
int minor; |
| 41 |
rust_binder_context ctx; |
| 42 |
}; |
| 43 |
|
| 44 |
int rust_binder_stats_show(struct seq_file *m, void *unused); |
| 45 |
int rust_binder_state_show(struct seq_file *m, void *unused); |
| 46 |
int rust_binder_transactions_show(struct seq_file *m, void *unused); |
| 47 |
int rust_binder_proc_show(struct seq_file *m, void *pid); |
| 48 |
|
| 49 |
extern const struct file_operations rust_binder_fops; |
| 50 |
rust_binder_context rust_binder_new_context(char *name); |
| 51 |
void rust_binder_remove_context(rust_binder_context device); |
| 52 |
|
| 53 |
/** |
| 54 |
* binderfs_mount_opts - mount options for binderfs |
| 55 |
* @max: maximum number of allocatable binderfs binder devices |
| 56 |
* @stats_mode: enable binder stats in binderfs. |
| 57 |
*/ |
| 58 |
struct binderfs_mount_opts { |
| 59 |
int max; |
| 60 |
int stats_mode; |
| 61 |
}; |
| 62 |
|
| 63 |
/** |
| 64 |
* binderfs_info - information about a binderfs mount |
| 65 |
* @ipc_ns: The ipc namespace the binderfs mount belongs to. |
| 66 |
* @control_dentry: This records the dentry of this binderfs mount |
| 67 |
* binder-control device. |
| 68 |
* @root_uid: uid that needs to be used when a new binder device is |
| 69 |
* created. |
| 70 |
* @root_gid: gid that needs to be used when a new binder device is |
| 71 |
* created. |
| 72 |
* @mount_opts: The mount options in use. |
| 73 |
* @device_count: The current number of allocated binder devices. |
| 74 |
* @proc_log_dir: Pointer to the directory dentry containing process-specific |
| 75 |
* logs. |
| 76 |
*/ |
| 77 |
struct binderfs_info { |
| 78 |
struct ipc_namespace *ipc_ns; |
| 79 |
struct dentry *control_dentry; |
| 80 |
kuid_t root_uid; |
| 81 |
kgid_t root_gid; |
| 82 |
struct binderfs_mount_opts mount_opts; |
| 83 |
int device_count; |
| 84 |
struct dentry *proc_log_dir; |
| 85 |
}; |
| 86 |
|
| 87 |
#endif /* _LINUX_RUST_BINDER_INTERNAL_H */ |