linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
To: linuxppc-dev@ozlabs.org, tony.luck@intel.com,
	linux-kernel@vger.kernel.org, keescook@chromium.org
Cc: jkenisto@linux.vnet.ibm.com, cbouatmailru@gmail.com,
	mahesh@linux.vnet.ibm.com, ccross@android.com
Subject: [RFC PATCH v2 10/11] efi-pstore: Read and write to the 'compressed' flag of pstore
Date: Fri, 16 Aug 2013 18:48:57 +0530	[thread overview]
Message-ID: <20130816131857.3338.26295.stgit@aruna-ThinkPad-T420> (raw)
In-Reply-To: <20130816131403.3338.82330.stgit@aruna-ThinkPad-T420>

In pstore write, Efi will add a character 'C'(compressed) or
D'(decompressed) in its header while writing to persistent store.
In pstore read, read the header and update the 'compressed' flag
accordingly.

Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
---
 drivers/firmware/efi/efi-pstore.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 9a5425f..5002d50 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -35,6 +35,7 @@ struct pstore_read_data {
 	enum pstore_type_id *type;
 	int *count;
 	struct timespec *timespec;
+	bool *compressed;
 	char **buf;
 };
 
@@ -42,7 +43,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 {
 	efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
 	struct pstore_read_data *cb_data = data;
-	char name[DUMP_NAME_LEN];
+	char name[DUMP_NAME_LEN], data_type;
 	int i;
 	int cnt;
 	unsigned int part;
@@ -54,12 +55,23 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 	for (i = 0; i < DUMP_NAME_LEN; i++)
 		name[i] = entry->var.VariableName[i];
 
-	if (sscanf(name, "dump-type%u-%u-%d-%lu",
+	if (sscanf(name, "dump-type%u-%u-%d-%lu-%c",
+		   cb_data->type, &part, &cnt, &time, &data_type) == 5) {
+		*cb_data->id = part;
+		*cb_data->count = cnt;
+		cb_data->timespec->tv_sec = time;
+		cb_data->timespec->tv_nsec = 0;
+		if (data_type == 'C')
+			*cb_data->compressed = true;
+		else
+			*cb_data->compressed = false;
+	} else if (sscanf(name, "dump-type%u-%u-%d-%lu",
 		   cb_data->type, &part, &cnt, &time) == 4) {
 		*cb_data->id = part;
 		*cb_data->count = cnt;
 		cb_data->timespec->tv_sec = time;
 		cb_data->timespec->tv_nsec = 0;
+		*cb_data->compressed = false;
 	} else if (sscanf(name, "dump-type%u-%u-%lu",
 			  cb_data->type, &part, &time) == 3) {
 		/*
@@ -71,6 +83,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 		*cb_data->count = 0;
 		cb_data->timespec->tv_sec = time;
 		cb_data->timespec->tv_nsec = 0;
+		*cb_data->compressed = false;
 	} else
 		return 0;
 
@@ -96,6 +109,7 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
 	data.type = type;
 	data.count = count;
 	data.timespec = timespec;
+	data.compressed = compressed;
 	data.buf = buf;
 
 	return __efivar_entry_iter(efi_pstore_read_func, &efivar_sysfs_list, &data,
@@ -112,8 +126,8 @@ static int efi_pstore_write(enum pstore_type_id type,
 	efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
 	int i, ret = 0;
 
-	sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count,
-		get_seconds());
+	sprintf(name, "dump-type%u-%u-%d-%lu-%c", type, part, count,
+		get_seconds(), compressed ? 'C' : 'D');
 
 	for (i = 0; i < DUMP_NAME_LEN; i++)
 		efi_name[i] = name[i];

  parent reply	other threads:[~2013-08-16 13:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16 13:17 [RFC PATCH v2 00/11] Add (de)compression support to pstore Aruna Balakrishnaiah
2013-08-16 13:17 ` [RFC PATCH v2 01/11] powerpc/pseries: Remove (de)compression in nvram with pstore enabled Aruna Balakrishnaiah
2013-08-16 13:17 ` [RFC PATCH v2 02/11] pstore: Add new argument 'compressed' in pstore write callback Aruna Balakrishnaiah
2013-08-16 13:17 ` [RFC PATCH v2 03/11] pstore/Kconfig: Select ZLIB_DEFLATE and ZLIB_INFLATE when PSTORE is selected Aruna Balakrishnaiah
2013-08-16 13:18 ` [RFC PATCH v2 04/11] pstore: Add compression support to pstore Aruna Balakrishnaiah
2013-08-22 23:07   ` Seiji Aguchi
2013-08-22 23:17     ` Luck, Tony
2013-08-22 23:47       ` Seiji Aguchi
2013-08-27  5:19       ` Aruna Balakrishnaiah
2013-09-04  1:44         ` Seiji Aguchi
2013-09-04  6:01           ` Aruna Balakrishnaiah
2013-09-04 16:11             ` Luck, Tony
2013-09-04 16:39               ` Seiji Aguchi
2013-08-16 13:18 ` [RFC PATCH v2 05/11] pstore: Introduce new argument 'compressed' in the read callback Aruna Balakrishnaiah
2013-08-16 13:18 ` [RFC PATCH v2 06/11] pstore: Add decompression support to pstore Aruna Balakrishnaiah
2013-08-22 23:04   ` Seiji Aguchi
2013-08-27  9:39     ` Aruna Balakrishnaiah
2013-08-16 13:18 ` [RFC PATCH v2 07/11] pstore: Add file extension to pstore file if compressed Aruna Balakrishnaiah
2013-08-16 13:18 ` [RFC PATCH v2 08/11] powerpc/pseries: Read and write to the 'compressed' flag of pstore Aruna Balakrishnaiah
2013-08-16 13:18 ` [RFC PATCH v2 09/11] erst: " Aruna Balakrishnaiah
2013-08-16 13:18 ` Aruna Balakrishnaiah [this message]
2013-08-16 13:19 ` [RFC PATCH v2 11/11] pstore/ram: " Aruna Balakrishnaiah
2013-08-17 18:26   ` Kees Cook
2013-08-16 22:15 ` [RFC PATCH v2 00/11] Add (de)compression support to pstore Luck, Tony
2013-08-17 18:32   ` Kees Cook
2013-08-19 17:29     ` Tony Luck

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=20130816131857.3338.26295.stgit@aruna-ThinkPad-T420 \
    --to=aruna@linux.vnet.ibm.com \
    --cc=cbouatmailru@gmail.com \
    --cc=ccross@android.com \
    --cc=jkenisto@linux.vnet.ibm.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=tony.luck@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).