Skip to content

Commit

Permalink
pstore: Pass header size in the pstore write callback
Browse files Browse the repository at this point in the history
Header size is needed to distinguish between header and the dump data.
Incorporate the addition of new argument (hsize) in the pstore write
callback.

Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Aruna Balakrishnaiah authored and Benjamin Herrenschmidt committed Jul 1, 2013
1 parent 74251fe commit 6bbbca7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
4 changes: 3 additions & 1 deletion arch/powerpc/platforms/pseries/nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ static int nvram_pstore_open(struct pstore_info *psi)
* @part: pstore writes data to registered buffer in parts,
* part number will indicate the same.
* @count: Indicates oops count
* @hsize: Size of header added by pstore
* @size: number of bytes written to the registered buffer
* @psi: registered pstore_info structure
*
Expand All @@ -512,7 +513,8 @@ static int nvram_pstore_open(struct pstore_info *psi)
static int nvram_pstore_write(enum pstore_type_id type,
enum kmsg_dump_reason reason,
u64 *id, unsigned int part, int count,
size_t size, struct pstore_info *psi)
size_t hsize, size_t size,
struct pstore_info *psi)
{
int rc;
struct oops_log_info *oops_hdr = (struct oops_log_info *) oops_buf;
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/apei/erst.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,
struct timespec *time, char **buf,
struct pstore_info *psi);
static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
u64 *id, unsigned int part, int count,
u64 *id, unsigned int part, int count, size_t hsize,
size_t size, struct pstore_info *psi);
static int erst_clearer(enum pstore_type_id type, u64 id, int count,
struct timespec time, struct pstore_info *psi);
Expand Down Expand Up @@ -1055,7 +1055,7 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,
}

static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
u64 *id, unsigned int part, int count,
u64 *id, unsigned int part, int count, size_t hsize,
size_t size, struct pstore_info *psi)
{
struct cper_pstore_record *rcd = (struct cper_pstore_record *)
Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/efi/efi-pstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,

static int efi_pstore_write(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id,
unsigned int part, int count, size_t size,
unsigned int part, int count, size_t hsize, size_t size,
struct pstore_info *psi)
{
char name[DUMP_NAME_LEN];
Expand Down
10 changes: 6 additions & 4 deletions fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
break;

ret = psinfo->write(PSTORE_TYPE_DMESG, reason, &id, part,
oopscount, hsize + len, psinfo);
oopscount, hsize, hsize + len, psinfo);
if (ret == 0 && reason == KMSG_DUMP_OOPS && pstore_is_mounted())
pstore_new_entry = 1;

Expand Down Expand Up @@ -196,7 +196,7 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
spin_lock_irqsave(&psinfo->buf_lock, flags);
}
memcpy(psinfo->buf, s, c);
psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, 0, c, psinfo);
psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, 0, 0, c, psinfo);
spin_unlock_irqrestore(&psinfo->buf_lock, flags);
s += c;
c = e - s;
Expand All @@ -221,9 +221,11 @@ static void pstore_register_console(void) {}
static int pstore_write_compat(enum pstore_type_id type,
enum kmsg_dump_reason reason,
u64 *id, unsigned int part, int count,
size_t size, struct pstore_info *psi)
size_t hsize, size_t size,
struct pstore_info *psi)
{
return psi->write_buf(type, reason, id, part, psinfo->buf, size, psi);
return psi->write_buf(type, reason, id, part, psinfo->buf, hsize,
size, psi);
}

/*
Expand Down
3 changes: 2 additions & 1 deletion fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
enum kmsg_dump_reason reason,
u64 *id, unsigned int part,
const char *buf, size_t size,
const char *buf,
size_t hsize, size_t size,
struct pstore_info *psi)
{
struct ramoops_context *cxt = psi->data;
Expand Down
8 changes: 4 additions & 4 deletions include/linux/pstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ struct pstore_info {
struct pstore_info *psi);
int (*write)(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id,
unsigned int part, int count, size_t size,
struct pstore_info *psi);
unsigned int part, int count, size_t hsize,
size_t size, struct pstore_info *psi);
int (*write_buf)(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id,
unsigned int part, const char *buf, size_t size,
struct pstore_info *psi);
unsigned int part, const char *buf, size_t hsize,
size_t size, struct pstore_info *psi);
int (*erase)(enum pstore_type_id type, u64 id,
int count, struct timespec time,
struct pstore_info *psi);
Expand Down

0 comments on commit 6bbbca7

Please sign in to comment.