git: 5ba2a74e3a20 - main - nanobsd: Add a nano_makefs function
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 17 Jan 2026 18:13:06 UTC
The branch main has been updated by jlduran:
URL: https://cgit.FreeBSD.org/src/commit/?id=5ba2a74e3a208ec5641832ffcb9674c0e4b06950
commit 5ba2a74e3a208ec5641832ffcb9674c0e4b06950
Author: Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2026-01-17 18:08:52 +0000
Commit: Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2026-01-17 18:08:52 +0000
nanobsd: Add a nano_makefs function
Add a NANO_MAKEFS global variable with options equivalent to NANO_NEWFS
to be used with a nano_makefs function for creating images.
Also add a function that adjusts the code size calculation, so makefs -s
won't error about the minimum rounded size. Ideally this shim should be
removed, therefore the suspicious _xxx prefix.
Initially not wired.
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D48789
---
tools/tools/nanobsd/defaults.sh | 14 ++++++++++++++
tools/tools/nanobsd/legacy.sh | 11 +++++++++++
2 files changed, 25 insertions(+)
diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
index 13e7797df2f5..9827095b334c 100755
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -107,6 +107,7 @@ NANO_LATE_CUSTOMIZE=""
# Newfs parameters to use
NANO_NEWFS="-b 4096 -f 512 -i 8192 -U"
+NANO_MAKEFS="-o bsize=4096,density=8192,fsize=512,softupdates=1,version=2"
# The drive name of the media at runtime
NANO_DRIVE=ada0
@@ -688,6 +689,18 @@ newfs_part() {
mount -o async ${dev} ${mnt}
}
+nano_makefs() {
+ local dir image metalog options size
+ options=$1
+ metalog=$2
+ size=$3
+ image=$4
+ dir=$5
+
+ makefs ${options} -F "${metalog}" -N "${NANO_WORLDDIR}/etc" \
+ -s "${size}b" -T "${NANO_TIMESTAMP}" -t ffs "${image}" "${dir}"
+}
+
# Convenient spot to work around any umount issues that your build environment
# hits by overriding this method.
nano_umount() {
@@ -1002,6 +1015,7 @@ set_defaults_and_export() {
export_var NANO_IMGNAME
export_var NANO_IMG1NAME
export_var NANO_MAKE
+ export_var NANO_MAKEFS
export_var NANO_MAKE_CONF_BUILD
export_var NANO_MAKE_CONF_INSTALL
export_var NANO_MEDIASIZE
diff --git a/tools/tools/nanobsd/legacy.sh b/tools/tools/nanobsd/legacy.sh
index 5ba2d81c6017..ff951f4b762b 100644
--- a/tools/tools/nanobsd/legacy.sh
+++ b/tools/tools/nanobsd/legacy.sh
@@ -92,6 +92,17 @@ calculate_partitioning() {
' > ${NANO_LOG}/_.partitioning
}
+_xxx_adjust_code_size()
+{
+ # XXX adjust the CODE_SIZE value by rounding it up to
+ # a bsize of 32768 (DFL_BLKSIZE).
+ # Otherwise makefs -s will fail because of the guard
+ # introduced in 5ad283b3c60d.
+ codesize=$1
+ bsize=32768
+ echo $(( ((codesize + (bsize - 1)) / bsize) * bsize ))
+}
+
create_code_slice() {
pprint 2 "build code slice"
pprint 3 "log: ${NANO_OBJ}/_.cs"