Module Name: src Committed By: tsutsui Date: Sun Mar 30 03:03:27 UTC 2025
Modified Files: src/usr.sbin/installboot/arch: hp300.c Log Message: Always read LIF volume/directory from stage1 even on cd9660 stage2 case. mmap(2) against the bootstrap file in the target cd9660 could fail because the sector size of ISO9660 is 2048 so each file could be allocated at an offset not pagesize (4096 or 8192) aligned. This could fail if stage1 (specified via "primary" arg on command line) and stage2 (on the target filesystem) files are different, but in "build.sh iso-image" case they are always identical. The problem (build failures in auotomated builds for hp300 on Linux) was reported by Jan-Benedict Glaw. Should also be pulled up to netbsd-10. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/installboot/arch/hp300.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/installboot/arch/hp300.c diff -u src/usr.sbin/installboot/arch/hp300.c:1.19 src/usr.sbin/installboot/arch/hp300.c:1.20 --- src/usr.sbin/installboot/arch/hp300.c:1.19 Sun May 19 15:48:57 2024 +++ src/usr.sbin/installboot/arch/hp300.c Sun Mar 30 03:03:27 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: hp300.c,v 1.19 2024/05/19 15:48:57 tsutsui Exp $ */ +/* $NetBSD: hp300.c,v 1.20 2025/03/30 03:03:27 tsutsui Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if !defined(__lint) -__RCSID("$NetBSD: hp300.c,v 1.19 2024/05/19 15:48:57 tsutsui Exp $"); +__RCSID("$NetBSD: hp300.c,v 1.20 2025/03/30 03:03:27 tsutsui Exp $"); #endif /* !__lint */ /* We need the target disklabel.h, not the hosts one..... */ @@ -103,6 +103,9 @@ hp300_setboot(ib_params *params) retval = 0; bootstrap = MAP_FAILED; + /* needs whole LIF volume/directory and actual bootstrap by default */ + bootstrap_size = params->s1stat.st_size; + label = malloc(params->sectorsize); if (label == NULL) { warn("Failed to allocate memory for disklabel"); @@ -223,27 +226,12 @@ hp300_setboot(ib_params *params) } } -#ifdef SUPPORT_CD9660 - if (params->stage2 != NULL) { - /* Use bootstrap file in the target filesystem. */ - bootstrap = mmap(NULL, bootstrap_size, - PROT_READ | PROT_WRITE, MAP_PRIVATE, params->fsfd, - boot_offset); - if (bootstrap == MAP_FAILED) { - warn("mmapping `%s'", params->filesystem); - goto done; - } - } else -#endif - { - /* Use bootstrap specified as stage1. */ - bootstrap_size = params->s1stat.st_size; - bootstrap = mmap(NULL, bootstrap_size, - PROT_READ | PROT_WRITE, MAP_PRIVATE, params->s1fd, 0); - if (bootstrap == MAP_FAILED) { - warn("mmapping `%s'", params->stage1); - goto done; - } + /* Read LIF volume/directory (and bootstrap) from stage1 */ + bootstrap = mmap(NULL, bootstrap_size, + PROT_READ | PROT_WRITE, MAP_PRIVATE, params->s1fd, 0); + if (bootstrap == MAP_FAILED) { + warn("mmapping `%s'", params->stage1); + goto done; } /* Relocate files, sanity check LIF directory on the way */