initramfs_validate: resolve path and harden existence check
• Resolve input dir to absolute with resolve_path and perform early -d check in [bash.initramfs_validate()](scripts/lib/initramfs.sh:774) to avoid safe_execute aborts on missing paths • Use plain ls/find logging for sanity snapshot (not safe_execute) so validation reports context even if directory is absent
This commit is contained in:
@@ -772,15 +772,26 @@ function initramfs_create_cpio() {
|
|||||||
|
|
||||||
# Validate initramfs contents
|
# Validate initramfs contents
|
||||||
function initramfs_validate() {
|
function initramfs_validate() {
|
||||||
local initramfs_dir="$1"
|
local initramfs_dir_in="$1"
|
||||||
|
local initramfs_dir
|
||||||
|
initramfs_dir=$(resolve_path "${initramfs_dir_in}")
|
||||||
|
|
||||||
section_header "Validating initramfs contents"
|
section_header "Validating initramfs contents"
|
||||||
|
|
||||||
local errors=0
|
local errors=0
|
||||||
|
|
||||||
|
# Early existence check to avoid aborting via safe_execute
|
||||||
|
if [[ ! -d "${initramfs_dir}" ]]; then
|
||||||
|
log_error "Initramfs directory not found: ${initramfs_dir_in} (resolved: ${initramfs_dir})"
|
||||||
|
log_info "PWD: $(pwd)"
|
||||||
|
log_info "Listing current directory:"
|
||||||
|
ls -la . 2>/dev/null || true
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Sanity snapshot to aid debugging when validation fails
|
# Sanity snapshot to aid debugging when validation fails
|
||||||
log_info "Validation sanity: top-level of ${initramfs_dir}:"
|
log_info "Validation sanity: top-level of ${initramfs_dir}:"
|
||||||
safe_execute ls -la "${initramfs_dir}" || true
|
ls -la "${initramfs_dir}" 2>/dev/null || log_warn "Cannot list ${initramfs_dir}"
|
||||||
local _count_sanity
|
local _count_sanity
|
||||||
_count_sanity=$(find "${initramfs_dir}" -mindepth 1 | wc -l || echo "0")
|
_count_sanity=$(find "${initramfs_dir}" -mindepth 1 | wc -l || echo "0")
|
||||||
log_info "Validation sanity: ${_count_sanity} total entries under ${initramfs_dir}"
|
log_info "Validation sanity: ${_count_sanity} total entries under ${initramfs_dir}"
|
||||||
|
|||||||
Reference in New Issue
Block a user