tools/testing/selftests/ublk/metadata_size.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/ublk/metadata_size.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/ublk/metadata_size.c- Extension
.c- Size
- 698 bytes
- Lines
- 37
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fcntl.hlinux/fs.hstdio.hsys/ioctl.h
Detected Declarations
function main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <fcntl.h>
#include <linux/fs.h>
#include <stdio.h>
#include <sys/ioctl.h>
int main(int argc, char **argv)
{
struct logical_block_metadata_cap cap = {};
const char *filename;
int fd;
int result;
if (argc != 2) {
fprintf(stderr, "Usage: %s BLOCK_DEVICE\n", argv[0]);
return 1;
}
filename = argv[1];
fd = open(filename, O_RDONLY);
if (fd < 0) {
perror(filename);
return 1;
}
result = ioctl(fd, FS_IOC_GETLBMD_CAP, &cap);
if (result < 0) {
perror("ioctl");
return 1;
}
printf("metadata_size: %u\n", cap.lbmd_size);
printf("pi_offset: %u\n", cap.lbmd_pi_offset);
printf("pi_tuple_size: %u\n", cap.lbmd_pi_size);
return 0;
}
Annotation
- Immediate include surface: `fcntl.h`, `linux/fs.h`, `stdio.h`, `sys/ioctl.h`.
- Detected declarations: `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.