[elbe-devel] [PATCH v2 1/2] fstab: Find a loop device for losetup
Olivier Dion
dion at linutronix.de
Thu Mar 26 20:54:56 CET 2020
This fix issue #255, see <https://github.com/Linutronix/elbe/issues/254>.
According to losetup(8), detaching a loop device will not return EBUSY
if the device is busy since kernel 3.7, because of lazy device
destruction.
However, EBUSY is returned if we try to acquire a device that is busy,
even though its reference count is 0.
For this reason, letting losetup to find a proper device and returning
it would avoid such situation.
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/fstab.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/elbepack/fstab.py b/elbepack/fstab.py
index 94f11d2f..3abea797 100644
--- a/elbepack/fstab.py
+++ b/elbepack/fstab.py
@@ -7,7 +7,7 @@
import os
-from elbepack.shellhelper import do
+from elbepack.shellhelper import do, get_command_out
def get_mtdnum(xml, label):
@@ -140,9 +140,11 @@ class fstabentry(object):
self.partnum = ppart.number
self.number = '{}{}'.format(disk.type, ppart.number)
- def losetup(self, loopdev):
- do('losetup -o%d --sizelimit %d /dev/%s "%s"' %
- (self.offset, self.size, loopdev, self.filename))
+ def losetup(self):
+
+ loopdev = get_command_out('losetup -o%d --sizelimit %d --show -f "%s"' %
+ (self.offset, self.size, self.filename))
+ return loopdev.rstrip('\n')
def tuning(self, loopdev):
if self.tune:
--
2.26.0
More information about the elbe-devel
mailing list