title: Checking only the O_RDONLY flag to open(2)
body: <p>I'm checking the flags sent to the open(2) call against permissions I've set up in some meta files. The perms here are related to the octal values typically sent to calls like chmod. I want the if block to be entered when perms is not matched by the relevant flag.</p>
  
  <pre><code>if((perms == 4 &amp;&amp; !(flags &amp; O_RDONLY)) ||
     (perms == 2 &amp;&amp; !(flags &amp; O_WRONLY)) ||
     (perms == 6 &amp;&amp; !(flags &amp; O_RDWR))) 
  </code></pre>
  
  <p>I expected this to work, and it does just fine in the the O_WRONLY and O_RDWR. However, the actual value of O_RDONLY is 0, so the &amp; operator will return false for every value. Unfortunately, removing the negation will lead to the undesired behavior of every perms value of 4 skipping the if block. How can I achieve my goal here?</p>