File: sdext_symlink.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 (78 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download | duplicates (8)
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
/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
   reiser4progs/COPYING.
   
   sdext_symlink.c -- symlink stat data extension plugin. */

#include <reiser4/plugin.h>
#ifdef ENABLE_SYMLINKS

reiser4_core_t *sdext_symlink_core = NULL;

static uint32_t sdext_symlink_length(stat_entity_t *stat, void *hint) {
	char *name;
	
	aal_assert("vpf-1843", stat != NULL || hint != NULL);
	
	name = (hint != NULL) ? hint : stat_body(stat);
	return aal_strlen(name) + 1;
}

static errno_t sdext_symlink_open(stat_entity_t *stat, void *hint) {
	char *data;
	uint32_t len;
	
	aal_assert("umka-1483", stat != NULL);
	aal_assert("umka-1484", hint != NULL);

	data = (char *)stat_body(stat);
	len = aal_strlen(data);
	
	aal_memcpy(hint, data, len);
	*((char *)hint + len) = '\0';
	
	return 0;
}

#ifndef ENABLE_MINIMAL
static errno_t sdext_symlink_init(stat_entity_t *stat, void *hint) {
	uint32_t len;
	
	aal_assert("umka-1481", stat != NULL);
	aal_assert("umka-1482", hint != NULL);

	len = aal_strlen((char *)hint);

	aal_memcpy(stat_body(stat), hint, len);
	*((char *)stat_body(stat) + len) = '\0';
	
	return 0;
}

extern errno_t sdext_symlink_check_struct(stat_entity_t *stat, 
					  repair_hint_t *hint);

extern void sdext_symlink_print(stat_entity_t *stat, 
				aal_stream_t *stream, 
				uint16_t options);

#endif

reiser4_sdext_plug_t sdext_symlink_plug = {
	.p = {
		.id    = {SDEXT_SYMLINK_ID, 0, SDEXT_PLUG_TYPE},
#ifndef ENABLE_MINIMAL
		.label = "sdext_symlink",
		.desc  = "Symlink stat data extension plugin.",
#endif
	},
	
#ifndef ENABLE_MINIMAL
	.init	 	= sdext_symlink_init,
	.print   	= sdext_symlink_print,
	.check_struct   = sdext_symlink_check_struct,
#endif		
	.open	 	= sdext_symlink_open,
	.info		= NULL,
	.length		= sdext_symlink_length
};
#endif