title: How to use a created Linux Kernel character driver from the commandline
body: <p>I've been following the tutorial on Linux Kernel programming over here: <a href="http://www.tldp.org/LDP/lkmpg/2.6/html/index.html" rel="nofollow noreferrer">http://www.tldp.org/LDP/lkmpg/2.6/html/index.html</a></p>
  
  <p>I've gotten to the section that is dedicated to "character device drivers" and while I've gotten it to compile, it will not function on the described case:</p>
  
  <p>"Called when a process writes to dev file: echo "hi" > /dev/chardev"</p>
  
  <p>I've tried several Linux console commands such as: </p>
  
  <p>echo "hi" > sudo /dev/chardev/ </p>
  
  <p>and</p>
  
  <p>sudo sh -c 'printf "hi" > sudo /dev/chardev/'</p>
  
  <p>I'm running my code on a Raspberry Pi 3 B+ </p>
  
  <p>When I run the first command I will get nothing in return, and nothing is added to /var/logs/messages</p>
  
  <p>When I run the second command I get:
  sh:printf: I/O error</p>
  
  <p>Full code over at: <a href="http://www.tldp.org/LDP/lkmpg/2.6/html/x569.html" rel="nofollow noreferrer">http://www.tldp.org/LDP/lkmpg/2.6/html/x569.html</a></p>
  
  <p>I've modified the code with my snippet below.</p>
  
  <pre><code>/*  
   * Called when a process writes to dev file: echo "hi" &gt; /dev/chardev
   */
  static ssize_t
  device_write(struct file *filp, const char *buff, size_t len, loff_t * off)
  {
      printk(KERN_INFO "%s\n", buff);
      return -EINVAL;
  }
  </code></pre>
  
  <p>What I'm expecting to happen is when I use echo "hi" > sudo /dev/chardev that in my /var/logs/messages a line will appear that simply says "hi".</p>