17 #include <linux/module.h>
18 #include <linux/string.h>
19 #include <linux/slab.h>
21 #include <linux/capability.h>
54 ret = boot_kobj->
show(boot_kobj->
data, boot_attr->
type, str);
58 static const struct sysfs_ops iscsi_boot_attr_ops = {
59 .show = iscsi_boot_show_attribute,
62 static void iscsi_boot_kobj_release(
struct kobject *kobj)
72 static struct kobj_type iscsi_boot_ktype = {
73 .release = iscsi_boot_kobj_release,
74 .sysfs_ops = &iscsi_boot_attr_ops,
77 #define iscsi_boot_rd_attr(fnname, sysfs_name, attr_type) \
78 static struct iscsi_boot_attr iscsi_boot_attr_##fnname = { \
79 .attr = { .name = __stringify(sysfs_name), .mode = 0444 }, \
99 static struct attribute *target_attrs[] = {
100 &iscsi_boot_attr_tgt_index.attr,
101 &iscsi_boot_attr_tgt_flags.attr,
102 &iscsi_boot_attr_tgt_ip.attr,
103 &iscsi_boot_attr_tgt_port.attr,
104 &iscsi_boot_attr_tgt_lun.attr,
105 &iscsi_boot_attr_tgt_chap.attr,
106 &iscsi_boot_attr_tgt_nic.attr,
107 &iscsi_boot_attr_tgt_name.attr,
108 &iscsi_boot_attr_tgt_chap_name.attr,
109 &iscsi_boot_attr_tgt_chap_secret.attr,
110 &iscsi_boot_attr_tgt_chap_rev_name.attr,
111 &iscsi_boot_attr_tgt_chap_rev_secret.attr,
115 static umode_t iscsi_boot_tgt_attr_is_visible(
struct kobject *kobj,
121 if (attr == &iscsi_boot_attr_tgt_index.attr)
124 else if (attr == &iscsi_boot_attr_tgt_flags.attr)
127 else if (attr == &iscsi_boot_attr_tgt_ip.attr)
130 else if (attr == &iscsi_boot_attr_tgt_port.attr)
133 else if (attr == &iscsi_boot_attr_tgt_lun.attr)
136 else if (attr == &iscsi_boot_attr_tgt_chap.attr)
139 else if (attr == &iscsi_boot_attr_tgt_nic.attr)
142 else if (attr == &iscsi_boot_attr_tgt_name.attr)
145 else if (attr == &iscsi_boot_attr_tgt_chap_name.attr)
148 else if (attr == &iscsi_boot_attr_tgt_chap_secret.attr)
151 else if (attr == &iscsi_boot_attr_tgt_chap_rev_name.attr)
154 else if (attr == &iscsi_boot_attr_tgt_chap_rev_secret.attr)
161 .attrs = target_attrs,
162 .is_visible = iscsi_boot_tgt_attr_is_visible,
180 static struct attribute *ethernet_attrs[] = {
181 &iscsi_boot_attr_eth_index.attr,
182 &iscsi_boot_attr_eth_flags.attr,
183 &iscsi_boot_attr_eth_ip.attr,
184 &iscsi_boot_attr_eth_subnet.attr,
185 &iscsi_boot_attr_eth_origin.attr,
186 &iscsi_boot_attr_eth_gateway.attr,
187 &iscsi_boot_attr_eth_primary_dns.attr,
188 &iscsi_boot_attr_eth_secondary_dns.attr,
189 &iscsi_boot_attr_eth_dhcp.attr,
190 &iscsi_boot_attr_eth_vlan.attr,
191 &iscsi_boot_attr_eth_mac.attr,
192 &iscsi_boot_attr_eth_hostname.attr,
196 static umode_t iscsi_boot_eth_attr_is_visible(
struct kobject *kobj,
202 if (attr == &iscsi_boot_attr_eth_index.attr)
205 else if (attr == &iscsi_boot_attr_eth_flags.attr)
208 else if (attr == &iscsi_boot_attr_eth_ip.attr)
211 else if (attr == &iscsi_boot_attr_eth_subnet.attr)
214 else if (attr == &iscsi_boot_attr_eth_origin.attr)
217 else if (attr == &iscsi_boot_attr_eth_gateway.attr)
220 else if (attr == &iscsi_boot_attr_eth_primary_dns.attr)
223 else if (attr == &iscsi_boot_attr_eth_secondary_dns.attr)
226 else if (attr == &iscsi_boot_attr_eth_dhcp.attr)
229 else if (attr == &iscsi_boot_attr_eth_vlan.attr)
232 else if (attr == &iscsi_boot_attr_eth_mac.attr)
235 else if (attr == &iscsi_boot_attr_eth_hostname.attr)
242 .attrs = ethernet_attrs,
243 .is_visible = iscsi_boot_eth_attr_is_visible,
257 static struct attribute *initiator_attrs[] = {
258 &iscsi_boot_attr_ini_index.attr,
259 &iscsi_boot_attr_ini_flags.attr,
260 &iscsi_boot_attr_ini_isns.attr,
261 &iscsi_boot_attr_ini_slp.attr,
262 &iscsi_boot_attr_ini_primary_radius.attr,
263 &iscsi_boot_attr_ini_secondary_radius.attr,
264 &iscsi_boot_attr_ini_name.attr,
268 static umode_t iscsi_boot_ini_attr_is_visible(
struct kobject *kobj,
274 if (attr == &iscsi_boot_attr_ini_index.attr)
277 if (attr == &iscsi_boot_attr_ini_flags.attr)
280 if (attr == &iscsi_boot_attr_ini_isns.attr)
283 if (attr == &iscsi_boot_attr_ini_slp.attr)
286 if (attr == &iscsi_boot_attr_ini_primary_radius.attr)
289 if (attr == &iscsi_boot_attr_ini_secondary_radius.attr)
292 if (attr == &iscsi_boot_attr_ini_name.attr)
300 .attrs = initiator_attrs,
301 .is_visible = iscsi_boot_ini_attr_is_visible,
314 boot_kobj = kzalloc(
sizeof(*boot_kobj),
GFP_KERNEL);
317 INIT_LIST_HEAD(&boot_kobj->
list);
319 boot_kobj->
kobj.kset = boot_kset->
kset;
321 NULL, name, index)) {
375 return iscsi_boot_create_kobj(boot_kset, &iscsi_boot_target_attr_group,
400 return iscsi_boot_create_kobj(boot_kset,
401 &iscsi_boot_initiator_attr_group,
402 "initiator", index, data,
show,
426 return iscsi_boot_create_kobj(boot_kset,
427 &iscsi_boot_ethernet_attr_group,
428 "ethernet%d", index, data,
show,
441 boot_kset = kzalloc(
sizeof(*boot_kset),
GFP_KERNEL);
446 if (!boot_kset->
kset) {
490 iscsi_boot_remove_kobj(boot_kobj);