Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755841Ab2JRLDW (ORCPT ); Thu, 18 Oct 2012 07:03:22 -0400 Received: from mga03.intel.com ([143.182.124.21]:42979 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755661Ab2JRLDU (ORCPT ); Thu, 18 Oct 2012 07:03:20 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,606,1344236400"; d="scan'208";a="157620800" 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 Subject: [PATCH v3 2/9] pstore: add debugfs support for causing dumps and panics Date: Thu, 18 Oct 2012 14:06:00 +0300 Message-Id: <1350558367-31801-3-git-send-email-dragos.tatulea@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350558367-31801-1-git-send-email-dragos.tatulea@intel.com> References: <1350558367-31801-1-git-send-email-dragos.tatulea@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2433 Lines: 100 From: Adrian Hunter There are 2 debugfs files: pstore/dump writing a kmsg dump reason code will cause a dump to persistent storage pstore/panic writing anything will cause a panic Signed-off-by: Adrian Hunter --- fs/pstore/platform.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index c4ea778..9d65723 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "internal.h" @@ -206,6 +207,54 @@ static int pstore_write_compat(enum pstore_type_id type, return psi->write_buf(type, reason, id, part, psinfo->buf, size, psi); } +#ifdef CONFIG_DEBUG_FS + +static DEFINE_SPINLOCK(dbg_lock); + +static int dbg_dump(void *data, u64 val) +{ + unsigned long flags; + + switch (val) { + case KMSG_DUMP_PANIC: + case KMSG_DUMP_OOPS: + case KMSG_DUMP_EMERG: + case KMSG_DUMP_RESTART: + case KMSG_DUMP_HALT: + case KMSG_DUMP_POWEROFF: + spin_lock_irqsave(&dbg_lock, flags); + kmsg_dump(val); + spin_unlock_irqrestore(&dbg_lock, flags); + return 0; + } + return -EINVAL; +} +DEFINE_SIMPLE_ATTRIBUTE(dbg_dump_fops, NULL, dbg_dump, "%llu\n"); + +static int dbg_panic(void *data, u64 val) +{ + panic(KERN_EMERG "pstore debugging panic!\n"); + return 0; +} +DEFINE_SIMPLE_ATTRIBUTE(dbg_panic_fops, NULL, dbg_panic, "%llu\n"); + +static void pstore_debugfs_init(void) +{ + struct dentry *root; + + root = debugfs_create_dir("pstore", NULL); + debugfs_create_file("dump", S_IWUSR, root, NULL, &dbg_dump_fops); + debugfs_create_file("panic", S_IWUSR, root, NULL, &dbg_panic_fops); +} + +#else + +static inline void pstore_debugfs_init(void) +{ +} + +#endif + /* * platform specific persistent storage driver registers with * us here. If pstore is already mounted, call the platform @@ -257,6 +306,8 @@ int pstore_register(struct pstore_info *psi) add_timer(&pstore_timer); } + pstore_debugfs_init(); + return 0; } EXPORT_SYMBOL_GPL(pstore_register); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/