git: 9d133c76402e - main - nanobsd: Get the code size by its partition index
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 May 2026 00:36:58 UTC
The branch main has been updated by jlduran:
URL: https://cgit.FreeBSD.org/src/commit/?id=9d133c76402e769fd63ed838ad641572439cd126
commit 9d133c76402e769fd63ed838ad641572439cd126
Author: Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2026-05-27 00:13:15 +0000
Commit: Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2026-05-27 00:13:15 +0000
nanobsd: Get the code size by its partition index
Previously the code was assumed to be on the on the first line of the
_.partitioning file. Instead, explicitly look up the size by its
partition index to make the parsing order-independent.
The _.partitioning file:
1. First column: starting sector.
2. Second column: size in 512-byte sectors.
3. Third column: partition index.
Get the code size by explicitly selecting when the partition index is 1.
Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D57216
---
tools/tools/nanobsd/legacy.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/tools/nanobsd/legacy.sh b/tools/tools/nanobsd/legacy.sh
index 6ce477ea0c88..efe49bbf692c 100644
--- a/tools/tools/nanobsd/legacy.sh
+++ b/tools/tools/nanobsd/legacy.sh
@@ -111,7 +111,7 @@ create_code_slice() {
IMG=${NANO_DISKIMGDIR}/${NANO_IMG1NAME}
MNT=${NANO_OBJ}/_.mnt
mkdir -p ${MNT}
- CODE_SIZE=$(head -n 1 ${NANO_LOG}/_.partitioning | awk '{ print $2 }')
+ CODE_SIZE=$(awk '$3 == 1 {print $2}' "${NANO_LOG}/_.partitioning")
if [ "${NANO_MD_BACKING}" = "swap" ] ; then
MD=$(mdconfig -a -t swap -s ${CODE_SIZE} -x ${NANO_SECTS} \
@@ -161,7 +161,7 @@ _create_code_slice() {
(
IMG=${NANO_DISKIMGDIR}/${NANO_IMG1NAME}
- CODE_SIZE=$(head -n 1 "${NANO_LOG}/_.partitioning" | awk '{ print $2 }')
+ CODE_SIZE=$(awk '$3 == 1 {print $2}' "${NANO_LOG}/_.partitioning")
CODE_SIZE=$(_xxx_adjust_code_size "$CODE_SIZE")
echo "Writing code image..."
@@ -290,7 +290,7 @@ _create_diskimage() {
(
local altroot bootloader cfgimage dataimage diskimage
- CODE_SIZE=$(head -n 1 "${NANO_LOG}/_.partitioning" | awk '{ print $2 }')
+ CODE_SIZE=$(awk '$3 == 1 {print $2}' "${NANO_LOG}/_.partitioning")
CODE_SIZE=$(_xxx_adjust_code_size "$CODE_SIZE")
IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}