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
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user