[elbe-devel] [PATCH v2 1/5] fstab: Fix losetup
Torben Hohn
torben.hohn at linutronix.de
Wed Aug 19 11:31:08 CEST 2020
On Mon, Aug 17, 2020 at 09:49:16AM -0400, Olivier Dion wrote:
> Busy loop until a device is available. This should ensure that
> there's no more problem with finding a loop devices.
>
> Signed-off-by: Olivier Dion <dion at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> elbepack/fstab.py | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/elbepack/fstab.py b/elbepack/fstab.py
> index 425c9132..0ad6a743 100644
> --- a/elbepack/fstab.py
> +++ b/elbepack/fstab.py
> @@ -6,6 +6,7 @@
> # SPDX-License-Identifier: GPL-3.0-or-later
>
> import os
> +import time
>
> from elbepack.shellhelper import do, get_command_out, CommandError
>
> @@ -134,15 +135,21 @@ class fstabentry(object):
> self.number = '{}{}'.format(disk.type, ppart.number)
>
> def losetup(self):
> +
> cmd = ('losetup --offset %d --sizelimit %d --find --show "%s"' %
> (self.offset, self.size, self.filename))
> - try:
> - loopdev = get_command_out(cmd)
> - except CommandError as e:
> - if e.returncode != 1:
> - raise
> - do('sync')
> - loopdev = get_command_out(cmd)
> +
> + while True:
> +
> + try:
> + loopdev = get_command_out(cmd)
> + except CommandError as e:
> + if e.returncode != 1:
> + raise
> + do('sync')
> + time.sleep(1)
> + else:
> + break
>
> return loopdev.rstrip('\n')
>
> --
> 2.28.0
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
--
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/kontakt/Datenschutz.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
More information about the elbe-devel
mailing list