File: pset.c

package info (click to toggle)
reiser4progs 1.0.9-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,608 kB
  • ctags: 3,844
  • sloc: ansic: 33,541; sh: 10,679; makefile: 1,010
file content (92 lines) | stat: -rw-r--r-- 2,205 bytes parent folder | download | duplicates (4)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
   reiser4progs/COPYING.
   
   pset.c -- reiser4 plugin set (&heir set) repair functions. */

#include <repair/librepair.h>

extern reiser4_profile_t defprof;
extern rid_t pset_prof[];

errno_t repair_pset_check_backup(backup_hint_t *hint) {
	struct reiser4_pset_backup *pset;
	int present;
	rid_t id;
	char *p;
	int i;
	
	aal_assert("vpf-1909", hint != NULL);
	
	p = hint->block.data + hint->off[BK_PSET];
	present = !aal_strncmp(p, PSET_MAGIC, aal_strlen(PSET_MAGIC));
	if ((hint->version == 0 && present == 1) || 
	    (hint->version > 0 && present == 0))
	{
		return RE_FATAL;
	}
	
	if (hint->version == 0)
		return 0;
	
	pset = (struct reiser4_pset_backup *)(p + aal_strlen(PSET_MAGIC));
	
	for (i = 0; i < PSET_STORE_LAST; i++) {
		id = aal_get_le32(pset, id[i]);
		
		if (id >= defprof.pid[pset_prof[i]].max) 
			return RE_FATAL;
	}
	
	hint->off[BK_PSET + 1] += sizeof(rid_t) * (PSET_STORE_LAST + 5);
	return 0;
}

errno_t repair_pset_root_check(reiser4_fs_t *fs, 
			       reiser4_object_t *root, 
			       uint8_t mode)
{
	struct reiser4_pset_backup *pset;
	rid_t id, root_id;
	int i;
	
	aal_assert("vpf-1910", fs != NULL);
	aal_assert("vpf-1911", root != NULL);
	
	if (!fs->backup)
		return 0;

	pset = (struct reiser4_pset_backup *)
		(fs->backup->hint.block.data + 
		 fs->backup->hint.off[BK_PSET] +
		 aal_strlen(PSET_MAGIC));
	
	/* Check that backed up pset matches the root one. */
	for (i = 0; i < PSET_STORE_LAST; i++) {
		id = aal_get_le32(pset, id[i]);
		
		root_id = fs->tree->ent.param_mask & (1 << i) ? 
			(rid_t)root->info.pset.plug[i] : 
			root->info.pset.plug[i]->id.id;
		
		if (root_id == id)
			continue;

		fsck_mess("The Plugin Set slot %u of the root directory is %u, "
			  "does not match the backed up value %u.%s", i, root_id, 
			  id, mode == RM_BUILD ? " Fixed." : "");
		
		if (mode != RM_BUILD)
			return RE_FATAL;
		
		if (fs->tree->ent.param_mask & (1 << i)) {
			root->info.pset.plug[i] = (void *)id;
		} else {
			root->info.pset.plug[i] = reiser4_factory_ifind(
				defprof.pid[pset_prof[i]].id.type, id);

			aal_assert("vpf-1912", root->info.pset.plug[i] != NULL);
		}
	}
	
	return 0;
}