title: Get Nanosecond Unix Timestamp in Kernel Module
body: <p>I am pretty new to kernel module programming. Therefore I compiled an easy hello world tutorial module. However, I failed at an easy task while modifying the hello world:</p>
  
  <p>How do I get a unix timestamp with nanosecond granularity?
  I expected the following code to work, but it returns a value, that is not the nanosecond unix timestamp:</p>
  
  <pre><code>unsigned long ns_time;
  
  struct timespec ts;
  getnstimeofday(&amp;ts);
  
  ns_time = 1000000000 * ts.tv_sec + ts.tv_nsec;
  </code></pre>