title: Read Config File Line By Line in Kernel
body: <p>I am trying to read a config file ( which is located/generated in a specific place in kernel) for a module that I am working. </p>
  
  <p>I can read the file as a whole by using filp_open with O_RDONLY flag (read only ) but I can't think out a way to read it line by line.</p>
  
  <p>Current Code </p>
  
  <pre><code>f = filp_open("/etc/my_module",O_RDONLY, 0);
  
  if ( f==NULL) {
      printk("Error in loading config for birdge.\n");
      return 1;
  } else {
      fs = get_fs();
      set_fs(get_ds());
  
      /* read line config here */
      f-&gt;f_op-&gt;read(f, buf, 128, &amp;f-&gt;f_pos);
  
      set_fs(fs);
      printk("buf:%s\n",buf);
  }
  </code></pre>
  
  <p>Linux Kernel Version: 3.8.0-29-generic</p>
  
  <p>What I am trying to achieve is putting each(nth) line into a buffer array(char *buf[128][128]) and later I will chunk out the param and value using pure c. </p>
  
  <p>By that way the variables from the config file could be used in module's runtime and of course I will make some condition checks whether the configs are ok or not.</p>
  
  <p>Thanks</p>