title: Kernel space write a file
body: <p>I'm trying to write a file <strong>/proc/test/enable</strong> in kernel 5.10 C code. <br>
  I can write it in user space by calling fwrite. <br></p>
  <p>When I using <strong>kernel_write</strong> in kernel C code, I will get the error <strong>kernel write not supported for file test/enable and error code 22</strong>. <br></p>
  <pre><code>struct file *filp;
  char context[] = &quot;test&quot;;
  filp = filp_open(&quot;/proc/test/enable&quot;, O_WRONLY, 0);
  int err = kernel_write(filp, (void *)context, sizeof(context), &amp;filp-&gt;f_pos);
  dev_info(afe-&gt;dev, &quot;%s(), DONE, code = %d&quot;, __func__, err);
  </code></pre>
  <p>I can't understand why kernel_write can't get proc file write function, but userspace fwrite can</p>