]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/configs: refactor directory list merging
authorKarel Zak <kzak@redhat.com>
Wed, 15 Oct 2025 12:52:29 +0000 (14:52 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 15 Oct 2025 12:52:29 +0000 (14:52 +0200)
commit9ff054b2d3253d43bc50082e1fa979e92d91d702
tree23cdbd087fb73e015462c9b39dbcb8e3941dbfc8
parent3c8321ac7c7c26505424ae7a432b345b6ab5b139
lib/configs: refactor directory list merging

The original implementation used complex nested loops to merge
configuration file lists from different directories. This commit
simplifies the code by introducing a new config_merge_list()
function that handles the merging logic.

Changes:
- Add config_merge_list() to merge lists with duplicate detection
- Add config_cmp() comparison function using strcoll() (consistent
  with alphasort() behavior from scandirat())
- Add configs_add_filename() helper to reduce code duplication
- Simplify ul_configs_file_list() by replacing ~120 lines of
  merging logic with 3 calls to config_merge_list()
- Remove intermediate etc_run_file_list, merge directly to output
- Update read_dir() to return 0/-ENOMEM instead of entry count
- Use list_count_entries() to get final count

The new config_merge_list() moves entries directly from source
lists to the destination list without extra allocations, making
it more efficient than the previous approach.

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/configs.c