From 45ba6a367d7765c9cb81a57e4caf3259bebe94fc Mon Sep 17 00:00:00 2001 From: vxtls <187420201+vxtls@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:04:16 -0500 Subject: [PATCH] fix(gawk): add typed read_func prototype patch and validate with dry-run AND fix(import-payload): switch to procfs /proc/partitions major/minor enumeration with magic-verified payload import --- .../patches/fix-read-func-prototype.patch | 53 +++++++++++++++++++ steps/improve/import_payload.sh | 11 ++-- steps/payload-import-1.0/src/payload-import.c | 4 +- 3 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 steps-guix/gawk-4.2.1/patches/fix-read-func-prototype.patch diff --git a/steps-guix/gawk-4.2.1/patches/fix-read-func-prototype.patch b/steps-guix/gawk-4.2.1/patches/fix-read-func-prototype.patch new file mode 100644 index 00000000..f186b356 --- /dev/null +++ b/steps-guix/gawk-4.2.1/patches/fix-read-func-prototype.patch @@ -0,0 +1,53 @@ +SPDX-License-Identifier: GPL-3.0-or-later + +Fix read_func prototype to use a modern typed function pointer. + +--- gawk-4.2.1/gawkapi.h ++++ gawk-4.2.1/gawkapi.h +@@ -190,7 +190,7 @@ + * No argument prototype on read_func to allow for older systems + * whose headers are not up to date. + */ +- ssize_t (*read_func)(); ++ ssize_t (*read_func)(int, void *, size_t); + + /* + * The close_func is called to allow the parser to free private data. +--- gawk-4.2.1/io.c ++++ gawk-4.2.1/io.c +@@ -310,7 +310,7 @@ + + static NODE *in_PROCINFO(const char *pidx1, const char *pidx2, NODE **full_idx); + static long get_read_timeout(IOBUF *iop); +-static ssize_t read_with_timeout(int fd, char *buf, size_t size); ++static ssize_t read_with_timeout(int fd, void *buf, size_t size); + + static bool read_can_timeout = false; + static long read_timeout; +@@ -3340,7 +3340,7 @@ + + iop->public.fd = fd; + iop->public.name = name; +- iop->public.read_func = ( ssize_t(*)() ) read; ++ iop->public.read_func = (ssize_t (*)(int, void *, size_t)) read; + iop->valid = false; + iop->errcode = errno_val; + +@@ -4318,7 +4318,7 @@ + tmout = read_default_timeout; /* initialized from env. variable in init_io() */ + + /* overwrite read routine only if an extension has not done so */ +- if ((iop->public.read_func == ( ssize_t(*)() ) read) && tmout > 0) ++ if ((iop->public.read_func == (ssize_t (*)(int, void *, size_t)) read) && tmout > 0) + iop->public.read_func = read_with_timeout; + + return tmout; +@@ -4330,7 +4330,7 @@ + */ + + static ssize_t +-read_with_timeout(int fd, char *buf, size_t size) ++read_with_timeout(int fd, void *buf, size_t size) + { + #if ! defined(VMS) + fd_set readfds; diff --git a/steps/improve/import_payload.sh b/steps/improve/import_payload.sh index e2f66e4c..3dbdf397 100644 --- a/steps/improve/import_payload.sh +++ b/steps/improve/import_payload.sh @@ -8,8 +8,11 @@ set -ex if [ "${PAYLOAD_REQUIRED}" = True ]; then mkdir -p /external/distfiles mkdir -p /proc - mount -t proc proc /proc >/dev/null 2>&1 || : + # Reliable enumeration in Fiwix: mount procfs and read /proc/partitions. + if [ ! -r /proc/partitions ]; then + mount -t proc proc /proc + fi if [ ! -r /proc/partitions ]; then echo "payload-import failed: /proc/partitions is unavailable." >&2 exit 1 @@ -22,13 +25,13 @@ if [ "${PAYLOAD_REQUIRED}" = True ]; then continue ;; *[0-9]) - # Skip partitions (sda1, vdb2, ...); payload is attached as a whole disk. + # Skip partitions (hda1, sdb2, ...); payload is a whole disk. continue ;; esac dev_path="/dev/${name}" - mknod -m 600 "${dev_path}" b "${major}" "${minor}" >/dev/null 2>&1 || : + [ -b "${dev_path}" ] || mknod -m 600 "${dev_path}" b "${major}" "${minor}" if payload-import --probe "${dev_path}"; then payload-import --device "${dev_path}" /external/distfiles @@ -38,7 +41,7 @@ if [ "${PAYLOAD_REQUIRED}" = True ]; then done < /proc/partitions if [ "${found_payload}" != 1 ]; then - echo "payload-import failed: no payload image found on probed block devices." >&2 + echo "payload-import failed: no payload image found in /proc/partitions." >&2 exit 1 fi fi diff --git a/steps/payload-import-1.0/src/payload-import.c b/steps/payload-import-1.0/src/payload-import.c index 8be94df3..d937d70b 100644 --- a/steps/payload-import-1.0/src/payload-import.c +++ b/steps/payload-import-1.0/src/payload-import.c @@ -227,10 +227,10 @@ static int extract_payload(const char *device, const char *dest_dir) static int import_from_first_payload(const char *dest_dir) { - const char *prefixes[] = {"/dev/sd", "/dev/vd", "/dev/hd"}; + const char *prefixes[] = {"/dev/sd", "/dev/hd", "/dev/vd", "/dev/xvd"}; int p; - for (p = 0; p < 3; ++p) { + for (p = 0; p < 4; ++p) { char letter; for (letter = 'b'; letter <= 'z'; ++letter) { char device[16];