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

📄 pass0.c

📁 reiserfsprogs-3.6.19.tar.gz 源码 给有需要的人!
💻 C
📖 第 1 页 / 共 5 页
字号:
                /* fix i-th */                if (!is_stat_data_ih (ih)) {                    fsck_log("pass0: vpf-10430: block %lu, item %d: Wrong order of items - "			"change the dir_id of the key %k to %lu\n",                    	bh->b_blocknr, i, &ih->ih_key, get_key_dirid (&(ih - 1)->ih_key));		    set_key_dirid (&ih->ih_key, get_key_dirid (&(ih - 1)->ih_key));		    dirty = 1;                } else if (i + 1 < nr_items) {                    fsck_log("pass0: vpf-10440: block %lu, item %d: Wrong order of items - "			"change the dir_id of the key %k to %lu\n",                    	bh->b_blocknr, i, &ih->ih_key, get_key_dirid (&(ih + 1)->ih_key));		    set_key_dirid (&ih->ih_key, get_key_dirid (&(ih + 1)->ih_key));		    dirty = 1;                }            } else 	            if ((i + 1 < nr_items) && get_key_dirid (&ih->ih_key) == get_key_dirid (&(ih + 1)->ih_key)) {                fsck_log("pass0: vpf-10450: block %lu, item %d: Wrong order of items - "		    "change the dir_id of the key %k to %lu\n",                    bh->b_blocknr, i - 1, &(ih - 1)->ih_key, get_key_dirid (&ih->ih_key));                /* fix (i - 1)-th */		set_key_dirid (&(ih - 1)->ih_key, get_key_dirid (&ih->ih_key));		dirty = 1;            }	        } 	if (i && i + 1 < nr_items) {      	    /* there is a previous and a next items */	    if ((get_key_dirid (&(ih - 1)->ih_key) == get_key_dirid (&(ih + 1)->ih_key)) &&		(get_key_dirid (&(ih - 1)->ih_key) != get_key_dirid (&ih->ih_key)))	    {                fsck_log("pass0: vpf-10460: block %lu, item %d: Wrong order of items - "		    "change the dir_id of the key %k to %lu\n",                    bh->b_blocknr, i, &ih->ih_key, get_key_dirid (&(ih - 1)->ih_key));		set_key_dirid (&ih->ih_key, get_key_dirid (&(ih - 1)->ih_key));		dirty = 1;            }            if (is_stat_data_ih (ih - 1) && is_indirect_ih (ih) && is_direct_ih (ih + 1)) {	    	if ((get_key_objectid (&(ih - 1)->ih_key) == get_key_objectid (&(ih + 1)->ih_key)) &&		    (get_key_objectid (&(ih - 1)->ih_key) != get_key_objectid (&ih->ih_key)))            	{		    fsck_log("pass0: vpf-10470: block %lu, item %d: Wrong order of items - "			"change the object_id of the key %k to %lu\n",                    	bh->b_blocknr, i, &ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));		    set_key_objectid (&ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));		    dirty = 1;		}	    	if ((get_key_objectid (&(ih - 1)->ih_key) == get_key_objectid (&ih->ih_key)) &&		    (get_key_objectid (&(ih - 1)->ih_key) != get_key_objectid (&(ih + 1)->ih_key)))            	{		    fsck_log("pass0: vpf-10480: block %lu, item %d: Wrong order of items - "			"change the object_id of the key %k to %lu\n",                    	bh->b_blocknr, i + 1, &(ih+1)->ih_key, get_key_objectid (&(ih - 1)->ih_key));		    set_key_objectid (&(ih + 1)->ih_key, get_key_objectid (&(ih - 1)->ih_key));		    dirty = 1;		}	    	if ((get_key_objectid (&ih->ih_key) == get_key_objectid (&(ih + 1)->ih_key)) &&		    (get_key_objectid (&(ih - 1)->ih_key) != get_key_objectid (&(ih + 1)->ih_key)))            	{		    fsck_log("pass0: vpf-10490: block %lu, item %d: Wrong order of items - "			"change the object_id of the key %k to %lu\n",                    	bh->b_blocknr, i - 1, &(ih-1)->ih_key, get_key_objectid (&(ih + 1)->ih_key));		    set_key_objectid (&(ih - 1)->ih_key, get_key_objectid (&(ih + 1)->ih_key));		    dirty = 1;		}		if ((get_key_dirid (&(ih - 1)->ih_key) == get_key_dirid (&ih->ih_key)) &&		    (get_key_dirid (&(ih - 1)->ih_key) != get_key_dirid (&(ih + 1)->ih_key)))	    	{		    fsck_log("pass0: vpf-10500: block %lu, item %d: Wrong order of items - "			"change the dir_id of the key %k to %lu\n",                    	bh->b_blocknr, i + 1, &(ih+1)->ih_key, get_key_dirid (&(ih - 1)->ih_key));		    set_key_dirid (&(ih + 1)->ih_key, get_key_dirid (&(ih - 1)->ih_key));		    dirty = 1;		}		if ((get_key_dirid (&ih->ih_key) == get_key_dirid (&(ih + 1)->ih_key)) &&		    (get_key_dirid (&(ih - 1)->ih_key) != get_key_dirid (&(ih + 1)->ih_key)))	    	{		    fsck_log("pass0: vpf-10510: block %lu, item %d: Wrong order of items - " 			"change the dir_id of the key %k to %lu\n",                    	bh->b_blocknr, i - 1, &(ih-1)->ih_key, get_key_dirid (&(ih + 1)->ih_key));		    set_key_dirid (&(ih - 1)->ih_key, get_key_dirid (&(ih + 1)->ih_key));		    dirty = 1;		}            }     	}	if (i && is_stat_data_ih (ih) &&	    get_key_dirid (&(ih - 1)->ih_key) == get_key_dirid (&ih->ih_key) &&	    get_key_objectid (&(ih - 1)->ih_key) >= get_key_objectid (&ih->ih_key)) {	    if ((i + 1 < nr_items) && !is_stat_data_ih (ih + 1)) {         	if (get_key_objectid (&(ih - 1)->ih_key) < get_key_objectid (&(ih + 1)->ih_key)) {		    fsck_log("pass0: vpf-10520: block %lu, item %d: Wrong order of items - "			"change the object_id of the key %k to %lu\n",			bh->b_blocknr, i - 1, &(ih-1)->ih_key, get_key_objectid (&(ih + 1)->ih_key));		    set_key_objectid (&ih->ih_key, get_key_objectid (&(ih + 1)->ih_key));		    dirty = 1;		}	    }	}        if (i && is_stat_data_ih (ih - 1) && !is_stat_data_ih (ih) &&	    (get_key_objectid (&(ih - 1)->ih_key) != get_key_objectid (&ih->ih_key)))        {            int err = 0;            if (i > 1) {                if (comp_short_keys (&(ih - 2)->ih_key, &(ih - 1)->ih_key) != -1)                    misc_set_bit (1, &err);                if (comp_short_keys (&(ih - 2)->ih_key, &ih->ih_key) != -1)                    misc_set_bit (2, &err);            }            if (i + 1 < nr_items) {                if (comp_short_keys (&(ih - 1)->ih_key, &(ih + 1)->ih_key) != -1)                    misc_set_bit (3, &err);                if (comp_short_keys (&ih->ih_key, &(ih + 1)->ih_key) != -1)                    misc_set_bit (4, &err);            }/*            if ((test_bit (1, err) || test_bit (3, err)) &&		(test_bit (2, err) || test_bit (4, err))) {      		// thera are no problem-free keys, delete them both                delete_item (fs, bh, i - 1);                delete_item (fs, bh, i - 1);                goto start_again;      	    }*/            if (!misc_test_bit (1, &err) && !misc_test_bit (3, &err) &&		!misc_test_bit (2, &err) && !misc_test_bit (4, &err)) {      		if (i <= 1) {            	    /* take bigger */                    if (comp_short_keys (&(ih - 1)->ih_key, &ih->ih_key) == 1) {			fsck_log("pass0: vpf-10530: block %lu, item %d: Wrong order of items - "			    "change the object_id of the key %k to %lu\n",                    	    bh->b_blocknr, i, &ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));			set_key_objectid (&ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));                    } else {			fsck_log("pass0: vpf-10540: block %lu, item %d: Wrong order of items - "			    "change the object_id of the key %k to %lu\n",                    	    bh->b_blocknr, i - 1, &(ih - 1)->ih_key, get_key_objectid (&ih->ih_key));                        set_key_objectid (&(ih - 1)->ih_key, get_key_objectid (&ih->ih_key));                    }            	} else {                    /* take smaller */                    if (comp_short_keys (&(ih - 1)->ih_key, &ih->ih_key) == 1) {			fsck_log("pass0: vpf-10550: block %lu, item %d: Wrong order of items - "			    "change the object_id of the key %k to %lu\n",                    	    bh->b_blocknr, i - 1, &(ih - 1)->ih_key, get_key_objectid (&ih->ih_key));                        set_key_objectid (&(ih - 1)->ih_key, get_key_objectid (&ih->ih_key));                    } else {			fsck_log("pass0: vpf-10560: block %lu, item %d: Wrong order of items - "			    "change the object_id of the key %k to %lu\n",                    	    bh->b_blocknr, i, &ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));			set_key_objectid (&ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));                    }                }		dirty = 1;	    } else if (!misc_test_bit (1, &err) && !misc_test_bit (3, &err)) {      		/* take i - 1 */		fsck_log("pass0: vpf-10590: block %lu, item %d: Wrong order of items - "		    "change the object_id of the key %k to %lu\n",                    bh->b_blocknr, i, &ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));		set_key_objectid (&ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));		dirty = 1; 	    } else if (!misc_test_bit (2, &err) && !misc_test_bit (4, &err)) {      		/* take i */		fsck_log("pass0: vpf-10600: block %lu, item %d: Wrong order of items - "		    "change the object_id of the key %k to %lu\n",              	    bh->b_blocknr, i - 1, &(ih - 1)->ih_key, get_key_objectid (&ih->ih_key));                set_key_objectid (&(ih - 1)->ih_key, get_key_objectid (&ih->ih_key));		dirty = 1;	    }        }	/* this recovers corruptions like the below: 	   1774 1732 0 0	   116262638 1732 1 3	   1774 1736 0 0 */	if (i && is_stat_data_ih (ih - 1) && !is_stat_data_ih (ih)) {	    if (get_key_objectid (&ih->ih_key) != get_key_objectid (&(ih - 1)->ih_key) ||		get_key_dirid (&ih->ih_key) != get_key_dirid (&(ih - 1)->ih_key) ||		get_offset (&ih->ih_key) != 1) {		if (is_direntry_ih (ih)) {		    fsck_log ("pass0: vpf-10160: block %lu: item %d: No \".\" entry found in "			      "the first item of a directory\n", bh->b_blocknr, i);		    set_key_dirid (&ih->ih_key, get_key_dirid (&(ih - 1)->ih_key));		    set_key_objectid (&ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));		    dirty = 1;		} else {		    fsck_log ("pass0: vpf-10170: block %lu: item %d: Wrong order of items - "			"the item \n\t%H fixed to ", bh->b_blocknr, i, ih);		    		    set_key_dirid (&ih->ih_key, get_key_dirid (&(ih - 1)->ih_key));		    set_key_objectid (&ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));		    		    if (get_ih_item_len (ih - 1) == SD_SIZE) {			/* stat data is new, therefore this item is new too */			set_offset (KEY_FORMAT_2, &(ih->ih_key), 1);			if ((get_ih_entry_count (ih) != 0xffff) && (get_ih_item_len (ih) % 4 == 0))			    set_type (KEY_FORMAT_2, &(ih->ih_key), TYPE_INDIRECT);			else			    set_type (KEY_FORMAT_2, &(ih->ih_key), TYPE_DIRECT);			set_ih_key_format (ih, KEY_FORMAT_2);		    } else {			/* stat data is old, therefore this item is old too */			set_offset (KEY_FORMAT_1, &(ih->ih_key), 1);			if ((get_ih_entry_count (ih) != 0xffff) && (get_ih_item_len (ih) % 4 == 0))			    set_type (KEY_FORMAT_1, &(ih->ih_key), TYPE_INDIRECT);			else {			    set_type (KEY_FORMAT_1, &(ih->ih_key), TYPE_DIRECT);			    set_ih_free_space (ih, 0xffff);			}			set_ih_key_format (ih, KEY_FORMAT_1);		    }		    fsck_log ("\n\t%H\n", ih);		    dirty = 1;		}	    }	}	/* FIXME: corruptions like:	   56702 66802 1 2	   56702 65536 0 0	   56702 66803 1 2	   do not get recovered (both last items will be deleted) */	/* delete item if it is not in correct order of object items */	if (i && not_of_one_file (&ih->ih_key, &(ih - 1)->ih_key) &&	    !is_stat_data_ih (ih)) {	    fsck_log ("pass0: vpf-10180: block %lu: item %d: The item %k, which follows non StatData item %k, is deleted\n",		      bh->b_blocknr, i, &ih->ih_key, &(ih - 1)->ih_key);	    delete_item (fs, bh, i);	    goto start_again;	}		if (is_stat_data_ih (ih)) {            if (get_offset (&ih->ih_key) != 0) {                set_offset(KEY_FORMAT_1, &ih->ih_key, 0);                dirty = 1;            }	} else if (!is_direntry_ih (ih)) {	    /* not SD, not direntry */            if (i && comp_short_keys (&(ih - 1)->ih_key, &ih->ih_key) == 0) {                if (is_stat_data_ih (ih - 1)) {        	    if (get_offset (&ih->ih_key) != 1) {                        set_offset(key_format(&ih->ih_key), &ih->ih_key, 1);                        dirty = 1;                    }                } else if (is_indirect_ih (ih - 1) && is_direct_ih (ih)) {        	    if (get_offset (&ih->ih_key) !=         	        get_offset(&(ih - 1)->ih_key) + I_UNFM_NUM (ih - 1) * fs->fs_blocksize)         	    {                        set_offset(key_format(&ih->ih_key), &ih->ih_key,                            get_offset(&(ih - 1)->ih_key) + I_UNFM_NUM (ih - 1) * fs->fs_blocksize);                        dirty = 1;        	    }                } else {                    /* if indirect item or not the first direct item in the leaf */                    fsck_log("pass0: vpf-10250: block %lu, item %d: The item %k with wrong type is deleted\n",                         bh->b_blocknr, i, &ih->ih_key);                    delete_item (fs, bh, i);                    goto start_again;                }				/* Check the lenght of the direct item; offset should be ok already. */		if (is_direct_ih (ih)) {		    if (STORE_TAIL_IN_UNFM (get_offset (&ih->ih_key) + get_ih_item_len (ih) - 1, 			    get_ih_item_len (ih), bh->b_size)) 		    {                            fsck_log("pass0: vpf-10700: block %lu, item %d: The item with wrong offset"				" or length found %k, len % lu - deleted\n", bh->b_blocknr, i, &ih->ih_key, 				get_ih_item_len (ih));                            delete_item (fs, bh, i);                            goto start_again;		    }  		}            } else {		/*first item in the node or first item of the file */		  		if (i) {        	    /* first item of the file, but not SD - delete */		    fsck_log("pass0: vpf-10190: block %lu, item %d: The item %k, which follows non StatData"			" item %k, is deleted\n", bh->b_blocknr, i, &ih->ih_key, &(ih - 1)->ih_key );			delete_item (fs, bh, i);			goto start_again;        	}		/* indirect or direct is the first in the leaf */		offset = (__u64)get_offset (&ih->ih_key);		if (is_indirect_ih (ih)) {		    if (offset % fs->fs_blocksize != 1) {			fsck_log("pass0: vpf-10200: block %lu, item %d: The item %k with wrong offset is deleted\n",			    bh->b_blocknr, i, &ih->ih_key);			delete_item (fs, bh, i);			goto start_again;		    }		} else if (is_direct_ih (ih)) {		    if (!correct_direct_item_offset (get_offset (&ih->ih_key), key_format (&ih->ih_key)) ||			((get_offset (&ih->ih_key) % bh->b_size - 1) + get_ih_item_len (ih) > bh->b_size) ||           		STORE_TAIL_IN_UNFM (offset + get_ih_item_len (ih) - 1, get_ih_item_len (ih), bh->b_size)) 		    {                            fsck_log("pass0: vpf-10210: block %lu, item %d: The item with wrong offset ",                                 bh->b_blocknr, i);                            fsck_log("or length found %k, len % lu - deleted\n", &ih->ih_key, get_ih_item_len (ih));                            delete_item (fs, bh, i);                            goto start_again;		    }  		}				offset += get_bytes_number (ih, fs->fs_blocksize);		if (!does_it_fit_into_dev (offset, fs_size)) {                    fsck_log("pass0: vpf-10230: block %lu, item %d: The item offset is is too big %k - deleted\n",                                        bh->b_blocknr, i, &ih->ih_key);                    delete_item (fs, bh, i);                    goto start_again;		}			    }        }                	if (i &&  comp_keys (&(ih - 1)->ih_key, &ih->ih_key) != -1) {	    /* previous item has key not smaller than the key of currect item */	    if (is_stat_data_ih (ih - 1) && !is_stat_data_ih (ih)) {		/* fix key of stat data such as if it was stat data of that item */		fsck_log ("pass0: block %lu, items %d, %d: Wrong order of items - make the StatData item %k of the file %k\n",		    bh->b_blocknr, i - 1, i, &(ih - 1)->ih_key, &ih->ih_key);		set_key_dirid (&(ih - 1)->ih_key, get_key_dirid (&ih->ih_key));		set_key_objectid (&(ih - 1)->ih_key, get_key_objectid (&ih->ih_key));		set_offset (KEY_FORMAT_1, &(ih - 1)->ih_key, 0);		set_type (KEY_FORMAT_1, &(ih - 1)->ih_key, TYPE_STAT_DATA);		dirty = 1;	    } else {		/* ok, we have to delete one of these two - decide which one */		int retval;		/* something will be deleted */		dirty = 1;		retval = upper_correct (bh, ih - 1, i - 1);		switch (retval) {		case 0:		    /* delete upper item */		    fsck_log ("pass0: block %lu, item %d (upper): Item %k is out of order - deleted\n",			      bh->b_blocknr, i - 1, &(ih - 1)->ih_key);		    delete_item (fs, bh, i - 1);		    goto start_again;		case 1:		    /* delete lower item */		    fsck_log ("pass0: block %lu, item %d (lower): Item %k is out of order - deleted\n",			      bh->b_blocknr, i, &ih->ih_key);		    delete_item (fs, bh, i);		    goto start_again;		default:		    /* upper item was the first item of a node */		    /* to make gcc 3.2 do not sware here */;		}		retval = lower_correct (bh, ih, i);		switch (retval) {		case 0:		    /* delete lower item */		    fsck_log ("pass0: block %lu, item %d (lower): Item %k is out of order - deleted\n",			      bh->b_blocknr, i, &ih->ih_key);		    delete_item (fs, bh, i);		    goto start_again;		case 1:		    /* delete upper item */		    fsck_log ("pass0: block %lu, %d (upper): Item %k is out of order - deleted\n",			      bh->b_blocknr, i - 1, &(ih - 1)->ih_key);		    delete_item (fs, bh, i - 1);		    goto start_again;		default:		    /* only 2 items in the node, how to decide what to delete, go and ask user */		    /* to make gcc 3.2 do not sware here */;		}		fsck_log ("pass0: block %lu, items %d and %d: Which of these items looks better (the other will be deleted.)?\n"			  "%k\n%k\n", bh->b_blocknr, i-1, i, &(ih - 1)->ih_key, &ih->ih_key);		if (fsck_user_confirmed (fs, "1 or 2?", "1\n", 1))		    delete_item (fs, bh, i - 1);		else		    delete_item (fs, bh, i);		goto start_again;	    }	}	if (is_stat_data_ih (ih) && (get_ih_item_len (ih) != SD_SIZE &&				     get_ih_item_len (ih) != SD_V1_SIZE)) {	    fsck_log ("pass0: block %lu, item %d: StatData item of wrong length found %H - deleted\n",		      bh->b_blocknr, i, ih);	    delete_item (fs, bh, i);	    goto start_again;

⌨️ 快捷键说明

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