mm-only debug patch...
[mmotm.git] / fs / reiser4 / plugin / plugin_header.h
blobf6e54044d7871eb08c4df76f6ff510bf0f688c0f
1 /* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */
3 /* plugin header. Data structures required by all plugin types. */
5 #if !defined(__PLUGIN_HEADER_H__)
6 #define __PLUGIN_HEADER_H__
8 /* plugin data-types and constants */
10 #include "../debug.h"
11 #include "../dformat.h"
13 /* The list of Reiser4 interfaces */
14 typedef enum {
15 REISER4_FILE_PLUGIN_TYPE, /* manage VFS objects */
16 REISER4_DIR_PLUGIN_TYPE, /* manage directories */
17 REISER4_ITEM_PLUGIN_TYPE, /* manage items */
18 REISER4_NODE_PLUGIN_TYPE, /* manage formatted nodes */
19 REISER4_HASH_PLUGIN_TYPE, /* hash methods */
20 REISER4_FIBRATION_PLUGIN_TYPE, /* directory fibrations */
21 REISER4_FORMATTING_PLUGIN_TYPE, /* dispatching policy */
22 REISER4_PERM_PLUGIN_TYPE, /* stub (vacancy) */
23 REISER4_SD_EXT_PLUGIN_TYPE, /* manage stat-data extensions */
24 REISER4_FORMAT_PLUGIN_TYPE, /* disk format specifications */
25 REISER4_JNODE_PLUGIN_TYPE, /* manage in-memory headers */
26 REISER4_CIPHER_PLUGIN_TYPE, /* cipher transform methods */
27 REISER4_DIGEST_PLUGIN_TYPE, /* digest transform methods */
28 REISER4_COMPRESSION_PLUGIN_TYPE, /* compression methods */
29 REISER4_COMPRESSION_MODE_PLUGIN_TYPE, /* dispatching policies */
30 REISER4_CLUSTER_PLUGIN_TYPE, /* manage logical clusters */
31 REISER4_PLUGIN_TYPES
32 } reiser4_plugin_type;
34 /* Supported plugin groups */
35 typedef enum {
36 REISER4_DIRECTORY_FILE,
37 REISER4_REGULAR_FILE,
38 REISER4_SYMLINK_FILE,
39 REISER4_SPECIAL_FILE,
40 } file_plugin_group;
42 struct reiser4_plugin_ops;
43 /* generic plugin operations, supported by each
44 plugin type. */
45 typedef struct reiser4_plugin_ops reiser4_plugin_ops;
47 /* the common part of all plugin instances. */
48 typedef struct plugin_header {
49 /* plugin type */
50 reiser4_plugin_type type_id;
51 /* id of this plugin */
52 reiser4_plugin_id id;
53 /* bitmask of groups the plugin belongs to. */
54 reiser4_plugin_groups groups;
55 /* plugin operations */
56 reiser4_plugin_ops *pops;
57 /* NIKITA-FIXME-HANS: usage of and access to label and desc is not commented and
58 * defined. */
59 /* short label of this plugin */
60 const char *label;
61 /* descriptive string.. */
62 const char *desc;
63 /* list linkage */
64 struct list_head linkage;
65 } plugin_header;
67 #define plugin_of_group(plug, group) (plug->h.groups & (1 << group))
69 /* PRIVATE INTERFACES */
70 /* NIKITA-FIXME-HANS: what is this for and why does it duplicate what is in
71 * plugin_header? */
72 /* plugin type representation. */
73 struct reiser4_plugin_type_data {
74 /* internal plugin type identifier. Should coincide with
75 index of this item in plugins[] array. */
76 reiser4_plugin_type type_id;
77 /* short symbolic label of this plugin type. Should be no longer
78 than MAX_PLUGIN_TYPE_LABEL_LEN characters including '\0'. */
79 const char *label;
80 /* plugin type description longer than .label */
81 const char *desc;
83 /* NIKITA-FIXME-HANS: define built-in */
84 /* number of built-in plugin instances of this type */
85 int builtin_num;
86 /* array of built-in plugins */
87 void *builtin;
88 struct list_head plugins_list;
89 size_t size;
92 extern struct reiser4_plugin_type_data plugins[REISER4_PLUGIN_TYPES];
94 int is_plugin_type_valid(reiser4_plugin_type type);
95 int is_plugin_id_valid(reiser4_plugin_type type, reiser4_plugin_id id);
97 static inline reiser4_plugin *plugin_at(struct reiser4_plugin_type_data *ptype,
98 int i)
100 char *builtin;
102 builtin = ptype->builtin;
103 return (reiser4_plugin *) (builtin + i * ptype->size);
106 /* return plugin by its @type_id and @id */
107 static inline reiser4_plugin *plugin_by_id(reiser4_plugin_type type,
108 reiser4_plugin_id id)
110 assert("nikita-1651", is_plugin_type_valid(type));
111 assert("nikita-1652", is_plugin_id_valid(type, id));
112 return plugin_at(&plugins[type], id);
115 extern reiser4_plugin *plugin_by_unsafe_id(reiser4_plugin_type type_id,
116 reiser4_plugin_id id);
119 * plugin_by_disk_id - get reiser4_plugin
120 * @type_id: plugin type id
121 * @did: plugin id in disk format
123 * Returns reiser4_plugin by plugin type id an dplugin_id.
125 static inline reiser4_plugin *plugin_by_disk_id(reiser4_tree * tree UNUSED_ARG,
126 reiser4_plugin_type type_id,
127 __le16 *plugin_id)
130 * what we should do properly is to maintain within each file-system a
131 * dictionary that maps on-disk plugin ids to "universal" ids. This
132 * dictionary will be resolved on mount time, so that this function
133 * will perform just one additional array lookup.
135 return plugin_by_unsafe_id(type_id, le16_to_cpu(*plugin_id));
138 /* __PLUGIN_HEADER_H__ */
139 #endif
142 * Local variables:
143 * c-indentation-style: "K&R"
144 * mode-name: "LC"
145 * c-basic-offset: 8
146 * tab-width: 8
147 * fill-column: 79
148 * End: