summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2019-03-15 10:14:48 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-18 09:43:35 +0100
commitac960f1d6e51d7462e4f36a37ef4bc9e7f6db904 (patch)
treef3be892b54e62ba3a0f5f52df40bd89c35cb50c2 /fs
parent6906ffb57888c99024f4ff2257c2fd2e50058240 (diff)
downloadbarebox-ac960f1d6e51d7462e4f36a37ef4bc9e7f6db904.tar.gz
pstore: Switch pstore_mkfile to pass record
Instead of the long list of arguments, just pass the new record struct. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/fs.c45
-rw-r--r--fs/pstore/internal.h4
-rw-r--r--fs/pstore/platform.c6
3 files changed, 26 insertions, 29 deletions
diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index 9a7e0b5..e9c7ae7 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 0a8df1f..6b507e4 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 5d00186..bad735e 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);