drivers/md/dm-audit.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-audit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-audit.c- Extension
.c- Size
- 2192 bytes
- Lines
- 85
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/audit.hlinux/module.hlinux/device-mapper.hlinux/bio.hlinux/blkdev.hdm-audit.hdm-core.h
Detected Declarations
function Copyrightfunction dm_audit_log_tifunction dm_audit_log_bioexport dm_audit_log_tiexport dm_audit_log_bio
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Creating audit records for mapped devices.
*
* Copyright (C) 2021 Fraunhofer AISEC. All rights reserved.
*
* Authors: Michael Weiß <michael.weiss@aisec.fraunhofer.de>
*/
#include <linux/audit.h>
#include <linux/module.h>
#include <linux/device-mapper.h>
#include <linux/bio.h>
#include <linux/blkdev.h>
#include "dm-audit.h"
#include "dm-core.h"
static struct audit_buffer *dm_audit_log_start(int audit_type,
const char *dm_msg_prefix,
const char *op)
{
struct audit_buffer *ab;
if (audit_enabled == AUDIT_OFF)
return NULL;
ab = audit_log_start(audit_context(), GFP_KERNEL, audit_type);
if (unlikely(!ab))
return NULL;
audit_log_format(ab, "module=%s op=%s", dm_msg_prefix, op);
return ab;
}
void dm_audit_log_ti(int audit_type, const char *dm_msg_prefix, const char *op,
struct dm_target *ti, int result)
{
struct audit_buffer *ab = NULL;
struct mapped_device *md = dm_table_get_md(ti->table);
int dev_major = dm_disk(md)->major;
int dev_minor = dm_disk(md)->first_minor;
switch (audit_type) {
case AUDIT_DM_CTRL:
ab = dm_audit_log_start(audit_type, dm_msg_prefix, op);
if (unlikely(!ab))
return;
audit_log_task_info(ab);
audit_log_format(ab, " dev=%d:%d error_msg='%s'", dev_major,
dev_minor, !result ? ti->error : "success");
break;
case AUDIT_DM_EVENT:
ab = dm_audit_log_start(audit_type, dm_msg_prefix, op);
if (unlikely(!ab))
return;
audit_log_format(ab, " dev=%d:%d sector=?", dev_major,
dev_minor);
break;
default: /* unintended use */
return;
}
audit_log_format(ab, " res=%d", result);
audit_log_end(ab);
}
EXPORT_SYMBOL_GPL(dm_audit_log_ti);
void dm_audit_log_bio(const char *dm_msg_prefix, const char *op,
struct bio *bio, sector_t sector, int result)
{
struct audit_buffer *ab;
int dev_major = MAJOR(bio->bi_bdev->bd_dev);
int dev_minor = MINOR(bio->bi_bdev->bd_dev);
ab = dm_audit_log_start(AUDIT_DM_EVENT, dm_msg_prefix, op);
if (unlikely(!ab))
return;
audit_log_format(ab, " dev=%d:%d sector=%llu res=%d",
dev_major, dev_minor, sector, result);
audit_log_end(ab);
}
EXPORT_SYMBOL_GPL(dm_audit_log_bio);
Annotation
- Immediate include surface: `linux/audit.h`, `linux/module.h`, `linux/device-mapper.h`, `linux/bio.h`, `linux/blkdev.h`, `dm-audit.h`, `dm-core.h`.
- Detected declarations: `function Copyright`, `function dm_audit_log_ti`, `function dm_audit_log_bio`, `export dm_audit_log_ti`, `export dm_audit_log_bio`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: integration implementation candidate.
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.