diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2008-07-26 04:22:45 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-10-18 06:51:27 -0400 |
commit | f0482ee3669a78bdb1e15b9f9c58a9f1ffc5a997 (patch) | |
tree | cfc14aa482e58f7047f95610f1fb5cb8a705dba7 | |
parent | ecd5b3102322011610a2521c389ab5804c811837 (diff) |
[MTD] mtdoops: Add a magic number to logged kernel oops
Add a magic number to logged kernel oops messages so that they
can be more accurately detected rather than just having to rely
on the sequence number. This also allows easier detection of
saved crashes by userspace.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/mtdoops.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index f40e45727aed..6f6b2f3c70df 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |
34 | #include <linux/mtd/mtd.h> | 34 | #include <linux/mtd/mtd.h> |
35 | 35 | ||
36 | #define MTDOOPS_KERNMSG_MAGIC 0x5d005d00 | ||
36 | #define OOPS_PAGE_SIZE 4096 | 37 | #define OOPS_PAGE_SIZE 4096 |
37 | 38 | ||
38 | static struct mtdoops_context { | 39 | static struct mtdoops_context { |
@@ -224,31 +225,33 @@ static void find_next_position(struct mtdoops_context *cxt) | |||
224 | { | 225 | { |
225 | struct mtd_info *mtd = cxt->mtd; | 226 | struct mtd_info *mtd = cxt->mtd; |
226 | int ret, page, maxpos = 0; | 227 | int ret, page, maxpos = 0; |
227 | u32 count, maxcount = 0xffffffff; | 228 | u32 count[2], maxcount = 0xffffffff; |
228 | size_t retlen; | 229 | size_t retlen; |
229 | 230 | ||
230 | for (page = 0; page < cxt->oops_pages; page++) { | 231 | for (page = 0; page < cxt->oops_pages; page++) { |
231 | ret = mtd->read(mtd, page * OOPS_PAGE_SIZE, 4, &retlen, (u_char *) &count); | 232 | ret = mtd->read(mtd, page * OOPS_PAGE_SIZE, 8, &retlen, (u_char *) &count[0]); |
232 | if ((retlen != 4) || ((ret < 0) && (ret != -EUCLEAN))) { | 233 | if ((retlen != 8) || ((ret < 0) && (ret != -EUCLEAN))) { |
233 | printk(KERN_ERR "mtdoops: Read failure at %d (%td of 4 read)" | 234 | printk(KERN_ERR "mtdoops: Read failure at %d (%td of 8 read)" |
234 | ", err %d.\n", page * OOPS_PAGE_SIZE, retlen, ret); | 235 | ", err %d.\n", page * OOPS_PAGE_SIZE, retlen, ret); |
235 | continue; | 236 | continue; |
236 | } | 237 | } |
237 | 238 | ||
238 | if (count == 0xffffffff) | 239 | if (count[1] != MTDOOPS_KERNMSG_MAGIC) |
240 | continue; | ||
241 | if (count[0] == 0xffffffff) | ||
239 | continue; | 242 | continue; |
240 | if (maxcount == 0xffffffff) { | 243 | if (maxcount == 0xffffffff) { |
241 | maxcount = count; | 244 | maxcount = count[0]; |
242 | maxpos = page; | 245 | maxpos = page; |
243 | } else if ((count < 0x40000000) && (maxcount > 0xc0000000)) { | 246 | } else if ((count[0] < 0x40000000) && (maxcount > 0xc0000000)) { |
244 | maxcount = count; | 247 | maxcount = count[0]; |
245 | maxpos = page; | 248 | maxpos = page; |
246 | } else if ((count > maxcount) && (count < 0xc0000000)) { | 249 | } else if ((count[0] > maxcount) && (count[0] < 0xc0000000)) { |
247 | maxcount = count; | 250 | maxcount = count[0]; |
248 | maxpos = page; | 251 | maxpos = page; |
249 | } else if ((count > maxcount) && (count > 0xc0000000) | 252 | } else if ((count[0] > maxcount) && (count[0] > 0xc0000000) |
250 | && (maxcount > 0x80000000)) { | 253 | && (maxcount > 0x80000000)) { |
251 | maxcount = count; | 254 | maxcount = count[0]; |
252 | maxpos = page; | 255 | maxpos = page; |
253 | } | 256 | } |
254 | } | 257 | } |
@@ -358,8 +361,9 @@ mtdoops_console_write(struct console *co, const char *s, unsigned int count) | |||
358 | 361 | ||
359 | if (cxt->writecount == 0) { | 362 | if (cxt->writecount == 0) { |
360 | u32 *stamp = cxt->oops_buf; | 363 | u32 *stamp = cxt->oops_buf; |
361 | *stamp = cxt->nextcount; | 364 | *stamp++ = cxt->nextcount; |
362 | cxt->writecount = 4; | 365 | *stamp = MTDOOPS_KERNMSG_MAGIC; |
366 | cxt->writecount = 8; | ||
363 | } | 367 | } |
364 | 368 | ||
365 | if ((count + cxt->writecount) > OOPS_PAGE_SIZE) | 369 | if ((count + cxt->writecount) > OOPS_PAGE_SIZE) |