Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d46bcfa authored by Hridya Valsaraju's avatar Hridya Valsaraju
Browse files

UPSTREAM: binder: Add default binder devices through binderfs when configured



Currently, since each binderfs instance needs its own
private binder devices, every time a binderfs instance is
mounted, all the default binder devices need to be created
via the BINDER_CTL_ADD IOCTL. This patch aims to
add a solution to automatically create the default binder
devices for each binderfs instance that gets mounted.
To achieve this goal, when CONFIG_ANDROID_BINDERFS is set,
the default binder devices specified by CONFIG_ANDROID_BINDER_DEVICES
are created in each binderfs instance instead of global devices
being created by the binder driver.

Co-developed-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: default avatarHridya Valsaraju <hridya@google.com>
Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>

Bug: 136497735
(cherry picked from commit ca2864c6e8965c37df97f11e6f99e83e09806b1c)
Change-Id: I4f6c5d95997ffd3df182d6ec32d467b15d1f0c42
Signed-off-by: default avatarHridya Valsaraju <hridya@google.com>
parent c3032267
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR |
	BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION;
module_param_named(debug_mask, binder_debug_mask, uint, 0644);

static char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES;
char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES;
module_param_named(devices, binder_devices_param, charp, 0444);

static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait);
@@ -6129,7 +6129,8 @@ static int __init binder_init(void)
				    &transaction_log_fops);
	}

	if (strcmp(binder_devices_param, "") != 0) {
	if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) &&
	    strcmp(binder_devices_param, "") != 0) {
		/*
		* Copy the module_parameter string, because we don't want to
		* tokenize it in-place.
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ struct binder_device {

extern const struct file_operations binder_fops;

extern char *binder_devices_param;

#ifdef CONFIG_ANDROID_BINDERFS
extern bool is_binderfs_device(const struct inode *inode);
#else
+20 −3
Original line number Diff line number Diff line
@@ -186,8 +186,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
	req->major = MAJOR(binderfs_dev);
	req->minor = minor;

	ret = copy_to_user(userp, req, sizeof(*req));
	if (ret) {
	if (userp && copy_to_user(userp, req, sizeof(*req))) {
		ret = -EFAULT;
		goto err;
	}
@@ -467,6 +466,9 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
	int ret;
	struct binderfs_info *info;
	struct inode *inode = NULL;
	struct binderfs_device device_info = { 0 };
	const char *name;
	size_t len;

	sb->s_blocksize = PAGE_SIZE;
	sb->s_blocksize_bits = PAGE_SHIFT;
@@ -521,7 +523,22 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
	if (!sb->s_root)
		return -ENOMEM;

	return binderfs_binder_ctl_create(sb);
	ret = binderfs_binder_ctl_create(sb);
	if (ret)
		return ret;

	name = binder_devices_param;
	for (len = strcspn(name, ","); len > 0; len = strcspn(name, ",")) {
		strscpy(device_info.name, name, len + 1);
		ret = binderfs_binder_device_create(inode, NULL, &device_info);
		if (ret)
			return ret;
		name += len;
		if (*name == ',')
			name++;
	}

	return 0;
}

static struct dentry *binderfs_mount(struct file_system_type *fs_type,