From: Daan De Meyer Date: Mon, 30 Sep 2024 11:41:11 +0000 (+0200) Subject: repart: Shortcut copy if source or target starts with exclude path X-Git-Tag: v257-rc1~354^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc4710ceb2cccf9ddc42839fd99884d9148c994e;p=thirdparty%2Fsystemd.git repart: Shortcut copy if source or target starts with exclude path If the source or target we're copying to is a subdirectory of any of the directories specified in ExcludeFiles= or ExcludeFilesTarget=, shortcut the entire copy operation. --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 48ba4d79732..026b4241697 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -5254,6 +5254,9 @@ static int make_copy_files_denylist( } STRV_FOREACH(e, override_exclude_src ?: p->exclude_files_source) { + if (path_startswith(source, *e)) + return 1; + r = add_exclude_path(*e, &denylist, endswith(*e, "/") ? DENY_CONTENTS : DENY_INODE); if (r < 0) return r; @@ -5262,6 +5265,9 @@ static int make_copy_files_denylist( STRV_FOREACH(e, override_exclude_tgt ?: p->exclude_files_target) { _cleanup_free_ char *path = NULL; + if (path_startswith(target, *e)) + return 1; + const char *s = path_startswith(*e, target); if (!s) continue; @@ -5492,6 +5498,8 @@ static int do_copy_files(Context *context, Partition *p, const char *root) { r = make_copy_files_denylist(context, p, *source, *target, &denylist); if (r < 0) return r; + if (r > 0) + continue; r = make_subvolumes_set(p, *source, *target, &subvolumes_by_source_inode); if (r < 0)