|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
From 1d7e8a74bb6c282ebe6c9193e4bd0218ec689e46 Mon Sep 17 00:00:00 2001
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
From: Josh Poimboeuf <jpoimboe@redhat.com>
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
Date: Wed, 17 Aug 2022 12:21:04 -0700
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
Subject: [PATCH 106/108] kpatch-build: support Linux 5.19 .cmd file format
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
Rewrite kobj_find() to deal with Linux 5.19, where the .cmd files use
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
object file paths relative to the .cmd file rather than relative to the
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
root of the kernel tree.
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
While at it, add several performance enhancements to prevent all
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
currently known deep finds.
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
This is all quite fiddly. But it works.
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
Fixes #1277.
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
---
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
kpatch-build/kpatch-build | 243 +++++++++++++++++++++++++++++---------
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
1 file changed, 188 insertions(+), 55 deletions(-)
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
index 5435a19..bec8010 100755
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
--- a/kpatch-build/kpatch-build
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+++ b/kpatch-build/kpatch-build
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
@@ -434,82 +434,215 @@ find_special_section_data() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
-filter_parent_obj()
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
-{
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- local dir="${1}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- local file="${2}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+# path of file, relative to dir
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+# adapted from https://stackoverflow.com/a/24848739
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+relpath() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local file="$1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local dir="$2"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local filedir
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local common
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local result
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ filedir="$(dirname "$(readlink -f "$file")")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ common="$(readlink -f "$dir")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ "$filedir" = "$common" ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ basename "$file"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ while [[ "${filedir#$common/}" = "$filedir" ]]; do
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ common="$(dirname "$common")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ result="../$result"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ done
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- grep -v "\.mod\.cmd$" | grep -Fv "${dir}/.${file}.cmd"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ result="${result}${filedir#$common/}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ echo "${result}/$(basename "$file")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
-find_parent_obj() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- dir="$(dirname "$1")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- absdir="$(readlink -f "$dir")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- pwddir="$(readlink -f .)"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- pdir="${absdir#$pwddir/}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- file="$(basename "$1")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- grepname="${1%.o}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- grepname="$grepname\\.o"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- if [[ "$DEEP_FIND" -eq 1 ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- num=0
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- if [[ -n "$last_deep_find" ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- parent="$(grep -lw "$grepname" "$last_deep_find"/.*.cmd | filter_parent_obj "${pdir}" "${file}" | head -n1)"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- num="$(grep -lw "$grepname" "$last_deep_find"/.*.cmd | filter_parent_obj "${pdir}" "${file}" | wc -l)"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+cmd_file_to_o_file() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local parent="$1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # convert cmd file name to corresponding .o
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parent_dir="$(dirname "$parent")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parent_dir="${parent_dir#./}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parent="$(basename "$parent")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parent="${parent#.}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parent="${parent%.cmd}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parent="$parent_dir/$parent"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -f $parent ]] || die "can't find $parent associated with $1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ echo "$parent"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+get_parent_from_parents() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local parents=("$@")
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ ${#parents[@]} -eq 0 ]] && PARENT="" && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ ${#parents[@]} -eq 1 ]] && PARENT="${parents[0]}" && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # multiple parents:
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local parent
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local mod_name="${parents[0]%.*}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local mod_file
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ for parent in "${parents[@]}"; do
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # for modules, there can be multiple matches. Some
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # combination of foo.o, foo.mod, and foo.ko, depending
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # on kernel version and whether the module is single or
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # multi-object. Make sure a .mod and/or .ko exists, and no
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # more than one .mod/.ko exists.
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ $parent = *.o ]] && continue
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ ${parent%.*} != "$mod_name" ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ mod_file=""
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ break
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- if [[ "$num" -eq 0 ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- parent="$(find . -name ".*.cmd" -print0 | xargs -0 grep -lw "$grepname" | filter_parent_obj "${pdir}" "${file}" | cut -c3- | head -n1)"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- num="$(find . -name ".*.cmd" -print0 | xargs -0 grep -lw "$grepname" | filter_parent_obj "${pdir}" "${file}" | wc -l)"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- [[ "$num" -eq 1 ]] && last_deep_find="$(dirname "$parent")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ $parent = *.mod || $parent = *.ko ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ mod_file=$parent
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ continue
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ mod_file=""
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ break
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ done
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ -n $mod_file ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ PARENT="$mod_file"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ ERROR_IF_DIFF="multiple parent matches for $file: ${parents[*]}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ PARENT="${parents[0]}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+__find_parent_obj_in_dir() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local file="$1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local dir="$2"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ declare -a parents
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ while IFS='' read -r parent; do
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parent="$(cmd_file_to_o_file "$parent")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ $parent -ef $file ]] && continue
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parents+=("$parent")
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ done < <(grep -El "[ ]${file/./\\.}([ \)]|$)" "$dir"/.*.cmd)
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ get_parent_from_parents "${parents[@]}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+find_parent_obj_in_dir() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local file="$1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local dir="$2"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # make sure the dir has .cmd files
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if ! compgen -G "$dir"/.*.cmd > /dev/null; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ PARENT=""
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # 5.19+: ../acp/acp_hw.o
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ __find_parent_obj_in_dir "$(relpath "$file" "$dir")" "$dir"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -n $PARENT ]] && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # pre-5.19 (and 5.19+ single-object modules):
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ $file == $dir* ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # arch/x86/kernel/smp.o
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ __find_parent_obj_in_dir "$file" "$dir"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
else
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- parent="$(grep -lw "$grepname" "$dir"/.*.cmd | filter_parent_obj "${dir}" "${file}" | head -n1)"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- num="$(grep -lw "$grepname" "$dir"/.*.cmd | filter_parent_obj "${dir}" "${file}" | wc -l)"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # drivers/gpu/drm/amd/amdgpu/../acp/acp_hw.o
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ __find_parent_obj_in_dir "$dir"/"$(relpath "$file" "$dir")" "$dir"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- [[ "$num" -eq 0 ]] && PARENT="" && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- [[ "$num" -gt 1 ]] && ERROR_IF_DIFF="two parent matches for $1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+find_parent_obj() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local file="$1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # common case: look in same directory
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ find_parent_obj_in_dir "$file" "$(dirname "$file")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -n $PARENT ]] && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- dir="$(dirname "$parent")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- PARENT="$(basename "$parent")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- PARENT="${PARENT#.}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- PARENT="${PARENT%.cmd}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- [[ $dir != "." ]] && PARENT="$dir/$PARENT"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- [[ ! -e "$PARENT" ]] && die "ERROR: can't find parent $PARENT for $1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # if we previously had a successful deep find, try that dir first
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ -n "$LAST_DEEP_FIND_DIR" ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ find_parent_obj_in_dir "$file" "$LAST_DEEP_FIND_DIR"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -n "$PARENT" ]] && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # prevent known deep finds
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ $file = drivers/gpu/drm/amd/* ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ find_parent_obj_in_dir "$file" "drivers/gpu/drm/amd/amdgpu"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -n "$PARENT" ]] && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ $file = virt/kvm/* ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ find_parent_obj_in_dir "$file" "arch/x86/kvm"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -n "$PARENT" ]] && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ $file = drivers/oprofile/* ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ find_parent_obj_in_dir "$file" "arch/x86/oprofile"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -n "$PARENT" ]] && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # check higher-level dirs
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local dir
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ dir="$(dirname "$file")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ while [[ ! $dir -ef . ]]; do
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ dir="$(dirname "$dir")"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ find_parent_obj_in_dir "$file" "$dir"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -n $PARENT ]] && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ done
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ # slow path: search the entire tree ("deep find")
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ echo 'doing "deep find" for parent object'
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ declare -a parents
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ while IFS= read -r -d '' dir; do
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ find_parent_obj_in_dir "$file" "$dir"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ if [[ -n $PARENT ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ parents+=("$PARENT")
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ LAST_DEEP_FIND_DIR="$dir"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ done < <(find . -type d -print0)
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ get_parent_from_parents "${parents[@]}"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+# find vmlinux or .ko associated with a .o file
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
find_kobj() {
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- arg="$1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ local file="$1"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
if [[ -n $OOT_MODULE ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
KOBJFILE="$OOT_MODULE"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- KOBJFILE="$arg"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- DEEP_FIND=0
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ KOBJFILE="$file"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
ERROR_IF_DIFF=
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
while true; do
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ case "$KOBJFILE" in
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ *.mod)
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ KOBJFILE=${PARENT/.mod/.ko}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -e $KOBJFILE ]] || die "can't find .ko for $PARENT"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ ;;
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ *.ko)
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ ;;
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ */built-in.o|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ */built-in.a|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ arch/x86/kernel/ebda.o|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ arch/x86/kernel/head*.o|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ arch/x86/kernel/platform-quirks.o|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ arch/x86/lib/lib.a|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ lib/lib.a)
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ KOBJFILE=vmlinux
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ ;;
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ esac
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
find_parent_obj "$KOBJFILE"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- [[ -n "$PARENT" ]] && DEEP_FIND=0
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- if [[ -z "$PARENT" ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- [[ "$KOBJFILE" = *.ko ]] && return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- case "$KOBJFILE" in
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- */built-in.o|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- */built-in.a|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- arch/x86/lib/lib.a|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- arch/x86/kernel/head*.o|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- arch/x86/kernel/ebda.o|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- arch/x86/kernel/platform-quirks.o|\
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- lib/lib.a)
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- KOBJFILE=vmlinux
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- return
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- esac
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- if [[ "$DEEP_FIND" -eq 0 ]]; then
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- DEEP_FIND=1
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- continue;
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- die "invalid ancestor $KOBJFILE for $arg"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
- fi
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
+ [[ -z "$PARENT" ]] && die "invalid ancestor $KOBJFILE for $file"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
KOBJFILE="$PARENT"
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
done
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
}
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
--
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
2.37.3
|
|
![](https://seccdn.libravatar.org/avatar/fd810b62950cc276bea6dfd556fddb46f443946a2cb6243830c798dc8682dd7c?s=16&d=retro) |
642cd7 |
|