linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Let modules register for panics, kernel 2.4.6-pre3
@ 2001-06-14 18:24 Pat O'Rourke
  0 siblings, 0 replies; only message in thread
From: Pat O'Rourke @ 2001-06-14 18:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: torvalds

The patch below permits a loadable module / driver to add itself to
the panic_notifier_list.  Previously only code compiled directly into
the kernel was able to register for panic notification.

Thanks,

Pat

--
Patrick O'Rourke
orourke@missioncriticallinux.com

diff -u --new-file --recursive linux-2.4.6-pre3-orig/include/linux/kernel.h linux-2.4.6-pre3/include/linux/kernel.h
--- linux-2.4.6-pre3-orig/include/linux/kernel.h	Thu Jun 14 11:38:25 2001
+++ linux-2.4.6-pre3/include/linux/kernel.h	Thu Jun 14 11:50:21 2001
@@ -48,6 +48,8 @@
 struct semaphore;
 
 extern struct notifier_block *panic_notifier_list;
+extern int register_panic_notifier(struct notifier_block *);
+extern int unregister_panic_notifier(struct notifier_block *);
 NORET_TYPE void panic(const char * fmt, ...)
 	__attribute__ ((NORET_AND format (printf, 1, 2)));
 NORET_TYPE void do_exit(long error_code)
diff -u --new-file --recursive linux-2.4.6-pre3-orig/kernel/ksyms.c linux-2.4.6-pre3/kernel/ksyms.c
--- linux-2.4.6-pre3-orig/kernel/ksyms.c	Thu Jun 14 11:38:26 2001
+++ linux-2.4.6-pre3/kernel/ksyms.c	Thu Jun 14 11:41:18 2001
@@ -468,6 +468,8 @@
 EXPORT_SYMBOL(cap_bset);
 EXPORT_SYMBOL(daemonize);
 EXPORT_SYMBOL(csum_partial); /* for networking and md */
+EXPORT_SYMBOL(register_panic_notifier);
+EXPORT_SYMBOL(unregister_panic_notifier);
 
 /* Program loader interfaces */
 EXPORT_SYMBOL(setup_arg_pages);
diff -u --new-file --recursive linux-2.4.6-pre3-orig/kernel/panic.c linux-2.4.6-pre3/kernel/panic.c
--- linux-2.4.6-pre3-orig/kernel/panic.c	Mon Oct 16 15:58:51 2000
+++ linux-2.4.6-pre3/kernel/panic.c	Thu Jun 14 13:05:00 2001
@@ -101,3 +101,33 @@
 		CHECK_EMERGENCY_SYNC
 	}
 }
+
+/**
+ *	register_panic_notifier - Register a function to be called on panic
+ *	@nb: Info about notifier function to be called
+ *
+ *	Registers a function with the list of functions to be called at
+ *	the time of a system panic.
+ *
+ *	Currently always returns zero, as notifier_chain_register
+ *	always returns zero.
+ */
+
+int register_panic_notifier(struct notifier_block *nb)
+{
+	return notifier_chain_register(&panic_notifier_list, nb);
+}
+
+/**
+ *	unregister_panic_notifier - Unregister a panic notifier
+ *	@nb:	Hook to be unregistered
+ *
+ *	Unregisters a previously registered panic notifier function.
+ *
+ *	Returns zero on success, or %-ENOENT on failure.
+ */
+
+int unregister_panic_notifier(struct notifier_block *nb)
+{
+	return notifier_chain_unregister(&panic_notifier_list, nb);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-06-14 18:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-14 18:24 [PATCH] Let modules register for panics, kernel 2.4.6-pre3 Pat O'Rourke

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).