tools/testing/selftests/liveupdate/luo_test_utils.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/liveupdate/luo_test_utils.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/liveupdate/luo_test_utils.c- Extension
.c- Size
- 6476 bytes
- Lines
- 291
- 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.hstdlib.hstring.hgetopt.hfcntl.hunistd.hsys/ioctl.hsys/syscall.hsys/mman.hsys/types.hsys/resource.hsys/stat.herrno.hstdarg.hluo_test_utils.h
Detected Declarations
function Copyrightfunction luo_ensure_nofile_limitfunction luo_create_sessionfunction luo_retrieve_sessionfunction create_and_preserve_memfdfunction restore_and_verify_memfdfunction luo_session_finishfunction create_state_filefunction restore_and_read_stagefunction daemonize_and_waitfunction parse_stage_argsfunction luo_test
Annotated Snippet
switch (opt) {
case 's':
stage = atoi(optarg);
if (stage != 1 && stage != 2)
fail_exit("Invalid stage argument");
break;
default:
fail_exit("Unknown argument");
}
}
return stage;
}
int luo_test(int argc, char *argv[],
const char *state_session_name,
luo_test_stage1_fn stage1,
luo_test_stage2_fn stage2)
{
int target_stage = parse_stage_args(argc, argv);
int luo_fd = luo_open_device();
int state_session_fd;
int detected_stage;
if (luo_fd < 0) {
ksft_exit_skip("Failed to open %s. Is the luo module loaded?\n",
LUO_DEVICE);
}
state_session_fd = luo_retrieve_session(luo_fd, state_session_name);
if (state_session_fd == -ENOENT)
detected_stage = 1;
else if (state_session_fd >= 0)
detected_stage = 2;
else
fail_exit("Failed to check for state session");
if (target_stage != detected_stage) {
ksft_exit_fail_msg("Stage mismatch Requested --stage %d, but system is in stage %d.\n"
"(State session %s: %s)\n",
target_stage, detected_stage, state_session_name,
(detected_stage == 2) ? "EXISTS" : "MISSING");
}
if (target_stage == 1)
stage1(luo_fd);
else
stage2(luo_fd, state_session_fd);
return 0;
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `getopt.h`, `fcntl.h`, `unistd.h`, `sys/ioctl.h`, `sys/syscall.h`.
- Detected declarations: `function Copyright`, `function luo_ensure_nofile_limit`, `function luo_create_session`, `function luo_retrieve_session`, `function create_and_preserve_memfd`, `function restore_and_verify_memfd`, `function luo_session_finish`, `function create_state_file`, `function restore_and_read_stage`, `function daemonize_and_wait`.
- 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.