tools/testing/selftests/ublk/test_part_01.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/ublk/test_part_01.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/ublk/test_part_01.sh- Extension
.sh- Size
- 2287 bytes
- Lines
- 105
- 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
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
ERR_CODE=0
format_backing_file()
{
local backing_file=$1
# Create ublk device to write partition table
local tmp_dev=$(_add_ublk_dev -t loop "${backing_file}")
[ $? -ne 0 ] && return 1
# Write partition table with sfdisk
sfdisk /dev/ublkb"${tmp_dev}" > /dev/null 2>&1 <<EOF
label: dos
start=2048, size=100MiB, type=83
start=206848, size=100MiB, type=83
EOF
local ret=$?
"${UBLK_PROG}" del -n "${tmp_dev}"
return $ret
}
test_auto_part_scan()
{
local backing_file=$1
# Create device WITHOUT --no_auto_part_scan
local dev_id=$(_add_ublk_dev -t loop "${backing_file}")
[ $? -ne 0 ] && return 1
udevadm settle
# Partitions should be auto-detected
if [ ! -e /dev/ublkb"${dev_id}"p1 ] || [ ! -e /dev/ublkb"${dev_id}"p2 ]; then
"${UBLK_PROG}" del -n "${dev_id}"
return 1
fi
"${UBLK_PROG}" del -n "${dev_id}"
return 0
}
test_no_auto_part_scan()
{
local backing_file=$1
# Create device WITH --no_auto_part_scan
local dev_id=$(_add_ublk_dev -t loop --no_auto_part_scan "${backing_file}")
[ $? -ne 0 ] && return 1
udevadm settle
# Partitions should NOT be auto-detected
if [ -e /dev/ublkb"${dev_id}"p1 ]; then
"${UBLK_PROG}" del -n "${dev_id}"
return 1
fi
# Manual scan should work
blockdev --rereadpt /dev/ublkb"${dev_id}" > /dev/null 2>&1
udevadm settle
if [ ! -e /dev/ublkb"${dev_id}"p1 ] || [ ! -e /dev/ublkb"${dev_id}"p2 ]; then
"${UBLK_PROG}" del -n "${dev_id}"
Annotation
- 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.