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

📄 obj40_repair.c

📁 reiser4progs ReiserFS V4 ReiserFs官方已经关闭 这个是1.0.6 2006-02-22发布的 给需要的朋友
💻 C
📖 第 1 页 / 共 2 页
字号:
	}	if (ops->check_mode == NULL) {		/* Call the default one. */		fixed = obj40_check_mode(obj, &correct.mode, hint->mode);	} else if (ops->check_mode != SKIP_METHOD) {		fixed = ops->check_mode(obj, &correct.mode, hint->mode);	} else {		fixed = 0;	}	if (fixed) {		fsck_mess("Node (%llu), item (%u), [%s] (%s): wrong mode (%u), "			  "%s (%u).", place_blknr(start), start->pos.item, 			  print_inode(obj40_core, &start->key), 			  start->plug->p.label, lwh.mode, mode == RM_CHECK ? 			  "Should be" : "Fixed to", correct.mode);		res = RE_FIXABLE;	}	if (ops->check_size == NULL) {		/* Call the default one. */		fixed = obj40_check_size(obj, &correct.size, hint->size);	} else if (ops->check_size != SKIP_METHOD) {		fixed = ops->check_size(obj, &correct.size, hint->size);	} else {		fixed = 0;	}	if (fixed) {		fsck_mess("Node (%llu), item (%u), [%s] (%s): wrong size (%llu)"			  ", %s (%llu).", place_blknr(start), start->pos.item, 			  print_inode(obj40_core, &start->key), 			  start->plug->p.label, lwh.size, mode == RM_CHECK ? 			  "Should be" : "Fixed to", correct.size);		res = RE_FIXABLE;	}	if (res && mode != RM_CHECK)		return obj40_write_ext(obj, SDEXT_LW_ID, &correct);		return res;}/*   This is not yet clear how to detect the correct plugin, e.g. formatting,   and figure out if it is essential or not and leave detected or fix evth    to the one from SD. So evth is recovered according to SD plugins, except    essential ones. The knowledge if a pset member is essensial is hardcoded    yet.       obj40_check_plug is used to form the on-disk pset according to already   existent SD pset and tree->pset. Actually used for the root only. */static inline errno_t obj40_stat_pset_check(reiser4_object_t *obj, 					    uint8_t mode, int present) {	reiser4_place_t *start;	sdhint_plug_t plugh;	trans_hint_t trans;	stat_hint_t stat;	uint64_t diff;	uint64_t mask;	errno_t res;	aal_assert("vpf-1650", obj != NULL);		start = &obj->info.start;		/* Get plugins that must exists in the PLUGID extention. */	mask = obj40_core->pset_ops.build_mask(obj->info.tree, &obj->info.pset);	mask &= ((1 << PSET_STORE_LAST) - 1);		if ((diff = (mask != obj->info.pset.plug_mask))) {		fsck_mess("Node (%llu), item (%u), [%s] (%s): wrong plugin "			  "set is stored on disk (0x%llx). %s (0x%llx).",			  place_blknr(start), start->pos.item,			  print_inode(obj40_core, &start->key),			  start->plug->p.label, obj->info.pset.plug_mask,			  mode == RM_CHECK ? "Should be" : "Fixed to",			  mask);	}		if (!diff || mode == RM_CHECK) 		return diff ? RE_FIXABLE : 0;	/* Prepare hints. For removing & adding plug extention. */	aal_memset(&trans, 0, sizeof(trans));	aal_memset(&stat, 0, sizeof(stat));		trans.shift_flags = SF_DEFAULT;	trans.specific = &stat;	trans.plug = start->plug;	start->pos.unit = 0;	stat.extmask = (1 << SDEXT_PSET_ID);	if (present) {		/* Plug extention is the SD is wrong. Remove it first. */		if ((res = obj40_remove(obj, start, &trans)))			return res;				if ((res = obj40_update(obj)))			return res;		if ((res = obj40_fetch_item(&obj->info.start)))			return res;	}		obj->info.pset.plug_mask = mask;		/* Pass plugh there instead of obj->info.pset to not get the 	   altered result after the modification */	aal_memcpy(&plugh, &obj->info.pset, sizeof(plugh));	stat.ext[SDEXT_PSET_ID] = &plugh;		start->pos.unit = 0;		if ((res = obj40_insert(obj, start, &trans, LEAF_LEVEL)))		return res;	return obj40_update(obj);}/* Check the set of SD extentions and their contents. */errno_t obj40_update_stat(reiser4_object_t *obj, obj40_stat_ops_t *ops,			  obj40_stat_hint_t *hint, uint8_t mode){	reiser4_place_t *start;	uint64_t extmask;	errno_t res;		aal_assert("vpf-1213", obj != NULL);		start = &obj->info.start;		/* Update the SD place. */	if ((res = obj40_update(obj)))		return res;		/* Get the set of present SD extentions. */	if ((extmask = obj40_extmask(start)) == MAX_UINT64) {		aal_error("Node (%llu), item (%u), (%s): failed "			  "to obtain the StatData extention mask.",			  place_blknr(start), start->pos.item,			  start->plug->p.label);		return -EIO;	}	/* Remove unknown SD extentions. */	if (extmask & reiser4_psobj(obj)->sdext_unknown) {		trans_hint_t trans;		stat_hint_t stat;				aal_memset(&trans, 0, sizeof(trans));		aal_memset(&stat, 0, sizeof(stat));				stat.extmask = extmask & reiser4_psobj(obj)->sdext_unknown;				fsck_mess("Node (%llu), item (%u), [%s]: StatData has some "			  "unknown extentions (mask=%llu).%s Plugin (%s).",			  place_blknr(start), start->pos.item, 			  print_inode(obj40_core, &start->key),			  stat.extmask, mode != RM_CHECK ? 			  " Removed." : "", start->plug->p.label);		if (mode != RM_CHECK) {			trans.specific = &stat;			trans.shift_flags = SF_DEFAULT;			start->pos.unit = 0;			trans.count = 0;			if ((res = obj40_remove(obj, start, &trans)))				return res;			/* Update the SD place. */			if ((res = obj40_update(obj)))				return res;			if ((res = obj40_fetch_item(&obj->info.start)))				return res;		}	}		/* Check the UNIX extention. */	if ((res = obj40_stat_unix_check(obj, ops, hint, mode,					 extmask & (1 << SDEXT_UNIX_ID))) < 0)	{		return res;	}		/* Check the LW extension. */	if ((res |= obj40_stat_lw_check(obj, ops, hint, mode, 					extmask & (1 << SDEXT_LW_ID))) < 0)	{		return res;	}		/* Check the Plugin SET extention. */	if ((res |= obj40_stat_pset_check(obj, mode, 					  extmask & (1 << SDEXT_PSET_ID))) < 0)	{		return res;	}		/* The sdext_sym & sdext_crc are either mandatory or unknown.	   Nothing to check there. */		return res;}errno_t obj40_prepare_stat(reiser4_object_t *obj, uint16_t objmode, uint8_t mode) {	reiser4_place_t *start;	trans_hint_t trans;	reiser4_key_t *key;	lookup_t lookup;	errno_t res;	aal_assert("vpf-1225", obj != NULL);		start = STAT_PLACE(obj);	key = &obj->info.object;	/* Update the place of SD. */	if ((lookup = obj40_find_item(obj, key, FIND_EXACT, 				      NULL, NULL, start)) < 0)		return lookup;	if (lookup == PRESENT) {		/* Check if SD item is found. */		if (start->plug->p.id.group == STAT_ITEM)			return 0;				/* Not SD item is found. Possible only when a fake		   object was created. */		fsck_mess("Node (%llu), item (%u), (%s): not "			  "StatData is found by the key (%s).%s",			  place_blknr(start), start->pos.item, 			  start->plug->p.label, print_key(obj40_core, key),			  mode == RM_BUILD ? "Removed." : "");		if (mode != RM_BUILD)			return RE_FATAL;		aal_memset(&trans, 0, sizeof(trans));		trans.shift_flags = SF_DEFAULT;		trans.count = 1;		start->pos.unit = MAX_UINT32;		if ((res = obj40_remove(obj, start, &trans)))			return res;	}	/* SD is absent. Create a new one. 	   THIS IS THE SPECIAL CASE and usually is not used as object plugin 	   cannot be recognized w/out SD. Used for for "/" and "lost+found" 	   recovery only. */		fsck_mess("The file [%s] does not have a StatData item.%s Plugin %s.",		  print_inode(obj40_core, key), mode == RM_BUILD ? " Creating "		  "a new one." : "",  reiser4_psobj(obj)->p.label);	if (mode != RM_BUILD)		return RE_FATAL;		if ((res = obj40_create_stat(obj, 0, 0, 0, 0, objmode, 				     objmode == S_IFLNK ? "FAKE_LINK" : NULL)))	{		aal_error("The file [%s] failed to create a StatData item. "			  "Plugin %s.", print_inode(obj40_core, key),			  reiser4_psobj(obj)->p.label);	}	return res;}lookup_t obj40_check_item(reiser4_object_t *obj, 			  obj_func_t item_func,			  obj_func_t update_func,			  void *data){	object_info_t *info;	trans_hint_t trans;	errno_t res;			info = &obj->info;		while (1) {		res = obj40_update_body(obj, update_func);		if (res != PRESENT && res != -ESTRUCT)			return res;				if ((res = item_func(obj, data)) && res != -ESTRUCT)			return res;				if (res == 0)			return PRESENT;				aal_memset(&trans, 0, sizeof(trans));				trans.count = 1;		trans.shift_flags = SF_DEFAULT & ~SF_ALLOW_PACK;		obj->body.pos.unit = MAX_UINT32;				/* Item has wrong key, remove it. */		if ((res = obj40_remove(obj, &obj->body, &trans)) < 0)			return res;	}}#endif

⌨️ 快捷键说明

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