[elbe-devel] [PATCH v3 1/5] fstab: Find a loop device for losetup
Olivier Dion
dion at linutronix.de
Sat Apr 4 19:27:51 CEST 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 | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/elbepack/fstab.py b/elbepack/fstab.py
index 94f11d2f..970d508b 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,10 @@ 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 --offset %d --sizelimit %d --find --show "%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