tools/testing/selftests/zram/zram_lib.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/zram/zram_lib.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/zram/zram_lib.sh- Extension
.sh- Size
- 5568 bytes
- Lines
- 270
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
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.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function check_prereqs
Annotated Snippet
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
#
# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
# Modified: Naresh Kamboju <naresh.kamboju@linaro.org>
dev_makeswap=-1
dev_mounted=-1
dev_start=0
dev_end=-1
module_load=-1
sys_control=-1
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
kernel_version=`uname -r | cut -d'.' -f1,2`
kernel_major=${kernel_version%.*}
kernel_minor=${kernel_version#*.}
trap INT
check_prereqs()
{
local msg="skip all tests:"
local uid=$(id -u)
if [ $uid -ne 0 ]; then
echo $msg must be run as root >&2
exit $ksft_skip
fi
}
kernel_gte()
{
major=${1%.*}
minor=${1#*.}
if [ $kernel_major -gt $major ]; then
return 0
elif [[ $kernel_major -eq $major && $kernel_minor -ge $minor ]]; then
return 0
fi
return 1
}
zram_cleanup()
{
echo "zram cleanup"
local i=
for i in $(seq $dev_start $dev_makeswap); do
swapoff /dev/zram$i
done
for i in $(seq $dev_start $dev_mounted); do
umount /dev/zram$i
done
for i in $(seq $dev_start $dev_end); do
echo 1 > /sys/block/zram${i}/reset
rm -rf zram$i
done
if [ $sys_control -eq 1 ]; then
for i in $(seq $dev_start $dev_end); do
echo $i > /sys/class/zram-control/hot_remove
done
fi
if [ $module_load -eq 1 ]; then
Annotation
- Detected declarations: `function check_prereqs`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
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.