Module Name:    src
Committed By:   snj
Date:           Thu Aug  6 21:13:44 UTC 2015

Modified Files:
        src/distrib/sets/lists/etc [netbsd-7]: mi
        src/distrib/sets/lists/tests [netbsd-7]: mi
        src/distrib/utils/embedded [netbsd-7]: mkimage
        src/distrib/utils/embedded/conf [netbsd-7]: evbarm.conf rpi.conf
            rpi_inst.conf usermode.conf x86.conf
        src/etc/defaults [netbsd-7]: rc.conf
        src/etc/etc.evbarm [netbsd-7]: Makefile.inc
        src/etc/rc.d [netbsd-7]: Makefile root
        src/sbin/resize_ffs [netbsd-7]: Makefile resize_ffs.8 resize_ffs.c
        src/share/man/man5 [netbsd-7]: rc.conf.5
        src/tests/sbin/resize_ffs [netbsd-7]: Makefile common.sh t_grow.sh
            t_grow_swapped.sh t_shrink.sh t_shrink_swapped.sh
Added Files:
        src/distrib/utils/embedded/conf [netbsd-7]: armv7.conf
        src/distrib/utils/embedded/files [netbsd-7]: resize_disklabel
        src/etc/rc.d [netbsd-7]: resize_root
        src/tests/sbin/resize_ffs [netbsd-7]: t_check.sh
Removed Files:
        src/distrib/utils/embedded/conf [netbsd-7]: beagleboard.conf

