[elbe-devel] [PATCH 1/2] fstab: Fix losetup
Olivier Dion
dion at linutronix.de
Tue Aug 11 17:32:24 CEST 2020
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>
---
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
More information about the elbe-devel
mailing list