title: How to create a folder within a folder in sysfs
body: <p>I am trying to create a sysfs for an implementation of mine in android and stuck at creating a folder of my own in <code>CLASS</code>.</p>
  
  <p><strong>My requirement:</strong> </p>
  
  <pre><code>/sys/class/example_class/my_sysfs_directory/file_one.
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>    #include&lt;linux/module.h&gt;
      #include&lt;linux/kernel.h&gt;
      #include&lt;linux/device.h&gt;
      #include &lt;linux/err.h&gt;
  
      MODULE_LICENSE("GPL");
      MODULE_AUTHOR("Manoj");
  
      static ssize_t sysfs_demo_show(struct class *class,
          struct class_attribute *attr, char *buf)
      {
      pr_info("%s [%d]: \n", __func__, __LINE__);
      return sprintf(buf, "%s \n", __func__);
      }
  
      static ssize_t sysfs_demo_store(struct class *class,
      struct class_attribute *attr, const char *buf, size_t size)
      {
      pr_info("%s [%d]: \n", __func__, __LINE__);
      return size;
      }
  
      static CLASS_ATTR(file_one, 0777, sysfs_demo_show, sysfs_demo_store);
      int  sysfs_my_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
      {
      pr_info("%s [%d]: \n", __func__, __LINE__);
      return 0;
      }
  
      struct class *example_class;
  
      int sysfs_demo_init(void)
      {
      int ret;
      pr_info("%s [%d]: \n", __func__, __LINE__);
      example_class = class_create(THIS_MODULE, "demo");
      if (IS_ERR(example_class)) {
      pr_err("Failed to create sys_class\n");
      return -1;
      }
      example_class-&gt;dev_uevent = sysfs_my_dev_uevent;
      ret = class_create_file(example_class, &amp;class_attr_file_one);
      if (ret) {
      pr_err("Failed to create class file @ parent class dirs\n");
      return -1;
      }
      return 0;
      }
  
      void sysfs_demo_exit(void)
      {
      pr_info("%s [%d]: \n", __func__, __LINE__);
      class_remove_file(example_class, &amp;class_attr_file_one);
      class_destroy(example_class);
      }
  
  
      module_init(sysfs_demo_init);
      module_exit(sysfs_demo_exit);
  </code></pre>
  
  <p>I have pasted my code here,
  Please help me in this regard.</p>