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