diff options
| author | Jose Luis Duran <jlduran@FreeBSD.org> | 2026-05-27 00:13:15 +0000 |
|---|---|---|
| committer | Jose Luis Duran <jlduran@FreeBSD.org> | 2026-05-27 00:13:15 +0000 |
| commit | 9d133c76402e769fd63ed838ad641572439cd126 (patch) | |
| tree | 64a2fac07a2e7845b87504351fc773fc2f20715f | |
| parent | 689f7466c1aee7810e6a965e82338c765105a1cf (diff) | |
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
| -rw-r--r-- | tools/tools/nanobsd/legacy.sh | 6 |
1 files 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} |
