drivers/mtd/inftlmount.c
Source file repositories/reference/linux-study-clean/drivers/mtd/inftlmount.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/inftlmount.c- Extension
.c- Size
- 21735 bytes
- Lines
- 777
- Domain
- Driver Families
- Bucket
- drivers/mtd
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/kernel.hlinux/module.hasm/errno.hasm/io.hlinux/uaccess.hlinux/delay.hlinux/slab.hlinux/mtd/mtd.hlinux/mtd/nftl.hlinux/mtd/inftl.h
Detected Declarations
function find_boot_recordfunction memcmpbfunction check_free_sectorsfunction INFTL_formatblockfunction headfunction INFTL_dumptablesfunction INFTL_dumpVUchainsfunction INFTL_mount
Annotated Snippet
if (retlen != SECTORSIZE) {
static int warncount = 5;
if (warncount) {
pr_warn("INFTL: block read at 0x%x "
"of mtd%d failed: %d\n",
block * inftl->EraseSize,
inftl->mbd.mtd->index, ret);
if (!--warncount)
pr_warn("INFTL: further "
"failures for this block will "
"not be printed\n");
}
continue;
}
if (retlen < 6 || memcmp(buf, "BNAND", 6)) {
/* BNAND\0 not found. Continue */
continue;
}
/* To be safer with BIOS, also use erase mark as discriminant */
ret = inftl_read_oob(mtd,
block * inftl->EraseSize + SECTORSIZE + 8,
8, &retlen,(char *)&h1);
if (ret < 0) {
pr_warn("INFTL: ANAND header found at "
"0x%x in mtd%d, but OOB data read failed "
"(err %d)\n", block * inftl->EraseSize,
inftl->mbd.mtd->index, ret);
continue;
}
/*
* This is the first we've seen.
* Copy the media header structure into place.
*/
memcpy(mh, buf, sizeof(struct INFTLMediaHeader));
/* Read the spare media header at offset 4096 */
mtd_read(mtd, block * inftl->EraseSize + 4096, SECTORSIZE,
&retlen, buf);
if (retlen != SECTORSIZE) {
pr_warn("INFTL: Unable to read spare "
"Media Header\n");
return -1;
}
/* Check if this one is the same as the first one we found. */
if (memcmp(mh, buf, sizeof(struct INFTLMediaHeader))) {
pr_warn("INFTL: Primary and spare Media "
"Headers disagree.\n");
return -1;
}
mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks);
mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions);
mh->NoOfBDTLPartitions = le32_to_cpu(mh->NoOfBDTLPartitions);
mh->BlockMultiplierBits = le32_to_cpu(mh->BlockMultiplierBits);
mh->FormatFlags = le32_to_cpu(mh->FormatFlags);
mh->PercentUsed = le32_to_cpu(mh->PercentUsed);
pr_debug("INFTL: Media Header ->\n"
" bootRecordID = %s\n"
" NoOfBootImageBlocks = %d\n"
" NoOfBinaryPartitions = %d\n"
" NoOfBDTLPartitions = %d\n"
" BlockMultiplierBits = %d\n"
" FormatFlgs = %d\n"
" OsakVersion = 0x%x\n"
" PercentUsed = %d\n",
mh->bootRecordID, mh->NoOfBootImageBlocks,
mh->NoOfBinaryPartitions,
mh->NoOfBDTLPartitions,
mh->BlockMultiplierBits, mh->FormatFlags,
mh->OsakVersion, mh->PercentUsed);
if (mh->NoOfBDTLPartitions == 0) {
pr_warn("INFTL: Media Header sanity check "
"failed: NoOfBDTLPartitions (%d) == 0, "
"must be at least 1\n", mh->NoOfBDTLPartitions);
return -1;
}
if ((mh->NoOfBDTLPartitions + mh->NoOfBinaryPartitions) > 4) {
pr_warn("INFTL: Media Header sanity check "
"failed: Total Partitions (%d) > 4, "
"BDTL=%d Binary=%d\n", mh->NoOfBDTLPartitions +
mh->NoOfBinaryPartitions,
mh->NoOfBDTLPartitions,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `asm/errno.h`, `asm/io.h`, `linux/uaccess.h`, `linux/delay.h`, `linux/slab.h`, `linux/mtd/mtd.h`.
- Detected declarations: `function find_boot_record`, `function memcmpb`, `function check_free_sectors`, `function INFTL_formatblock`, `function head`, `function INFTL_dumptables`, `function INFTL_dumpVUchains`, `function INFTL_mount`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source 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.