[elbe-devel] [PATCH] efilesystem: Fix copy_filelist
Torben Hohn
torben.hohn at linutronix.de
Tue Jul 21 12:24:08 CEST 2020
On Mon, Jul 20, 2020 at 08:34:34PM -0400, Olivier Dion wrote:
> The current algorithm was adding the target of a symlink on top of the
> stack. But this break the assumption of sorted list for 'files'.
> Thus, when the target of a symlink is not yet in the RFS destination,
> we recursively call copy_filelist.
>
> Signed-off-by: Olivier Dion <dion at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> elbepack/efilesystem.py | 19 ++++++++-----------
> 1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
> index 40865c28..ef697c46 100644
> --- a/elbepack/efilesystem.py
> +++ b/elbepack/efilesystem.py
> @@ -56,23 +56,20 @@ def copy_filelist(src, file_lst, dst):
>
> tgt = src.readlink(f)
>
> - # If the target of the symlink is relative, we need the
> - # absolute path of it
> - if not os.path.isabs(tgt):
> - tgt = os.path.join(os.path.dirname(f), tgt)
> -
> # If the target is not yet in the destination RFS, we need
> # to defer the copy of the symlink after the target is
> - # resolved. Thus, we put the symlink back on the stack
> - # and we add the target to resolve on top of it.
> + # resolved. Thus, we recusively call copy_filelist
> #
> # Not that this will result in an infinite loop for
> # circular symlinks
> if not dst.lexists(tgt):
> - files.append(f)
> - files.append(tgt)
> - else:
> - dst.symlink(tgt, f)
> + if not os.path.isabs(tgt):
> + lst = [os.path.join(os.path.dirname(f), tgt)]
> + else:
> + lst = [tgt]
> + copy_filelist(src, lst, dst)
> +
> + dst.symlink(tgt, f, allow_exists=True)
>
> elif src.isdir(f):
> if not dst.isdir(f):
> --
> 2.27.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