mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-03 10:55:20 +00:00
Add simple message printing
Add a message printing function whose output includes the device and major:minor and which handles the kernel level string prefix. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
20
kmod/src/msg.c
Normal file
20
kmod/src/msg.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
void scoutfs_msg(struct super_block *sb, const char *prefix, const char *str,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
struct va_format vaf;
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
vaf.fmt = fmt;
|
||||
vaf.va = &args;
|
||||
|
||||
printk("%sscoutfs (%s %u:%u)%s: %pV\n", prefix,
|
||||
sb->s_id, MAJOR(sb->s_bdev->bd_dev), MINOR(sb->s_bdev->bd_dev),
|
||||
str, &vaf);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
16
kmod/src/msg.h
Normal file
16
kmod/src/msg.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef _SCOUTFS_MSG_H_
|
||||
#define _SCOUTFS_MSG_H_
|
||||
|
||||
void scoutfs_msg(struct super_block *sb, const char *prefix, const char *str,
|
||||
const char *fmt, ...);
|
||||
|
||||
#define scoutfs_err(sb, fmt, args...) \
|
||||
scoutfs_msg(sb, KERN_ERR, " error", fmt, ##args)
|
||||
|
||||
#define scoutfs_warn(sb, fmt, args...) \
|
||||
scoutfs_msg(sb, KERN_WARNING, " warning", fmt, ##args)
|
||||
|
||||
#define scoutfs_info(sb, fmt, args...) \
|
||||
scoutfs_msg(sb, KERN_INFO, "", fmt, ##args)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user