tools/testing/selftests/livepatch/test-sysfs.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/livepatch/test-sysfs.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/livepatch/test-sysfs.sh- Extension
.sh- Size
- 8751 bytes
- Lines
- 227
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022 Song Liu <song@kernel.org>
. $(dirname $0)/functions.sh
MOD_LIVEPATCH=test_klp_livepatch
MOD_LIVEPATCH2=test_klp_callbacks_demo
MOD_LIVEPATCH3=test_klp_syscall
HAS_PATCH_ATTR=0
HAS_REPLACE_ATTR=0
HAS_STACK_ORDER_ATTR=0
setup_config
# - load a livepatch and verifies the sysfs entries work as expected
start_test "sysfs test"
load_lp $MOD_LIVEPATCH
check_sysfs_rights "$MOD_LIVEPATCH" "" "drwxr-xr-x"
check_sysfs_rights "$MOD_LIVEPATCH" "enabled" "-rw-r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "enabled" "1"
check_sysfs_rights "$MOD_LIVEPATCH" "force" "--w-------"
check_sysfs_rights "$MOD_LIVEPATCH" "transition" "-r--r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "transition" "0"
if does_sysfs_exist "$MOD_LIVEPATCH/vmlinux" "patched"; then
check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "vmlinux/patched" "1"
HAS_PATCH_ATTR=1
fi
if does_sysfs_exist "$MOD_LIVEPATCH" "replace"; then
check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--"
HAS_REPLACE_ATTR=1
fi
if does_sysfs_exist "$MOD_LIVEPATCH" "stack_order"; then
check_sysfs_rights "$MOD_LIVEPATCH" "stack_order" "-r--r--r--"
check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
HAS_STACK_ORDER_ATTR=1
fi
disable_lp $MOD_LIVEPATCH
unload_lp $MOD_LIVEPATCH
check_result "% insmod test_modules/$MOD_LIVEPATCH.ko
livepatch: enabling patch '$MOD_LIVEPATCH'
livepatch: '$MOD_LIVEPATCH': initializing patching transition
livepatch: '$MOD_LIVEPATCH': starting patching transition
livepatch: '$MOD_LIVEPATCH': completing patching transition
livepatch: '$MOD_LIVEPATCH': patching complete
% echo 0 > $SYSFS_KLP_DIR/$MOD_LIVEPATCH/enabled
livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
livepatch: '$MOD_LIVEPATCH': starting unpatching transition
livepatch: '$MOD_LIVEPATCH': completing unpatching transition
livepatch: '$MOD_LIVEPATCH': unpatching complete
% rmmod $MOD_LIVEPATCH"
if [[ "$HAS_PATCH_ATTR" == "1" ]]; then
start_test "sysfs test object/patched"
MOD_TARGET=test_klp_callbacks_mod
load_lp $MOD_LIVEPATCH2
# check the "patch" file changes as target module loads/unloads
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.