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 */
11 #include "../dformat.h"
13 /* Every plugin type can be considered as a class of virtual objects
14 {(type, i) | i = 0, 1, ...}, which has one the following categories
16 A - no virtualization;
17 F - per-file virtualization;
18 S - per-superblock virtualization;
19 FIXME-EDWARD: Define every such category */
21 /* Supported plugin types: (id, (virtualization category), short description) */
23 REISER4_FILE_PLUGIN_TYPE
, /* (F) service VFS enry-points */
24 REISER4_DIR_PLUGIN_TYPE
, /* (F) service VFS enry-points */
25 REISER4_ITEM_PLUGIN_TYPE
, /* (F) manage items */
26 REISER4_NODE_PLUGIN_TYPE
, /* (S) manage formatted nodes */
27 REISER4_HASH_PLUGIN_TYPE
, /* (F) compute hash */
28 REISER4_FIBRATION_PLUGIN_TYPE
, /* (F) directory fibrations */
29 REISER4_FORMATTING_PLUGIN_TYPE
, /* (F) tail-packing policy */
30 REISER4_PERM_PLUGIN_TYPE
, /* stub (vacancy) */
31 REISER4_SD_EXT_PLUGIN_TYPE
, /* (A) stat-data extensions */
32 REISER4_FORMAT_PLUGIN_TYPE
, /* (S) specify disk format */
33 REISER4_JNODE_PLUGIN_TYPE
, /* (A) in-memory node headers */
34 REISER4_CIPHER_PLUGIN_TYPE
, /* (F) cipher transform algs */
35 REISER4_DIGEST_PLUGIN_TYPE
, /* (F) digest transform algs */
36 REISER4_COMPRESSION_PLUGIN_TYPE
, /* (F) compression tfm algs */
37 REISER4_COMPRESSION_MODE_PLUGIN_TYPE
, /* (F) compression heuristic */
38 REISER4_CLUSTER_PLUGIN_TYPE
, /* (F) size of logical cluster */
40 } reiser4_plugin_type
;
42 /* Supported plugin groups */
44 REISER4_DIRECTORY_FILE
,
50 struct reiser4_plugin_ops
;
51 /* generic plugin operations, supported by each
53 typedef struct reiser4_plugin_ops reiser4_plugin_ops
;
55 /* the common part of all plugin instances. */
56 typedef struct plugin_header
{
58 reiser4_plugin_type type_id
;
59 /* id of this plugin */
61 /* bitmask of groups the plugin belongs to. */
62 reiser4_plugin_groups groups
;
63 /* plugin operations */
64 reiser4_plugin_ops
*pops
;
65 /* NIKITA-FIXME-HANS: usage of and access to label and desc is not commented and defined. */
66 /* short label of this plugin */
68 /* descriptive string.. */
71 struct list_head linkage
;
74 #define plugin_of_group(plug, group) (plug->h.groups & (1 << group))
76 /* PRIVATE INTERFACES */
77 /* NIKITA-FIXME-HANS: what is this for and why does it duplicate what is in plugin_header? */
78 /* plugin type representation. */
79 struct reiser4_plugin_type_data
{
80 /* internal plugin type identifier. Should coincide with
81 index of this item in plugins[] array. */
82 reiser4_plugin_type type_id
;
83 /* short symbolic label of this plugin type. Should be no longer
84 than MAX_PLUGIN_TYPE_LABEL_LEN characters including '\0'. */
86 /* plugin type description longer than .label */
89 /* NIKITA-FIXME-HANS: define built-in */
90 /* number of built-in plugin instances of this type */
92 /* array of built-in plugins */
94 struct list_head plugins_list
;
98 extern struct reiser4_plugin_type_data plugins
[REISER4_PLUGIN_TYPES
];
100 int is_plugin_type_valid(reiser4_plugin_type type
);
101 int is_plugin_id_valid(reiser4_plugin_type type
, reiser4_plugin_id id
);
103 static inline reiser4_plugin
*plugin_at(struct reiser4_plugin_type_data
* ptype
,
108 builtin
= ptype
->builtin
;
109 return (reiser4_plugin
*) (builtin
+ i
* ptype
->size
);
112 /* return plugin by its @type_id and @id */
113 static inline reiser4_plugin
*plugin_by_id(reiser4_plugin_type type
,
114 reiser4_plugin_id id
)
116 assert("nikita-1651", is_plugin_type_valid(type
));
117 assert("nikita-1652", is_plugin_id_valid(type
, id
));
118 return plugin_at(&plugins
[type
], id
);
121 extern reiser4_plugin
*plugin_by_unsafe_id(reiser4_plugin_type type_id
,
122 reiser4_plugin_id id
);
125 * plugin_by_disk_id - get reiser4_plugin
126 * @type_id: plugin type id
127 * @did: plugin id in disk format
129 * Returns reiser4_plugin by plugin type id an dplugin_id.
131 static inline reiser4_plugin
*plugin_by_disk_id(reiser4_tree
* tree UNUSED_ARG
,
132 reiser4_plugin_type type_id
,
136 * what we should do properly is to maintain within each file-system a
137 * dictionary that maps on-disk plugin ids to "universal" ids. This
138 * dictionary will be resolved on mount time, so that this function
139 * will perform just one additional array lookup.
141 return plugin_by_unsafe_id(type_id
, le16_to_cpu(*plugin_id
));
144 /* __PLUGIN_HEADER_H__ */
149 * c-indentation-style: "K&R"