[elbe-devel] [PATCH v2 2/2] hdimg: Find loop device instead of providing it

Torben Hohn torben.hohn at linutronix.de
Thu Apr 2 15:29:19 CEST 2020


On Thu, Mar 26, 2020 at 03:54:57PM -0400, Olivier Dion wrote:
> Since we might not be able to acquire /dev/loop0, we let losetup
> find a free device for us and use it.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>


But note, that this is not complete.
the grubinstaller logic still uses hardcoded /dev/loop0 
and /dev/poop0 (this is just code to avoid special treatment for
/dev/loop* in the grub installer scripts.

so for the grubinstallers you need a way to create /dev/poop10 is
losetup returns /dev/loop10 

and also make these things dynamic.

> ---
>  elbepack/hdimg.py | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
> index 22522821..a9d2666c 100644
> --- a/elbepack/hdimg.py
> +++ b/elbepack/hdimg.py
> @@ -331,20 +331,21 @@ def create_label(disk, part, ppart, fslabel, target, grub):
>  
>      grub.add_fs_entry(entry)
>  
> -    entry.losetup("loop0")
> -    do('mkfs.%s %s %s /dev/loop0' %
> +    loopdev = entry.losetup()
> +    do('mkfs.%s %s %s %s' %
>         (entry.fstype,
>          entry.mkfsopt,
> -        entry.get_label_opt()))
> +        entry.get_label_opt(),
> +        loopdev))
>  
> -    do('mount /dev/loop0 %s' % os.path.join(target, "imagemnt"))
> +    do('mount %s %s' % (loopdev, os.path.join(target, "imagemnt")))
>      do('cp -a "%s/." "%s/"' %
>         (os.path.join(target, "filesystems", entry.id),
>          os.path.join(target, "imagemnt")),
>         allow_fail=True)
> -    entry.tuning("/dev/loop0")
> -    do('umount /dev/loop0')
> -    do('losetup -d /dev/loop0')
> +    entry.tuning(loopdev)
> +    do('umount %s' % loopdev)
> +    do('losetup -d %s' % loopdev)
>  
>      return ppart
>  
> -- 
> 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