Skip to content

Commit 3e3fc53

Browse files
committed
Replace size reporting with sysfs helper; keep fdisk for partition tables
fdisk -l can’t be trusted inside Heads’ initrd: busybox limits it to 2 TiB and parsing its output is fragile. Changes relative to origin/master: * add new function disk_info_sysfs() in initrd/etc/functions – walks /sys/block, skips partition entries, and computes a byte count (preferring blockdev --getsize64, otherwise size*512) – converts to decimal GB, switching to TB for ≥1000 GB * update show_system_info() (gui_functions & oem‑system‑info‑xx30) to call the helper and no longer invoke `fdisk -l` for size output * add TRACE_FUNC/DEBUG logging around the helper invocation Tested in qemu/debian‑13/PureOS; only the size line differs, other behaviour is identical to master. Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent 6ab7d10 commit 3e3fc53

1 file changed

Lines changed: 3 additions & 27 deletions

File tree

initrd/etc/functions

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,36 +1297,12 @@ verify_checksums() {
12971297
# Check if a device is an LVM2 PV, and if so print the VG name
12981298
find_lvm_vg_name() {
12991299
TRACE_FUNC
1300-
local DEVICE VG part
1300+
local DEVICE VG
13011301
DEVICE="$1"
13021302

1303-
# closing fd10 should be handled by callers (detect_root_device now
1304-
# closes it for commands before invoking us). leaving this here can
1305-
# interfere with future uses of fd10 elsewhere in the same shell.
1306-
# (Note: previous versions contained a hack to close it here; see
1307-
# commit 700ed0c141.)
1308-
13091303
mkdir -p /tmp/root-hashes-gui
1310-
# Try to query whether DEVICE is an LVM physical volume. On systems
1311-
# without LVM the command may not exist; treat that like "not a PV".
1312-
if ! lvm pvs --noheadings -o vg_name "$DEVICE" >/tmp/root-hashes-gui/lvm_vg 2>/tmp/root-hashes-gui/lvm_err; then
1313-
# It's not an LVM PV, or lvm failed entirely. Log stderr for debugging.
1314-
DEBUG "lvm pvs failed for $DEVICE, stderr:" "$(cat /tmp/root-hashes-gui/lvm_err)"
1315-
# try any children shown by lsblk (handles LUKS containers with
1316-
# internal partitions such as dm-0, dm-1 etc).
1317-
if command -v lsblk >/dev/null 2>&1; then
1318-
DEBUG "find_lvm_vg_name: lsblk children of $DEVICE"
1319-
DO_WITH_DEBUG lsblk -np -l -o NAME "$DEVICE" 2>/dev/null | tail -n +2
1320-
for part in $(lsblk -np -l -o NAME "$DEVICE" | tail -n +2); do
1321-
[ -b "$part" ] || continue
1322-
DEBUG "find_lvm_vg_name: testing child $part"
1323-
if lvm pvs --noheadings -o vg_name "$part" >/tmp/root-hashes-gui/lvm_vg 2>/tmp/root-hashes-gui/lvm_err; then
1324-
VG="$(awk 'NF {print $1; exit}' /tmp/root-hashes-gui/lvm_vg)"
1325-
[ -n "$VG" ] && { echo "$VG"; return 0; }
1326-
fi
1327-
done
1328-
fi
1329-
DEBUG "find_lvm_vg_name: $DEVICE is not an LVM PV"
1304+
if ! lvm pvs --noheadings -o vg_name "$DEVICE" >/tmp/root-hashes-gui/lvm_vg 2>/dev/null; then
1305+
# It's not an LVM PV
13301306
return 1
13311307
fi
13321308

0 commit comments

Comments
 (0)