Note that there are some explanatory texts on larger screens.

plurals
  1. POC & Android kernel module: what happened with f_flags here?
    text
    copied!<p>I have a self-coded kernel module in Android which I open with <code>O_RDONLY|O_NONBLOCK</code>.</p> <p><code>O_NONBLOCK</code> is <code>2048</code> in both the user-program and the kernel module.</p> <p>I checked that with </p> <pre><code>print..("O_NONBLOCK is %d", O_NONBLOCK) </code></pre> <p>in user- &amp; kernel-space.</p> <p>But now, when I try to check if <code>O_NONBLOCK</code> was set, I got a really strange problem:</p> <pre><code>static int my_open(struct inode *inode, struct file *filp) { if (filp-&gt;f_flags &amp; O_NONBLOCK) { printk("O_NONBLOCK"); } else { printk("NOT O_NONBLOCK"); printk("O_NONBLOCK in my_open is: %d", O_NONBLOCK); // -&gt; prints 2048 printk("filp-&gt;f_flags in my_open is: %d", filp-&gt;f_flags); // -&gt; prints 1, not 2048 or larger } .. } </code></pre> <p>I tried something else:</p> <pre><code>cat my_device </code></pre> <p>but again, <code>filp-&gt;f_flags</code> is <code>1</code>.</p> <p>I would assume maybe <code>0</code> for <code>O_RDONLY</code> but not <code>1</code> which means <code>O_WRONLY</code>.</p> <p>Anyone an idea or explanation?</p> <p>EDIT:</p> <p>I also <strong>don't</strong> expect <code>cat</code> beeing <code>O_NONBLOCK</code>, but <code>O_WRONLY</code> is totally wrong. </p> <p>I open it this way: </p> <pre><code>pcm-&gt;dfd=open(fname, O_RDONLY|O_NONBLOCK); </code></pre> <p>and there's no <code>fcntl</code> later (and that shouldn't affect <code>my_open</code> at all. But of course I also tried to "re-set" <code>O_NONBLOCK</code> with <code>fcntl</code> without luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload