31 #include <linux/module.h>
32 #include <linux/slab.h>
89 char *
p = (
char *) page;
92 if ((*p !=
'\0') && (*p !=
'\n'))
103 static ssize_t childless_description_read(
struct childless *childless,
109 "The childless subsystem is the simplest possible subsystem in\n"
110 "configfs. It does not support the creation of child config_items.\n"
111 "It only has a few attributes. In fact, it isn't much different\n"
112 "than a directory in /proc.\n");
117 .show = childless_showme_read,
121 .show = childless_storeme_read,
122 .store = childless_storeme_write,
126 .show = childless_description_read,
130 &childless_attr_showme.
attr,
131 &childless_attr_storeme.
attr,
132 &childless_attr_description.
attr,
140 struct childless *childless = to_childless(item);
145 if (childless_attr->
show)
146 ret = childless_attr->
show(childless, page);
152 const char *page,
size_t count)
154 struct childless *childless = to_childless(item);
159 if (childless_attr->
store)
160 ret = childless_attr->
store(childless, page, count);
165 .show_attribute = childless_attr_show,
166 .store_attribute = childless_attr_store,
170 .ct_item_ops = &childless_item_ops,
171 .ct_attrs = childless_attrs,
175 static struct childless childless_subsys = {
179 .ci_namebuf =
"01-childless",
180 .ci_type = &childless_type,
210 .ca_name =
"storeme",
215 &simple_child_attr_storeme,
233 const char *page,
size_t count)
237 char *p = (
char *) page;
240 if (!p || (*p && (*p !=
'\n')))
251 static void simple_child_release(
struct config_item *item)
253 kfree(to_simple_child(item));
257 .release = simple_child_release,
258 .show_attribute = simple_child_attr_show,
259 .store_attribute = simple_child_attr_store,
263 .ct_item_ops = &simple_child_item_ops,
264 .ct_attrs = simple_child_attrs,
280 struct simple_child *simple_child;
282 simple_child = kzalloc(
sizeof(
struct simple_child),
GFP_KERNEL);
291 return &simple_child->
item;
296 .ca_name =
"description",
301 &simple_children_attr_description,
310 "[02-simple-children]\n"
312 "This subsystem allows the creation of child config_items. These\n"
313 "items have only one attribute that is readable and writeable.\n");
316 static void simple_children_release(
struct config_item *item)
318 kfree(to_simple_children(item));
322 .release = simple_children_release,
323 .show_attribute = simple_children_attr_show,
331 .make_item = simple_children_make_item,
335 .ct_item_ops = &simple_children_item_ops,
336 .ct_group_ops = &simple_children_group_ops,
337 .ct_attrs = simple_children_attrs,
344 .ci_namebuf =
"02-simple-children",
345 .ci_type = &simple_children_type,
367 simple_children = kzalloc(
sizeof(
struct simple_children),
369 if (!simple_children)
373 &simple_children_type);
375 return &simple_children->
group;
380 .ca_name =
"description",
385 &group_children_attr_description,
394 "[03-group-children]\n"
396 "This subsystem allows the creation of child config_groups. These\n"
397 "groups are like the subsystem simple-children.\n");
401 .show_attribute = group_children_attr_show,
409 .make_group = group_children_make_group,
413 .ct_item_ops = &group_children_item_ops,
414 .ct_group_ops = &group_children_group_ops,
415 .ct_attrs = group_children_attrs,
422 .ci_namebuf =
"03-group-children",
423 .ci_type = &group_children_type,
439 &simple_children_subsys,
440 &group_children_subsys,
444 static int __init configfs_example_init(
void)
450 for (i = 0; example_subsys[
i]; i++) {
451 subsys = example_subsys[
i];
459 subsys->
su_group.cg_item.ci_namebuf);
467 for (i--; i >= 0; i--)
473 static void __exit configfs_example_exit(
void)
477 for (i = 0; example_subsys[
i]; i++)