2 #define DEBUG_SUBSYSTEM S_FILTER
6 #include <linux/module.h>
7 #include <linux/kmod.h>
8 #include <linux/slab.h>
9 #include <linux/extN_fs.h>
10 #include <linux/extN_jbd.h>
11 #include <linux/extN_xattr.h>
12 #include <linux/kp30.h>
13 #include <linux/lustre_fsfilt.h>
15 LIST_HEAD(fsfilt_types);
17 static struct fsfilt_operations *fsfilt_search_type(const char *type)
19 struct fsfilt_operations *found;
22 list_for_each(p, &fsfilt_types) {
23 found = list_entry(p, struct fsfilt_operations, fs_list);
24 if (!strcmp(found->fs_type, type)) {
31 int fsfilt_register_ops(struct fsfilt_operations *fs_ops)
33 struct fsfilt_operations *found;
35 /* lock fsfilt_types list */
36 if ((found = fsfilt_search_type(fs_ops->fs_type))) {
37 if (found != fs_ops) {
38 CERROR("different operations for type %s\n",
40 /* unlock fsfilt_types list */
45 list_add(&fs_ops->fs_list, &fsfilt_types);
48 /* unlock fsfilt_types list */
52 void fsfilt_unregister_ops(struct fsfilt_operations *fs_ops)
56 /* lock fsfilt_types list */
57 list_for_each(p, &fsfilt_types) {
58 struct fsfilt_operations *found;
60 found = list_entry(p, typeof(*found), fs_list);
61 if (found == fs_ops) {
67 /* unlock fsfilt_types list */
70 struct fsfilt_operations *fsfilt_get_ops(char *type)
72 struct fsfilt_operations *fs_ops;
74 /* lock fsfilt_types list */
75 if (!(fs_ops = fsfilt_search_type(type))) {
79 snprintf(name, sizeof(name) - 1, "fsfilt_%s", type);
80 name[sizeof(name) - 1] = '\0';
82 if ((rc = request_module(name))) {
83 fs_ops = fsfilt_search_type(type);
84 CDEBUG(D_INFO, "Loaded module '%s'\n", name);
90 CERROR("Can't find fsfilt_%s interface\n", name);
92 /* unlock fsfilt_types list */
95 __MOD_INC_USE_COUNT(fs_ops->fs_owner);
96 /* unlock fsfilt_types list */
101 void fsfilt_put_ops(struct fsfilt_operations *fs_ops)
103 __MOD_DEC_USE_COUNT(fs_ops->fs_owner);
107 EXPORT_SYMBOL(fsfilt_register_ops);
108 EXPORT_SYMBOL(fsfilt_unregister_ops);
109 EXPORT_SYMBOL(fsfilt_get_ops);
110 EXPORT_SYMBOL(fsfilt_put_ops);