[PATCH openbmc v6 11/18] initfs: update: check individual mtd partitions for mounts

Andrew Jeffery andrew at aj.id.au
Thu Jun 23 15:35:06 AEST 2016


On Wed, 2016-06-22 at 19:30 -0500, OpenBMC Patches wrote:
> From: "Milton D. Miller II" <miltonm at us.ibm.com>
> 
> Instead of checking for any mtd device, only check mtd devices
> that are to be updated.

What do you mean by "instead of"? We're not removing any code here, and
from a quick look we loop over the update images in existing checks.

>   Include child mtd devices when looking
> for mounted filesystems.
> 
> If this check is suppressed flash updates are suppressed.
> Suppressing the check may be useful to verify a update could
> succeed at shutdown.
> 
> Signed-off-by: Milton Miller <miltonm at us.ibm.com>
> ---
>  .../obmc-phosphor-initfs/files/obmc-update.sh      | 47 +++++++++++++++++++---
>  1 file changed, 41 insertions(+), 6 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> index 4442e5b..22c9dcc 100755
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> @@ -19,11 +19,34 @@ then
>  	mount -t devtmpfs dev dev
>  fi
>  
> -if grep mtd /proc/mounts
> -then
> -	echo 1>&2 "ERROR: A mtd device is mounted."
> -	exit 1
> -fi
> +# mtd number N with mtd name Name can be mounted via mtdN, or mtd:Name
> +# (with a mtd aware fs) or by /dev/mtdblockN (with a mtd or block fs).
> +mtdismounted() {

I keep reading this as mt-dismounted rather than mtd-is-mounted. Can we
add some underscores?

> +	m=${1##mtd}
> +	if grep -s "mtdblock$m " /proc/mounts || grep -s "mtd$m " /proc/mounts
> +	then
> +		return 0
> +	fi
> +	n=$(cat /sys/class/mtd/mtd$m/name)
> +	if test -n "$n" && grep -s "mtd:$n " /proc/mounts
> +	then
> +		return 0
> +	fi
> +	return 1
> +}
> +
> +# Detect child partitions when the whole flash is to be updated.
> +# Ignore mtdNro and mtdblockN names in the class subsystem directory.
> +childmtds() {
> +	for m in /sys/class/mtd/$1/mtd*
> +	do
> +		m=${m##*/}
> +		if test "${m%ro}" = "${m#mtdblock}"
> +		then
> +			echo $m
> +		fi
> +	done
> +}
>  
>  findmtd() {
>  	m=$(grep -xl "$1" /sys/class/mtd/*/name)
> @@ -62,10 +85,10 @@ doclean=
>  dosave=y
>  dorestore=y
>  toram=
> +checkmount=y
>  
>  whitelist=/run/initramfs/whitelist
>  image=/run/initramfs/image-
> -
>  E="ERROR:"
>  
>  while test "$1" != "${1#-}"
> @@ -92,6 +115,10 @@ do
>  	--no-flash)
>  		doflash=
>  		shift ;;
> +	--ignore-mount)
> +		checkmount=
> +		doflash=
> +		shift ;;
>  	--copy-files)
>  		toram=y
>  		shift ;;
> @@ -135,6 +162,14 @@ do
>  		echo 1>&2 "$E Unable to find mtd partiton for ${f##*/}."
>  		exit 1
>  	fi
> +	for s in $m $(childmtds $m)
> +	do
> +		if test -n "$checkmount" && mtdismounted $s

$checkmount is invariant with respect to $s, so is it worth hoisting
the check out of the loop? Though it would mean another indent...

Cheers,

Andrew

> +		then
> +			echo 1>&2 "$E Device $s is mounted, ${f##*/} is busy."
> +			exit 1
> +		fi
> +	done
>  done
>  
>  if test -n "$doflash"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160623/461a4ba8/attachment.sig>


More information about the openbmc mailing list