iscsi_boot_sysfs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /*
  2. * Export the iSCSI boot info to userland via sysfs.
  3. *
  4. * Copyright (C) 2010 Red Hat, Inc. All rights reserved.
  5. * Copyright (C) 2010 Mike Christie
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License v2.0 as published by
  9. * the Free Software Foundation
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/string.h>
  18. #include <linux/slab.h>
  19. #include <linux/sysfs.h>
  20. #include <linux/capability.h>
  21. #include <linux/iscsi_boot_sysfs.h>
  22. MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu>");
  23. MODULE_DESCRIPTION("sysfs interface and helpers to export iSCSI boot information");
  24. MODULE_LICENSE("GPL");
  25. /*
  26. * The kobject and attribute structures.
  27. */
  28. struct iscsi_boot_attr {
  29. struct attribute attr;
  30. int type;
  31. ssize_t (*show) (void *data, int type, char *buf);
  32. };
  33. /*
  34. * The routine called for all sysfs attributes.
  35. */
  36. static ssize_t iscsi_boot_show_attribute(struct kobject *kobj,
  37. struct attribute *attr, char *buf)
  38. {
  39. struct iscsi_boot_kobj *boot_kobj =
  40. container_of(kobj, struct iscsi_boot_kobj, kobj);
  41. struct iscsi_boot_attr *boot_attr =
  42. container_of(attr, struct iscsi_boot_attr, attr);
  43. ssize_t ret = -EIO;
  44. char *str = buf;
  45. if (!capable(CAP_SYS_ADMIN))
  46. return -EACCES;
  47. if (boot_kobj->show)
  48. ret = boot_kobj->show(boot_kobj->data, boot_attr->type, str);
  49. return ret;
  50. }
  51. static const struct sysfs_ops iscsi_boot_attr_ops = {
  52. .show = iscsi_boot_show_attribute,
  53. };
  54. static void iscsi_boot_kobj_release(struct kobject *kobj)
  55. {
  56. struct iscsi_boot_kobj *boot_kobj =
  57. container_of(kobj, struct iscsi_boot_kobj, kobj);
  58. kfree(boot_kobj->data);
  59. kfree(boot_kobj);
  60. }
  61. static struct kobj_type iscsi_boot_ktype = {
  62. .release = iscsi_boot_kobj_release,
  63. .sysfs_ops = &iscsi_boot_attr_ops,
  64. };
  65. #define iscsi_boot_rd_attr(fnname, sysfs_name, attr_type) \
  66. static struct iscsi_boot_attr iscsi_boot_attr_##fnname = { \
  67. .attr = { .name = __stringify(sysfs_name), .mode = 0444 }, \
  68. .type = attr_type, \
  69. }
  70. /* Target attrs */
  71. iscsi_boot_rd_attr(tgt_index, index, ISCSI_BOOT_TGT_INDEX);
  72. iscsi_boot_rd_attr(tgt_flags, flags, ISCSI_BOOT_TGT_FLAGS);
  73. iscsi_boot_rd_attr(tgt_ip, ip-addr, ISCSI_BOOT_TGT_IP_ADDR);
  74. iscsi_boot_rd_attr(tgt_port, port, ISCSI_BOOT_TGT_PORT);
  75. iscsi_boot_rd_attr(tgt_lun, lun, ISCSI_BOOT_TGT_LUN);
  76. iscsi_boot_rd_attr(tgt_chap, chap-type, ISCSI_BOOT_TGT_CHAP_TYPE);
  77. iscsi_boot_rd_attr(tgt_nic, nic-assoc, ISCSI_BOOT_TGT_NIC_ASSOC);
  78. iscsi_boot_rd_attr(tgt_name, target-name, ISCSI_BOOT_TGT_NAME);
  79. iscsi_boot_rd_attr(tgt_chap_name, chap-name, ISCSI_BOOT_TGT_CHAP_NAME);
  80. iscsi_boot_rd_attr(tgt_chap_secret, chap-secret, ISCSI_BOOT_TGT_CHAP_SECRET);
  81. iscsi_boot_rd_attr(tgt_chap_rev_name, rev-chap-name,
  82. ISCSI_BOOT_TGT_REV_CHAP_NAME);
  83. iscsi_boot_rd_attr(tgt_chap_rev_secret, rev-chap-name-secret,
  84. ISCSI_BOOT_TGT_REV_CHAP_SECRET);
  85. static struct attribute *target_attrs[] = {
  86. &iscsi_boot_attr_tgt_index.attr,
  87. &iscsi_boot_attr_tgt_flags.attr,
  88. &iscsi_boot_attr_tgt_ip.attr,
  89. &iscsi_boot_attr_tgt_port.attr,
  90. &iscsi_boot_attr_tgt_lun.attr,
  91. &iscsi_boot_attr_tgt_chap.attr,
  92. &iscsi_boot_attr_tgt_nic.attr,
  93. &iscsi_boot_attr_tgt_name.attr,
  94. &iscsi_boot_attr_tgt_chap_name.attr,
  95. &iscsi_boot_attr_tgt_chap_secret.attr,
  96. &iscsi_boot_attr_tgt_chap_rev_name.attr,
  97. &iscsi_boot_attr_tgt_chap_rev_secret.attr,
  98. NULL
  99. };
  100. static mode_t iscsi_boot_tgt_attr_is_visible(struct kobject *kobj,
  101. struct attribute *attr, int i)
  102. {
  103. struct iscsi_boot_kobj *boot_kobj =
  104. container_of(kobj, struct iscsi_boot_kobj, kobj);
  105. if (attr == &iscsi_boot_attr_tgt_index.attr)
  106. return boot_kobj->is_visible(boot_kobj->data,
  107. ISCSI_BOOT_TGT_INDEX);
  108. else if (attr == &iscsi_boot_attr_tgt_flags.attr)
  109. return boot_kobj->is_visible(boot_kobj->data,
  110. ISCSI_BOOT_TGT_FLAGS);
  111. else if (attr == &iscsi_boot_attr_tgt_ip.attr)
  112. return boot_kobj->is_visible(boot_kobj->data,
  113. ISCSI_BOOT_TGT_IP_ADDR);
  114. else if (attr == &iscsi_boot_attr_tgt_port.attr)
  115. return boot_kobj->is_visible(boot_kobj->data,
  116. ISCSI_BOOT_TGT_PORT);
  117. else if (attr == &iscsi_boot_attr_tgt_lun.attr)
  118. return boot_kobj->is_visible(boot_kobj->data,
  119. ISCSI_BOOT_TGT_LUN);
  120. else if (attr == &iscsi_boot_attr_tgt_chap.attr)
  121. return boot_kobj->is_visible(boot_kobj->data,
  122. ISCSI_BOOT_TGT_CHAP_TYPE);
  123. else if (attr == &iscsi_boot_attr_tgt_nic.attr)
  124. return boot_kobj->is_visible(boot_kobj->data,
  125. ISCSI_BOOT_TGT_NIC_ASSOC);
  126. else if (attr == &iscsi_boot_attr_tgt_name.attr)
  127. return boot_kobj->is_visible(boot_kobj->data,
  128. ISCSI_BOOT_TGT_NAME);
  129. else if (attr == &iscsi_boot_attr_tgt_chap_name.attr)
  130. return boot_kobj->is_visible(boot_kobj->data,
  131. ISCSI_BOOT_TGT_CHAP_NAME);
  132. else if (attr == &iscsi_boot_attr_tgt_chap_secret.attr)
  133. return boot_kobj->is_visible(boot_kobj->data,
  134. ISCSI_BOOT_TGT_CHAP_SECRET);
  135. else if (attr == &iscsi_boot_attr_tgt_chap_rev_name.attr)
  136. return boot_kobj->is_visible(boot_kobj->data,
  137. ISCSI_BOOT_TGT_REV_CHAP_NAME);
  138. else if (attr == &iscsi_boot_attr_tgt_chap_rev_secret.attr)
  139. return boot_kobj->is_visible(boot_kobj->data,
  140. ISCSI_BOOT_TGT_REV_CHAP_SECRET);
  141. return 0;
  142. }
  143. static struct attribute_group iscsi_boot_target_attr_group = {
  144. .attrs = target_attrs,
  145. .is_visible = iscsi_boot_tgt_attr_is_visible,
  146. };
  147. /* Ethernet attrs */
  148. iscsi_boot_rd_attr(eth_index, index, ISCSI_BOOT_ETH_INDEX);
  149. iscsi_boot_rd_attr(eth_flags, flags, ISCSI_BOOT_ETH_FLAGS);
  150. iscsi_boot_rd_attr(eth_ip, ip-addr, ISCSI_BOOT_ETH_IP_ADDR);
  151. iscsi_boot_rd_attr(eth_subnet, subnet-mask, ISCSI_BOOT_ETH_SUBNET_MASK);
  152. iscsi_boot_rd_attr(eth_origin, origin, ISCSI_BOOT_ETH_ORIGIN);
  153. iscsi_boot_rd_attr(eth_gateway, gateway, ISCSI_BOOT_ETH_GATEWAY);
  154. iscsi_boot_rd_attr(eth_primary_dns, primary-dns, ISCSI_BOOT_ETH_PRIMARY_DNS);
  155. iscsi_boot_rd_attr(eth_secondary_dns, secondary-dns,
  156. ISCSI_BOOT_ETH_SECONDARY_DNS);
  157. iscsi_boot_rd_attr(eth_dhcp, dhcp, ISCSI_BOOT_ETH_DHCP);
  158. iscsi_boot_rd_attr(eth_vlan, vlan, ISCSI_BOOT_ETH_VLAN);
  159. iscsi_boot_rd_attr(eth_mac, mac, ISCSI_BOOT_ETH_MAC);
  160. iscsi_boot_rd_attr(eth_hostname, hostname, ISCSI_BOOT_ETH_HOSTNAME);
  161. static struct attribute *ethernet_attrs[] = {
  162. &iscsi_boot_attr_eth_index.attr,
  163. &iscsi_boot_attr_eth_flags.attr,
  164. &iscsi_boot_attr_eth_ip.attr,
  165. &iscsi_boot_attr_eth_subnet.attr,
  166. &iscsi_boot_attr_eth_origin.attr,
  167. &iscsi_boot_attr_eth_gateway.attr,
  168. &iscsi_boot_attr_eth_primary_dns.attr,
  169. &iscsi_boot_attr_eth_secondary_dns.attr,
  170. &iscsi_boot_attr_eth_dhcp.attr,
  171. &iscsi_boot_attr_eth_vlan.attr,
  172. &iscsi_boot_attr_eth_mac.attr,
  173. &iscsi_boot_attr_eth_hostname.attr,
  174. NULL
  175. };
  176. static mode_t iscsi_boot_eth_attr_is_visible(struct kobject *kobj,
  177. struct attribute *attr, int i)
  178. {
  179. struct iscsi_boot_kobj *boot_kobj =
  180. container_of(kobj, struct iscsi_boot_kobj, kobj);
  181. if (attr == &iscsi_boot_attr_eth_index.attr)
  182. return boot_kobj->is_visible(boot_kobj->data,
  183. ISCSI_BOOT_ETH_INDEX);
  184. else if (attr == &iscsi_boot_attr_eth_flags.attr)
  185. return boot_kobj->is_visible(boot_kobj->data,
  186. ISCSI_BOOT_ETH_FLAGS);
  187. else if (attr == &iscsi_boot_attr_eth_ip.attr)
  188. return boot_kobj->is_visible(boot_kobj->data,
  189. ISCSI_BOOT_ETH_IP_ADDR);
  190. else if (attr == &iscsi_boot_attr_eth_subnet.attr)
  191. return boot_kobj->is_visible(boot_kobj->data,
  192. ISCSI_BOOT_ETH_SUBNET_MASK);
  193. else if (attr == &iscsi_boot_attr_eth_origin.attr)
  194. return boot_kobj->is_visible(boot_kobj->data,
  195. ISCSI_BOOT_ETH_ORIGIN);
  196. else if (attr == &iscsi_boot_attr_eth_gateway.attr)
  197. return boot_kobj->is_visible(boot_kobj->data,
  198. ISCSI_BOOT_ETH_GATEWAY);
  199. else if (attr == &iscsi_boot_attr_eth_primary_dns.attr)
  200. return boot_kobj->is_visible(boot_kobj->data,
  201. ISCSI_BOOT_ETH_PRIMARY_DNS);
  202. else if (attr == &iscsi_boot_attr_eth_secondary_dns.attr)
  203. return boot_kobj->is_visible(boot_kobj->data,
  204. ISCSI_BOOT_ETH_SECONDARY_DNS);
  205. else if (attr == &iscsi_boot_attr_eth_dhcp.attr)
  206. return boot_kobj->is_visible(boot_kobj->data,
  207. ISCSI_BOOT_ETH_DHCP);
  208. else if (attr == &iscsi_boot_attr_eth_vlan.attr)
  209. return boot_kobj->is_visible(boot_kobj->data,
  210. ISCSI_BOOT_ETH_VLAN);
  211. else if (attr == &iscsi_boot_attr_eth_mac.attr)
  212. return boot_kobj->is_visible(boot_kobj->data,
  213. ISCSI_BOOT_ETH_MAC);
  214. else if (attr == &iscsi_boot_attr_eth_hostname.attr)
  215. return boot_kobj->is_visible(boot_kobj->data,
  216. ISCSI_BOOT_ETH_HOSTNAME);
  217. return 0;
  218. }
  219. static struct attribute_group iscsi_boot_ethernet_attr_group = {
  220. .attrs = ethernet_attrs,
  221. .is_visible = iscsi_boot_eth_attr_is_visible,
  222. };
  223. /* Initiator attrs */
  224. iscsi_boot_rd_attr(ini_index, index, ISCSI_BOOT_INI_INDEX);
  225. iscsi_boot_rd_attr(ini_flags, flags, ISCSI_BOOT_INI_FLAGS);
  226. iscsi_boot_rd_attr(ini_isns, isns-server, ISCSI_BOOT_INI_ISNS_SERVER);
  227. iscsi_boot_rd_attr(ini_slp, slp-server, ISCSI_BOOT_INI_SLP_SERVER);
  228. iscsi_boot_rd_attr(ini_primary_radius, pri-radius-server,
  229. ISCSI_BOOT_INI_PRI_RADIUS_SERVER);
  230. iscsi_boot_rd_attr(ini_secondary_radius, sec-radius-server,
  231. ISCSI_BOOT_INI_SEC_RADIUS_SERVER);
  232. iscsi_boot_rd_attr(ini_name, initiator-name, ISCSI_BOOT_INI_INITIATOR_NAME);
  233. static struct attribute *initiator_attrs[] = {
  234. &iscsi_boot_attr_ini_index.attr,
  235. &iscsi_boot_attr_ini_flags.attr,
  236. &iscsi_boot_attr_ini_isns.attr,
  237. &iscsi_boot_attr_ini_slp.attr,
  238. &iscsi_boot_attr_ini_primary_radius.attr,
  239. &iscsi_boot_attr_ini_secondary_radius.attr,
  240. &iscsi_boot_attr_ini_name.attr,
  241. NULL
  242. };
  243. static mode_t iscsi_boot_ini_attr_is_visible(struct kobject *kobj,
  244. struct attribute *attr, int i)
  245. {
  246. struct iscsi_boot_kobj *boot_kobj =
  247. container_of(kobj, struct iscsi_boot_kobj, kobj);
  248. if (attr == &iscsi_boot_attr_ini_index.attr)
  249. return boot_kobj->is_visible(boot_kobj->data,
  250. ISCSI_BOOT_INI_INDEX);
  251. if (attr == &iscsi_boot_attr_ini_flags.attr)
  252. return boot_kobj->is_visible(boot_kobj->data,
  253. ISCSI_BOOT_INI_FLAGS);
  254. if (attr == &iscsi_boot_attr_ini_isns.attr)
  255. return boot_kobj->is_visible(boot_kobj->data,
  256. ISCSI_BOOT_INI_ISNS_SERVER);
  257. if (attr == &iscsi_boot_attr_ini_slp.attr)
  258. return boot_kobj->is_visible(boot_kobj->data,
  259. ISCSI_BOOT_INI_SLP_SERVER);
  260. if (attr == &iscsi_boot_attr_ini_primary_radius.attr)
  261. return boot_kobj->is_visible(boot_kobj->data,
  262. ISCSI_BOOT_INI_PRI_RADIUS_SERVER);
  263. if (attr == &iscsi_boot_attr_ini_secondary_radius.attr)
  264. return boot_kobj->is_visible(boot_kobj->data,
  265. ISCSI_BOOT_INI_SEC_RADIUS_SERVER);
  266. if (attr == &iscsi_boot_attr_ini_name.attr)
  267. return boot_kobj->is_visible(boot_kobj->data,
  268. ISCSI_BOOT_INI_INITIATOR_NAME);
  269. return 0;
  270. }
  271. static struct attribute_group iscsi_boot_initiator_attr_group = {
  272. .attrs = initiator_attrs,
  273. .is_visible = iscsi_boot_ini_attr_is_visible,
  274. };
  275. static struct iscsi_boot_kobj *
  276. iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset,
  277. struct attribute_group *attr_group,
  278. const char *name, int index, void *data,
  279. ssize_t (*show) (void *data, int type, char *buf),
  280. mode_t (*is_visible) (void *data, int type))
  281. {
  282. struct iscsi_boot_kobj *boot_kobj;
  283. boot_kobj = kzalloc(sizeof(*boot_kobj), GFP_KERNEL);
  284. if (!boot_kobj)
  285. return NULL;
  286. INIT_LIST_HEAD(&boot_kobj->list);
  287. boot_kobj->kobj.kset = boot_kset->kset;
  288. if (kobject_init_and_add(&boot_kobj->kobj, &iscsi_boot_ktype,
  289. NULL, name, index)) {
  290. kfree(boot_kobj);
  291. return NULL;
  292. }
  293. boot_kobj->data = data;
  294. boot_kobj->show = show;
  295. boot_kobj->is_visible = is_visible;
  296. if (sysfs_create_group(&boot_kobj->kobj, attr_group)) {
  297. /*
  298. * We do not want to free this because the caller
  299. * will assume that since the creation call failed
  300. * the boot kobj was not setup and the normal release
  301. * path is not being run.
  302. */
  303. boot_kobj->data = NULL;
  304. kobject_put(&boot_kobj->kobj);
  305. return NULL;
  306. }
  307. boot_kobj->attr_group = attr_group;
  308. kobject_uevent(&boot_kobj->kobj, KOBJ_ADD);
  309. /* Nothing broke so lets add it to the list. */
  310. list_add_tail(&boot_kobj->list, &boot_kset->kobj_list);
  311. return boot_kobj;
  312. }
  313. static void iscsi_boot_remove_kobj(struct iscsi_boot_kobj *boot_kobj)
  314. {
  315. list_del(&boot_kobj->list);
  316. sysfs_remove_group(&boot_kobj->kobj, boot_kobj->attr_group);
  317. kobject_put(&boot_kobj->kobj);
  318. }
  319. /**
  320. * iscsi_boot_create_target() - create boot target sysfs dir
  321. * @boot_kset: boot kset
  322. * @index: the target id
  323. * @data: driver specific data for target
  324. * @show: attr show function
  325. * @is_visible: attr visibility function
  326. *
  327. * Note: The boot sysfs lib will free the data passed in for the caller
  328. * when all refs to the target kobject have been released.
  329. */
  330. struct iscsi_boot_kobj *
  331. iscsi_boot_create_target(struct iscsi_boot_kset *boot_kset, int index,
  332. void *data,
  333. ssize_t (*show) (void *data, int type, char *buf),
  334. mode_t (*is_visible) (void *data, int type))
  335. {
  336. return iscsi_boot_create_kobj(boot_kset, &iscsi_boot_target_attr_group,
  337. "target%d", index, data, show, is_visible);
  338. }
  339. EXPORT_SYMBOL_GPL(iscsi_boot_create_target);
  340. /**
  341. * iscsi_boot_create_initiator() - create boot initiator sysfs dir
  342. * @boot_kset: boot kset
  343. * @index: the initiator id
  344. * @data: driver specific data
  345. * @show: attr show function
  346. * @is_visible: attr visibility function
  347. *
  348. * Note: The boot sysfs lib will free the data passed in for the caller
  349. * when all refs to the initiator kobject have been released.
  350. */
  351. struct iscsi_boot_kobj *
  352. iscsi_boot_create_initiator(struct iscsi_boot_kset *boot_kset, int index,
  353. void *data,
  354. ssize_t (*show) (void *data, int type, char *buf),
  355. mode_t (*is_visible) (void *data, int type))
  356. {
  357. return iscsi_boot_create_kobj(boot_kset,
  358. &iscsi_boot_initiator_attr_group,
  359. "initiator", index, data, show,
  360. is_visible);
  361. }
  362. EXPORT_SYMBOL_GPL(iscsi_boot_create_initiator);
  363. /**
  364. * iscsi_boot_create_ethernet() - create boot ethernet sysfs dir
  365. * @boot_kset: boot kset
  366. * @index: the ethernet device id
  367. * @data: driver specific data
  368. * @show: attr show function
  369. * @is_visible: attr visibility function
  370. *
  371. * Note: The boot sysfs lib will free the data passed in for the caller
  372. * when all refs to the ethernet kobject have been released.
  373. */
  374. struct iscsi_boot_kobj *
  375. iscsi_boot_create_ethernet(struct iscsi_boot_kset *boot_kset, int index,
  376. void *data,
  377. ssize_t (*show) (void *data, int type, char *buf),
  378. mode_t (*is_visible) (void *data, int type))
  379. {
  380. return iscsi_boot_create_kobj(boot_kset,
  381. &iscsi_boot_ethernet_attr_group,
  382. "ethernet%d", index, data, show,
  383. is_visible);
  384. }
  385. EXPORT_SYMBOL_GPL(iscsi_boot_create_ethernet);
  386. /**
  387. * iscsi_boot_create_kset() - creates root sysfs tree
  388. * @set_name: name of root dir
  389. */
  390. struct iscsi_boot_kset *iscsi_boot_create_kset(const char *set_name)
  391. {
  392. struct iscsi_boot_kset *boot_kset;
  393. boot_kset = kzalloc(sizeof(*boot_kset), GFP_KERNEL);
  394. if (!boot_kset)
  395. return NULL;
  396. boot_kset->kset = kset_create_and_add(set_name, NULL, firmware_kobj);
  397. if (!boot_kset->kset) {
  398. kfree(boot_kset);
  399. return NULL;
  400. }
  401. INIT_LIST_HEAD(&boot_kset->kobj_list);
  402. return boot_kset;
  403. }
  404. EXPORT_SYMBOL_GPL(iscsi_boot_create_kset);
  405. /**
  406. * iscsi_boot_create_host_kset() - creates root sysfs tree for a scsi host
  407. * @hostno: host number of scsi host
  408. */
  409. struct iscsi_boot_kset *iscsi_boot_create_host_kset(unsigned int hostno)
  410. {
  411. struct iscsi_boot_kset *boot_kset;
  412. char *set_name;
  413. set_name = kasprintf(GFP_KERNEL, "iscsi_boot%u", hostno);
  414. if (!set_name)
  415. return NULL;
  416. boot_kset = iscsi_boot_create_kset(set_name);
  417. kfree(set_name);
  418. return boot_kset;
  419. }
  420. EXPORT_SYMBOL_GPL(iscsi_boot_create_host_kset);
  421. /**
  422. * iscsi_boot_destroy_kset() - destroy kset and kobjects under it
  423. * @boot_kset: boot kset
  424. *
  425. * This will remove the kset and kobjects and attrs under it.
  426. */
  427. void iscsi_boot_destroy_kset(struct iscsi_boot_kset *boot_kset)
  428. {
  429. struct iscsi_boot_kobj *boot_kobj, *tmp_kobj;
  430. list_for_each_entry_safe(boot_kobj, tmp_kobj,
  431. &boot_kset->kobj_list, list)
  432. iscsi_boot_remove_kobj(boot_kobj);
  433. kset_unregister(boot_kset->kset);
  434. }
  435. EXPORT_SYMBOL_GPL(iscsi_boot_destroy_kset);