Log Message:
Pull up following revision(s) (requested by skrll in ticket #909):
        distrib/sets/lists/etc/mi: revision 1.237
        distrib/sets/lists/tests/mi: revision 1.613
        distrib/utils/embedded/conf/armv7.conf: revisions 1.1, 1.2
        distrib/utils/embedded/conf/beagleboard.conf: delete
        distrib/utils/embedded/conf/evbarm.conf: revisions 1.21, 1.22
        distrib/utils/embedded/conf/rpi.conf: revisions 1.28, 1.29
        distrib/utils/embedded/conf/rpi_inst.conf: revisions 1.7, 1.8
        distrib/utils/embedded/conf/usermode.conf: revision 1.5
        distrib/utils/embedded/conf/x86.conf: revision 1.5
        distrib/utils/embedded/files/resize_disklabel: revision 1.1
        distrib/utils/embedded/mkimage: revisions 1.49, 1.55-1.59
        etc/defaults/rc.conf: revision 1.133
        etc/etc.evbarm/Makefile.inc: revisions 1.72, 1.76
        etc/rc.d/Makefile: revision 1.93 via patch
        etc/rc.d/resize_root: revisions 1.1-1.3
        etc/rc.d/root: revision 1.5
        sbin/resize_ffs/Makefile: revision 1.5
        sbin/resize_ffs/resize_ffs.8: revisions 1.14-1.16
        sbin/resize_ffs/resize_ffs.c: revisions 1.39-1.44
        share/man/man5/rc.conf.5: revision 1.158, 1.159
        tests/sbin/resize_ffs/Makefile: revision 1.4
        tests/sbin/resize_ffs/common.sh: revision 1.14
        tests/sbin/resize_ffs/t_check.sh: revision 1.1
        tests/sbin/resize_ffs/t_grow.sh: revision 1.9
        tests/sbin/resize_ffs/t_grow_swapped.sh: revision 1.3
        tests/sbin/resize_ffs/t_shrink.sh: revision 1.8
        tests/sbin/resize_ffs/t_shrink_swapped.sh: revision 1.2
fix image building:
         - round up the total size of the disk image
         - fix fdisk offset for netbsd ffs images
--
Make get_dev_size work on regular files too.
--
Use `!= -1' instead of `== 0' out of paranoia.
--
- Add -c to check to see if grow/shrink is required
- Divide by DEV_BSIZE when returning size of file.
- Update manpage
--
New sentence, new line. Sort option descriptions.
--
Add resize_root boot operation. If resize_root=YES in rc.conf then
the system attempts to resize the root file system to fill it's
partition prior to mounting read-write. Useful for things like AMI
file system images. May eventually be used by arm images after
coming up with similar solution for increasing the parition size.
--
- Add new tests for -c check flag in resize_ffs
--
Bump date for previous.
it's -> its
--
Handle case in grow() where last cylinder group is too small for ufs2.
Align with code in shrink().
--
factor out geometry calculation and use this also in CheckOnly mode.
be a bit more verbose in Verbose mode.
--
Add support for auto-growing the root partition. Enable it for rpi.img.
--
initialize resize before pulling in board config
--
add KEYWORD: interactive, honour resize_root_flags and
resize_root_postcmd rc vars
--
if the -p flag is specified, display a progress bar while growing the
file-system
--
show resize_ffs progress bar when resizing root partition
--
fix typo in previous; pass -y unconditionally to resize_ffs, not -p
--
Rename beagleboard.img to armv7.img. The new image includes the same
kernels as beagleboard.img plus support for Raspberry Pi 2, ODROID-C1,
Cubieboard2, Cubietruck, Hummingbird A31, and Banana Pi.
--
Properly spell X' name. From X(7):
        The  X.Org  Foundation  requests  that the following names be
used when
        referring to this software:
                                           X
                                    X Window System
                                     X Version 11
                              X Window System, Version 11
                                          X11
--
Add some documentation:
Tell what this does, and what it expects from conf files
--
Cleanup: make_filesystems is not used any longer, purge remains
--
More cleanup:
Instead of first overwriting the *_evbarm functions with own code,
and then calling them from the regular functions, directly put the
code into the regular functions.
No more functions from evbarm.conf are used now.
Some variables are still used!
--
define TOOL_MKUBOOTIMAGE for mkimage
--
fix mkubootimage


To generate a diff of this commit:
cvs rdiff -u -r1.232.4.2 -r1.232.4.3 src/distrib/sets/lists/etc/mi
cvs rdiff -u -r1.584.2.2 -r1.584.2.3 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.48.4.5 -r1.48.4.6 src/distrib/utils/embedded/mkimage
cvs rdiff -u -r0 -r1.7.2.2 src/distrib/utils/embedded/conf/armv7.conf
cvs rdiff -u -r1.17.4.1 -r0 src/distrib/utils/embedded/conf/beagleboard.conf
cvs rdiff -u -r1.15.4.4 -r1.15.4.5 \
    src/distrib/utils/embedded/conf/evbarm.conf
cvs rdiff -u -r1.24.4.3 -r1.24.4.4 src/distrib/utils/embedded/conf/rpi.conf
cvs rdiff -u -r1.5.6.1 -r1.5.6.2 \
    src/distrib/utils/embedded/conf/rpi_inst.conf
cvs rdiff -u -r1.3.12.1 -r1.3.12.2 \
    src/distrib/utils/embedded/conf/usermode.conf
cvs rdiff -u -r1.4.6.2 -r1.4.6.3 src/distrib/utils/embedded/conf/x86.conf
cvs rdiff -u -r0 -r1.1.2.2 src/distrib/utils/embedded/files/resize_disklabel
cvs rdiff -u -r1.123.2.3 -r1.123.2.4 src/etc/defaults/rc.conf
cvs rdiff -u -r1.63.2.4 -r1.63.2.5 src/etc/etc.evbarm/Makefile.inc
cvs rdiff -u -r1.89.6.1 -r1.89.6.2 src/etc/rc.d/Makefile
cvs rdiff -u -r0 -r1.3.2.2 src/etc/rc.d/resize_root
cvs rdiff -u -r1.4 -r1.4.26.1 src/etc/rc.d/root
cvs rdiff -u -r1.4 -r1.4.20.1 src/sbin/resize_ffs/Makefile
cvs rdiff -u -r1.13 -r1.13.20.1 src/sbin/resize_ffs/resize_ffs.8
cvs rdiff -u -r1.38 -r1.38.6.1 src/sbin/resize_ffs/resize_ffs.c
cvs rdiff -u -r1.157 -r1.157.4.1 src/share/man/man5/rc.conf.5
cvs rdiff -u -r1.3 -r1.3.24.1 src/tests/sbin/resize_ffs/Makefile
cvs rdiff -u -r1.13 -r1.13.8.1 src/tests/sbin/resize_ffs/common.sh
cvs rdiff -u -r0 -r1.1.2.2 src/tests/sbin/resize_ffs/t_check.sh
cvs rdiff -u -r1.8 -r1.8.24.1 src/tests/sbin/resize_ffs/t_grow.sh
cvs rdiff -u -r1.2 -r1.2.24.1 src/tests/sbin/resize_ffs/t_grow_swapped.sh
cvs rdiff -u -r1.7 -r1.7.24.1 src/tests/sbin/resize_ffs/t_shrink.sh
cvs rdiff -u -r1.1 -r1.1.24.1 src/tests/sbin/resize_ffs/t_shrink_swapped.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/etc/mi
diff -u src/distrib/sets/lists/etc/mi:1.232.4.2 src/distrib/sets/lists/etc/mi:1.232.4.3
--- src/distrib/sets/lists/etc/mi:1.232.4.2	Thu Apr 30 06:07:32 2015
+++ src/distrib/sets/lists/etc/mi	Thu Aug  6 21:13:43 2015
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.232.4.2 2015/04/30 06:07:32 riz Exp $
+# $NetBSD: mi,v 1.232.4.3 2015/08/06 21:13:43 snj Exp $
 #
 # Note: end-user configuration files that are moved to another location
 #	should not be marked "obsolete"; they should just be removed from
@@ -265,6 +265,7 @@
 ./etc/rc.d/random_seed				etc-sys-rc
 ./etc/rc.d/rarpd				etc-bootserver-rc
 ./etc/rc.d/rbootd				etc-bootserver-rc
+./etc/rc.d/resize_root				etc-sys-rc
 ./etc/rc.d/rndctl				etc-sys-rc
 ./etc/rc.d/root					etc-sys-rc
 ./etc/rc.d/route6d				etc-router-rc

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.584.2.2 src/distrib/sets/lists/tests/mi:1.584.2.3
--- src/distrib/sets/lists/tests/mi:1.584.2.2	Sat May 16 17:58:46 2015
+++ src/distrib/sets/lists/tests/mi	Thu Aug  6 21:13:43 2015
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.584.2.2 2015/05/16 17:58:46 snj Exp $
+# $NetBSD: mi,v 1.584.2.3 2015/08/06 21:13:43 snj Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3216,6 +3216,7 @@
 ./usr/tests/sbin/resize_ffs			tests-sbin-tests
 ./usr/tests/sbin/resize_ffs/Atffile		tests-sbin-tests	atf
 ./usr/tests/sbin/resize_ffs/Kyuafile		tests-sbin-tests	atf,kyua
+./usr/tests/sbin/resize_ffs/t_check		tests-sbin-tests	atf
 ./usr/tests/sbin/resize_ffs/t_grow		tests-sbin-tests	atf
 ./usr/tests/sbin/resize_ffs/t_grow_swapped	tests-sbin-tests	atf
 ./usr/tests/sbin/resize_ffs/t_resize_ffs	tests-obsolete		obsolete

Index: src/distrib/utils/embedded/mkimage
diff -u src/distrib/utils/embedded/mkimage:1.48.4.5 src/distrib/utils/embedded/mkimage:1.48.4.6
--- src/distrib/utils/embedded/mkimage:1.48.4.5	Mon Apr  6 18:47:54 2015
+++ src/distrib/utils/embedded/mkimage	Thu Aug  6 21:13:43 2015
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: mkimage,v 1.48.4.5 2015/04/06 18:47:54 snj Exp $
+# $NetBSD: mkimage,v 1.48.4.6 2015/08/06 21:13:43 snj Exp $
 #
 # Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -32,6 +32,20 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
+#
+# Makes a bootable image for the host architecture given.
+# The host specific functions are pulled in from a /bin/sh script in the
+# "conf" directory, and is expected to provide the following shell
+# functions, which are called in the following order:
+#
+#  - make_fstab: Creates the host's /etc/fstab with / on ${rootdev}.
+#    If -m is given, a number of directories are put on a tmpfs RAM disk
+#  - customize: After unpacking the sets, this gets the system to
+#    a working state, e. g. by setting up /etc/rc.conf and /dev
+#  - populate: Add common goods like kernel and bootloader
+#  - make_label: Prints disklabel to stdout
+#
+
 set -e
 
 DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -42,6 +56,7 @@ FDISK=${TOOL_FDISK:-fdisk}
 MAKEFS=${TOOL_MAKEFS:-makefs}
 MTREE=${TOOL_MTREE:-mtree}
 INSTALLBOOT=${TOOL_INSTALLBOOT:-installboot}
+MKUBOOTIMAGE=${TOOL_MKUBOOTIMAGE:-mkubootimage}
 GZIP_CMD=${TOOL_GZIP:-gzip} # ${GZIP} is special to gzip(1)
 
 src="/usr/src"
@@ -75,7 +90,7 @@ Usage: $PROG -h <host-arch> [-bdmx] [-K 
 -r	root device kind (sd, wd, ld)
 -d	Add the debug sets
 -m	Optimize the OS installation to mimimize disk writes for SSDs
--x	Load the x sets too, not just the base ones
+-x	Load the X sets too, not just the base ones
 EOF
 	exit 1
 }
@@ -102,6 +117,8 @@ then
 	exit 1
 fi
 
+resize=false
+
 . "${DIR}/conf/${h}.conf"
 release="/usr/obj/${MACHINE}/release"
 
@@ -186,6 +203,13 @@ if [ "${size}" = 0 ]; then
 	size="$(getsize "${image}")"
 fi
 newsize=$((${size} / 2 / 1024))
+compare=$((${newsize} * 2 * 1024))
+while [ "${compare}" != "${size}" ]
+do    
+	size="$((size + size - compare))"  
+	newsize="$((${size} / 2 / 1024))"
+	compare="$((${newsize} * 2 * 1024))"
+done                      
 
 echo ${bar} Adding label ${bar}
 make_label > ${tmp}/label
@@ -198,7 +222,7 @@ if [ -n "${msdosid}" ]; then
 elif [ -n "${netbsdid}" ]; then
 	echo ${bar} Running fdisk ${bar}
 	${FDISK} -f -i ${image}
-	${FDISK} -f -a -u -0 -s 169 ${image}
+	${FDISK} -f -a -u -0 -s 169/${init} ${image}
 	${INSTALLBOOT} -f -v ${image} ${release}/usr/mdec/bootxx_ffsv1
 fi
 

Index: src/distrib/utils/embedded/conf/evbarm.conf
diff -u src/distrib/utils/embedded/conf/evbarm.conf:1.15.4.4 src/distrib/utils/embedded/conf/evbarm.conf:1.15.4.5
--- src/distrib/utils/embedded/conf/evbarm.conf:1.15.4.4	Thu Jan 29 15:12:48 2015
+++ src/distrib/utils/embedded/conf/evbarm.conf	Thu Aug  6 21:13:43 2015
@@ -1,4 +1,4 @@
-# $NetBSD: evbarm.conf,v 1.15.4.4 2015/01/29 15:12:48 martin Exp $
+# $NetBSD: evbarm.conf,v 1.15.4.5 2015/08/06 21:13:43 snj Exp $
 # evbarm shared config
 #
 image=$HOME/${board}.img
@@ -132,9 +132,26 @@ hostname=${board}
 sshd=YES
 dhcpcd=YES
 EOF
+
+	if $resize; then
+		cat >> ${mnt}/etc/rc.conf << EOF
+resize_disklabel=YES
+resize_disklabel_disk=ld0
+resize_disklabel_part=a
+resize_root=YES
+resize_root_flags="-p"
+resize_root_postcmd="/sbin/reboot -n"
+EOF
+	fi
+
 	echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \
 	    >> "$tmp/selected_sets"
 
+	mkdir ${mnt}/etc/rc.d
+	cp ${DIR}/files/resize_disklabel ${mnt}/etc/rc.d/resize_disklabel
+	echo "./etc/rc.d/resize_disklabel type=file uname=root gname=wheel mode=0555" \
+	    >> "$tmp/selected_sets"
+
 	if [ ! -f ${release}/dev/MAKEDEV ]; then
 		echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
 		exit 1

Index: src/distrib/utils/embedded/conf/rpi.conf
diff -u src/distrib/utils/embedded/conf/rpi.conf:1.24.4.3 src/distrib/utils/embedded/conf/rpi.conf:1.24.4.4
--- src/distrib/utils/embedded/conf/rpi.conf:1.24.4.3	Wed Mar 11 20:22:55 2015
+++ src/distrib/utils/embedded/conf/rpi.conf	Thu Aug  6 21:13:43 2015
@@ -1,19 +1,16 @@
-# $NetBSD: rpi.conf,v 1.24.4.3 2015/03/11 20:22:55 snj Exp $
+# $NetBSD: rpi.conf,v 1.24.4.4 2015/08/06 21:13:43 snj Exp $
 # Raspberry Pi customization script used by mkimage
 #
 
 board=rpi
 kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI.bin
+resize=true
 
 . ${DIR}/conf/evbarm.conf
 
 firmwaredir=$src/external/broadcom/rpi-firmware/dist
 firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
 
-make_filesystems() {
-	make_filesystems_evbarm
-}
-
 make_fstab() {
 	make_fstab_evbarm
 }

Index: src/distrib/utils/embedded/conf/rpi_inst.conf
diff -u src/distrib/utils/embedded/conf/rpi_inst.conf:1.5.6.1 src/distrib/utils/embedded/conf/rpi_inst.conf:1.5.6.2
--- src/distrib/utils/embedded/conf/rpi_inst.conf:1.5.6.1	Wed Jan 28 11:27:03 2015
+++ src/distrib/utils/embedded/conf/rpi_inst.conf	Thu Aug  6 21:13:43 2015
@@ -1,4 +1,4 @@
-# $NetBSD: rpi_inst.conf,v 1.5.6.1 2015/01/28 11:27:03 martin Exp $
+# $NetBSD: rpi_inst.conf,v 1.5.6.2 2015/08/06 21:13:43 snj Exp $
 # Raspberry Pi customization script used by mkimage
 #
 
@@ -17,7 +17,7 @@ init=8
 size=$(( 10485760 + ${swap} * 1024 * 512 + ${boot} * 1024 * 512 + ${init} * 1024 * 512 ))
 msdosid=12
 
-make_label_evbarm() {
+make_label() {
 	# compute all sizes in terms of sectors
 	local totalsize=$(( ${newsize} * 1024 * 2 / 512 ))
 
@@ -64,32 +64,17 @@ drivedata: 0 
 EOF
 }
 
-make_fstab_evbarm() {
-:
-}
-
-customize_evbarm() {
+customize() {
 	echo "${bar} creating directories ${bar}"
 	mkdir ${mnt}/proc ${mnt}/kern
 }
-firmwaredir=$src/external/broadcom/rpi-firmware/dist
-firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
-
-make_filesystems() {
-	make_filesystems_evbarm
-}
 
 make_fstab() {
-	make_fstab_evbarm
+	:
 }
 
-make_label() {
-	make_label_evbarm
-}
-
-customize() {
-	customize_evbarm
-}
+firmwaredir=$src/external/broadcom/rpi-firmware/dist
+firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
 
 populate() {
 	cat > ${mnt}/boot/cmdline.txt << EOF

Index: src/distrib/utils/embedded/conf/usermode.conf
diff -u src/distrib/utils/embedded/conf/usermode.conf:1.3.12.1 src/distrib/utils/embedded/conf/usermode.conf:1.3.12.2
--- src/distrib/utils/embedded/conf/usermode.conf:1.3.12.1	Wed Jan 28 11:27:03 2015
+++ src/distrib/utils/embedded/conf/usermode.conf	Thu Aug  6 21:13:43 2015
@@ -1,4 +1,4 @@
-# $NetBSD: usermode.conf,v 1.3.12.1 2015/01/28 11:27:03 martin Exp $
+# $NetBSD: usermode.conf,v 1.3.12.2 2015/08/06 21:13:43 snj Exp $
 # NetBSD/usermode customization script used by mkimage
 
 # XXX: BROKEN, needs to be converted to makefs
@@ -10,11 +10,6 @@ setsdir=/usr/build/release/$(uname -m)/b
 size=0	# in MB
 usermodedirs="/var.cow /etc.cow /root.cow /pkgs"
 
-make_filesystems() {
-	newfs /dev/r${vnddev}a
-	mount /dev/${vnddev}a ${mnt}
-}
-
 make_fstab() {
 cat > ${mnt}/etc/fstab << EOF
 # NetBSD/usermode /etc/fstab

Index: src/distrib/utils/embedded/conf/x86.conf
diff -u src/distrib/utils/embedded/conf/x86.conf:1.4.6.2 src/distrib/utils/embedded/conf/x86.conf:1.4.6.3
--- src/distrib/utils/embedded/conf/x86.conf:1.4.6.2	Thu Jan 29 15:12:48 2015
+++ src/distrib/utils/embedded/conf/x86.conf	Thu Aug  6 21:13:43 2015
@@ -1,4 +1,4 @@
-# $NetBSD: x86.conf,v 1.4.6.2 2015/01/29 15:12:48 martin Exp $
+# $NetBSD: x86.conf,v 1.4.6.3 2015/08/06 21:13:43 snj Exp $
 # x86 shared config
 #
 
@@ -10,13 +10,14 @@ bootfile=$release/usr/mdec/boot
 extra=8		# spare space
 size=0		# autocompute
 netbsdid=169
-ffsoffset=63b
+init=63
+ffsoffset=${init}b
 
 make_label() {
 	# compute all sizes in terms of sectors
 	local totalsize=$(( ${newsize} * 1024 * 2 / 512 ))
 
-	local aoffset=63
+	local aoffset=${init}
 	local asize=$(( ${totalsize} - ${aoffset} ))
 
 	local bps=512

Index: src/etc/defaults/rc.conf
diff -u src/etc/defaults/rc.conf:1.123.2.3 src/etc/defaults/rc.conf:1.123.2.4
--- src/etc/defaults/rc.conf:1.123.2.3	Thu Apr 30 06:07:32 2015
+++ src/etc/defaults/rc.conf	Thu Aug  6 21:13:43 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: rc.conf,v 1.123.2.3 2015/04/30 06:07:32 riz Exp $
+#	$NetBSD: rc.conf,v 1.123.2.4 2015/08/06 21:13:43 snj Exp $
 #
 # /etc/defaults/rc.conf --
 #	default configuration of /etc/rc.conf
@@ -120,6 +120,7 @@ lvm=NO
 #
 savecore=YES		savecore_flags="-z"
 			savecore_dir="/var/crash"
+resize_root=NO					# resize root to fill partition
 per_user_tmp=NO					# per-user /tmp directories
 per_user_tmp_dir="/private/tmp"			# real storage for /tmp
 clear_tmp=YES					# clear /tmp after reboot

Index: src/etc/etc.evbarm/Makefile.inc
diff -u src/etc/etc.evbarm/Makefile.inc:1.63.2.4 src/etc/etc.evbarm/Makefile.inc:1.63.2.5
--- src/etc/etc.evbarm/Makefile.inc:1.63.2.4	Sat Mar 21 08:51:17 2015
+++ src/etc/etc.evbarm/Makefile.inc	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.63.2.4 2015/03/21 08:51:17 snj Exp $
+#	$NetBSD: Makefile.inc,v 1.63.2.5 2015/08/06 21:13:44 snj Exp $
 #
 #	etc.evbarm/Makefile.inc -- evbarm-specific etc Makefile targets
 #
@@ -125,10 +125,11 @@ __mkimage: .USE
 	TOOL_GZIP=${TOOL_GZIP} \
 	TOOL_MKNOD=${TOOL_MKNOD} \
 	TOOL_PAX=${TOOL_PAX} \
+	TOOL_MKUBOOTIMAGE=${TOOL_MKUBOOTIMAGE} \
 	TOOL_MTREE=${TOOL_MTREE} \
 	HOST_SH=${HOST_SH} \
 	${HOST_SH} ${MKIMAGE} -x -h ${.TARGET:S/smp_//} -D ${DESTDIR} \
-	    -K ${.ALLSRC} -S ${NETBSDSRCDIR} ${MKI_OPTS.${.TARGET}} \
+	    -S ${NETBSDSRCDIR} ${MKI_OPTS.${.TARGET}} \
 	    ${IMAGE.dir}/${.TARGET:S/smp_//}.img.gz
 
 ARCHES.arm=		armv4 xscale armv5t armv6 armv7
@@ -157,23 +158,21 @@ BUILD_KERNELS+=		${board}_INSTALL
 KERNEL_SETS+=		${KERNEL_SETS.${arch}}
 .endfor
 
-.if !empty(KERNEL_SETS:MBEAGLEBOARD) && !empty(KERNEL_SETS:MBEAGLEBONE)
-smp_beagleboard: ${IMAGE.kern}/netbsd-BEAGLEBOARD.ub.gz __mkimage
-#            XXX ${IMAGE.kern}/netbsd-BEAGLEBONE.ub.gz
-.if empty(ALL_KERNELS) || (!empty(ALL_KERNELS:MBEAGLEBOARD) && !empty(ALL_KERNELS:MBEAGLEBONE))
-SNAP_MD_POST_DEPS+=	smp_beagleboard
-.endif
+.if !empty(MACHINE_ARCH:M*armv7*) && empty(ALL_KERNELS)
+smp_armv7: __mkimage
+MKI_OPTS.smp_armv7=	-K ${IMAGE.kern}
+SNAP_MD_POST_DEPS+=	smp_armv7
 .endif
 
 .if !empty(KERNEL_SETS:MRPI)
-smp_rpi: ${IMAGE.kern}/netbsd-RPI.bin.gz __mkimage
-#            XXX ${IMAGE.kern}/netbsd-RPI2.bin.gz
+smp_rpi: __mkimage
 .if empty(ALL_KERNELS) || !empty(ALL_KERNELS:MRPI)
+MKI_OPTS.smp_rpi=	-K ${IMAGE.kern}/netbsd-RPI.bin.gz
 SNAP_MD_POST_DEPS+=	smp_rpi
 .endif
-MKI_OPTS.smp_rpi_inst="-b"
 smp_rpi_inst: ${IMAGE.instk}/netbsd-RPI_INSTALL.bin.gz __mkimage
 .if empty(ALL_KERNELS) || !empty(ALL_KERNELS:MRPI_INSTALL)
+MKI_OPTS.smp_rpi_inst=	-b -K ${IMAGE.instk}/netbsd-RPI_INSTALL.bin.gz
 SNAP_MD_POST_DEPS+=	smp_rpi_inst
 .endif
 .endif

Index: src/etc/rc.d/Makefile
diff -u src/etc/rc.d/Makefile:1.89.6.1 src/etc/rc.d/Makefile:1.89.6.2
--- src/etc/rc.d/Makefile:1.89.6.1	Thu Mar 26 10:54:35 2015
+++ src/etc/rc.d/Makefile	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.89.6.1 2015/03/26 10:54:35 martin Exp $
+# $NetBSD: Makefile,v 1.89.6.2 2015/08/06 21:13:44 snj Exp $
 
 .include <bsd.own.mk>
 
@@ -33,7 +33,7 @@ CONFIGFILES=\
 		perusertmp pf pf_boot pflogd postfix powerd ppp pwcheck \
 		quota \
 		racoon rpcbind raidframe raidframeparity random_seed rarpd \
-		rbootd rndctl root route6d routed rtadvd rtclocaltime \
+		rbootd resize_root rndctl root route6d routed rtadvd rtclocaltime \
 		rtsold rwho \
 		savecore screenblank securelevel sshd \
 		staticroute swap1 swap2 sysctl sysdb syslogd \

Index: src/etc/rc.d/root
diff -u src/etc/rc.d/root:1.4 src/etc/rc.d/root:1.4.26.1
--- src/etc/rc.d/root:1.4	Tue Apr 21 16:08:57 2009
+++ src/etc/rc.d/root	Thu Aug  6 21:13:44 2015
@@ -1,10 +1,10 @@
 #!/bin/sh
 #
-# $NetBSD: root,v 1.4 2009/04/21 16:08:57 joerg Exp $
+# $NetBSD: root,v 1.4.26.1 2015/08/06 21:13:44 snj Exp $
 #
 
 # PROVIDE: root
-# REQUIRE: fsck_root
+# REQUIRE: fsck_root resize_root
 
 $_rc_subr_loaded . /etc/rc.subr
 

Index: src/sbin/resize_ffs/Makefile
diff -u src/sbin/resize_ffs/Makefile:1.4 src/sbin/resize_ffs/Makefile:1.4.20.1
--- src/sbin/resize_ffs/Makefile:1.4	Mon Aug 15 02:19:50 2011
+++ src/sbin/resize_ffs/Makefile	Thu Aug  6 21:13:44 2015
@@ -1,11 +1,14 @@
-#	$NetBSD: Makefile,v 1.4 2011/08/15 02:19:50 dholland Exp $
+#	$NetBSD: Makefile,v 1.4.20.1 2015/08/06 21:13:44 snj Exp $
 
 .include <bsd.own.mk>
 
 PROG=resize_ffs
 MAN=resize_ffs.8
-SRCS=resize_ffs.c ffs_bswap.c
+SRCS=resize_ffs.c ffs_bswap.c progress.c
+
+CPPFLAGS+=-I${NETBSDSRCDIR}/sbin/fsck
 
 .PATH: ${NETBSDSRCDIR}/sys/ufs/ffs
+.PATH: ${NETBSDSRCDIR}/sbin/fsck
 
 .include <bsd.prog.mk>

Index: src/sbin/resize_ffs/resize_ffs.8
diff -u src/sbin/resize_ffs/resize_ffs.8:1.13 src/sbin/resize_ffs/resize_ffs.8:1.13.20.1
--- src/sbin/resize_ffs/resize_ffs.8:1.13	Sun Aug 28 21:25:11 2011
+++ src/sbin/resize_ffs/resize_ffs.8	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-.\"     $NetBSD: resize_ffs.8,v 1.13 2011/08/28 21:25:11 wiz Exp $
+.\"     $NetBSD: resize_ffs.8,v 1.13.20.1 2015/08/06 21:13:44 snj Exp $
 .\"
 .\" As its sole author, I explicitly place this man page in the public
 .\" domain.  Anyone may use it in any way for any purpose (though I would
@@ -9,7 +9,7 @@
 .\"  X  Against HTML               [email protected]
 .\" / \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
 .\"
-.Dd January 4, 2011
+.Dd April 6, 2015
 .Dt RESIZE_FFS 8
 .Os
 .Sh NAME
@@ -17,7 +17,7 @@
 .Nd resize a file system on disk or in a file
 .Sh SYNOPSIS
 .Nm
-.Op Fl y
+.Op Fl cpvy
 .Op Fl s Ar size
 .Ar special
 .Sh DESCRIPTION
@@ -55,6 +55,11 @@ determined from
 .Pp
 The options are as follows:
 .Bl -tag -width indent
+.It Fl c
+Check to see if the new size would change the file system.
+No changes will be made to the file system.
+.It Fl p
+Display a progress meter during the resize process.
 .It Fl s
 Specify the file system size to which the file system should be
 resized.
@@ -63,6 +68,8 @@ It will not work correctly for file syst
 To see the
 exact value, have a look at the disk specification or the disklabel.
 Mostly used to shrink file systems.
+.It Fl v
+Be more verbose.
 .It Fl y
 Disable sanity questions made by
 .Nm .

Index: src/sbin/resize_ffs/resize_ffs.c
diff -u src/sbin/resize_ffs/resize_ffs.c:1.38 src/sbin/resize_ffs/resize_ffs.c:1.38.6.1
--- src/sbin/resize_ffs/resize_ffs.c:1.38	Sun Jun 23 22:03:34 2013
+++ src/sbin/resize_ffs/resize_ffs.c	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: resize_ffs.c,v 1.38 2013/06/23 22:03:34 dholland Exp $	*/
+/*	$NetBSD: resize_ffs.c,v 1.38.6.1 2015/08/06 21:13:44 snj Exp $	*/
 /* From sources sent on February 17, 2003 */
 /*-
  * As its sole author, I explicitly place this code in the public
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: resize_ffs.c,v 1.38 2013/06/23 22:03:34 dholland Exp $");
+__RCSID("$NetBSD: resize_ffs.c,v 1.38.6.1 2015/08/06 21:13:44 snj Exp $");
 
 #include <sys/disk.h>
 #include <sys/disklabel.h>
@@ -59,12 +59,17 @@ __RCSID("$NetBSD: resize_ffs.c,v 1.38 20
 #include <strings.h>
 #include <unistd.h>
 
+#include "progress.h"
+
 /* new size of file system, in sectors */
 static int64_t newsize;
 
 /* fd open onto disk device or file */
 static int fd;
 
+/* disk device or file path */
+char *special;
+
 /* must we break up big I/O operations - see checksmallio() */
 static int smallio;
 
@@ -152,6 +157,8 @@ static unsigned char *iflags;
 /* global flags */
 int is_ufs2 = 0;
 int needswap = 0;
+int verbose = 0;
+int progress = 0;
 
 static void usage(void) __dead;
 
@@ -913,35 +920,17 @@ timestamp(void)
 	time(&t);
 	return (t);
 }
+
 /*
- * Grow the file system.
+ * Calculate new filesystem geometry
+ *  return 0 if geometry actually changed
  */
-static void
-grow(void)
+static int
+makegeometry(int chatter)
 {
-	int i;
 
-	/* Update the timestamp. */
-	newsb->fs_time = timestamp();
-	/* Allocate and clear the new-inode area, in case we add any cgs. */
-	zinodes = alloconce(newsb->fs_ipg * sizeof(*zinodes), "zeroed inodes");
-	memset(zinodes, 0, newsb->fs_ipg * sizeof(*zinodes));
 	/* Update the size. */
 	newsb->fs_size = FFS_DBTOFSB(newsb, newsize);
-	/* Did we actually not grow?  (This can happen if newsize is less than
-	 * a frag larger than the old size - unlikely, but no excuse to
-	 * misbehave if it happens.) */
-	if (newsb->fs_size == oldsb->fs_size) {
-		printf("New fs size %"PRIu64" = old fs size %"PRIu64
-		    ", not growing.\n", newsb->fs_size, oldsb->fs_size);
-		return;
-	}
-	/* Check that the new last sector (frag, actually) is writable.  Since
-	 * it's at least one frag larger than it used to be, we know we aren't
-	 * overwriting anything important by this.  (The choice of sbbuf as
-	 * what to write is irrelevant; it's just something handy that's known
-	 * to be at least one frag in size.) */
-	writeat(FFS_FSBTODB(newsb,newsb->fs_size - 1), &sbbuf, newsb->fs_fsize);
 	if (is_ufs2)
 		newsb->fs_ncg = howmany(newsb->fs_size, newsb->fs_fpg);
 	else {
@@ -958,13 +947,62 @@ grow(void)
 	 * minimal, at most the pre-sb data area. */
 	if (cgdmin(newsb, newsb->fs_ncg - 1) > newsb->fs_size) {
 		newsb->fs_ncg--;
-		newsb->fs_old_ncyl = newsb->fs_ncg * newsb->fs_old_cpg;
-		newsb->fs_size = (newsb->fs_old_ncyl * newsb->fs_old_spc)
-		    / NSPF(newsb);
-		printf("Warning: last cylinder group is too small;\n");
-		printf("    dropping it.  New size = %lu.\n",
-		    (unsigned long int) FFS_FSBTODB(newsb, newsb->fs_size));
+		if (is_ufs2)
+			newsb->fs_size = newsb->fs_ncg * newsb->fs_fpg;
+		else {
+			newsb->fs_old_ncyl = newsb->fs_ncg * newsb->fs_old_cpg;
+			newsb->fs_size = (newsb->fs_old_ncyl *
+				newsb->fs_old_spc) / NSPF(newsb);
+		}
+		if (chatter || verbose) {
+			printf("Warning: last cylinder group is too small;\n");
+			printf("    dropping it.  New size = %lu.\n",
+			(unsigned long int) FFS_FSBTODB(newsb, newsb->fs_size));
+		}
 	}
+
+	/* Did we actually not grow?  (This can happen if newsize is less than
+	 * a frag larger than the old size - unlikely, but no excuse to
+	 * misbehave if it happens.) */
+	if (newsb->fs_size == oldsb->fs_size)
+		return 1;
+
+	return 0;
+}
+
+
+/*
+ * Grow the file system.
+ */
+static void
+grow(void)
+{
+	int i;
+
+	if (makegeometry(1)) {
+		printf("New fs size %"PRIu64" = old fs size %"PRIu64
+		    ", not growing.\n", newsb->fs_size, oldsb->fs_size);
+		return;
+	}
+
+	if (verbose) {
+		printf("Growing fs from %"PRIu64" blocks to %"PRIu64
+		    " blocks.\n", oldsb->fs_size, newsb->fs_size);
+	}
+
+	/* Update the timestamp. */
+	newsb->fs_time = timestamp();
+	/* Allocate and clear the new-inode area, in case we add any cgs. */
+	zinodes = alloconce(newsb->fs_ipg * sizeof(*zinodes), "zeroed inodes");
+	memset(zinodes, 0, newsb->fs_ipg * sizeof(*zinodes));
+	
+	/* Check that the new last sector (frag, actually) is writable.  Since
+	 * it's at least one frag larger than it used to be, we know we aren't
+	 * overwriting anything important by this.  (The choice of sbbuf as
+	 * what to write is irrelevant; it's just something handy that's known
+	 * to be at least one frag in size.) */
+	writeat(FFS_FSBTODB(newsb,newsb->fs_size - 1), &sbbuf, newsb->fs_fsize);
+
 	/* Find out how big the csum area is, and realloc csums if bigger. */
 	newsb->fs_cssize = ffs_fragroundup(newsb,
 	    newsb->fs_ncg * sizeof(struct csum));
@@ -983,6 +1021,8 @@ grow(void)
                                 "cgs");
 		for (i = oldsb->fs_ncg; i < newsb->fs_ncg; i++) {
 			cgs[i] = (struct cg *) cgp;
+			progress_bar(special, "grow cg",
+			    i - oldsb->fs_ncg, newsb->fs_ncg - oldsb->fs_ncg);
 			initcg(i);
 			cgp += cgblksz;
 		}
@@ -1011,6 +1051,8 @@ grow(void)
 	csum_fixup();
 	/* Make fs_dsize match the new reality. */
 	recompute_fs_dsize();
+
+	progress_done();
 }
 /*
  * Call (*fn)() for each inode, passing the inode and its inumber.  The
@@ -1685,38 +1727,28 @@ shrink(void)
 {
 	int i;
 
-	/* Load the inodes off disk - we'll need 'em. */
-	loadinodes();
-	/* Update the timestamp. */
-	newsb->fs_time = timestamp();
-	/* Update the size figures. */
-	newsb->fs_size = FFS_DBTOFSB(newsb, newsize);
-	if (is_ufs2)
-		newsb->fs_ncg = howmany(newsb->fs_size, newsb->fs_fpg);
-	else {
-		newsb->fs_old_ncyl = howmany(newsb->fs_size * NSPF(newsb),
-		    newsb->fs_old_spc);
-		newsb->fs_ncg = howmany(newsb->fs_old_ncyl, newsb->fs_old_cpg);
+	if (makegeometry(1)) {
+		printf("New fs size %"PRIu64" = old fs size %"PRIu64
+		    ", not shrinking.\n", newsb->fs_size, oldsb->fs_size);
+		return;
 	}
-	/* Does the (new) last cg end before the end of its inode area?  See
-	 * the similar code in grow() for more on this. */
-	if (cgdmin(newsb, newsb->fs_ncg - 1) > newsb->fs_size) {
-		newsb->fs_ncg--;
-		if (is_ufs2 == 0) {
-			newsb->fs_old_ncyl = newsb->fs_ncg * newsb->fs_old_cpg;
-			newsb->fs_size = (newsb->fs_old_ncyl *
-			    newsb->fs_old_spc) / NSPF(newsb);
-		} else
-			newsb->fs_size = newsb->fs_ncg * newsb->fs_fpg;
 
-		printf("Warning: last cylinder group is too small;\n");
-		printf("    dropping it.  New size = %lu.\n",
-		    (unsigned long int) FFS_FSBTODB(newsb, newsb->fs_size));
-	}
 	/* Let's make sure we're not being shrunk into oblivion. */
 	if (newsb->fs_ncg < 1)
 		errx(EXIT_FAILURE, "Size too small - file system would "
 		    "have no cylinders");
+
+	if (verbose) {
+		printf("Shrinking fs from %"PRIu64" blocks to %"PRIu64
+		    " blocks.\n", oldsb->fs_size, newsb->fs_size);
+	}
+
+	/* Load the inodes off disk - we'll need 'em. */
+	loadinodes();
+
+	/* Update the timestamp. */
+	newsb->fs_time = timestamp();
+
 	/* Initialize for block motion. */
 	blkmove_init();
 	/* Update csum size, then fix up for the new size */
@@ -1968,6 +2000,8 @@ flush_cgs(void)
 	int i;
 
 	for (i = 0; i < newsb->fs_ncg; i++) {
+		progress_bar(special, "flush cg",
+		    i, newsb->fs_ncg - 1);
 		if (cgflags[i] & CGF_BLKMAPS) {
 			rescan_blkmaps(i);
 		}
@@ -1987,6 +2021,8 @@ flush_cgs(void)
 	if (needswap)
 		ffs_csum_swap(csums,csums,newsb->fs_cssize);
 	writeat(FFS_FSBTODB(newsb, newsb->fs_csaddr), csums, newsb->fs_cssize);
+
+	progress_done();
 }
 /*
  * Write the superblock, both to the main superblock and to each cg's
@@ -2016,8 +2052,36 @@ write_sbs(void)
 		ffs_sb_swap(newsb,newsb);
 	writeat(where /  DEV_BSIZE, newsb, SBLOCKSIZE);
 	for (i = 0; i < oldsb->fs_ncg; i++) {
+		progress_bar(special, "write sb",
+		    i, oldsb->fs_ncg - 1);
 		writeat(FFS_FSBTODB(oldsb, cgsblock(oldsb, i)), newsb, SBLOCKSIZE);
 	}
+
+	progress_done();
+}
+
+/*
+ * Check to see wether new size changes the filesystem
+ *  return exit code
+ */
+static int
+checkonly(void)
+{
+	if (makegeometry(0)) {
+		if (verbose) {
+			printf("Wouldn't change: already %" PRId64
+			    " blocks\n", (int64_t)oldsb->fs_size);
+		}
+		return 1;
+	}
+
+	if (verbose) {
+		printf("Would change: newsize: %" PRId64 " oldsize: %"
+		    PRId64 " fsdb: %" PRId64 "\n", FFS_DBTOFSB(oldsb, newsize),
+		    (int64_t)oldsb->fs_size,
+		    (int64_t)oldsb->fs_fsbtodb);
+	}
+	return 0;
 }
 
 static off_t
@@ -2026,22 +2090,23 @@ get_dev_size(char *dev_name)
 	struct dkwedge_info dkw;
 	struct partition *pp;
 	struct disklabel lp;
+	struct stat st;
 	size_t ptn;
 
 	/* Get info about partition/wedge */
-	if (ioctl(fd, DIOCGWEDGEINFO, &dkw) == -1) {
-		if (ioctl(fd, DIOCGDINFO, &lp) == -1)
-			return 0;
-
+	if (ioctl(fd, DIOCGWEDGEINFO, &dkw) != -1)
+		return dkw.dkw_size;
+	if (ioctl(fd, DIOCGDINFO, &lp) != -1) {
 		ptn = strchr(dev_name, '\0')[-1] - 'a';
 		if (ptn >= lp.d_npartitions)
 			return 0;
-
 		pp = &lp.d_partitions[ptn];
 		return pp->p_size;
 	}
+	if (fstat(fd, &st) != -1 && S_ISREG(st.st_mode))
+		return st.st_size / DEV_BSIZE;
 
-	return dkw.dkw_size;
+	return 0;
 }
 
 /*
@@ -2051,19 +2116,26 @@ int
 main(int argc, char **argv)
 {
 	int ch;
+	int CheckOnlyFlag;
 	int ExpertFlag;
 	int SFlag;
 	size_t i;
 
-	char *special;
 	char reply[5];
 
 	newsize = 0;
 	ExpertFlag = 0;
 	SFlag = 0;
+        CheckOnlyFlag = 0;
 
-	while ((ch = getopt(argc, argv, "s:y")) != -1) {
+	while ((ch = getopt(argc, argv, "cps:vy")) != -1) {
 		switch (ch) {
+                case 'c':
+			CheckOnlyFlag = 1;
+			break;
+		case 'p':
+			progress = 1;
+			break;
 		case 's':
 			SFlag = 1;
 			newsize = strtoll(optarg, NULL, 10);
@@ -2071,6 +2143,9 @@ main(int argc, char **argv)
 				usage();
 			}
 			break;
+		case 'v':
+			verbose = 1;
+			break;
 		case 'y':
 			ExpertFlag = 1;
 			break;
@@ -2089,7 +2164,7 @@ main(int argc, char **argv)
 
 	special = *argv;
 
-	if (ExpertFlag == 0) {
+	if (ExpertFlag == 0 && CheckOnlyFlag == 0) {
 		printf("It's required to manually run fsck on file system "
 		    "before you can resize it\n\n"
 		    " Did you run fsck on your disk (Yes/No) ? ");
@@ -2163,14 +2238,37 @@ main(int argc, char **argv)
 	 * thing.  SBLOCKSIZE may be an over-estimate, but we do this
 	 * just once, so being generous is cheap. */
 	memcpy(newsb, oldsb, SBLOCKSIZE);
+
+	if (progress) {
+		progress_ttywidth(0);
+		signal(SIGWINCH, progress_ttywidth);
+	}
+
 	loadcgs();
+
+	if (progress && !CheckOnlyFlag) {
+		progress_switch(progress);
+		progress_init();
+	}
+
 	if (newsize > FFS_FSBTODB(oldsb, oldsb->fs_size)) {
+		if (CheckOnlyFlag)
+			exit(checkonly());
 		grow();
 	} else if (newsize < FFS_FSBTODB(oldsb, oldsb->fs_size)) {
 		if (is_ufs2)
 			errx(EXIT_FAILURE,"shrinking not supported for ufs2");
+		if (CheckOnlyFlag)
+			exit(checkonly());
 		shrink();
+	} else {
+		if (CheckOnlyFlag)
+			exit(checkonly());
+		if (verbose)
+			printf("No change requested: already %" PRId64
+			    " blocks\n", (int64_t)oldsb->fs_size);
 	}
+
 	flush_cgs();
 	write_sbs();
 	if (isplainfile())
@@ -2182,7 +2280,7 @@ static void
 usage(void)
 {
 
-	(void)fprintf(stderr, "usage: %s [-y] [-s size] special\n",
+	(void)fprintf(stderr, "usage: %s [-cvy] [-s size] special\n",
 	    getprogname());
 	exit(EXIT_FAILURE);
 }

Index: src/share/man/man5/rc.conf.5
diff -u src/share/man/man5/rc.conf.5:1.157 src/share/man/man5/rc.conf.5:1.157.4.1
--- src/share/man/man5/rc.conf.5:1.157	Wed Jan 15 11:42:43 2014
+++ src/share/man/man5/rc.conf.5	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rc.conf.5,v 1.157 2014/01/15 11:42:43 apb Exp $
+.\"	$NetBSD: rc.conf.5,v 1.157.4.1 2015/08/06 21:13:44 snj Exp $
 .\"
 .\" Copyright (c) 1996 Matthew R. Green
 .\" All rights reserved.
@@ -55,7 +55,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd January 15, 2014
+.Dd March 30, 2015
 .Dt RC.CONF 5
 .Os
 .Sh NAME
@@ -320,6 +320,13 @@ unbootable even if the file system check
 Boolean value.
 Should be true if you have deliberately configured your system with no swap.
 If false and no swap devices are configured, the system will warn you.
+.It Sy resize_root
+Boolean value.
+Set to true to have the system resize the root file system to fill its
+partition.
+Will only attempt to resize the root file system if it is of type ffs and does
+not have logging enabled.
+Defaults to false.
 .It Sy swapoff
 Boolean value.
 Remove block-type swap devices at shutdown time.

Index: src/tests/sbin/resize_ffs/Makefile
diff -u src/tests/sbin/resize_ffs/Makefile:1.3 src/tests/sbin/resize_ffs/Makefile:1.3.24.1
--- src/tests/sbin/resize_ffs/Makefile:1.3	Wed Jan  5 02:25:27 2011
+++ src/tests/sbin/resize_ffs/Makefile	Thu Aug  6 21:13:44 2015
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.3 2011/01/05 02:25:27 riz Exp $
+# $NetBSD: Makefile,v 1.3.24.1 2015/08/06 21:13:44 snj Exp $
 
 .include <bsd.own.mk>
 
 TESTSDIR=	${TESTSBASE}/sbin/resize_ffs
 
-.for name in t_grow t_shrink t_grow_swapped t_shrink_swapped
+.for name in t_check t_grow t_shrink t_grow_swapped t_shrink_swapped
 TESTS_SH+=	${name}
 TESTS_SH_SRC_${name}=	common.sh ${name}.sh
 .endfor

Index: src/tests/sbin/resize_ffs/common.sh
diff -u src/tests/sbin/resize_ffs/common.sh:1.13 src/tests/sbin/resize_ffs/common.sh:1.13.8.1
--- src/tests/sbin/resize_ffs/common.sh:1.13	Tue Feb 19 21:08:25 2013
+++ src/tests/sbin/resize_ffs/common.sh	Thu Aug  6 21:13:44 2015
@@ -146,6 +146,8 @@ resize_ffs()
 	fi
 
 	umount mnt
+	# Check that resize needed
+	atf_check -s exit:0 -o ignore resize_ffs -c -y -s ${nsize} ${IMG}
 	atf_check -s exit:0 -o ignore resize_ffs -y -s ${nsize} ${IMG}
 	atf_check -s exit:0 -o ignore fsck_ffs -f -n -F ${IMG}
 	atf_check -s exit:0 -e ignore rump_ffs ${IMG} mnt
@@ -155,5 +157,7 @@ resize_ffs()
 	    # checking everything because we don't delete on grow
 	    check_data_range 1 ${numdata}
 	fi
+	# Check that no resize needed
+	atf_check -s exit:1 -o ignore resize_ffs -c -y -s ${nsize} ${IMG}
 	umount mnt
 }

Index: src/tests/sbin/resize_ffs/t_grow.sh
diff -u src/tests/sbin/resize_ffs/t_grow.sh:1.8 src/tests/sbin/resize_ffs/t_grow.sh:1.8.24.1
--- src/tests/sbin/resize_ffs/t_grow.sh:1.8	Tue Jan 11 00:50:02 2011
+++ src/tests/sbin/resize_ffs/t_grow.sh	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-# $NetBSD: t_grow.sh,v 1.8 2011/01/11 00:50:02 riz Exp $
+# $NetBSD: t_grow.sh,v 1.8.24.1 2015/08/06 21:13:44 snj Exp $
 #
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -131,8 +131,10 @@ grow_ffsv1_partial_cg_body()
 	atf_check -o ignore -e ignore newfs -V1 -s 4000 -F ${IMG}
 
 	# size to grow to is chosen to cause partial cg
+	atf_check -s exit:0 -o ignore resize_ffs -c -y -s 5760 ${IMG}
 	atf_check -s exit:0 -o ignore resize_ffs -y -s 5760 ${IMG}
 	atf_check -s exit:0 -o ignore fsck_ffs -f -n -F ${IMG}
+	atf_check -s exit:1 -o ignore resize_ffs -c -y -s 5760 ${IMG}
 }
 
 atf_init_test_cases()

Index: src/tests/sbin/resize_ffs/t_grow_swapped.sh
diff -u src/tests/sbin/resize_ffs/t_grow_swapped.sh:1.2 src/tests/sbin/resize_ffs/t_grow_swapped.sh:1.2.24.1
--- src/tests/sbin/resize_ffs/t_grow_swapped.sh:1.2	Tue Jan 11 00:50:02 2011
+++ src/tests/sbin/resize_ffs/t_grow_swapped.sh	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-# $NetBSD: t_grow_swapped.sh,v 1.2 2011/01/11 00:50:02 riz Exp $
+# $NetBSD: t_grow_swapped.sh,v 1.2.24.1 2015/08/06 21:13:44 snj Exp $
 #
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -130,8 +130,10 @@ grow_ffsv1_partial_cg_body()
 	atf_check -o ignore -e ignore newfs -B be -V1 -s 4000 -F ${IMG}
 
 	# size to grow to is chosen to cause partial cg
+	atf_check -s exit:0 -o ignore resize_ffs -c -y -s 5760 ${IMG}
 	atf_check -s exit:0 -o ignore resize_ffs -y -s 5760 ${IMG}
 	atf_check -s exit:0 -o ignore fsck_ffs -f -n -F ${IMG}
+	atf_check -s exit:1 -o ignore resize_ffs -c -y -s 5760 ${IMG}
 }
 
 atf_init_test_cases()

Index: src/tests/sbin/resize_ffs/t_shrink.sh
diff -u src/tests/sbin/resize_ffs/t_shrink.sh:1.7 src/tests/sbin/resize_ffs/t_shrink.sh:1.7.24.1
--- src/tests/sbin/resize_ffs/t_shrink.sh:1.7	Wed Jan  5 02:25:27 2011
+++ src/tests/sbin/resize_ffs/t_shrink.sh	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-# $NetBSD: t_shrink.sh,v 1.7 2011/01/05 02:25:27 riz Exp $
+# $NetBSD: t_shrink.sh,v 1.7.24.1 2015/08/06 21:13:44 snj Exp $
 #
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -112,8 +112,10 @@ shrink_ffsv1_partial_cg_body()
 	atf_check -o ignore -e ignore newfs -V1 -F -s 5760 ${IMG}
 
 	# shrink so there's a partial cg at the end
+	atf_check -s exit:0 resize_ffs -c -s 4000 -y ${IMG}
 	atf_check -s exit:0 resize_ffs -s 4000 -y ${IMG}
 	atf_check -s exit:0 -o ignore fsck_ffs -f -n -F ${IMG}
+	atf_check -s exit:1 resize_ffs -c -s 4000 -y ${IMG}
 }
 
 atf_init_test_cases()

Index: src/tests/sbin/resize_ffs/t_shrink_swapped.sh
diff -u src/tests/sbin/resize_ffs/t_shrink_swapped.sh:1.1 src/tests/sbin/resize_ffs/t_shrink_swapped.sh:1.1.24.1
--- src/tests/sbin/resize_ffs/t_shrink_swapped.sh:1.1	Wed Jan  5 02:25:27 2011
+++ src/tests/sbin/resize_ffs/t_shrink_swapped.sh	Thu Aug  6 21:13:44 2015
@@ -1,4 +1,4 @@
-# $NetBSD: t_shrink_swapped.sh,v 1.1 2011/01/05 02:25:27 riz Exp $
+# $NetBSD: t_shrink_swapped.sh,v 1.1.24.1 2015/08/06 21:13:44 snj Exp $
 #
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -112,8 +112,10 @@ shrink_ffsv1_partial_cg_body()
 	atf_check -o ignore -e ignore newfs -V1 -F -s 5760 ${IMG}
 
 	# shrink so there's a partial cg at the end
+	atf_check -s exit:0 resize_ffs -c -s 4000 -y ${IMG}
 	atf_check -s exit:0 resize_ffs -s 4000 -y ${IMG}
 	atf_check -s exit:0 -o ignore fsck_ffs -f -n -F ${IMG}
+	atf_check -s exit:1 resize_ffs -c -s 4000 -y ${IMG}
 }
 
 atf_init_test_cases()

Added files:

Index: src/distrib/utils/embedded/conf/armv7.conf
diff -u /dev/null src/distrib/utils/embedded/conf/armv7.conf:1.7.2.2
--- /dev/null	Thu Aug  6 21:13:44 2015
+++ src/distrib/utils/embedded/conf/armv7.conf	Thu Aug  6 21:13:43 2015
@@ -0,0 +1,122 @@
+# $NetBSD: armv7.conf,v 1.7.2.2 2015/08/06 21:13:43 snj Exp $
+# ARMv7 customization script used by mkimage
+#
+board=armv7
+console=fb
+
+. ${DIR}/conf/evbarm.conf
+
+kernels_beagle="BEAGLEBOARD BEAGLEBONE"
+kernels_awin="BPI CUBIEBOARD CUBIETRUCK HUMMINGBIRD_A31"
+kernels_rpi="RPI2"
+kernels_amlogic="ODROID-C1"
+
+make_label() {
+	make_label_evbarm
+}
+
+make_fstab() {
+	make_fstab_evbarm
+}
+
+customize() {
+	customize_evbarm
+	cat >> ${mnt}/etc/rc.conf << EOF
+mdnsd=YES
+wscons=YES
+devpubd=YES
+EOF
+}
+
+populate_beagle() {
+	bboard_kernelimg=netbsd-BEAGLEBOARD.ub
+	bboard_loadaddr=81000000
+	bbone_kernelimg=netbsd-BEAGLEBONE.ub
+	bbone_loadaddr=82000000
+
+	# Create a uEnv.txt to auto boot the correct kernel
+	cat >> ${mnt}/boot/uEnv.txt << EOF
+loaduimage=if test \$board = am335x; then fatload mmc 0 ${bbone_loadaddr} ${bbone_kernelimg}; bootm ${bbone_loadaddr} root=ld0a; else fatload mmc 0 ${bboard_loadaddr} ${bboard_kernelimg}; bootm ${bboard_loadaddr} root=ld0a; fi
+EOF
+}
+
+populate_awin() {
+	cat >> ${mnt}/boot/uEnv.txt << EOF
+bootargs=root=ld0a console=${console}
+uenvcmd=mmc dev 0; mmc rescan; if test \$fdtfile = sun7i-a20-cubieboard2.dtb; then setenv kernel netbsd-CUBIEBOARD2.ub; elif test \$fdtfile = sun7i-a20-cubietruck.dtb; then setenv kernel netbsd-CUBIETRUCK.ub; elif test \$fdtfile = sun6i-a31-hummingbird.dtb; then setenv kernel netbsd-HUMMINGBIRD_A31.ub; elif test \$fdtfile = sun7i-a20-bananapi.dtb; then setenv kernel netbsd-BPI.ub; fi; fatload mmc 0:1 82000000 ${kernel}; bootm 82000000
+EOF
+}
+
+populate_rpi() {
+	firmwaredir=${src}/external/broadcom/rpi-firmware/dist
+	firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
+
+	# RPI2 kernel needs to be installed as kernel7.img
+	if [ -f "${mnt}/boot/netbsd-RPI2.bin" ]; then
+		echo "${bar} renaming netbsd-RPI2.bin to kernel7.img ${bar}"
+		mv "${mnt}/boot/netbsd-RPI2.bin" "${mnt}/boot/kernel7.img"
+
+		cat > ${mnt}/boot/cmdline.txt << EOF
+root=ld0a console=${console}
+#fb=1280x1024		# to select a mode, otherwise try EDID
+#fb=disable		# to disable fb completely
+EOF
+
+	        echo "${bar} installing firmware files ${bar}"
+		(cd ${mnt}/boot &&
+			for f in ${firmwarefiles}; do
+				echo " $f"
+				cp ${firmwaredir}/${f} .
+			done
+        	)
+
+	fi
+}
+
+populate_amlogic() {
+	odroidc1_kernelimg=netbsd-ODROID-C1.ub
+
+	# Create a boot.ini for Amlogic U-Boot
+	cat >> ${mnt}/boot/boot.ini << EOF
+ODROIDC-UBOOT-CONFIG
+
+setenv bootargs "root=ld0f awge0.mac-address=\${ethaddr} console=${console}"
+setenv bootcmd "fatload mmc 0:1 0x21000000 ${odroidc1_kernelimg}; bootm 0x21000000"
+run bootcmd
+EOF
+}
+
+populate() {
+	echo "${bar} looking for kernels in ${kernel} ${bar}"
+	kernels=""
+	# .ub kernels
+	for k in $kernels_beagle $kernels_awin $kernels_amlogic; do
+		f="${kernel}/netbsd-${k}.ub.gz"
+		test -f "${f}" && kernels="${kernels} ${f}"
+	done
+	# .bin kernels
+	for k in $kernels_rpi; do
+		f="${kernel}/netbsd-${k}.bin.gz"
+		test -f "${f}" && kernels="${kernels} ${f}"
+	done
+
+	# install kernels to /boot partition
+	for k in ${kernels}; do
+		tgt="$(basename ${k} | sed 's/\.gz$//')"
+		echo "${bar} installing ${k} to /boot/${tgt} ${bar}"
+		case "${k}" in
+		*.gz)
+			${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}"
+			;;
+		*)
+			cp "${k}" "${mnt}/boot/${tgt}"
+			;;
+		esac
+	done
+
+	# board specific configuration
+	populate_beagle
+	populate_awin
+	populate_rpi
+	populate_amlogic
+}

Index: src/distrib/utils/embedded/files/resize_disklabel
diff -u /dev/null src/distrib/utils/embedded/files/resize_disklabel:1.1.2.2
--- /dev/null	Thu Aug  6 21:13:44 2015
+++ src/distrib/utils/embedded/files/resize_disklabel	Thu Aug  6 21:13:43 2015
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# $NetBSD: resize_disklabel,v 1.1.2.2 2015/08/06 21:13:43 snj Exp $
+#
+
+# PROVIDE: resize_disklabel
+# REQUIRE: fsck_root
+# BEFORE: resize_root
+
+$_rc_subr_loaded . /etc/rc.subr
+
+name="resize_disklabel"
+rcvar=$name
+start_cmd="resize_disklabel_start"
+stop_cmd=":"
+
+get_rawpart()
+{
+	partno=$(/sbin/sysctl -n kern.rawpartition)
+	test $partno = 2 && echo c || echo d
+}
+
+get_total_sectors()
+{
+	disk=$1
+	/sbin/drvctl -p $disk disk-info/geometry/sectors-per-unit
+}
+
+get_rawpart_sectors()
+{
+	disk=$1
+	rawpart=$2
+	/sbin/disklabel $disk | grep "^ $rawpart:" | awk '{ print $2; }'
+}
+
+grow_disklabel()
+{
+	disk=$1
+	part=$2
+	rawpart=$(get_rawpart)
+
+	ts=$(get_total_sectors $disk)
+	rs=$(get_rawpart_sectors $disk $rawpart)
+
+	if [ "$ts" = "$rs" ]; then
+		return
+	fi
+
+	oldsize=$(($rs * 512 / 1024 / 1024))
+	newsize=$(($ts * 512 / 1024 / 1024))
+	echo "Growing $disk disklabel (${oldsize}MB -> ${newsize}MB)"
+	printf "A\ny\n$part\n\n\n\$\nc\n\n\n\$\nd\n\n\n\$\nW\ny\nQ\n" | \
+	    disklabel -i $disk >/dev/null
+}
+
+resize_disklabel_start()
+{
+	if [ x"${resize_disklabel_disk}" = "x" ]; then
+		warn "\${resize_disklabel_disk} is not set, not resizing disklabel"
+		return
+	fi
+	if [ x"${resize_disklabel_part}" = "x" ]; then
+		warn "\${resize_disklabel_part} is not set, not resizing disklabel"
+		return
+	fi
+
+	grow_disklabel "${resize_disklabel_disk}" "${resize_disklabel_part}"
+}
+
+load_rc_config $name
+run_rc_command "$1"

Index: src/etc/rc.d/resize_root
diff -u /dev/null src/etc/rc.d/resize_root:1.3.2.2
--- /dev/null	Thu Aug  6 21:13:44 2015
+++ src/etc/rc.d/resize_root	Thu Aug  6 21:13:44 2015
@@ -0,0 +1,99 @@
+#!/bin/sh
+#
+# $NetBSD: resize_root,v 1.3.2.2 2015/08/06 21:13:44 snj Exp $
+#
+
+# PROVIDE: resize_root
+# REQUIRE: fsck_root
+# KEYWORD: interactive
+
+$_rc_subr_loaded . /etc/rc.subr
+
+name="resize_root"
+rcvar=$name
+start_cmd="resize_root_start"
+stop_cmd=":"
+fstab_file=/etc/fstab
+rootmp="/"
+
+split_options()
+{
+	local IFS
+	IFS=,
+	OPTS=$1
+	for i in $OPTS; do
+		echo $i
+	done
+}
+
+resize_root_start()
+{
+	# if ! checkyesno $rcvar; then
+	# 	echo "Not resizing $rootmp: resize_root must be set to YES/yes/..."
+	# 	return
+	# fi
+
+	trap : 2 		# Ignore SIGINT, SIGQUIT, so we
+	trap : 3		# enter single-user mode on failure.
+
+	# Do nothing if root file system is not mentioned in /etc/fstab, or if
+	# root file system seems to be a network mount, or if root file system
+	# is not ffs or if logging is enabled.
+	rootdev=""
+	while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno
+	do
+		# skip comment or blank line
+		case "${fs_spec}" in
+		\#*|'') continue ;;
+		esac
+
+		# skip non-root
+		if [ "${fs_file}" != "$rootmp" ]; then
+			continue
+		fi
+
+		if [ "${fs_vfstype}" != "ffs" ]; then
+			echo "Not resizing $rootmp: not an ffs file system"
+			return
+		fi
+
+		case "${fs_spec}" in
+		*:*)
+			echo "Not resizing $rootmp: network mount"
+			return
+			;;
+		esac
+
+		for opt in $(split_options "${fs_mntops}"); do
+			if [ "$opt" = "log" ];  then
+				echo "Not resizing $rootmp: logging unsupported"
+				return
+			fi
+		done
+
+		rootdev=${fs_spec%/*}/r${fs_spec##*/}
+		break
+	done < "${fstab_file}"
+
+	if [ -z "$rootdev" ]; then
+		echo "Not resizing $rootmp: not listed in ${fstab_file}"
+		return
+	fi
+
+	if resize_ffs -c $rootdev; then
+		echo "Resizing $rootmp"
+		if ! resize_ffs -y $resize_root_flags $rootdev; then
+		    echo "Error resizing root."
+		    stop_boot
+		fi
+		if [ ! -z "${resize_root_postcmd}" ]; then
+			${resize_root_postcmd}
+		fi
+	else
+		echo "Not resizing $rootmp: already correct size"
+	fi
+	return
+}
+
+load_rc_config $name
+run_rc_command "$1"

Index: src/tests/sbin/resize_ffs/t_check.sh
diff -u /dev/null src/tests/sbin/resize_ffs/t_check.sh:1.1.2.2
--- /dev/null	Thu Aug  6 21:13:44 2015
+++ src/tests/sbin/resize_ffs/t_check.sh	Thu Aug  6 21:13:44 2015
@@ -0,0 +1,56 @@
+# $NetBSD: t_check.sh,v 1.1.2.2 2015/08/06 21:13:44 snj Exp $
+#
+# Copyright (c) 2010 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Christian E. Hopps
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+atf_test_case check_grow
+
+check_grow_head() {
+	atf_set "descr" "Tests check for room to grow in image"
+	atf_set "require.user" "root"
+}
+
+check_grow_body() {
+	echo "***resize_ffs check grow test"
+
+	atf_check -o ignore -e ignore newfs -V1 -s 6144 -F ${IMG}
+	dd if=/dev/zero count=2048 >> ${IMG}
+
+	# test room to grow, grow then check that we did.
+	atf_check -s exit:0 -o match:"newsize: 8192 oldsize: 6144" resize_ffs -v -c -y ${IMG}
+	atf_check -s exit:0 -o ignore resize_ffs -y ${IMG}
+	atf_check -s exit:0 -o ignore fsck_ffs -f -n -F ${IMG}
+	atf_check -s exit:1 -o match:"already 8192 blocks" \
+	    resize_ffs -v -c -y ${IMG}
+}
+
+atf_init_test_cases()
+{
+	setupvars
+	atf_add_test_case check_grow
+}

Reply via email to