File: nodeptr40_repair.c

package info (click to toggle)
reiser4progs 1.0.6-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,348 kB
  • ctags: 3,714
  • sloc: ansic: 33,468; sh: 8,489; makefile: 1,012
file content (65 lines) | stat: -rw-r--r-- 1,474 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* Copyright 2001-2005 by Hans Reiser, licensing governed by
   reiser4progs/COPYING.
   
   nodeptr40_repair.c -- repair default node pointer item plugin methods. */

#ifndef ENABLE_MINIMAL
#include "nodeptr40.h"
#include <repair/plugin.h>

errno_t nodeptr40_check_layout(reiser4_place_t *place, 
			       repair_hint_t *hint,
			       region_func_t region_func, 
			       void *data)
{
	nodeptr40_t *nodeptr;
	blk_t blk;
	errno_t res;
	
	aal_assert("vpf-721", place != NULL);
	
	nodeptr = nodeptr40_body(place);
	
	blk = np40_get_ptr(nodeptr);
	
	res = region_func(blk, 1, data);
	
	if (res > 0) {
		fsck_mess("Node (%llu), item (%u): wrong pointer to "
			  "the block %llu.%s", place_blknr(place),
			  place->pos.item, blk, hint->mode == RM_BUILD ?
			  " Removed." : "");

		if (hint->mode == RM_BUILD) {
			hint->len = place->len;
			return 0;
		}
		
		return RE_FATAL;
	} else if (res < 0) {
		return res;
	}
	
	return 0;
}

errno_t nodeptr40_check_struct(reiser4_place_t *place, repair_hint_t *hint) {
	aal_assert("vpf-751", place != NULL);
	return place->len != sizeof(nodeptr40_t) ? RE_FATAL : 0;
}

/* Prints passed nodeptr into @stream */
void nodeptr40_print(reiser4_place_t *place, aal_stream_t *stream,
		     uint16_t options)
{
	nodeptr40_t *nodeptr;
	
	aal_assert("umka-544", place != NULL);
	aal_assert("umka-545", stream != NULL);
    
	nodeptr = nodeptr40_body(place);

	aal_stream_format(stream, " [%llu]\n", 
			  np40_get_ptr(nodeptr));
}
#endif