title: open /dev/mem - Operation not permitted
body: <p>I am working on ubuntu.</p>
  
  <p>I am trying to open <code>/dev/mem</code> and i am getting <code>permission denied</code></p>
  
  <pre><code>int32_t open_memdev()
  {
          int32_t fd;
  
          fd = open("/dev/mem", O_RDONLY);
          if (fd &lt; 0) {
                  printf("Failed to open /dev/mem : %s\n", strerror(errno));
                  return-EINVAL;
          }
  
          return fd;
  }
  </code></pre>
  
  <p>This code always prints <code>"Failed to open /dev/mem : Operation not permitted"</code></p>
  
  <p>I have searched for this on SO</p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/6134984/access-permissions-of-dev-mem">access-permissions-of-dev-mem</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/11891979/accessing-mmaped-dev-mem">accessing-mmaped-dev-mem</a></p></li>
  </ol>
  
  <p>These q's seem to discuss the issue of not being able to access above 1 MB, but my problem is that i am unable to open even once.</p>
  
  <p><strong>Addtitional details if they help:</strong></p>
  
  <p>1) I checked my configuration that CONFIG_STRICT_DEVMEM is enabled.</p>
  
  <pre><code>2) ls -l /dev/mem
  crw-r----- 1 root kmem 1, 1 2014-03-13 13:57 /dev/mem
  </code></pre>
  
  <p>Please let me know if additional information is required.</p>