Index: usr.sbin/freebsd-update/freebsd-update.sh =================================================================== --- usr.sbin/freebsd-update/freebsd-update.sh +++ usr.sbin/freebsd-update/freebsd-update.sh @@ -689,7 +689,12 @@ # Figure out what directory contains the running kernel BOOTFILE=`sysctl -n kern.bootfile` KERNELDIR=${BOOTFILE%/kernel} - if ! [ -d ${KERNELDIR} ]; then + # If a non-default bootloader is being used the bootfile, "/kernel" + # may be returned by sysctl. In this case, assume the default location. + KERNELDIR=${KERNELDIR:-/boot/kernel} + + if ! [ -d ${KERNELDIR} ] || + ! [ -f ${KERNELDIR}/${BOOTFILE} ]; then echo "Cannot identify running kernel" exit 1 fi @@ -831,7 +836,12 @@ # Figure out what directory contains the running kernel BOOTFILE=`sysctl -n kern.bootfile` KERNELDIR=${BOOTFILE%/kernel} - if ! [ -d ${KERNELDIR} ]; then + # If a non-default bootloader is being used the bootfile, "/kernel" + # may be returned by sysctl. In this case, assume the default location. + KERNELDIR=${KERNELDIR:-/boot/kernel} + + if ! [ -d ${KERNELDIR} ] || + ! [ -f ${KERNELDIR}/${BOOTFILE} ]; then echo "Cannot identify running kernel" exit 1 fi @@ -925,7 +935,12 @@ # Figure out what directory contains the running kernel BOOTFILE=`sysctl -n kern.bootfile` KERNELDIR=${BOOTFILE%/kernel} - if ! [ -d ${KERNELDIR} ]; then + # If a non-default bootloader is being used the bootfile, "/kernel" + # may be returned by sysctl. In this case, assume the default location. + KERNELDIR=${KERNELDIR:-/boot/kernel} + + if ! [ -d ${KERNELDIR} ] || + ! [ -f ${KERNELDIR}/${BOOTFILE} ]; then echo "Cannot identify running kernel" exit 1 fi