diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2013-01-23 02:27:11 +0900 |
---|---|---|
committer | Daniel Phillips <daniel@tux3.org> | 2013-01-23 02:27:11 +0900 |
commit | dca30566a919e467497b21058187e3ae7cd02643 (patch) | |
tree | e5782c19ca3d807eadf184a21c1b9540d0aeffa6 | |
parent | 58d0f80b8f04544f8f02d24371d8040e2ab9a466 (diff) | |
download | linux-tux3-dca30566a919e467497b21058187e3ae7cd02643.tar.gz |
tux3: Introduce message infrastructure
Now, our printing message is confusing. warn() is used for debug,
error, and warning.
Make helpers for each purpose.
tux3_msg() - informational message
tux3_err() - error message
tux3_warn() - warning message
__tux3_dbg() - debug message without \n
tux3_dbg() - debug message without __func__, __LINE__, and \n
tux3_fs_error() - critical error message, then will make fs read-only
panic, or something user specified behavior
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
-rw-r--r-- | fs/tux3/tux3.h | 21 | ||||
-rw-r--r-- | fs/tux3/utility.c | 43 |
2 files changed, 64 insertions, 0 deletions
diff --git a/fs/tux3/tux3.h b/fs/tux3/tux3.h index ec942b03f338c3..453840c043bbb8 100644 --- a/fs/tux3/tux3.h +++ b/fs/tux3/tux3.h @@ -649,6 +649,14 @@ int devio(int rw, struct block_device *dev, loff_t offset, void *data, int blockio(int rw, struct sb *sb, struct buffer_head *buffer, block_t block); int blockio_vec(int rw, struct bufvec *bufvec, block_t block, unsigned count); +#define tux3_msg(sb, fmt, ...) \ + __tux3_msg(sb, KERN_INFO, "", fmt, ##__VA_ARGS__) +#define tux3_err(sb, fmt, ...) \ + __tux3_msg(sb, KERN_ERR, " error", \ + "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__) +#define tux3_warn(sb, fmt, ...) \ + __tux3_msg(sb, KERN_WARNING, " warning", fmt, ##__VA_ARGS__) + /* temporary hack for buffer */ struct buffer_head *peekblk(struct address_space *mapping, block_t iblock); struct buffer_head *blockread(struct address_space *mapping, block_t iblock); @@ -853,6 +861,19 @@ int replay_stage2(struct replay *rp); int replay_stage3(struct replay *rp, int apply); /* utility.c */ +void __printf(4, 5) +__tux3_msg(struct sb *sb, const char *level, const char *prefix, + const char *fmt, ...); +void __printf(1, 2) +__tux3_dbg(const char *fmt, ...); +#define tux3_dbg(fmt , ...) \ + __tux3_dbg("%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) +void __printf(4, 5) +__tux3_fs_error(struct sb *sb, const char *func, unsigned int line, + const char *fmt, ...); +#define tux3_fs_error(sb, fmt, ...) \ + __tux3_fs_error(sb, __func__, __LINE__, fmt , ##__VA_ARGS__) + void hexdump(void *data, unsigned size); void set_bits(u8 *bitmap, unsigned start, unsigned count); void clear_bits(u8 *bitmap, unsigned start, unsigned count); diff --git a/fs/tux3/utility.c b/fs/tux3/utility.c index abcb6932b12df1..1c76fb5ee440be 100644 --- a/fs/tux3/utility.c +++ b/fs/tux3/utility.c @@ -75,6 +75,49 @@ void hexdump(void *data, unsigned size) { print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 1, data, size, 1); } + +/* + * Message helpers + */ + +void __tux3_msg(struct sb *sb, const char *level, const char *prefix, + const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + va_start(args, fmt); + vaf.fmt = fmt; + vaf.va = &args; + printk("%sTUX3-fs%s (%s): %pV\n", level, prefix, + vfs_sb(sb)->s_id, &vaf); + va_end(args); +} + +void __tux3_fs_error(struct sb *sb, const char *func, unsigned int line, + const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + va_start(args, fmt); + vaf.fmt = fmt; + vaf.va = &args; + printk(KERN_ERR "TUX3-fs error (%s): %s:%d: %pV\n", + vfs_sb(sb)->s_id, func, line, &vaf); + va_end(args); + + BUG(); /* FIXME: maybe panic() or MS_RDONLY */ +} + +void __tux3_dbg(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); +} #endif /* !__KERNEL__ */ /* Bitmap operations... try to use linux/lib/bitmap.c */ |