mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Borleis <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Kees Cook <keescook@chromium.org>
Subject: [PATCH 10/15] pstore: Switch pstore_mkfile to pass record
Date: Fri, 15 Mar 2019 10:14:48 +0100	[thread overview]
Message-ID: <20190315091453.22393-10-jbe@pengutronix.de> (raw)
In-Reply-To: <20190315091453.22393-1-jbe@pengutronix.de>

From: Kees Cook <keescook@chromium.org>

Instead of the long list of arguments, just pass the new record struct.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 fs/pstore/fs.c       | 45 ++++++++++++++++++++++++---------------------
 fs/pstore/internal.h |  4 +---
 fs/pstore/platform.c |  6 +-----
 3 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index 9a7e0b5526..e9c7ae7adb 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -52,68 +52,71 @@ struct pstore_private {
  * Load it up with "size" bytes of data from "buf".
  * Set the mtime & ctime to the date that this record was originally stored.
  */
-int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
-		  char *data, bool compressed, size_t size,
-		  struct pstore_info *psi)
+int pstore_mkfile(struct pstore_record *record)
 {
 	struct pstore_private	*private, *pos;
+	size_t			size = record->size;
 
 	list_for_each_entry(pos, &allpstore, list) {
-		if (pos->type == type && pos->id == id && pos->psi == psi)
+		if (pos->type == record->type &&
+		    pos->id == record->id &&
+		    pos->psi == record->psi)
 			return -EEXIST;
 	}
 
 	private = xzalloc(sizeof(*private) + size);
-	private->type = type;
-	private->id = id;
-	private->count = count;
-	private->psi = psi;
+	private->type = record->type;
+	private->id = record->id;
+	private->count = record->count;
+	private->psi = record->psi;
 
-	switch (type) {
+	switch (record->type) {
 	case PSTORE_TYPE_DMESG:
 		scnprintf(private->name, sizeof(private->name),
-			  "dmesg-%s-%lld%s", psname, id,
-			  compressed ? ".enc.z" : "");
+			  "dmesg-%s-%lld%s", record->psi->name, record->id,
+			  record->compressed ? ".enc.z" : "");
 		break;
 	case PSTORE_TYPE_CONSOLE:
 		scnprintf(private->name, sizeof(private->name),
-			  "console-%s-%lld", psname, id);
+			  "console-%s-%lld", record->psi->name, record->id);
 		break;
 	case PSTORE_TYPE_FTRACE:
 		scnprintf(private->name, sizeof(private->name),
-			  "ftrace-%s-%lld", psname, id);
+			  "ftrace-%s-%lld", record->psi->name, record->id);
 		break;
 	case PSTORE_TYPE_MCE:
 		scnprintf(private->name, sizeof(private->name),
-			  "mce-%s-%lld", psname, id);
+			  "mce-%s-%lld", record->psi->name, record->id);
 		break;
 	case PSTORE_TYPE_PPC_RTAS:
 		scnprintf(private->name, sizeof(private->name),
-			  "rtas-%s-%lld", psname, id);
+			  "rtas-%s-%lld", record->psi->name, record->id);
 		break;
 	case PSTORE_TYPE_PPC_OF:
 		scnprintf(private->name, sizeof(private->name),
-			  "powerpc-ofw-%s-%lld", psname, id);
+			  "powerpc-ofw-%s-%lld", record->psi->name, record->id);
 		break;
 	case PSTORE_TYPE_PPC_COMMON:
 		scnprintf(private->name, sizeof(private->name),
-			  "powerpc-common-%s-%lld", psname, id);
+			  "powerpc-common-%s-%lld", record->psi->name,
+			  record->id);
 		break;
 	case PSTORE_TYPE_PMSG:
 		scnprintf(private->name, sizeof(private->name),
-			  "pmsg-%s-%lld", psname, id);
+			  "pmsg-%s-%lld", record->psi->name, record->id);
 		break;
 	case PSTORE_TYPE_UNKNOWN:
 		scnprintf(private->name, sizeof(private->name),
-			  "unknown-%s-%lld", psname, id);
+			  "unknown-%s-%lld", record->psi->name, record->id);
 		break;
 	default:
 		scnprintf(private->name, sizeof(private->name),
-			  "type%d-%s-%lld", type, psname, id);
+			  "type%d-%s-%lld", record->type, record->psi->name,
+			  record->id);
 		break;
 	}
 
-	memcpy(private->data, data, size);
+	memcpy(private->data, record->buf, size);
 	private->size = size;
 
 	list_add(&private->list, &allpstore);
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index 0a8df1f4e2..6b507e4bd3 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -11,9 +11,7 @@ extern struct pstore_info *psinfo;
 
 extern void	pstore_set_kmsg_bytes(int);
 extern void	pstore_get_records(int);
-extern int	pstore_mkfile(enum pstore_type_id, char *psname, u64 id,
-			      int count, char *data, bool compressed,
-			      size_t size, struct pstore_info *psi);
+extern int	pstore_mkfile(struct pstore_record *record);
 extern int	pstore_is_mounted(void);
 
 #endif
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 5d0018693b..bad735e574 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -190,11 +190,7 @@ void pstore_get_records(int quiet)
 			pr_err("barebox does not have ramoops compression support\n");
 			continue;
 		}
-		rc = pstore_mkfile(record.type, psi->name, record.id,
-				   record.count, record.buf,
-				   record.compressed,
-				   record.size,
-				   record.psi);
+		rc = pstore_mkfile(&record);
 		if (unzipped_len < 0) {
 			/* Free buffer other than big oops */
 			kfree(record.buf);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-03-15  9:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-15  9:14 [PATCH 01/15] ramoops: probe from device tree if OFTREE is enabled Juergen Borleis
2019-03-15  9:14 ` [PATCH 02/15] pstore/ram: add Device Tree bindings Juergen Borleis
2019-03-15  9:14 ` [PATCH 03/15] ramoops: use DT reserved-memory bindings Juergen Borleis
2019-03-15  9:14 ` [PATCH 04/15] pstore: Make ramoops_init_przs generic for other prz arrays Juergen Borleis
2019-03-15  9:14 ` [PATCH 05/15] pstore/ram: Do not use stack VLA for parity workspace Juergen Borleis
2019-03-15  9:14 ` [PATCH 06/15] pstore: improve error report for failed setup Juergen Borleis
2019-03-15  9:14 ` [PATCH 07/15] pstore/ram: Clarify resource reservation labels Juergen Borleis
2019-03-15  9:14 ` [PATCH 08/15] pstore: Extract common arguments into structure Juergen Borleis
2019-03-15  9:14 ` [PATCH 09/15] pstore: add console support Juergen Borleis
2019-03-15  9:14 ` Juergen Borleis [this message]
2019-03-15  9:14 ` [PATCH 11/15] pstore: Replace arguments for read() API Juergen Borleis
2019-03-15  9:14 ` [PATCH 12/15] pstore: Replace arguments for write() API Juergen Borleis
2019-03-15  9:14 ` [PATCH 13/15] pstore: pass ramoops configuration to kernel via device tree Juergen Borleis
2019-03-15  9:14 ` [PATCH 14/15] pstore: ramoops: allow zapping invalid buffers in read-only mode Juergen Borleis
2019-03-15  9:14 ` [PATCH 15/15] pstore/doc: fix layout Juergen Borleis
2019-03-18  8:44 ` [PATCH 01/15] ramoops: probe from device tree if OFTREE is enabled Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190315091453.22393-10-jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=keescook@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox