Skip to content

Instantly share code, notes, and snippets.

@nasitra
Created October 31, 2015 02:22
Show Gist options
  • Select an option

  • Save nasitra/6f9da44ee8c13858b5ee to your computer and use it in GitHub Desktop.

Select an option

Save nasitra/6f9da44ee8c13858b5ee to your computer and use it in GitHub Desktop.
Add functions to change kernel log level dynamically
// kernel/kernel/printk.c
static int kmsg_level = 0;
void set_kmsg_lebel(int level)
{
kmsg_level = level;
}
void kmsg_write(const char *fmt, ...)
{
va_list args;
if (kmsg_level != 0) {
va_start(args, fmt);
vprintk(fmt, args);
va_end(args);
}
}
// kernel/include/linux/printk.h
extern void set_kmsg_lebel(int level);
extern void kmsg_write(const char *fmt, ...);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment