|
|
6f381c |
From 5006e4bd9aecea40ca3d907adc692c4c8001a6c1 Mon Sep 17 00:00:00 2001
|
|
|
6f381c |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
6f381c |
Date: Mon, 22 Jul 2019 11:08:06 +0900
|
|
|
6f381c |
Subject: [PATCH] pstore: do not add FILE= journal entry if content_size == 0
|
|
|
6f381c |
|
|
|
6f381c |
(cherry picked from commit 6bf18debddbe1b231f783617e054cc194bb36d1e)
|
|
|
6f381c |
|
|
|
6f381c |
Related: #2158832
|
|
|
6f381c |
---
|
|
|
6f381c |
src/pstore/pstore.c | 25 ++++++++++++++-----------
|
|
|
6f381c |
1 file changed, 14 insertions(+), 11 deletions(-)
|
|
|
6f381c |
|
|
|
6f381c |
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
|
|
|
6f381c |
index ce8080ceed..eb251d61c8 100644
|
|
|
6f381c |
--- a/src/pstore/pstore.c
|
|
|
6f381c |
+++ b/src/pstore/pstore.c
|
|
|
6f381c |
@@ -114,10 +114,8 @@ static int compare_pstore_entries(const void *_a, const void *_b) {
|
|
|
6f381c |
|
|
|
6f381c |
static int move_file(PStoreEntry *pe, const char *subdir) {
|
|
|
6f381c |
_cleanup_free_ char *ifd_path = NULL, *ofd_path = NULL;
|
|
|
6f381c |
- _cleanup_free_ void *field = NULL;
|
|
|
6f381c |
+ const char *suffix, *message;
|
|
|
6f381c |
struct iovec iovec[2];
|
|
|
6f381c |
- const char *suffix;
|
|
|
6f381c |
- size_t field_size;
|
|
|
6f381c |
int n_iovec = 0, r;
|
|
|
6f381c |
|
|
|
6f381c |
if (pe->handled)
|
|
|
6f381c |
@@ -133,15 +131,20 @@ static int move_file(PStoreEntry *pe, const char *subdir) {
|
|
|
6f381c |
|
|
|
6f381c |
/* Always log to the journal */
|
|
|
6f381c |
suffix = arg_storage == PSTORE_STORAGE_EXTERNAL ? strjoina(" moved to ", ofd_path) : (char *)".";
|
|
|
6f381c |
- field = strjoina("MESSAGE=PStore ", pe->dirent.d_name, suffix);
|
|
|
6f381c |
- iovec[n_iovec++] = IOVEC_MAKE_STRING(field);
|
|
|
6f381c |
+ message = strjoina("MESSAGE=PStore ", pe->dirent.d_name, suffix);
|
|
|
6f381c |
+ iovec[n_iovec++] = IOVEC_MAKE_STRING(message);
|
|
|
6f381c |
|
|
|
6f381c |
- field_size = strlen("FILE=") + pe->content_size;
|
|
|
6f381c |
- field = malloc(field_size);
|
|
|
6f381c |
- if (!field)
|
|
|
6f381c |
- return log_oom();
|
|
|
6f381c |
- memcpy(stpcpy(field, "FILE="), pe->content, pe->content_size);
|
|
|
6f381c |
- iovec[n_iovec++] = IOVEC_MAKE(field, field_size);
|
|
|
6f381c |
+ if (pe->content_size > 0) {
|
|
|
6f381c |
+ _cleanup_free_ void *field = NULL;
|
|
|
6f381c |
+ size_t field_size;
|
|
|
6f381c |
+
|
|
|
6f381c |
+ field_size = strlen("FILE=") + pe->content_size;
|
|
|
6f381c |
+ field = malloc(field_size);
|
|
|
6f381c |
+ if (!field)
|
|
|
6f381c |
+ return log_oom();
|
|
|
6f381c |
+ memcpy(stpcpy(field, "FILE="), pe->content, pe->content_size);
|
|
|
6f381c |
+ iovec[n_iovec++] = IOVEC_MAKE(field, field_size);
|
|
|
6f381c |
+ }
|
|
|
6f381c |
|
|
|
6f381c |
r = sd_journal_sendv(iovec, n_iovec);
|
|
|
6f381c |
if (r < 0)
|