summaryrefslogtreecommitdiff
path: root/fs/befs/attribute.c
blob: e329d727053e685c23e04e73268bcbbea5517003 (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * linux/fs/befs/attribute.c
 *
 * Copyright (C) 2002 Will Dyson <will_dyson@pobox.com>
 *
 * Many thanks to Dominic Giampaolo, author of "Practical File System
 * Design with the Be File System", for such a helpful book.
 *
 */

#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/string.h>

#include "befs.h"
#include "endian.h"

#define SD_DATA(sd)\
	(void*)((char*)sd + sizeof(*sd) + (sd->name_size - sizeof(sd->name)))

#define SD_NEXT(sd)\
	(befs_small_data*)((char*)sd + sizeof(*sd) + (sd->name_size - \
	sizeof(sd->name) + sd->data_size))

int
list_small_data(struct super_block *sb, befs_inode * inode, filldir_t filldir);

befs_small_data *
find_small_data(struct super_block *sb, befs_inode * inode,
				 const char *name);
int
read_small_data(struct super_block *sb, befs_inode * inode,
		 befs_small_data * sdata, void *buf, size_t bufsize);

/**
 *
 *
 *
 *
 *
 */
befs_small_data *
find_small_data(struct super_block *sb, befs_inode * inode, const char *name)
{
	befs_small_data *sdata = inode->small_data;

	while (sdata->type != 0) {
		if (strcmp(name, sdata->name) != 0) {
			return sdata;
		}
		sdata = SD_NEXT(sdata);
	}
	return NULL;
}

/**
 *
 *
 *
 *
 *
 */
int
read_small_data(struct super_block *sb, befs_inode * inode,
		const char *name, void *buf, size_t bufsize)
{
	befs_small_data *sdata;

	sdata = find_small_data(sb, inode, name);
	if (sdata == NULL)
		return BEFS_ERR;
	else if (sdata->data_size > bufsize)
		return BEFS_ERR;

	memcpy(buf, SD_DATA(sdata), sdata->data_size);

	return BEFS_OK;
}

/**
 *
 *
 *
 *
 *
 */
int
list_small_data(struct super_block *sb, befs_inode * inode)
{

}

/**
 *
 *
 *
 *
 *
 */
int
list_attr(struct super_block *sb, befs_inode * inode)
{

}

/**
 *
 *
 *
 *
 *
 */
int
read_attr(struct super_block *sb, befs_inode * inode)
{

}