/* * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README */ #include <linux/time.h> #include <linux/fs.h> #include "reiserfs.h" #include <linux/string.h> #include <linux/buffer_head.h> #include <linux/stdarg.h> static char error_buf[1024]; static char fmt_buf[1024]; static char off_buf[80]; static char *reiserfs_cpu_offset(struct cpu_key *key) { … } static char *le_offset(struct reiserfs_key *key) { … } static char *cpu_type(struct cpu_key *key) { … } static char *le_type(struct reiserfs_key *key) { … } /* %k */ static int scnprintf_le_key(char *buf, size_t size, struct reiserfs_key *key) { … } /* %K */ static int scnprintf_cpu_key(char *buf, size_t size, struct cpu_key *key) { … } static int scnprintf_de_head(char *buf, size_t size, struct reiserfs_de_head *deh) { … } static int scnprintf_item_head(char *buf, size_t size, struct item_head *ih) { … } static int scnprintf_direntry(char *buf, size_t size, struct reiserfs_dir_entry *de) { … } static int scnprintf_block_head(char *buf, size_t size, struct buffer_head *bh) { … } static int scnprintf_buffer_head(char *buf, size_t size, struct buffer_head *bh) { … } static int scnprintf_disk_child(char *buf, size_t size, struct disk_child *dc) { … } static char *is_there_reiserfs_struct(char *fmt, int *what) { … } /* * debugging reiserfs we used to print out a lot of different * variables, like keys, item headers, buffer heads etc. Values of * most fields matter. So it took a long time just to write * appropriative printk. With this reiserfs_warning you can use format * specification for complex structures like you used to do with * printfs for integers, doubles and pointers. For instance, to print * out key structure you have to write just: * reiserfs_warning ("bad key %k", key); * instead of * printk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid, * key->k_offset, key->k_uniqueness); */ static DEFINE_SPINLOCK(error_lock); static void prepare_error_buf(const char *fmt, va_list args) { … } /* * in addition to usual conversion specifiers this accepts reiserfs * specific conversion specifiers: * %k to print little endian key, * %K to print cpu key, * %h to print item_head, * %t to print directory entry * %z to print block head (arg must be struct buffer_head * * %b to print buffer_head */ #define do_reiserfs_warning(fmt) … void __reiserfs_warning(struct super_block *sb, const char *id, const char *function, const char *fmt, ...) { … } /* No newline.. reiserfs_info calls can be followed by printk's */ void reiserfs_info(struct super_block *sb, const char *fmt, ...) { … } /* No newline.. reiserfs_printk calls can be followed by printk's */ static void reiserfs_printk(const char *fmt, ...) { … } void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...) { … } /* * The format: * * maintainer-errorid: [function-name:] message * * where errorid is unique to the maintainer and function-name is * optional, is recommended, so that anyone can easily find the bug * with a simple grep for the short to type string * maintainer-errorid. Don't bother with reusing errorids, there are * lots of numbers out there. * * Example: * * reiserfs_panic( * p_sb, "reiser-29: reiserfs_new_blocknrs: " * "one of search_start or rn(%d) is equal to MAX_B_NUM," * "which means that we are optimizing location based on the " * "bogus location of a temp buffer (%p).", * rn, bh * ); * * Regular panic()s sometimes clear the screen before the message can * be read, thus the need for the while loop. * * Numbering scheme for panic used by Vladimir and Anatoly( Hans completely * ignores this scheme, and considers it pointless complexity): * * panics in reiserfs_fs.h have numbers from 1000 to 1999 * super.c 2000 to 2999 * preserve.c (unused) 3000 to 3999 * bitmap.c 4000 to 4999 * stree.c 5000 to 5999 * prints.c 6000 to 6999 * namei.c 7000 to 7999 * fix_nodes.c 8000 to 8999 * dir.c 9000 to 9999 * lbalance.c 10000 to 10999 * ibalance.c 11000 to 11999 not ready * do_balan.c 12000 to 12999 * inode.c 13000 to 13999 * file.c 14000 to 14999 * objectid.c 15000 - 15999 * buffer.c 16000 - 16999 * symlink.c 17000 - 17999 * * . */ void __reiserfs_panic(struct super_block *sb, const char *id, const char *function, const char *fmt, ...) { … } void __reiserfs_error(struct super_block *sb, const char *id, const char *function, const char *fmt, ...) { … } void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...) { … } /* * this prints internal nodes (4 keys/items in line) (dc_number, * dc_size)[k_dirid, k_objectid, k_offset, k_uniqueness](dc_number, * dc_size)... */ static int print_internal(struct buffer_head *bh, int first, int last) { … } static int print_leaf(struct buffer_head *bh, int print_mode, int first, int last) { … } char *reiserfs_hashname(int code) { … } /* return 1 if this is not super block */ static int print_super_block(struct buffer_head *bh) { … } static int print_desc_block(struct buffer_head *bh) { … } /* ..., int print_mode, int first, int last) */ void print_block(struct buffer_head *bh, ...) { … } static char print_tb_buf[2048]; /* this stores initial state of tree balance in the print_tb_buf */ void store_print_tb(struct tree_balance *tb) { … } void print_cur_tb(char *mes) { … } static void check_leaf_block_head(struct buffer_head *bh) { … } static void check_internal_block_head(struct buffer_head *bh) { … } void check_leaf(struct buffer_head *bh) { … } void check_internal(struct buffer_head *bh) { … } void print_statistics(struct super_block *s) { … }