[elbe-devel] [PATCH] fstab: Fix issue #254

Bastian Germann bage at linutronix.de
Tue Mar 24 00:34:11 CET 2020


Please use a more describing subject.

Am 24.03.20 um 00:35 schrieb Olivier Dion:
> See <https://github.com/Linutronix/elbe/issues/254>.

Write a line "Fixes #254." instead to trigger the GitHub issue management.

> 
> Before setting up a loop device, poll it to see if it's busy and wait
> until it's not.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
>  elbepack/fstab.py | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/elbepack/fstab.py b/elbepack/fstab.py
> index 94f11d2f..3d9fd112 100644
> --- a/elbepack/fstab.py
> +++ b/elbepack/fstab.py
> @@ -6,8 +6,10 @@
>  # SPDX-License-Identifier: GPL-3.0-or-later
>  
>  import os
> +import time
> +import logging
>  
> -from elbepack.shellhelper import do
> +from elbepack.shellhelper import do, get_command_out
>  
>  
>  def get_mtdnum(xml, label):
> @@ -141,6 +143,16 @@ class fstabentry(object):
>          self.number = '{}{}'.format(disk.type, ppart.number)
>  
>      def losetup(self, loopdev):
> +        while True:
> +            is_busy = get_command_out("losetup -l /dev/%s -n --raw | "
> +                                      "cut -d' ' -f6" % loopdev)
> +
> +            if is_busy == "\n" or is_busy == "":
> +                break
> +
> +            time.sleep(0.1)
> +            logging.warning("Device /dev/%s is busy .. retrying", loopdev)
> +
>          do('losetup -o%d --sizelimit %d /dev/%s "%s"' %
>             (self.offset, self.size, loopdev, self.filename))
>  
> 



More information about the elbe-devel mailing list