📄 prints.c
字号:
}static int sequence_finished (__u32 start, int * len, __u32 new){ if (le32_to_cpu (start) == INT_MAX) return 1; if (start == 0 && new == 0) { (*len) ++; return 0; } if (start != 0 && (le32_to_cpu (start) + *len) == le32_to_cpu (new)) { (*len) ++; return 0; } return 1;}static void print_sequence (FILE * fp, __u32 start, int len){ if (start == INT_MAX) return; if (len == 1) reiserfs_warning (fp, " %d", le32_to_cpu (start)); else reiserfs_warning (fp, " %d(%d)", le32_to_cpu (start), len);}void print_indirect_item (FILE * fp, struct buffer_head * bh, int item_num){ struct item_head * ih; unsigned int j; __u32 * unp, prev = INT_MAX; int num; ih = B_N_PITEM_HEAD (bh, item_num); unp = (__u32 *)B_I_PITEM (bh, ih); if (get_ih_item_len (ih) % UNFM_P_SIZE) reiserfs_warning (fp, "print_indirect_item: invalid item len"); reiserfs_warning (fp, "%d pointer%s\n[", I_UNFM_NUM (ih), I_UNFM_NUM (ih) != 1 ? "s" : "" ); for (j = 0; j < I_UNFM_NUM (ih); j ++) { if (sequence_finished (prev, &num, d32_get(unp, j))) { print_sequence (fp, prev, num); start_new_sequence (&prev, &num, d32_get(unp, j)); } } print_sequence (fp, prev, num); reiserfs_warning (fp, "]\n");}char timebuf[256];char * timestamp (time_t t){ strftime (timebuf, 256, "%d/%Y %T", localtime (&t)); return timebuf;}static int print_stat_data (FILE * fp, struct buffer_head * bh, struct item_head * ih, int alltimes){ int retval; /* we cannot figure out if it is new stat data or old by key_format macro. Stat data's key looks identical in both formats */ if (get_ih_key_format (ih) == KEY_FORMAT_1) { struct stat_data_v1 * sd_v1 = (struct stat_data_v1 *)B_I_PITEM (bh, ih); reiserfs_warning (fp, "(OLD SD), mode %M, size %u, nlink %u, uid %u, FDB %u, mtime %s blocks %u", sd_v1_mode(sd_v1), sd_v1_size(sd_v1), sd_v1_nlink(sd_v1), sd_v1_uid(sd_v1), sd_v1_first_direct_byte(sd_v1), timestamp (sd_v1_mtime(sd_v1)), sd_v1_blocks(sd_v1)); retval = (S_ISLNK (sd_v1_mode(sd_v1))) ? 1 : 0; if (alltimes) reiserfs_warning (fp, "%s %s\n", timestamp (sd_v1_ctime(sd_v1)), timestamp (sd_v1_atime(sd_v1))); } else { struct stat_data * sd = (struct stat_data *)B_I_PITEM (bh, ih); reiserfs_warning (fp, "(NEW SD), mode %M, size %Lu, nlink %u, mtime %s blocks %u, uid %u", sd_v2_mode(sd), sd_v2_size(sd), sd_v2_nlink(sd), timestamp (sd_v2_mtime(sd)), sd_v2_blocks(sd), sd_v2_uid(sd)); retval = (S_ISLNK (sd_v2_mode(sd))) ? 1 : 0; if (alltimes) reiserfs_warning (fp, "%s %s\n", timestamp (sd_v2_ctime(sd)), timestamp (sd_v2_atime(sd))); } reiserfs_warning (fp, "\n"); return retval;}/* used by debugreiserfs/scan.c */void reiserfs_print_item (FILE * fp, struct buffer_head * bh, struct item_head * ih){ reiserfs_warning (fp, "block %lu, item %d: %H\n", bh->b_blocknr, (ih - B_N_PITEM_HEAD (bh, 0))/sizeof(struct item_head), ih); if (is_stat_data_ih (ih)) { print_stat_data (fp, bh, ih, 0/*all times*/); return; } if (is_indirect_ih (ih)) { print_indirect_item (fp, bh, ih - B_N_PITEM_HEAD (bh, 0)); return; } if (is_direct_ih (ih)) { reiserfs_warning (fp, "direct item: block %lu, start %d, %d bytes\n", bh->b_blocknr, get_ih_location (ih), get_ih_item_len (ih)); return; } print_directory_item (fp, 0, bh, ih); }/* 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 (FILE * fp, struct buffer_head * bh, int first, int last){ struct key * key; struct disk_child * dc; int i; int from, to; if (!is_internal_node (bh)) return 1; if (first == -1) { from = 0; to = B_NR_ITEMS (bh); } else { from = first; to = last < B_NR_ITEMS (bh) ? last : B_NR_ITEMS (bh); } reiserfs_warning (fp, "INTERNAL NODE (%ld) contains %b\n", bh->b_blocknr, bh); dc = B_N_CHILD (bh, from); reiserfs_warning (fp, "PTR %d: %y ", from, dc); for (i = from, key = B_N_PDELIM_KEY (bh, from), dc ++; i < to; i ++, key ++, dc ++) { reiserfs_warning (fp, "KEY %d: %20k PTR %d: %20y ", i, key, i + 1, dc); if (i && i % 4 == 0) reiserfs_warning (fp, "\n"); } reiserfs_warning (fp, "\n"); return 0;}static int is_symlink = 0;static int print_leaf (FILE * fp, reiserfs_filsys_t * fs, struct buffer_head * bh, int print_mode, int first, int last){ struct block_head * blkh; struct item_head * ih; int i; int from, to; int real_nr, nr; if (!is_tree_node (bh, DISK_LEAF_NODE_LEVEL)) return 1; blkh = B_BLK_HEAD (bh); ih = B_N_PITEM_HEAD (bh,0); real_nr = leaf_count_ih(bh->b_data, bh->b_size); nr = get_blkh_nr_items((struct block_head *)bh->b_data); reiserfs_warning (fp, "\n===================================================================\n"); reiserfs_warning (fp, "LEAF NODE (%ld) contains %b (real items %d)\n", bh->b_blocknr, bh, real_nr); if (!(print_mode & PRINT_TREE_DETAILS)) { reiserfs_warning (fp, "FIRST ITEM_KEY: %k, LAST ITEM KEY: %k\n", &(ih->ih_key), &((ih + real_nr - 1)->ih_key)); return 0; } if (first < 0 || first > real_nr - 1) from = 0; else from = first; if (last < 0 || last > real_nr) to = real_nr; else to = last; reiserfs_warning (fp, "-------------------------------------------------------------------------------\n" "|###|type|ilen|f/sp| loc|fmt|fsck| key |\n" "| | | |e/cn| | |need| |\n"); for (i = from; i < to; i++) { reiserfs_warning (fp, "-------------------------------------------------------------------------------\n" "|%3d|%30H|%s\n", i, ih + i, i >= nr ? " DELETED" : ""); if (I_IS_STAT_DATA_ITEM(ih+i)) { is_symlink = print_stat_data (fp, bh, ih + i, 0/*all times*/); continue; } if (I_IS_DIRECTORY_ITEM(ih+i)) { print_directory_item (fp, fs, bh, ih+i); continue; } if (I_IS_INDIRECT_ITEM(ih+i)) { print_indirect_item (fp, bh, i); continue; } if (I_IS_DIRECT_ITEM(ih+i)) { int j = 0; if (is_symlink || print_mode & PRINT_DIRECT_ITEMS) { reiserfs_warning (fp, "\""); while (j < get_ih_item_len (&ih[i])) { if (B_I_PITEM(bh,ih+i)[j] == 10) reiserfs_warning (fp, "\\n"); else reiserfs_warning (fp, "%c", B_I_PITEM(bh,ih+i)[j]); j ++; } reiserfs_warning (fp, "\"\n"); } continue; } } reiserfs_warning (fp, "===================================================================\n"); return 0;}void print_journal_params (FILE * fp, struct journal_params * jp){ reiserfs_warning (fp, "\tDevice [0x%x]\n", get_jp_journal_dev (jp)); reiserfs_warning (fp, "\tMagic [0x%x]\n", get_jp_journal_magic (jp)); reiserfs_warning (fp, "\tSize %u blocks (including 1 for journal header) (first block %u)\n", get_jp_journal_size (jp) + 1, get_jp_journal_1st_block (jp)); reiserfs_warning (fp, "\tMax transaction length %u blocks\n", get_jp_journal_max_trans_len (jp)); reiserfs_warning (fp, "\tMax batch size %u blocks\n", get_jp_journal_max_batch (jp)); reiserfs_warning (fp, "\tMax commit age %u\n", get_jp_journal_max_commit_age (jp)); /*reiserfs_warning (fp, "\tMax transaction age %u\n", get_jp_journal_max_trans_age (jp));*/}/* return 1 if this is not super block */int print_super_block (FILE * fp, reiserfs_filsys_t * fs, char * file_name, struct buffer_head * bh, int short_print){ struct reiserfs_super_block * sb = (struct reiserfs_super_block *)(bh->b_data); dev_t rdev; int format = 0; __u16 state; if (!does_look_like_super_block (sb)) return 1; rdev = misc_device_rdev(file_name); reiserfs_warning (fp, "Reiserfs super block in block %lu on 0x%x of ", bh->b_blocknr, rdev); switch (get_reiserfs_format (sb)) { case REISERFS_FORMAT_3_5: reiserfs_warning (fp, "format 3.5 with "); format = 1; break; case REISERFS_FORMAT_3_6: reiserfs_warning (fp, "format 3.6 with "); format = 2; break; default: reiserfs_warning (fp, "unknown format with "); break; } if (is_reiserfs_jr_magic_string (sb)) reiserfs_warning (fp, "non-"); reiserfs_warning (fp, "standard journal\n"); if (short_print) { reiserfs_warning (fp, "Blocks (total/free): %u/%u by %d bytes\n", get_sb_block_count (sb), get_sb_free_blocks (sb), get_sb_block_size (sb)); } else { reiserfs_warning (fp, "Count of blocks on the device: %u\n", get_sb_block_count (sb)); reiserfs_warning (fp, "Number of bitmaps: %u\n", get_sb_bmap_nr (sb)); reiserfs_warning (fp, "Blocksize: %d\n", get_sb_block_size (sb)); reiserfs_warning (fp, "Free blocks (count of blocks - used [journal, " "bitmaps, data, reserved] blocks): %u\n", get_sb_free_blocks (sb)); reiserfs_warning (fp, "Root block: %u\n", get_sb_root_block (sb)); } reiserfs_warning (fp, "Filesystem is %sclean\n", (get_sb_umount_state (sb) == FS_CLEANLY_UMOUNTED) ? "" : "NOT "); if (short_print) return 0; reiserfs_warning (fp, "Tree height: %d\n", get_sb_tree_height (sb)); reiserfs_warning (fp, "Hash function used to sort names: %s\n", code2name (get_sb_hash_code (sb))); reiserfs_warning (fp, "Objectid map size %d, max %d\n", get_sb_oid_cursize (sb), get_sb_oid_maxsize (sb)); reiserfs_warning (fp, "Journal parameters:\n"); print_journal_params (fp, sb_jp (sb)); reiserfs_warning (fp, "Blocks reserved by journal: %u\n", get_sb_reserved_for_journal (sb)); state = get_sb_fs_state (sb); reiserfs_warning (fp, "Fs state field: 0x%x:\n", state); if ((state & FS_FATAL) == FS_FATAL) reiserfs_warning (fp, "\tFATAL corruptions exist.\n"); if ((state & FS_ERROR) == FS_ERROR) reiserfs_warning (fp, "\t some corruptions exist.\n"); if ((state & IO_ERROR) == IO_ERROR) reiserfs_warning (fp, "\tI/O corruptions exist.\n"); reiserfs_warning (fp, "sb_version: %u\n", get_sb_version (sb)); if (format == 2) { reiserfs_warning (fp, "inode generation number: %u\n", get_sb_v2_inode_generation (sb)); reiserfs_warning (fp, "UUID: %U\n", sb->s_uuid); reiserfs_warning (fp, "LABEL: %.16s\n", sb->s_label); reiserfs_warning (fp, "Set flags in SB:\n"); if ((get_sb_v2_flag (sb, reiserfs_attrs_cleared))) reiserfs_warning (fp, "\tATTRIBUTES CLEAN\n"); } return 0;}void print_filesystem_state (FILE * fp, reiserfs_filsys_t * fs){ reiserfs_warning (fp, "\nFilesystem state: "); if (reiserfs_is_fs_consistent (fs)) reiserfs_warning (fp, "consistent\n\n"); else reiserfs_warning (fp, "consistency is not checked after last mounting\n\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -