From: Lennart Poettering Date: Wed, 6 Mar 2019 10:40:31 +0000 (+0100) Subject: catalog: let's use mkdir_parents() and use same mode as tmpfiles.d for this dir X-Git-Tag: v242-rc1~181^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f1e2714a44d77493cf5d0d961d150ef6d3c2323;p=thirdparty%2Fsystemd.git catalog: let's use mkdir_parents() and use same mode as tmpfiles.d for this dir let's use mkdir_parents() (because its shorter), and 0755 as access mode, so that things have the access mode tmpfiles.d also suggests. Prompted by: #11903 --- diff --git a/src/journal/catalog.c b/src/journal/catalog.c index 5176b6013dd..efe86bdef44 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -371,21 +371,21 @@ int catalog_import_file(Hashmap *h, const char *path) { return 0; } -static int64_t write_catalog(const char *database, struct strbuf *sb, - CatalogItem *items, size_t n) { - CatalogHeader header; +static int64_t write_catalog( + const char *database, + struct strbuf *sb, + CatalogItem *items, + size_t n) { + _cleanup_fclose_ FILE *w = NULL; - int r; - _cleanup_free_ char *d, *p = NULL; + _cleanup_free_ char *p = NULL; + CatalogHeader header; size_t k; + int r; - d = dirname_malloc(database); - if (!d) - return log_oom(); - - r = mkdir_p(d, 0775); + r = mkdir_parents(database, 0755); if (r < 0) - return log_error_errno(r, "Recursive mkdir %s: %m", d); + return log_error_errno(r, "Failed to create parent directories of %s: %m", database); r = fopen_temporary(database, &w, &p); if (r < 0)