|
|
887953 |
From 1e1bda15377a133e9a91e6f99d13e02bf4469269 Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Amar Tumballi <amarts@redhat.com>
|
|
|
887953 |
Date: Thu, 7 Feb 2019 13:57:21 +0530
|
|
|
887953 |
Subject: [PATCH 518/529] logging: create parent dir if not available
|
|
|
887953 |
|
|
|
887953 |
As glusterfs logging uses different directory than /var/log
|
|
|
887953 |
(ie, /var/log/glusterfs), there is a chance it may not be
|
|
|
887953 |
present when starting glusterfs. Create parent dir if it
|
|
|
887953 |
doesn't exist.
|
|
|
887953 |
|
|
|
887953 |
Upstream fix:
|
|
|
887953 |
>> URL: https://review.gluster.org/21536
|
|
|
887953 |
|
|
|
887953 |
BUG: 1570958
|
|
|
887953 |
Change-Id: I6efaffd1e7e8aee350afcf2ca354b27747ff5e50
|
|
|
887953 |
Signed-off-by: Amar Tumballi <amarts@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/162470
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
libglusterfs/src/logging.c | 20 ++++++++++++++++++++
|
|
|
887953 |
1 file changed, 20 insertions(+)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
|
|
|
887953 |
index 0f238d0..631bc98 100644
|
|
|
887953 |
--- a/libglusterfs/src/logging.c
|
|
|
887953 |
+++ b/libglusterfs/src/logging.c
|
|
|
887953 |
@@ -758,6 +758,26 @@ gf_log_init (void *data, const char *file, const char *ident)
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
+ /* Also create parent dir */
|
|
|
887953 |
+ char *logdir = gf_strdup(file);
|
|
|
887953 |
+ if (!logdir) {
|
|
|
887953 |
+ return -1;
|
|
|
887953 |
+ }
|
|
|
887953 |
+ char *tmp_index = rindex(logdir, '/');
|
|
|
887953 |
+ if (tmp_index) {
|
|
|
887953 |
+ tmp_index[0] = '\0';
|
|
|
887953 |
+ }
|
|
|
887953 |
+ if (mkdir_p(logdir, 0755, _gf_true)) {
|
|
|
887953 |
+ /* EEXIST is handled in mkdir_p() itself */
|
|
|
887953 |
+ gf_msg("logging", GF_LOG_ERROR, 0, LG_MSG_STRDUP_ERROR,
|
|
|
887953 |
+ "failed to create metrics dir %s (%s)", logdir,
|
|
|
887953 |
+ strerror(errno));
|
|
|
887953 |
+ GF_FREE(logdir);
|
|
|
887953 |
+ return -1;
|
|
|
887953 |
+ }
|
|
|
887953 |
+ /* no need of this variable */
|
|
|
887953 |
+ GF_FREE(logdir);
|
|
|
887953 |
+
|
|
|
887953 |
ctx->log.filename = gf_strdup (file);
|
|
|
887953 |
if (!ctx->log.filename) {
|
|
|
887953 |
fprintf (stderr, "ERROR: updating log-filename failed: %s\n",
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|