index_close(node);
}
-void index_dump(struct index_file *in, int fd, const char *prefix)
+void index_dump(struct index_file *in, int fd, bool alias_prefix)
{
struct index_node_f *root;
struct strbuf buf;
return;
strbuf_init(&buf);
- if (prefix[0] == '\0' || strbuf_pushchars(&buf, prefix))
+ if (!alias_prefix || strbuf_pushchars(&buf, "alias "))
index_dump_node(root, &buf, fd);
strbuf_release(&buf);
}
strbuf_popchars(buf, pushed);
}
-void index_mm_dump(struct index_mm *idx, int fd, const char *prefix)
+void index_mm_dump(struct index_mm *idx, int fd, bool alias_prefix)
{
struct index_mm_node nbuf, *root;
struct strbuf buf;
return;
strbuf_init(&buf);
- if (prefix[0] == '\0' || strbuf_pushchars(&buf, prefix))
+ if (!alias_prefix || strbuf_pushchars(&buf, "alias "))
index_mm_dump_node(root, &buf, fd);
strbuf_release(&buf);
}
struct index_file *index_file_open(const char *filename);
void index_file_close(struct index_file *idx);
char *index_search(struct index_file *idx, const char *key);
-void index_dump(struct index_file *in, int fd, const char *prefix);
+void index_dump(struct index_file *in, int fd, bool alias_prefix);
struct index_value *index_searchwild(struct index_file *idx, const char *key);
void index_values_free(struct index_value *values);
void index_mm_close(struct index_mm *index);
char *index_mm_search(struct index_mm *idx, const char *key);
struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
-void index_mm_dump(struct index_mm *idx, int fd, const char *prefix);
+void index_mm_dump(struct index_mm *idx, int fd, bool alias_prefix);
static const struct {
const char *fn;
- const char *prefix;
+ bool alias_prefix;
} index_files[] = {
// clang-format off
- [KMOD_INDEX_MODULES_DEP] = { .fn = "modules.dep", .prefix = "" },
- [KMOD_INDEX_MODULES_ALIAS] = { .fn = "modules.alias", .prefix = "alias " },
- [KMOD_INDEX_MODULES_SYMBOL] = { .fn = "modules.symbols", .prefix = "alias " },
- [KMOD_INDEX_MODULES_BUILTIN_ALIAS] = { .fn = "modules.builtin.alias", .prefix = "" },
- [KMOD_INDEX_MODULES_BUILTIN] = { .fn = "modules.builtin", .prefix = "" },
+ [KMOD_INDEX_MODULES_DEP] = { .fn = "modules.dep" },
+ [KMOD_INDEX_MODULES_ALIAS] = { .fn = "modules.alias", .alias_prefix = true },
+ [KMOD_INDEX_MODULES_SYMBOL] = { .fn = "modules.symbols", .alias_prefix = true },
+ [KMOD_INDEX_MODULES_BUILTIN_ALIAS] = { .fn = "modules.builtin.alias" },
+ [KMOD_INDEX_MODULES_BUILTIN] = { .fn = "modules.builtin" },
// clang-format on
};
if (ctx->indexes[type] != NULL) {
DBG(ctx, "use mmapped index '%s'\n", index_files[type].fn);
- index_mm_dump(ctx->indexes[type], fd, index_files[type].prefix);
+ index_mm_dump(ctx->indexes[type], fd, index_files[type].alias_prefix);
} else {
char fn[PATH_MAX];
struct index_file *idx;
if (idx == NULL)
return -ENOSYS;
- index_dump(idx, fd, index_files[type].prefix);
+ index_dump(idx, fd, index_files[type].alias_prefix);
index_file_close(idx);
}