tools/testing/selftests/media_tests/media_device_open.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/media_tests/media_device_open.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/media_tests/media_device_open.c- Extension
.c- Size
- 1919 bytes
- Lines
- 83
- 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
stdio.hunistd.hstdlib.herrno.hstring.hfcntl.hsys/ioctl.hsys/stat.hlinux/media.hkselftest.h
Detected Declarations
function Copyright
Annotated Snippet
switch (opt) {
case 'd':
strncpy(media_device, optarg, sizeof(media_device) - 1);
media_device[sizeof(media_device)-1] = '\0';
break;
default:
printf("Usage: %s [-d </dev/mediaX>]\n", argv[0]);
exit(-1);
}
}
if (getuid() != 0)
ksft_exit_skip("Please run the test as root - Exiting.\n");
/* Open Media device and keep it open */
fd = open(media_device, O_RDWR);
if (fd == -1) {
printf("Media Device open errno %s\n", strerror(errno));
exit(-1);
}
ret = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi);
if (ret < 0)
printf("Media Device Info errno %s\n", strerror(errno));
else
printf("Media device model %s driver %s\n",
mdi.model, mdi.driver);
}
Annotation
- Immediate include surface: `stdio.h`, `unistd.h`, `stdlib.h`, `errno.h`, `string.h`, `fcntl.h`, `sys/ioctl.h`, `sys/stat.h`.
- Detected declarations: `function Copyright`.
- 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.