⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prints.c

📁 reiserfsprogs-3.6.19.tar.gz 源码 给有需要的人!
💻 C
📖 第 1 页 / 共 3 页
字号:
static int print_desc_block (FILE * fp, struct buffer_head * bh){    if (memcmp(get_jd_magic (bh), JOURNAL_DESC_MAGIC, 8))	return 1;    reiserfs_warning (fp, "Desc block %lu (j_trans_id %ld, j_mount_id %ld, j_len %ld)\n",		      bh->b_blocknr, get_desc_trans_id (bh),		      get_desc_mount_id (bh), get_desc_trans_len (bh));    return 0;}void print_block (FILE * fp, reiserfs_filsys_t * fs, 		  struct buffer_head * bh, ...)//int print_mode, int first, int last){    va_list args;    int mode, first, last;    char * file_name;    va_start (args, bh);    if ( ! bh ) {	reiserfs_warning (stderr, "print_block: buffer is NULL\n");	return;    }    mode = va_arg (args, int);    first = va_arg (args, int);    last = va_arg (args, int);    file_name = (fs) ? fs->fs_file_name : NULL ;    if (print_desc_block (fp, bh))        if (print_super_block (fp, fs, file_name, bh, 0))	    if (print_leaf (fp, fs, bh, mode, first, last))		if (print_internal (fp, bh, first, last))		    reiserfs_warning (fp, "Block %ld contains unformatted data\n", bh->b_blocknr);}void print_tb (int mode, int item_pos, int pos_in_item, struct tree_balance * tb, char * mes){  unsigned int h = 0;  struct buffer_head * tbSh, * tbFh;  if (!tb)    return;  printf ("\n********************** PRINT_TB for %s *******************\n", mes);  printf ("MODE=%c, ITEM_POS=%d POS_IN_ITEM=%d\n", mode, item_pos, pos_in_item);  printf ("*********************************************************************\n");  printf ("* h *    S    *    L    *    R    *   F   *   FL  *   FR  *  CFL  *  CFR  *\n");/*01234567890123456789012345678901234567890123456789012345678901234567890123456789       1        2         3         4         5         6         7         8  printk ("*********************************************************************\n");*/      for (h = 0; h < sizeof(tb->insert_size) / sizeof (tb->insert_size[0]); h ++) {    if (PATH_H_PATH_OFFSET (tb->tb_path, h) <= tb->tb_path->path_length && 	PATH_H_PATH_OFFSET (tb->tb_path, h) > ILLEGAL_PATH_ELEMENT_OFFSET) {      tbSh = PATH_H_PBUFFER (tb->tb_path, h);      tbFh = PATH_H_PPARENT (tb->tb_path, h);    } else {      /*      printk ("print_tb: h=%d, PATH_H_PATH_OFFSET=%d, path_length=%d\n", 	      h, PATH_H_PATH_OFFSET (tb->tb_path, h), tb->tb_path->path_length);*/      tbSh = 0;      tbFh = 0;    }    printf ("* %u * %3lu(%2lu) * %3lu(%2lu) * %3lu(%2lu) * %5ld * %5ld * %5ld * %5ld * %5ld *\n",	    h, 	    tbSh ? tbSh->b_blocknr : ~0ul,	    tbSh ? tbSh->b_count : ~0ul,	    tb->L[h] ? tb->L[h]->b_blocknr : ~0ul,	    tb->L[h] ? tb->L[h]->b_count : ~0ul,	    tb->R[h] ? tb->R[h]->b_blocknr : ~0ul,	    tb->R[h] ? tb->R[h]->b_count : ~0ul,	    tbFh ? tbFh->b_blocknr : ~0ul,	    tb->FL[h] ? tb->FL[h]->b_blocknr : ~0ul,	    tb->FR[h] ? tb->FR[h]->b_blocknr : ~0ul,	    tb->CFL[h] ? tb->CFL[h]->b_blocknr : ~0ul,	    tb->CFR[h] ? tb->CFR[h]->b_blocknr : ~0ul);  }  printf ("*********************************************************************\n");  /* print balance parameters for leaf level */  h = 0;  printf ("* h * size * ln * lb * rn * rb * blkn * s0 * s1 * s1b * s2 * s2b * curb * lk * rk *\n");  printf ("* %d * %4d * %2d * %2d * %2d * %2d * %4d * %2d * %2d * %3d * %2d * %3d * %4d * %2d * %2d *\n",	  h, tb->insert_size[h], tb->lnum[h], tb->lbytes, tb->rnum[h],tb->rbytes, tb->blknum[h], 	  tb->s0num, tb->s1num,tb->s1bytes,  tb->s2num, tb->s2bytes, tb->cur_blknum, tb->lkey[h], tb->rkey[h]);/* this prints balance parameters for non-leaf levels */  do {    h++;    printf ("* %d * %4d * %2d *    * %2d *    * %2d *\n",    h, tb->insert_size[h], tb->lnum[h], tb->rnum[h], tb->blknum[h]);  } while (tb->insert_size[h]);  printf ("*********************************************************************\n");  /* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */  for (h = 0; h < sizeof (tb->FEB) / sizeof (tb->FEB[0]); h++)    printf("%s%p (%lu %d)", h == 0 ? "FEB list: " : ", ", tb->FEB[h], tb->FEB[h] ? tb->FEB[h]->b_blocknr : 0,	    tb->FEB[h] ? tb->FEB[h]->b_count : 0);  printf ("\n");  printf ("********************** END OF PRINT_TB *******************\n\n");}static void print_bmap_block (FILE * fp, int i, unsigned long block, char * map, int blocks, int silent, int blocksize){    int j, k;    int bits = blocksize * 8;    int zeros = 0, ones = 0;      reiserfs_warning (fp, "#%d: block %lu: ", i, block);    blocks = blocksize * 8;    if (misc_test_bit (0, map)) {	/* first block addressed by this bitmap block is used */	ones ++;	if (!silent)	    reiserfs_warning (fp, "Busy (%d-", i * bits);	for (j = 1; j < blocks; j ++) {	    while (misc_test_bit (j, map)) {		ones ++;		if (j == blocks - 1) {		    if (!silent)			reiserfs_warning (fp, "%d)\n", j + i * bits);		    goto end;		}		j++;	    }	    if (!silent)		reiserfs_warning (fp, "%d) Free(%d-", j - 1 + i * bits, j + i * bits);	    while (!misc_test_bit (j, map)) {		zeros ++;		if (j == blocks - 1) {		    if (!silent)			reiserfs_warning (fp, "%d)\n", j + i * bits);		    goto end;		}		j++;	    }	    if (!silent)		reiserfs_warning (fp, "%d) Busy(%d-", j - 1 + i * bits, j + i * bits);	    j --;	end:	    /* to make gcc 3.2 do not sware here */;	}    } else {	/* first block addressed by this bitmap is free */	zeros ++;	if (!silent)	    reiserfs_warning (fp, "Free (%d-", i * bits);	for (j = 1; j < blocks; j ++) {	    k = 0;	    while (!misc_test_bit (j, map)) {		k ++;		if (j == blocks - 1) {		    if (!silent)			reiserfs_warning (fp, "%d)\n", j + i * bits);		    zeros += k;		    goto end2;		}		j++;	    }	    zeros += k;	    if (!silent)		reiserfs_warning (fp, "%d) Busy(%d-", j - 1 + i * bits, j + i * bits);	    	    k = 0;	    while (misc_test_bit (j, map)) {		ones ++;		if (j == blocks - 1) {		    if (!silent)			reiserfs_warning (fp, "%d)\n", j + i * bits);		    ones += k;		    goto end2;		}		j++;	    }	    ones += k;	    if (!silent)		reiserfs_warning (fp, "%d) Free(%d-", j - 1 + i * bits, j + i * bits);		    j --;	end2:	    /* to make gcc 3.2 do not sware here */;	}    }    reiserfs_warning (fp, "used %d, free %d\n", ones, zeros);}/* read bitmap of disk and print details */void print_bmap (FILE * fp, reiserfs_filsys_t * fs, int silent){    struct reiserfs_super_block * sb;    int bmap_nr;    int i;    int bits_per_block;    int blocks;    unsigned long block;    struct buffer_head * bh;    sb = fs->fs_ondisk_sb;    bmap_nr = get_sb_bmap_nr (sb);    bits_per_block = fs->fs_blocksize * 8;    blocks = bits_per_block;    reiserfs_warning (fp, "Bitmap blocks are:\n");    block = fs->fs_super_bh->b_blocknr + 1;    for (i = 0; i < bmap_nr; i ++) {	bh = bread (fs->fs_dev, block, fs->fs_blocksize);	if (!bh) {	    reiserfs_warning (stderr, "print_bmap: bread failed for %d: %lu\n", i, block);	    continue;	}	if (i == bmap_nr - 1)	    if (get_sb_block_count (sb) % bits_per_block)		blocks = get_sb_block_count (sb) % bits_per_block;	print_bmap_block (fp, i, block, bh->b_data, blocks, silent, fs->fs_blocksize);	brelse (bh);	if (spread_bitmaps (fs))	    block = (block / (fs->fs_blocksize * 8) + 1) * (fs->fs_blocksize * 8);	else	    block ++;	    }}void print_objectid_map (FILE * fp, reiserfs_filsys_t * fs){    int i;    struct reiserfs_super_block * sb;    __u32 * omap;    sb = fs->fs_ondisk_sb;    if (fs->fs_format == REISERFS_FORMAT_3_6)	omap = (__u32 *)(sb + 1);    else if (fs->fs_format == REISERFS_FORMAT_3_5)	omap = (__u32 *)((struct reiserfs_super_block_v1 *)sb + 1);    else {	reiserfs_warning (fp, "print_objectid_map: proper signature is not found\n");	return;    }	    reiserfs_warning (fp, "Map of objectids (super block size %d)\n",		      (char *)omap - (char *)sb);          for (i = 0; i < get_sb_oid_cursize (sb); i ++) {	if (i % 2 == 0) {	    reiserfs_warning(fp, "busy(%u-%u) ", le32_to_cpu (omap[i]),			     le32_to_cpu (omap[i+1]) - 1); 	} else {	    reiserfs_warning(fp, "free(%u-%u) ", le32_to_cpu (omap[i]),			    ((i+1) == get_sb_oid_cursize (sb)) ? 			    ~(__u32)0 : (le32_to_cpu (omap[i+1]) - 1));	}    }    reiserfs_warning (fp, "\nObject id array has size %d (max %d):", 		      get_sb_oid_cursize (sb), get_sb_oid_maxsize (sb));      for (i = 0; i < get_sb_oid_cursize (sb); i ++)	reiserfs_warning (fp, "%s%u ", i % 2 ? "" : "*", le32_to_cpu (omap[i]));     reiserfs_warning (fp, "\n");}void print_journal_header (reiserfs_filsys_t * fs){    struct reiserfs_journal_header * j_head;    j_head = (struct reiserfs_journal_header *)(fs->fs_jh_bh->b_data);    reiserfs_warning (stdout, "Journal header (block #%lu of %s):\n"		      "\tj_last_flush_trans_id %ld\n"		      "\tj_first_unflushed_offset %ld\n"		      "\tj_mount_id %ld\n", 		      fs->fs_jh_bh->b_blocknr, fs->fs_j_file_name,		      get_jh_last_flushed (j_head),		      get_jh_replay_start_offset (j_head),		      get_jh_mount_id (j_head));    print_journal_params (stdout, &j_head->jh_journal);}static void print_trans_element (reiserfs_filsys_t * fs, reiserfs_trans_t * trans,				 unsigned int index, unsigned long in_journal, 				 unsigned long in_place){    if (index % 8 == 0)	reiserfs_warning (stdout, "#%d\t", index);    reiserfs_warning (stdout, "%lu->%lu%s ",  in_journal, in_place,		      block_of_bitmap (fs, in_place) ? "B" : "");    if ((index + 1) % 8 == 0 || index == trans->trans_len - 1)	reiserfs_warning (stdout, "\n");}void print_one_transaction (reiserfs_filsys_t * fs, reiserfs_trans_t * trans){    reiserfs_warning (stdout, "Mountid %u, transid %u, desc %lu, length %u, commit %lu\n",		      trans->mount_id, trans->trans_id,		      trans->desc_blocknr,		      trans->trans_len, trans->commit_blocknr);    for_each_block (fs, trans, print_trans_element);}/* print all valid transactions and found dec blocks */void print_journal (reiserfs_filsys_t * fs){    if (!reiserfs_journal_opened (fs)) {	reiserfs_warning (stderr, "print_journal: journal is not opened\n");	return;    }    print_journal_header (fs);    for_each_transaction (fs, print_one_transaction);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -