drivers/md/dm-ioctl.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-ioctl.c- Extension
.c- Size
- 58286 bytes
- Lines
- 2495
- Domain
- Driver Families
- Bucket
- drivers/md
- 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
dm-core.hdm-ima.hlinux/module.hlinux/vmalloc.hlinux/miscdevice.hlinux/sched/mm.hlinux/init.hlinux/wait.hlinux/slab.hlinux/rbtree.hlinux/dm-ioctl.hlinux/hdreg.hlinux/compat.hlinux/nospec.hlinux/uaccess.hlinux/ima.h
Detected Declarations
struct dm_filestruct hash_cellstruct vers_iterfunction dm_hash_exitfunction __unlink_namefunction __unlink_uuidfunction __link_namefunction __link_uuidfunction free_cellfunction dm_ima_init_contextfunction do_resumefunction dm_ima_init_contextfunction dm_ima_need_measurefunction dm_hash_insertfunction dm_hash_remove_allfunction __set_cell_uuidfunction dm_deferred_removefunction remove_allfunction align_valfunction filter_devicefunction list_devicesfunction list_version_get_neededfunction list_version_get_infofunction __list_versionsfunction list_versionsfunction get_target_versionfunction check_namefunction __dev_statusfunction dev_createfunction dev_removefunction invalid_strfunction dev_renamefunction dev_set_geometryfunction do_suspendfunction do_resumefunction dev_suspendfunction dev_statusfunction retrieve_statusfunction dev_waitfunction dev_arm_pollfunction get_modefunction next_targetfunction populate_tablefunction is_valid_typefunction table_loadfunction table_clearfunction retrieve_depsfunction table_deps
Annotated Snippet
static const struct file_operations _ctl_fops = {
.open = dm_open,
.release = dm_release,
.poll = dm_poll,
.unlocked_ioctl = dm_ctl_ioctl,
.compat_ioctl = dm_compat_ctl_ioctl,
.owner = THIS_MODULE,
.llseek = noop_llseek,
};
static struct miscdevice _dm_misc = {
.minor = MAPPER_CTRL_MINOR,
.name = DM_NAME,
.nodename = DM_DIR "/" DM_CONTROL_NODE,
.fops = &_ctl_fops
};
MODULE_ALIAS_MISCDEV(MAPPER_CTRL_MINOR);
MODULE_ALIAS("devname:" DM_DIR "/" DM_CONTROL_NODE);
/*
* Create misc character device and link to DM_DIR/control.
*/
int __init dm_interface_init(void)
{
int r;
r = misc_register(&_dm_misc);
if (r) {
DMERR("misc_register failed for control device");
return r;
}
DMINFO("%d.%d.%d%s initialised: %s", DM_VERSION_MAJOR,
DM_VERSION_MINOR, DM_VERSION_PATCHLEVEL, DM_VERSION_EXTRA,
DM_DRIVER_EMAIL);
return 0;
}
void dm_interface_exit(void)
{
misc_deregister(&_dm_misc);
dm_hash_exit();
}
/**
* dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers
* @md: Pointer to mapped_device
* @name: Buffer (size DM_NAME_LEN) for name
* @uuid: Buffer (size DM_UUID_LEN) for uuid or empty string if uuid not defined
*/
int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
{
int r = 0;
struct hash_cell *hc;
if (!md)
return -ENXIO;
mutex_lock(&dm_hash_cells_mutex);
hc = dm_get_mdptr(md);
if (!hc) {
r = -ENXIO;
goto out;
}
if (name)
strcpy(name, hc->name);
if (uuid)
strcpy(uuid, hc->uuid ? : "");
out:
mutex_unlock(&dm_hash_cells_mutex);
return r;
}
EXPORT_SYMBOL_GPL(dm_copy_name_and_uuid);
/**
* dm_early_create - create a mapped device in early boot.
*
* @dmi: Contains main information of the device mapping to be created.
* @spec_array: array of pointers to struct dm_target_spec. Describes the
* mapping table of the device.
* @target_params_array: array of strings with the parameters to a specific
* target.
*
* Instead of having the struct dm_target_spec and the parameters for every
* target embedded at the end of struct dm_ioctl (as performed in a normal
* ioctl), pass them as arguments, so the caller doesn't need to serialize them.
Annotation
- Immediate include surface: `dm-core.h`, `dm-ima.h`, `linux/module.h`, `linux/vmalloc.h`, `linux/miscdevice.h`, `linux/sched/mm.h`, `linux/init.h`, `linux/wait.h`.
- Detected declarations: `struct dm_file`, `struct hash_cell`, `struct vers_iter`, `function dm_hash_exit`, `function __unlink_name`, `function __unlink_uuid`, `function __link_name`, `function __link_uuid`, `function free_cell`, `function dm_ima_init_context`.
- Atlas domain: Driver Families / drivers/md.
- 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.