Page MenuHomeFreeBSD

D59233.diff
No OneTemporary

D59233.diff

diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -63,6 +63,8 @@
NANO_IMGNAME="_.disk.${NANO_NAME}"
NANO_IMG1NAME="_.disk.image"
+NANO_FILE_SYSTEM="UFS"
+
# Options to put in make.conf during buildworld only
CONF_BUILD=' '
@@ -100,9 +102,6 @@
# Late customize commands.
NANO_LATE_CUSTOMIZE=""
-# makefs parameters to use
-NANO_MAKEFS="-o softupdates=1,version=2"
-
# The drive name of the media at runtime
NANO_DRIVE=ada0
@@ -1413,7 +1412,7 @@
tgt_pkg_update_config_files_content etc/defaults/rc.conf
fi
- if [ "$NANO_PLAN" = "default" ]; then
+ if [ "$NANO_PLAN" = "default" ] && [ "$NANO_FILE_SYSTEM" = "UFS" ]; then
tgt_patch_gptboot
fi
@@ -1451,13 +1450,13 @@
[Bb][Ii][Oo][Ss])
case "$part_type" in
[Mm][Bb][Rr]) echo "boot/boot" ;;
- [Gg][Pp][Tt]) echo "boot/gptboot" ;;
+ [Uu][Ff][Ss]) echo "boot/gptboot" ;;
*) err "Unsupported BIOS partition type '${part_type}'" ;;
esac
;;
[Uu][Ee][Ff][Ii])
case "$part_type" in
- [Gg][Pp][Tt]) echo "boot/gptboot.efi" ;;
+ [Uu][Ff][Ss]) echo "boot/gptboot.efi" ;;
[Zz][Ff][Ss]) echo "boot/loader.efi" ;;
*) err "Unsupported UEFI partition type '${part_type}'" ;;
esac
@@ -1481,23 +1480,31 @@
#
# Run makefs to create a UFS filesystem image from a source directory
# using a metalog spec and timestamp
-# Input: $1 = options, $2 = metalog path, $3 = size in bytes,
-# $4 = output image path, $5 = source dir
+# Input: $1 = fstype, $2 = options, $3 = metalog path, $4 = size in bytes,
+# $5 = output image path, $6 = source dir
#
nano_makefs() {
- local dir image metalog options size
- options=$1
- metalog=$2
- size=$3
- image=$4
- dir=$5
+ local dir fstype image metalog options size size_option
+ fstype=$1
+ options=$2
+ metalog=$3
+ size=$4
+ image=$5
+ dir=$6
+
+ # Prefer -R for UFS, as -s the does not include the offset.
+ if [ "$NANO_FILE_SYSTEM" = "UFS" ]; then
+ size_option="-R $size"
+ else
+ size_option="-s $size"
+ fi
if [ -n "$metalog" ] && [ -f "$metalog" ]; then
- makefs -t ffs -DxZ ${options} -F "$metalog" -N "${NANO_WORLDDIR}/etc" \
- -R "$size" -T "$NANO_TIMESTAMP" "$image" "$dir"
+ makefs -t ${fstype} -DxZ ${options} -F "$metalog" -N "${NANO_WORLDDIR}/etc" \
+ "$size_option" -T "$NANO_TIMESTAMP" "$image" "$dir"
else
- makefs -t ffs -Z ${options} -N "${NANO_WORLDDIR}/etc" \
- -R "$size" -T "$NANO_TIMESTAMP" "$image" "$dir"
+ makefs -t ${fstype} -Z ${options} -N "${NANO_WORLDDIR}/etc" \
+ "$size_option" -T "$NANO_TIMESTAMP" "$image" "$dir"
fi
}
@@ -1509,71 +1516,6 @@
umount ${1}
}
-#
-# Create a UFS filesystem image from a directory
-# Input: $1 = type (cfg/data), $2 = output image path, $3 = source dir,
-# $4 = label, $5 = size in bytes, $6 = metalog
-#
-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 -rf ${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="${NANO_METALOG}.${type}"
- 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=${NANO_DEF_UNAME}/g" |
- sed "s/gid=[[:digit:]]*/gname=${NANO_DEF_GNAME}/g" >> "${metalog}"
- )
- fi
-
- nano_makefs "$NANO_MAKEFS" "$metalog" "$size" "$fs" "$dir"
- fi
-}
-
-#
-# Thin wrapper around populate_part for creating
-# the configuration partition image file
-# Input: $1 = image path, $2 = source dir, $3 = label, $4 = size, $5 = metalog
-#
-populate_cfg_part() {
- populate_part "cfg" "$1" "$2" "$3" "$4" "$5"
-}
-
-#
-# Thin wrapper around populate_part for creating the data partition image file
-# Input: $1 = image path, $2 = source dir, $3 = label, $4 = size, $5 = metalog
-#
-populate_data_part() {
- populate_part "data" "$1" "$2" "$3" "$4" "$5"
-}
-
#
# Placeholder hook called after image build completes;
# override to copy or publish the finished image
diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh
--- a/tools/tools/nanobsd/nanobsd.sh
+++ b/tools/tools/nanobsd/nanobsd.sh
@@ -48,7 +48,7 @@
}
default() {
- . "${topdir}/gpt.sh"
+ . "${topdir}/ufs.sh"
NANO_PLAN="${NANO_PLAN:-default}"
}
diff --git a/tools/tools/nanobsd/gpt.sh b/tools/tools/nanobsd/ufs.sh
rename from tools/tools/nanobsd/gpt.sh
rename to tools/tools/nanobsd/ufs.sh
--- a/tools/tools/nanobsd/gpt.sh
+++ b/tools/tools/nanobsd/ufs.sh
@@ -61,6 +61,9 @@
NANO_ALIGN="${NANO_ALIGN:-1MiB}"
+# makefs parameters to use
+NANO_MAKEFS="-o softupdates=1,version=2"
+
# Create the /etc/fstab file
tgt_write_fstab() {
(
@@ -395,7 +398,7 @@
code_size=$(( code_sects * NANO_SECTOR_SIZE ))
echo "Writing code image..."
- nano_makefs "${NANO_MAKEFS} -o minfree=0,optimization=space" \
+ nano_makefs "ffs" "${NANO_MAKEFS} -o minfree=0,optimization=space" \
"$NANO_METALOG" "$code_size" "$IMG" "$NANO_WORLDDIR"
) > "${NANO_OBJ}/_.cp" 2>&1
}
@@ -472,7 +475,7 @@
if [ "$NANO_INIT_IMG2" -gt 0 ]; then
echo "Duplicating to second image..."
tgt_switch_root_fstab 1 2
- nano_makefs "${NANO_MAKEFS} -o minfree=0,optimization=space" \
+ nano_makefs "ffs" "${NANO_MAKEFS} -o minfree=0,optimization=space" \
"${NANO_METALOG}" "$code_size" \
"${NANO_OBJ}/_.${NANO_ALTROOT}.image" "${NANO_WORLDDIR}"
tgt_switch_root_fstab 2 1
@@ -561,3 +564,68 @@
fi
)
}
+
+#
+# Create a UFS filesystem image from a directory
+# Input: $1 = type (cfg/data), $2 = output image path, $3 = source dir,
+# $4 = label, $5 = size in bytes, $6 = metalog
+#
+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 -rf ${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="${NANO_METALOG}.${type}"
+ 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=${NANO_DEF_UNAME}/g" |
+ sed "s/gid=[[:digit:]]*/gname=${NANO_DEF_GNAME}/g" >> "${metalog}"
+ )
+ fi
+
+ nano_makefs "ffs" "$NANO_MAKEFS" "$metalog" "$size" "$fs" "$dir"
+ fi
+}
+
+#
+# Thin wrapper around populate_part for creating
+# the configuration partition image file
+# Input: $1 = image path, $2 = source dir, $3 = label, $4 = size, $5 = metalog
+#
+populate_cfg_part() {
+ populate_part "cfg" "$1" "$2" "$3" "$4" "$5"
+}
+
+#
+# Thin wrapper around populate_part for creating the data partition image file
+# Input: $1 = image path, $2 = source dir, $3 = label, $4 = size, $5 = metalog
+#
+populate_data_part() {
+ populate_part "data" "$1" "$2" "$3" "$4" "$5"
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Sep 26, 9:20 PM (5 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39695644
Default Alt Text
D59233.diff (7 KB)

Event Timeline