revert-mm-fix-blkdev-size-calculation-in-generic_write_checks
[linux-2.6/linux-trees-mm.git] / fs / reiser4 / plugin / plugin_header.h
blob51e1324f1b9e563aabd5ec1d15c0249d8f26aea9
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 /* Every plugin type can be considered as a class of virtual objects
14 {(type, i) | i = 0, 1, ...}, which has one the following categories
15 of virtualization:
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) */
22 typedef enum {
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 */
39 REISER4_PLUGIN_TYPES
40 } reiser4_plugin_type;
42 /* Supported plugin groups */
43 typedef enum {
44 REISER4_DIRECTORY_FILE,
45 REISER4_REGULAR_FILE,
46 REISER4_SYMLINK_FILE,
47 REISER4_SPECIAL_FILE,
48 } file_plugin_group;
50 struct reiser4_plugin_ops;
51 /* generic plugin operations, supported by each
52 plugin type. */
53 typedef struct reiser4_plugin_ops reiser4_plugin_ops;
55 /* the common part of all plugin instances. */
56 typedef struct plugin_header {
57 /* plugin type */
58 reiser4_plugin_type type_id;
59 /* id of this plugin */
60 reiser4_plugin_id id;
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 */
67 const char *label;
68 /* descriptive string.. */
69 const char *desc;
70 /* list linkage */
71 struct list_head linkage;
72 } plugin_header;
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'. */
85 const char *label;
86 /* plugin type description longer than .label */
87 const char *desc;
89 /* NIKITA-FIXME-HANS: define built-in */
90 /* number of built-in plugin instances of this type */
91 int builtin_num;
92 /* array of built-in plugins */
93 void *builtin;
94 struct list_head plugins_list;
95 size_t size;
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,
104 int i)
106 char *builtin;
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,
133 __le16 *plugin_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__ */
145 #endif
148 * Local variables:
149 * c-indentation-style: "K&R"
150 * mode-name: "LC"
151 * c-basic-offset: 8
152 * tab-width: 8
153 * fill-column: 79
154 * End: