Hi, I have some units installed remotely and I want to be prevented to be informed if they are doing the auto reboot because a kernel panic (It have happened before)

I have make a Kernel module which writes KERNEL PANIC in a file of the filesystem. It has worked in a precompiled kernel and filesystem during a forced kernel panic but not working today when I tried to applied it.

Here is my driver code, the panic event is received correctly (debugged with printk), and the write file functions works (tested calling the function from load function)
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/notifier.h>
#include <linux/module.h>
#include <linux/syscalls.h>

#include <linux/fs.h>
#include <linux/fcntl.h>
#include <asm/uaccess.h>

#include <linux/file.h>

char buf[100];
int i;
int count;
struct file *phMscd_Filp = NULL;
mm_segment_t old_fs;

// ****************************************************************************
// Here is where i receive the panic notification (from panic.c)
// ****************************************************************************
static int panic_happened(struct notifier_block *n, unsigned long val, void *message)
for(i=0;i<100;i++) buf[i] = 0;
      buf[0] ='K';
      buf[1] ='E';
      buf[2] ='R';
      buf[3] ='N';
      buf[4] ='E';
      buf[5] ='L';
      buf[6] =' ';
      buf[7] ='P';
      buf[8] ='A';
      buf[9] ='N';

  // request file
  phMscd_Filp = filp_open("/etc/gs/logs/panic.log", O_RDWR | O_LARGEFILE | O_CREAT , 0);
  if (phMscd_Filp == NULL)
    printk(KERN_EMERG "filp_open error!!.\n");

  // save actual space

  // jump to other space

  // write the file
  vfs_write(phMscd_Filp, buf, 13, &phMscd_Filp->f_pos);

  // close the file

  // back to old space
	return 0;

// ****************************************************************************
// block
// ****************************************************************************
static struct notifier_block panic_notifier = { panic_happened, NULL, 1 };

// ****************************************************************************
// load
// ****************************************************************************
static int __init register_my_panic(void)
	atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier);
  return 0;

// ****************************************************************************
// unload
// ****************************************************************************
static void __exit unregister_my_panic(void)
	atomic_notifier_chain_unregister(&panic_notifier_list, &panic_notifier);
here is the actual panic.c kernel code on kernel panic from my actual kernel, "atomic_notifier_call_chain(&panic_notifier_li st, 0, buf);" is which calls my module.

NORET_TYPE void panic(const char * fmt, ...)
	long i;
	static char buf[1024];
	va_list args;
#if defined(CONFIG_S390)
	unsigned long caller = (unsigned long) __builtin_return_address(0);

	 * It's possible to come here directly from a panic-assertion and not
	 * have preempt disabled. Some functions called from here want
	 * preempt to be disabled. No point enabling it later though...

	va_start(args, fmt);
	vsnprintf(buf, sizeof(buf), fmt, args);
	printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf);

	 * If we have crashed and we have a crash kernel loaded let it handle
	 * everything else.
	 * Do we want to call this before we try to display a message?

	 * Note smp_send_stop is the usual smp shutdown function, which
	 * unfortunately means it may not be hardened to work in a panic
	 * situation.

	atomic_notifier_call_chain(&panic_notifier_list, 0, buf);

	if (!panic_blink)
		panic_blink = no_blink;

	if (panic_timeout > 0) {
	 	 * Delay timeout seconds before rebooting the machine. 
		 * We can't use the "normal" timers since we just panicked..
		printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
		for (i = 0; i < panic_timeout*1000; ) {
			i += panic_blink(i);
		/*	This will not be a clean reboot, with everything
		 *	shutting down.  But if there is a chance of
		 *	rebooting the system it will be rebooted.
There is someting here than could be stopping my write file function?