drivers/android/binderfs.c
Source file repositories/reference/linux-study-clean/drivers/android/binderfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/android/binderfs.c- Extension
.c- Size
- 19557 bytes
- Lines
- 787
- Domain
- Driver Families
- Bucket
- drivers/android
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compiler_types.hlinux/errno.hlinux/fs.hlinux/fsnotify.hlinux/gfp.hlinux/idr.hlinux/init.hlinux/ipc_namespace.hlinux/kdev_t.hlinux/kernel.hlinux/list.hlinux/namei.hlinux/magic.hlinux/major.hlinux/miscdevice.hlinux/module.hlinux/mutex.hlinux/mount.hlinux/fs_parser.hlinux/sched.hlinux/seq_file.hlinux/slab.hlinux/spinlock_types.hlinux/stddef.hlinux/string.hlinux/types.hlinux/uaccess.hlinux/user_namespace.hlinux/xarray.huapi/linux/android/binder.huapi/linux/android/binderfs.hbinder_internal.h
Detected Declarations
struct binder_featuresenum binderfs_paramenum binderfs_stats_modefunction is_binderfs_devicefunction binderfs_binder_device_createfunction binder_ctl_ioctlfunction binderfs_evict_inodefunction binderfs_fs_context_parse_paramfunction binderfs_fs_context_reconfigurefunction binderfs_show_optionsfunction is_binderfs_control_devicefunction binderfs_renamefunction binderfs_unlinkfunction binderfs_binder_ctl_createfunction binder_features_showfunction init_binder_featuresfunction init_binder_logsfunction binder_for_each_debugfs_entryfunction binderfs_fill_superfunction binderfs_fs_context_get_treefunction binderfs_fs_context_freefunction binderfs_init_fs_contextfunction binderfs_kill_superfunction init_binderfs
Annotated Snippet
static const struct file_operations binder_ctl_fops = {
.owner = THIS_MODULE,
.open = nonseekable_open,
.unlocked_ioctl = binder_ctl_ioctl,
.compat_ioctl = binder_ctl_ioctl,
.llseek = noop_llseek,
};
/**
* binderfs_binder_ctl_create - create a new binder-control device
* @sb: super block of the binderfs mount
*
* This function creates a new binder-control device node in the binderfs mount
* referred to by @sb.
*
* Return: 0 on success, negative errno on failure
*/
static int binderfs_binder_ctl_create(struct super_block *sb)
{
int minor, ret;
struct dentry *dentry;
struct binder_device *device;
struct inode *inode = NULL;
struct dentry *root = sb->s_root;
struct binderfs_info *info = sb->s_fs_info;
#if defined(CONFIG_IPC_NS)
bool use_reserve = (info->ipc_ns == &init_ipc_ns);
#else
bool use_reserve = true;
#endif
device = kzalloc_obj(*device);
if (!device)
return -ENOMEM;
ret = -ENOMEM;
inode = new_inode(sb);
if (!inode)
goto out;
/* Reserve a new minor number for the new device. */
mutex_lock(&binderfs_minors_mutex);
minor = ida_alloc_max(&binderfs_minors,
use_reserve ? BINDERFS_MAX_MINOR - 1 :
BINDERFS_MAX_MINOR_CAPPED - 1,
GFP_KERNEL);
mutex_unlock(&binderfs_minors_mutex);
if (minor < 0) {
ret = minor;
goto out;
}
inode->i_ino = SECOND_INODE;
simple_inode_init_ts(inode);
init_special_inode(inode, S_IFCHR | 0600,
MKDEV(MAJOR(binderfs_dev), minor));
inode->i_fop = &binder_ctl_fops;
inode->i_uid = info->root_uid;
inode->i_gid = info->root_gid;
refcount_set(&device->ref, 1);
device->binderfs_inode = inode;
device->miscdev.minor = minor;
dentry = d_alloc_name(root, "binder-control");
if (!dentry)
goto out;
inode->i_private = device;
info->control_dentry = dentry;
d_make_persistent(dentry, inode);
dput(dentry);
return 0;
out:
kfree(device);
iput(inode);
return ret;
}
static const struct inode_operations binderfs_dir_inode_operations = {
.lookup = simple_lookup,
.rename = binderfs_rename,
.unlink = binderfs_unlink,
};
static struct inode *binderfs_make_inode(struct super_block *sb, int mode)
{
Annotation
- Immediate include surface: `linux/compiler_types.h`, `linux/errno.h`, `linux/fs.h`, `linux/fsnotify.h`, `linux/gfp.h`, `linux/idr.h`, `linux/init.h`, `linux/ipc_namespace.h`.
- Detected declarations: `struct binder_features`, `enum binderfs_param`, `enum binderfs_stats_mode`, `function is_binderfs_device`, `function binderfs_binder_device_create`, `function binder_ctl_ioctl`, `function binderfs_evict_inode`, `function binderfs_fs_context_parse_param`, `function binderfs_fs_context_reconfigure`, `function binderfs_show_options`.
- Atlas domain: Driver Families / drivers/android.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.