]> git.ipfire.org Git - thirdparty/systemd.git/commit
repart: don't try to extract directory of root dir when copying directories 19390/head
authorLennart Poettering <lennart@poettering.net>
Wed, 21 Apr 2021 21:23:07 +0000 (23:23 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Apr 2021 21:30:49 +0000 (23:30 +0200)
commitf21a3a82fb6532d0f858c4f59c235af263a4131b
treefa6fd168e5fe3d2098f8bd516e9f4e2a15710252
parente28190673ca83d62692dae6d791161bece820030
repart: don't try to extract directory of root dir when copying directories

It's OK to specify the root dir as target directory when copying
directories. However, in that case path_extract_filename() is going to
fail, because the root dir simply has not filename.

Let's address that by moving the call further down into the loop, when
we made sure that the target dir doesn't exist yet (the root dir always
exists, hence this check is sufficient).

Moreover, in the branch for copying regular files, also move the calls
down, and generate friendly error messages in case people try to
overwrite dirs with regular files (and the root dir is just a special
case of a dir).

Altogether this makes CopyFiles=/some/place:/ work, i.e. copying some
dir on the host into the root dir of the newly created fs. Previously
this would fail with an error about the inability to extract a filename
from "/", needlessly.
src/partition/repart.c