[elbe-devel] [PATCH v3 1/5] fstab: Find a loop device for losetup

Torben Hohn torben.hohn at linutronix.de
Wed Apr 15 17:21:50 CEST 2020


On Sat, Apr 04, 2020 at 01:27:51PM -0400, Olivier Dion wrote:
> 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>

Reviewed-by: Torben Hohn <torben.hohn 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
> 
> 
> _______________________________________________
> 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