mod.c (9fec6060d9e48ed7db0dac0e16d0f0f0e615b7f6) | mod.c (72029fe85d8d060b3f966f2dbc36b3c75b5a6532) |
---|---|
1/* 2 * net/9p/9p.c 3 * 4 * 9P entry point 5 * 6 * Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net> 7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> --- 17 unchanged lines hidden (view full) --- 26 27#include <linux/module.h> 28#include <linux/moduleparam.h> 29#include <net/9p/9p.h> 30#include <linux/fs.h> 31#include <linux/parser.h> 32#include <net/9p/transport.h> 33#include <linux/list.h> | 1/* 2 * net/9p/9p.c 3 * 4 * 9P entry point 5 * 6 * Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net> 7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> --- 17 unchanged lines hidden (view full) --- 26 27#include <linux/module.h> 28#include <linux/moduleparam.h> 29#include <net/9p/9p.h> 30#include <linux/fs.h> 31#include <linux/parser.h> 32#include <net/9p/transport.h> 33#include <linux/list.h> |
34#include <linux/spinlock.h> |
|
34 35#ifdef CONFIG_NET_9P_DEBUG 36unsigned int p9_debug_level = 0; /* feature-rific global debug level */ 37EXPORT_SYMBOL(p9_debug_level); 38module_param_named(debug, p9_debug_level, uint, 0); 39MODULE_PARM_DESC(debug, "9P debugging level"); 40#endif 41 42/* 43 * Dynamic Transport Registration Routines 44 * 45 */ 46 | 35 36#ifdef CONFIG_NET_9P_DEBUG 37unsigned int p9_debug_level = 0; /* feature-rific global debug level */ 38EXPORT_SYMBOL(p9_debug_level); 39module_param_named(debug, p9_debug_level, uint, 0); 40MODULE_PARM_DESC(debug, "9P debugging level"); 41#endif 42 43/* 44 * Dynamic Transport Registration Routines 45 * 46 */ 47 |
48static DEFINE_SPINLOCK(v9fs_trans_lock); |
|
47static LIST_HEAD(v9fs_trans_list); | 49static LIST_HEAD(v9fs_trans_list); |
48static struct p9_trans_module *v9fs_default_transport; | |
49 50/** 51 * v9fs_register_trans - register a new transport with 9p 52 * @m: structure describing the transport module and entry points 53 * 54 */ 55void v9fs_register_trans(struct p9_trans_module *m) 56{ | 50 51/** 52 * v9fs_register_trans - register a new transport with 9p 53 * @m: structure describing the transport module and entry points 54 * 55 */ 56void v9fs_register_trans(struct p9_trans_module *m) 57{ |
58 spin_lock(&v9fs_trans_lock); |
|
57 list_add_tail(&m->list, &v9fs_trans_list); | 59 list_add_tail(&m->list, &v9fs_trans_list); |
58 if (m->def) 59 v9fs_default_transport = m; | 60 spin_unlock(&v9fs_trans_lock); |
60} 61EXPORT_SYMBOL(v9fs_register_trans); 62 63/** | 61} 62EXPORT_SYMBOL(v9fs_register_trans); 63 64/** |
64 * v9fs_match_trans - match transport versus registered transports | 65 * v9fs_unregister_trans - unregister a 9p transport 66 * @m: the transport to remove 67 * 68 */ 69void v9fs_unregister_trans(struct p9_trans_module *m) 70{ 71 spin_lock(&v9fs_trans_lock); 72 list_del_init(&m->list); 73 spin_unlock(&v9fs_trans_lock); 74} 75EXPORT_SYMBOL(v9fs_unregister_trans); 76 77/** 78 * v9fs_get_trans_by_name - get transport with the matching name |
65 * @name: string identifying transport 66 * 67 */ | 79 * @name: string identifying transport 80 * 81 */ |
68struct p9_trans_module *v9fs_match_trans(const substring_t *name) | 82struct p9_trans_module *v9fs_get_trans_by_name(const substring_t *name) |
69{ | 83{ |
70 struct list_head *p; 71 struct p9_trans_module *t = NULL; | 84 struct p9_trans_module *t, *found = NULL; |
72 | 85 |
73 list_for_each(p, &v9fs_trans_list) { 74 t = list_entry(p, struct p9_trans_module, list); 75 if (strncmp(t->name, name->from, name->to-name->from) == 0) 76 return t; 77 } 78 return NULL; | 86 spin_lock(&v9fs_trans_lock); 87 88 list_for_each_entry(t, &v9fs_trans_list, list) 89 if (strncmp(t->name, name->from, name->to-name->from) == 0 && 90 try_module_get(t->owner)) { 91 found = t; 92 break; 93 } 94 95 spin_unlock(&v9fs_trans_lock); 96 return found; |
79} | 97} |
80EXPORT_SYMBOL(v9fs_match_trans); | 98EXPORT_SYMBOL(v9fs_get_trans_by_name); |
81 82/** | 99 100/** |
83 * v9fs_default_trans - returns pointer to default transport | 101 * v9fs_get_default_trans - get the default transport |
84 * 85 */ 86 | 102 * 103 */ 104 |
87struct p9_trans_module *v9fs_default_trans(void) | 105struct p9_trans_module *v9fs_get_default_trans(void) |
88{ | 106{ |
89 if (v9fs_default_transport) 90 return v9fs_default_transport; 91 else if (!list_empty(&v9fs_trans_list)) 92 return list_first_entry(&v9fs_trans_list, 93 struct p9_trans_module, list); 94 else 95 return NULL; | 107 struct p9_trans_module *t, *found = NULL; 108 109 spin_lock(&v9fs_trans_lock); 110 111 list_for_each_entry(t, &v9fs_trans_list, list) 112 if (t->def && try_module_get(t->owner)) { 113 found = t; 114 break; 115 } 116 117 if (!found) 118 list_for_each_entry(t, &v9fs_trans_list, list) 119 if (try_module_get(t->owner)) { 120 found = t; 121 break; 122 } 123 124 spin_unlock(&v9fs_trans_lock); 125 return found; |
96} | 126} |
97EXPORT_SYMBOL(v9fs_default_trans); | 127EXPORT_SYMBOL(v9fs_get_default_trans); |
98 | 128 |
129/** 130 * v9fs_put_trans - put trans 131 * @m: transport to put 132 * 133 */ 134void v9fs_put_trans(struct p9_trans_module *m) 135{ 136 if (m) 137 module_put(m->owner); 138} |
|
99 100/** 101 * v9fs_init - Initialize module 102 * 103 */ 104static int __init init_p9(void) 105{ 106 int ret = 0; --- 8 unchanged lines hidden (view full) --- 115/** 116 * v9fs_init - shutdown module 117 * 118 */ 119 120static void __exit exit_p9(void) 121{ 122 printk(KERN_INFO "Unloading 9P2000 support\n"); | 139 140/** 141 * v9fs_init - Initialize module 142 * 143 */ 144static int __init init_p9(void) 145{ 146 int ret = 0; --- 8 unchanged lines hidden (view full) --- 155/** 156 * v9fs_init - shutdown module 157 * 158 */ 159 160static void __exit exit_p9(void) 161{ 162 printk(KERN_INFO "Unloading 9P2000 support\n"); |
163 164 p9_trans_fd_exit(); |
|
123} 124 125module_init(init_p9) 126module_exit(exit_p9) 127 128MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>"); 129MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); 130MODULE_AUTHOR("Ron Minnich <rminnich@lanl.gov>"); 131MODULE_LICENSE("GPL"); | 165} 166 167module_init(init_p9) 168module_exit(exit_p9) 169 170MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>"); 171MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); 172MODULE_AUTHOR("Ron Minnich <rminnich@lanl.gov>"); 173MODULE_LICENSE("GPL"); |