Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / befs / attribute.c
blobe329d727053e685c23e04e73268bcbbea5517003
1 /*
2 * linux/fs/befs/attribute.c
4 * Copyright (C) 2002 Will Dyson <will_dyson@pobox.com>
6 * Many thanks to Dominic Giampaolo, author of "Practical File System
7 * Design with the Be File System", for such a helpful book.
9 */
11 #include <linux/fs.h>
12 #include <linux/kernel.h>
13 #include <linux/string.h>
15 #include "befs.h"
16 #include "endian.h"
18 #define SD_DATA(sd)\
19 (void*)((char*)sd + sizeof(*sd) + (sd->name_size - sizeof(sd->name)))
21 #define SD_NEXT(sd)\
22 (befs_small_data*)((char*)sd + sizeof(*sd) + (sd->name_size - \
23 sizeof(sd->name) + sd->data_size))
25 int
26 list_small_data(struct super_block *sb, befs_inode * inode, filldir_t filldir);
28 befs_small_data *
29 find_small_data(struct super_block *sb, befs_inode * inode,
30 const char *name);
31 int
32 read_small_data(struct super_block *sb, befs_inode * inode,
33 befs_small_data * sdata, void *buf, size_t bufsize);
35 /**
42 befs_small_data *
43 find_small_data(struct super_block *sb, befs_inode * inode, const char *name)
45 befs_small_data *sdata = inode->small_data;
47 while (sdata->type != 0) {
48 if (strcmp(name, sdata->name) != 0) {
49 return sdata;
51 sdata = SD_NEXT(sdata);
53 return NULL;
56 /**
63 int
64 read_small_data(struct super_block *sb, befs_inode * inode,
65 const char *name, void *buf, size_t bufsize)
67 befs_small_data *sdata;
69 sdata = find_small_data(sb, inode, name);
70 if (sdata == NULL)
71 return BEFS_ERR;
72 else if (sdata->data_size > bufsize)
73 return BEFS_ERR;
75 memcpy(buf, SD_DATA(sdata), sdata->data_size);
77 return BEFS_OK;
80 /**
87 int
88 list_small_data(struct super_block *sb, befs_inode * inode)
93 /**
101 list_attr(struct super_block *sb, befs_inode * inode)
114 read_attr(struct super_block *sb, befs_inode * inode)