-
-
Notifications
You must be signed in to change notification settings - Fork 206
Root hash generalize #2067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Root hash generalize #2067
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| #!/bin/bash | ||
|
|
||
| # maintain a cross-script trace stack. When a script sources /etc/functions | ||
| # this appends the script name/line to TRACE_STACK; the variable is exported so | ||
| # it survives into children invoked with exec. TRACE_FUNC will prepend this | ||
| # stack to the normal function call stack, giving a full picture from init to | ||
| # the current point (even across multiple scripts). | ||
| # Only add the current script once to avoid repetition when the same script | ||
| # sources this file multiple times or invokes TRACE_FUNC repeatedly. | ||
| case "${TRACE_STACK}" in | ||
| *"main($0:"*) | ||
| ;; | ||
| *) | ||
| TRACE_STACK="${TRACE_STACK:+$TRACE_STACK -> }main($0:0)" | ||
| export TRACE_STACK | ||
| ;; | ||
| esac | ||
|
|
||
| # ------- Start of functions coming from /etc/ash_functions | ||
|
|
||
| die() { | ||
|
|
@@ -680,8 +696,12 @@ TRACE_FUNC() { | |
| # Append the direct caller (without extra " -> " at the end) | ||
| stack_trace+="${FUNCNAME[1]}(${BASH_SOURCE[1]}:${BASH_LINENO[0]})" | ||
|
|
||
| # Print the final trace output | ||
| TRACE "${stack_trace}" | ||
| # Print the final trace output, including any inherited script-level stack | ||
| if [ -n "$TRACE_STACK" ]; then | ||
| TRACE "$TRACE_STACK -> $stack_trace" | ||
| else | ||
| TRACE "${stack_trace}" | ||
| fi | ||
| } | ||
|
|
||
| # Show the entire current call stack in debug output - useful if a catastrophic | ||
|
|
@@ -1277,12 +1297,35 @@ verify_checksums() { | |
| # Check if a device is an LVM2 PV, and if so print the VG name | ||
| find_lvm_vg_name() { | ||
| TRACE_FUNC | ||
| local DEVICE VG | ||
| local DEVICE VG part | ||
| DEVICE="$1" | ||
|
|
||
| # closing fd10 should be handled by callers (detect_root_device now | ||
| # closes it for commands before invoking us). leaving this here can | ||
| # interfere with future uses of fd10 elsewhere in the same shell. | ||
| # (Note: previous versions contained a hack to close it here; see | ||
| # commit 700ed0c141.) | ||
|
|
||
| mkdir -p /tmp/root-hashes-gui | ||
| if ! lvm pvs --noheadings -o vg_name "$DEVICE" >/tmp/root-hashes-gui/lvm_vg 2>/dev/null; then | ||
| # It's not an LVM PV | ||
| # Try to query whether DEVICE is an LVM physical volume. On systems | ||
| # without LVM the command may not exist; treat that like "not a PV". | ||
| if ! lvm pvs --noheadings -o vg_name "$DEVICE" >/tmp/root-hashes-gui/lvm_vg 2>/tmp/root-hashes-gui/lvm_err; then | ||
| # It's not an LVM PV, or lvm failed entirely. Log stderr for debugging. | ||
| DEBUG "lvm pvs failed for $DEVICE, stderr:" "$(cat /tmp/root-hashes-gui/lvm_err)" | ||
|
Comment on lines
1309
to
+1314
|
||
| # try any children shown by lsblk (handles LUKS containers with | ||
| # internal partitions such as dm-0, dm-1 etc). | ||
| if command -v lsblk >/dev/null 2>&1; then | ||
| DEBUG "find_lvm_vg_name: lsblk children of $DEVICE" | ||
| for part in $(lsblk -np -l -o NAME "$DEVICE" | tail -n +2); do | ||
| [ -b "$part" ] || continue | ||
| DEBUG "find_lvm_vg_name: testing child $part" | ||
| if lvm pvs --noheadings -o vg_name "$part" >/tmp/root-hashes-gui/lvm_vg 2>/tmp/root-hashes-gui/lvm_err; then | ||
| VG="$(awk 'NF {print $1; exit}' /tmp/root-hashes-gui/lvm_vg)" | ||
| [ -n "$VG" ] && { echo "$VG"; return 0; } | ||
| fi | ||
| done | ||
| fi | ||
| DEBUG "find_lvm_vg_name: $DEVICE is not an LVM PV" | ||
| return 1 | ||
| fi | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TRACE_STACK header comment says it appends the script name/line, but the code always records ":0" (TRACE_STACK="...main($0:0)"). Consider capturing the actual source location (e.g., using BASH_SOURCE[1] and BASH_LINENO[0]) so traces are accurate and match the documented format.