rust_binder_internal.h 2.9 KB

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