tools/perf/perf-archive.sh
Source file repositories/reference/linux-study-clean/tools/perf/perf-archive.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/perf-archive.sh- Extension
.sh- Size
- 4752 bytes
- Lines
- 147
- 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
# perf archive
# Arnaldo Carvalho de Melo <acme@redhat.com>
PERF_DATA=perf.data
PERF_SYMBOLS=perf.symbols
PERF_ALL=perf.all
ALL=0
UNPACK=0
while [ $# -gt 0 ] ; do
if [ $1 == "--all" ]; then
ALL=1
shift
elif [ $1 == "--unpack" ]; then
UNPACK=1
shift
elif [ $1 == "--exclude-buildids" ]; then
EXCLUDE_BUILDIDS="$2"
if [ ! -e "$EXCLUDE_BUILDIDS" ]; then
echo "Provided exclude-buildids file $EXCLUDE_BUILDIDS does not exist"
exit 1
fi
shift 2
else
PERF_DATA=$1
UNPACK_TAR=$1
shift
fi
done
if [ $UNPACK -eq 1 ]; then
if [ ! -z "$UNPACK_TAR" ]; then # tar given as an argument
if [ ! -e "$UNPACK_TAR" ]; then
echo "Provided file $UNPACK_TAR does not exist"
exit 1
fi
TARGET="$UNPACK_TAR"
else # search for perf tar in the current directory
TARGET=`find . -regex "\./perf.*\.tar\.bz2"`
TARGET_NUM=`echo -n "$TARGET" | grep -c '^'`
if [ -z "$TARGET" ] || [ $TARGET_NUM -gt 1 ]; then
echo -e "Error: $TARGET_NUM files found for unpacking:\n$TARGET"
echo "Provide the requested file as an argument"
exit 1
else
echo "Found target file for unpacking: $TARGET"
fi
fi
if [[ "$TARGET" =~ (\./)?$PERF_ALL.*.tar.bz2 ]]; then # perf tar generated by --all option
TAR_CONTENTS=`tar tvf "$TARGET" | tr -s " " | cut -d " " -f 6`
VALID_TAR=`echo "$TAR_CONTENTS" | grep "$PERF_SYMBOLS.tar.bz2" | wc -l` # check if it contains a sub-tar perf.symbols
if [ $VALID_TAR -ne 1 ]; then
echo "Error: $TARGET file is not valid (contains zero or multiple sub-tar files with debug symbols)"
exit 1
fi
INTERSECT=`comm -12 <(ls) <(echo "$TAR_CONTENTS") | tr "\n" " "` # check for overwriting
if [ ! -z "$INTERSECT" ]; then # prompt if file(s) already exist in the current directory
echo "File(s) ${INTERSECT::-1} already exist in the current directory."
while true; do
read -p 'Do you wish to overwrite them? ' yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
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.