<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2"><br>On 06/23/2016 around 12:35AM in some timezone, Andrew Jeffery wrote:<br>>On Wed, 2016-06-22 at 19:30 -0500, OpenBMC Patches wrote:<br>>> From: "Milton D. Miller II" <<a target="_blank" href="mailto:miltonm@us.ibm.com">miltonm@us.ibm.com</a>><br>>> <br>>> Instead of checking for any mtd device, only check mtd devices<br>>> that are to be updated.<br>><br>>What do you mean by "instead of"? We're not removing any code here,<br>>and<br>>from a quick look we loop over the update images in existing checks.<br>><br><br>The grep for mtd anywhere in proc at the top of the script (that you<br>had me move ERROR up to handle) is replaced with ...<br><br>>>   Include child mtd devices when looking<br>>> for mounted filesystems.<br>>> <br>>> If this check is suppressed flash updates are suppressed.<br>>> Suppressing the check may be useful to verify a update could<br>>> succeed at shutdown.<br>>> <br>>> Signed-off-by: Milton Miller <<a target="_blank" href="mailto:miltonm@us.ibm.com">miltonm@us.ibm.com</a>><br>>> ---<br>>>  .../obmc-phosphor-initfs/files/obmc-update.sh      | 47<br>>+++++++++++++++++++---<br>>>  1 file changed, 41 insertions(+), 6 deletions(-)<br>>> <br>>> diff --git<br>>a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/ob<br>>mc-update.sh<br>>b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/ob<br>>mc-update.sh<br>>> index 4442e5b..22c9dcc 100755<br>>> ---<br>>a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/ob<br>>mc-update.sh<br>>> +++<br>>b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/ob<br>>mc-update.sh<br>>> @@ -19,11 +19,34 @@ then<br>>>          mount -t devtmpfs dev dev<br>>>  fi<br>>>  <br>>> -if grep mtd /proc/mounts<br>>> -then<br>>> -        echo 1>&2 "ERROR: A mtd device is mounted."<br>>> -        exit 1<br>>> -fi<br><br>Right here is the "instead of" code that is being removed.<br><br><br>>> +# mtd number N with mtd name Name can be mounted via mtdN, or<br>>mtd:Name<br>>> +# (with a mtd aware fs) or by /dev/mtdblockN (with a mtd or block<br>>fs).<br>>> +mtdismounted() {<br>><br>>I keep reading this as mt-dismounted rather than mtd-is-mounted. Can<br>>we<br>>add some underscores?<br><br>If I do that then I have to add them to all the functions and then <br>my lines go over 80 characters and then ...<br><br>I considered ismtdmounted but that gets back to which is true like<br>checkmtdmounted would, so I decided to go with mountedmtd.<br><br>>>                  shift ;;<br>>> @@ -135,6 +162,14 @@ do<br>>>                  echo 1>&2 "$E Unable to find mtd partiton for ${f##*/}."<br>>>                  exit 1<br>>>          fi<br>>> +        for s in $m $(childmtds $m)<br>>> +        do<br>>> +                if test -n "$checkmount" && mtdismounted $s<br>><br>>$checkmount is invariant with respect to $s, so is it worth hoisting<br>>the check out of the loop? Though it would mean another indent...<br>><br><br>Since this also suppresses the call to childmtds I decided to <br>implement this, changing the error to be Device $s for ${f} is in use.<br><br><br>Unfortunately the file system can be unmounted to where it <br>no longer appears in /proc/mounts but is stlil mounted and in <br>use by the overlay.  I don't know how to fix this.  Some long <br>ideas are add sysfs status to mtd and add a process holding <br>the directory open with the systemd "don't kill leave to shutdown <br>script" process name (if that can be done from shell).  Or copying <br>the .proc/mounts to /run when mounting overlay and checking <br>that too.   This is to avoid root writing a new image while the <br>file system writes to the flash based on the old image, and<br>several of these options would not be detect mounting a device <br>node with a nonstandard name.<br><br>milton<br></font><BR>