File: sdext_crypto_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 (63 lines) | stat: -rw-r--r-- 1,478 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
/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
   reiser4progs/COPYING.
   
   sdext_crypto_repair.c -- crypto stat data extention plugin repair code. */

#ifndef ENABLE_MINIMAL

#include "sdext_crypto.h"
#include <repair/plugin.h>

void sdext_crypto_print(stat_entity_t *stat, 
			aal_stream_t *stream, 
			uint16_t options) 
{
	sdext_crypto_t *ext;
	uint16_t count, i;
	
	aal_assert("umka-1412", stat != NULL);
	aal_assert("umka-1413", stream != NULL);

	ext = (sdext_crypto_t *)stat_body(stat);
	
	aal_stream_format(stream, "key size:\t\t%u\n\t\t", 
			  sdext_crypto_get_keylen(ext));

	if (!stat->info.digest) {
		aal_stream_format(stream, "<unknown keyid>\n");
		return;
	}

	count = reiser4_keysign_size(stat->info.digest);
	aal_stream_format(stream, "[%u]: ", count);
	
	for (i = 0; i < count; i++)
		aal_stream_format(stream, "%.2x", ext->sign[i]);

	aal_stream_format(stream, "\n");
}

errno_t sdext_crypto_check_struct(stat_entity_t *stat, 
				  repair_hint_t *hint)
{
	uint32_t len;
	
	aal_assert("vpf-1845", stat != NULL);
	aal_assert("vpf-1846", stat->plug != NULL);

	len = sdext_crypto_length(stat, NULL);
	
	if (stat->offset + len > stat->place->len) {
		fsck_mess("Node (%llu), item (%u), [%s]: does not look "
			  "like a valid (%s) statdata extension.", 
			  place_blknr(stat->place), stat->place->pos.item,
			  print_key(sdext_crypto_core, &stat->place->key), 
			  stat->plug->p.label);
		
		return RE_FATAL;
	}

	return 0;
}

#endif