From: dragos.tatulea@intel.com
To: ccross@android.com, keescook@chromium.org, tony.luck@intel.com,
cbouatmailru@gmail.com, linux-kernel@vger.kernel.org
Cc: adrian.hunter@intel.com, octavian.purdila@intel.com,
Dragos Tatulea <dragos.tatulea@intel.com>
Subject: [PATCH v2 4/8] pstore: allow storing different type id's in ram backend
Date: Thu, 18 Oct 2012 11:28:24 +0300 [thread overview]
Message-ID: <1350548908-24407-5-git-send-email-dragos.tatulea@intel.com> (raw)
In-Reply-To: <1350548908-24407-1-git-send-email-dragos.tatulea@intel.com>
From: Dragos Tatulea <dragos.tatulea@intel.com>
Added pstore_type_id in message header when storing to ram.
On write, take into account the contents of this header and
set the type accordingly.
Signed-off-by: Dragos Tatulea <dragos.tatulea@intel.com>
---
fs/pstore/ram.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 1a4f6da..e1684ef 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -157,23 +157,30 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
time->tv_nsec = 0;
size = persistent_ram_old_size(prz);
+ if (!size)
+ return 0;
*buf = kmalloc(size, GFP_KERNEL);
if (*buf == NULL)
return -ENOMEM;
memcpy(*buf, persistent_ram_old(prz), size);
+ /* Read header. */
+ sscanf(*buf, "%u" RAMOOPS_KERNMSG_HDR "%lu.%lu",
+ type, &time->tv_sec, &time->tv_nsec);
+ time->tv_nsec *= 1000;
return size;
}
-static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
+static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
+ enum pstore_type_id type)
{
char *hdr;
struct timeval timestamp;
size_t len;
do_gettimeofday(×tamp);
- hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu\n",
- (long)timestamp.tv_sec, (long)timestamp.tv_usec);
+ hdr = kasprintf(GFP_ATOMIC, "%u" RAMOOPS_KERNMSG_HDR "%lu.%lu\n",
+ type, (long)timestamp.tv_sec, (long)timestamp.tv_usec);
WARN_ON_ONCE(!hdr);
len = hdr ? strlen(hdr) : 0;
persistent_ram_write(prz, hdr, len);
@@ -204,9 +211,6 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
return 0;
}
- if (type != PSTORE_TYPE_DMESG)
- return -EINVAL;
-
/* Out of the various dmesg dump types, ramoops is currently designed
* to only store crash logs, rather than storing general kernel logs.
*/
@@ -226,7 +230,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
if (part != 1)
return -ENOSPC;
- hlen = ramoops_write_kmsg_hdr(prz);
+ hlen = ramoops_write_kmsg_hdr(prz, type);
if (size + hlen > prz->buffer_size)
size = prz->buffer_size - hlen;
persistent_ram_write(prz, buf, size);
--
1.7.9.5
next prev parent reply other threads:[~2012-10-18 8:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 8:28 [PATCH v2 0/8] pstore: add interface for dumpers and add task list dumper dragos.tatulea
2012-10-18 8:28 ` [PATCH v2 1/8] pstore: add flags dragos.tatulea
2012-10-18 8:28 ` [PATCH v2 2/8] pstore: add debugfs support for causing dumps and panics dragos.tatulea
2012-10-18 8:28 ` [PATCH v2 3/8] pstore: add support for external writers dragos.tatulea
2012-10-18 8:28 ` dragos.tatulea [this message]
2012-10-18 8:28 ` [PATCH v2 5/8] pstore: add task list dumper dragos.tatulea
2012-10-18 8:28 ` [PATCH v2 6/8] pstore: do not run timer while pstore is not mounted dragos.tatulea
2012-10-18 8:28 ` [PATCH v2 7/8] pstore: make sure pstore_write exists on flush error dragos.tatulea
2012-10-18 8:28 ` [PATCH v2 8/8] pstore: max out console log level during sysfs dump switch dragos.tatulea
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=1350548908-24407-5-git-send-email-dragos.tatulea@intel.com \
--to=dragos.tatulea@intel.com \
--cc=adrian.hunter@intel.com \
--cc=cbouatmailru@gmail.com \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=octavian.purdila@intel.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
all inboxes | Powered by JetHome®