Module Name: src Committed By: jmcneill Date: Tue Apr 11 18:04:08 UTC 2017
Modified Files: src/distrib/utils/embedded: mkimage Log Message: Improvements and fixes for FAT+FFS images: - Add a "NETBSD" volume label to the MSDOS file-system. - Explicitly initialize boot sector. - Correct an issue where the MSDOS file-system was larger than the partition table entry. - Add NetBSD partition to the MBR partition table. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/distrib/utils/embedded/mkimage Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/utils/embedded/mkimage diff -u src/distrib/utils/embedded/mkimage:1.62 src/distrib/utils/embedded/mkimage:1.63 --- src/distrib/utils/embedded/mkimage:1.62 Tue Mar 14 06:37:39 2017 +++ src/distrib/utils/embedded/mkimage Tue Apr 11 18:04:08 2017 @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: mkimage,v 1.62 2017/03/14 06:37:39 skrll Exp $ +# $NetBSD: mkimage,v 1.63 2017/04/11 18:04:08 jmcneill Exp $ # # Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -82,6 +82,28 @@ getsize() { echo $5 } +getsectors() { + case "$1" in + *g) + m=1073741824 + v=${1%g} + ;; + *m) + m=1048576 + v=${1%m} + ;; + *k) + m=1024 + v=${1%k} + ;; + *[0-9b]) + m=1 + v=${1%b} + ;; + esac + echo $((m * v / 512)) +} + usage() { cat << EOF 1>&2 Usage: $PROG -h <host-arch> [-bdmx] [-B <byte-order>] [-K <kerneldir>] [-S <srcdir>] [-D <destdir>] [-c <custom-files-dir>] [-s <Mb size>] [<image>] @@ -188,8 +210,8 @@ populate if [ -n "${msdosid}" ]; then echo ${bar} Populating msdos filesystem ${bar} - ${MAKEFS} -N ${release}/etc -t msdos \ - -O $((${init} / 2))m -s $((${boot} / 2 + ${init} / 2))m \ + ${MAKEFS} -N ${release}/etc -t msdos -o volume_label=NETBSD \ + -O $((${init} / 2))m -s $((${boot} / 2))m \ ${image} ${mnt}/boot fi @@ -220,7 +242,15 @@ if [ -n "${msdosid}" ]; then echo ${bar} Running fdisk ${bar} initsecs=$((${init} * 1024)) bootsecs=$((${boot} * 1024)) + ${FDISK} -f -i ${image} ${FDISK} -f -a -u -0 -s ${msdosid}/${initsecs}/${bootsecs} -F ${image} + if [ -z "${bootonly}" ]; then + ffsstart="$(getsectors ${ffsoffset})" + imagesize="$(getsize "${image}")" + imagesecs="$(getsectors ${imagesize})" + ffssize="$(expr ${imagesecs} - ${ffsstart})" + ${FDISK} -f -u -1 -s 169/${ffsstart}/${ffssize} -F ${image} + fi elif [ -n "${netbsdid}" ]; then echo ${bar} Running fdisk ${bar} ${FDISK} -f -i ${image}