]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-files: rename .name field to .filename to make clearer what precisely it is...
authorLennart Poettering <lennart@poettering.net>
Mon, 15 Sep 2025 12:45:08 +0000 (14:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Sun, 25 Jan 2026 19:51:50 +0000 (20:51 +0100)
src/basic/conf-files.c
src/basic/conf-files.h
src/sysupdate/sysupdate.c

index 4d4cf27952f43126e1f36004e8fdb1489670934d..ff40eb617b29607157cd07173c12e313c0351c6d 100644 (file)
@@ -24,7 +24,7 @@ ConfFile* conf_file_free(ConfFile *c) {
         if (!c)
                 return NULL;
 
-        free(c->name);
+        free(c->filename);
         free(c->result);
         free(c->original_path);
         free(c->resolved_path);
@@ -302,7 +302,7 @@ int conf_file_new_at(
         if (!c->original_path)
                 return log_oom_full(log_level);
 
-        r = path_extract_filename(path, &c->name);
+        r = path_extract_filename(path, &c->filename);
         if (r < 0)
                 return log_full_errno(log_level, r, "Failed to extract filename from '%s': %m", path);
 
@@ -318,7 +318,7 @@ int conf_file_new_at(
                         return log_full_errno(log_level, r, "Failed to chase '%s%s': %m", empty_to_root(root), skip_leading_slash(dirpath));
         }
 
-        c->result = path_join(resolved_dirpath, c->name);
+        c->result = path_join(resolved_dirpath, c->filename);
         if (!c->result)
                 return log_oom_full(log_level);
 
@@ -327,7 +327,7 @@ int conf_file_new_at(
                         rfd,
                         c->original_path,
                         c->result,
-                        c->name,
+                        c->filename,
                         /* masked= */ NULL,
                         flags,
                         &c->resolved_path,
@@ -456,7 +456,7 @@ static int files_add(
                         return log_oom_full(log_level);
 
                 *c = (ConfFile) {
-                        .name = strdup(de->d_name),
+                        .filename = strdup(de->d_name),
                         .result = TAKE_PTR(p),
                         .original_path = TAKE_PTR(original_path),
                         .resolved_path = TAKE_PTR(resolved_path),
@@ -464,10 +464,10 @@ static int files_add(
                         .st = st,
                 };
 
-                if (!c->name)
+                if (!c->filename)
                         return log_oom_full(log_level);
 
-                r = hashmap_ensure_put(files, &conf_file_hash_ops, c->name, c);
+                r = hashmap_ensure_put(files, &conf_file_hash_ops, c->filename, c);
                 if (r < 0) {
                         assert(r == -ENOMEM);
                         return log_oom_full(log_level);
@@ -497,7 +497,7 @@ static int dump_files(Hashmap *fh, const char *root, ConfFilesFlags flags, ConfF
 
         /* Hence, we need to remove them from the hashmap. */
         FOREACH_ARRAY(i, files, n_files)
-                assert_se(hashmap_remove(fh, (*i)->name) == *i);
+                assert_se(hashmap_remove(fh, (*i)->filename) == *i);
 
         if (root)
                 FOREACH_ARRAY(i, files, n_files) {
@@ -538,7 +538,7 @@ static int copy_and_sort_files_from_hashmap(
                 const char *add = NULL;
 
                 if (FLAGS_SET(flags, CONF_FILES_BASENAME))
-                        add = c->name;
+                        add = c->filename;
                 else if (root) {
                         _cleanup_free_ char *p = NULL;
 
@@ -590,22 +590,22 @@ static int insert_replacement(Hashmap **fh, ConfFile *replacement, ConfFilesFlag
 
         /* This consumes the input ConfFile. */
 
-        ConfFile *existing = hashmap_get(*fh, c->name);
+        ConfFile *existing = hashmap_get(*fh, c->filename);
         if (existing) {
                 log_debug("An entry with higher priority '%s' -> '%s' already exists, ignoring the replacement: %s",
-                          existing->name, existing->result, c->original_path);
+                          existing->filename, existing->result, c->original_path);
                 *ret = NULL;
                 return 0;
         }
 
-        r = hashmap_ensure_put(fh, &conf_file_hash_ops, c->name, c);
+        r = hashmap_ensure_put(fh, &conf_file_hash_ops, c->filename, c);
         if (r < 0) {
                 assert(r == -ENOMEM);
                 return log_oom_full(conf_files_log_level(flags));
         }
         assert(r > 0);
 
-        log_debug("Inserted replacement: '%s' -> '%s'", c->name, c->result);
+        log_debug("Inserted replacement: '%s' -> '%s'", c->filename, c->result);
 
         *ret = TAKE_PTR(c);
         return 0;
@@ -651,7 +651,7 @@ static int conf_files_list_impl(
                         continue;
                 }
 
-                if (c && streq_ptr(path_startswith(c->result, path), c->name)) {
+                if (c && streq_ptr(path_startswith(c->result, path), c->filename)) {
                         r = insert_replacement(&fh, TAKE_PTR(c), flags, &inserted);
                         if (r < 0)
                                 return r;
index 444627b8d0410a5d6460638a323bfd248bbd95e8..fa460b9e914fb452384e811aa74584c97b0c5ba8 100644 (file)
@@ -18,11 +18,11 @@ typedef enum ConfFilesFlags {
 } ConfFilesFlags;
 
 typedef struct ConfFile {
-        char *name;          /* name of a file found in config directories */
-        char *result;        /* resolved config directory with the original file name found in the directory */
-        char *original_path; /* original config directory with the original file name found in the directory */
-        char *resolved_path; /* fully resolved path, where the filename part of the path may be different from the original name */
-        int fd;              /* O_PATH fd to resolved_path, -EBADF if the resolved_path does not exist */
+        char *filename;      /* filename of the discovered file (i.e. without any directory prefix) */
+        char *result;        /* full path to the file (with the directory prefix fully resolved, but the filename part left as is) */
+        char *original_path; /* full path to the file (original – non-resolved – directory prefix + filename part left as is) */
+        char *resolved_path; /* fully resolved path to the file with both directory prefix and filename fully resolved */
+        int fd;              /* O_PATH fd to resolved_path, -EBADF if resolved_path does not exist */
         struct stat st;      /* stat of the file. */
 } ConfFile;
 
index 6702358ccc6f26dd7e4207d2d2db807356a4f8c0..05163754af71debe6fc52cb0449805bdb5fc73d3 100644 (file)
@@ -1568,12 +1568,12 @@ static int verb_components(int argc, char **argv, void *userdata) {
         FOREACH_ARRAY(i, directories, n_directories) {
                 ConfFile *e = *i;
 
-                if (streq(e->name, "sysupdate.d")) {
+                if (streq(e->filename, "sysupdate.d")) {
                         has_default_component = true;
                         continue;
                 }
 
-                const char *s = startswith(e->name, "sysupdate.");
+                const char *s = startswith(e->filename, "sysupdate.");
                 if (!s)
                         continue;