git: 61ac7309c366 - main - nanobsd: Add a provisional populate_part function
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 17 Jan 2026 18:13:07 UTC
The branch main has been updated by jlduran:
URL: https://cgit.FreeBSD.org/src/commit/?id=61ac7309c3669bdadd3983f0bb03440a7c147820
commit 61ac7309c3669bdadd3983f0bb03440a7c147820
Author: Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2026-01-17 18:09:14 +0000
Commit: Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2026-01-17 18:09:14 +0000
nanobsd: Add a provisional populate_part function
Add a _populate_part(ition) function that mimics the current
populate_slice. Note however, that this function is not
backward-compatible with populate_slice, hence the different name. A
"_" is prepended to signal that it still experimental.
It can be used to populate the /cfg and /data partition using makefs(8).
Initially not wired.
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D48790
---
tools/tools/nanobsd/defaults.sh | 44 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
index 9827095b334c..7775dd572fb5 100755
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -724,6 +724,50 @@ populate_slice() {
nano_umount ${mnt}
}
+_populate_part() (
+ local dir fs lbl metalog size type
+ type=$1
+ fs=$2
+ dir=$3
+ lbl=$4
+ size=$5
+ metalog=$6
+
+ echo "Creating ${fs}"
+
+ # Use the directory provided, otherwise create an empty one temporarily.
+ if [ -n "${dir}" ] && [ -d "${dir}" ]; then
+ echo "Populating ${lbl} from ${dir}"
+ else
+ if [ "${type}" = "cfg" ]; then
+ dir=$(mktemp -d -p "${NANO_OBJ}" -t "${type}")
+ trap "rm -f ${dir}" 1 2 15 EXIT
+ fi
+ fi
+
+ if [ -d "${dir}" ]; then
+ # If there is no metalog, create one using the default
+ # NANO_DEF_UNAME and NANO_DEF_GNAME for all entries in the spec.
+ if [ -z "${metalog}" ]; then
+ metalog=$(mktemp -p "${NANO_OBJ}" -t "${type}")
+ trap "rm -f ${metalog}" 1 2 15 EXIT
+ echo "/set type=dir uname=${NANO_DEF_UNAME}" \
+ "gname=${NANO_DEF_GNAME} mode=0755" > "${metalog}"
+ echo ". type=dir uname=${NANO_DEF_UNAME}" \
+ "gname=${NANO_DEF_GNAME} mode=0755" >> "${metalog}"
+ (
+ cd "${dir}"
+ mtree -bc -k flags,gid,gname,link,mode,uid,uname |
+ mtree -C | tail -n +2 |
+ sed 's/uid=[[:digit:]]*/uname=root/g' |
+ sed 's/gid=[[:digit:]]*/gname=wheel/g' >> "${metalog}"
+ )
+ fi
+
+ nano_makefs "-DxZ ${NANO_MAKEFS}" "${metalog}" "${size}" "${fs}" "${dir}"
+ fi
+)
+
populate_cfg_slice() {
populate_slice "$1" "$2" "$3" "$4"
}