Note that there are some explanatory texts on larger screens.

plurals
  1. POopen file O_NONBLOCKING gets lost in kernel module
    primarykey
    data
    text
    <p>I am opening a file in my C program:</p> <pre><code>pcm-&gt;dfd = open(fname, O_RDONLY|O_NONBLOCK); </code></pre> <p>and later call <code>select()</code> and <code>read()</code> on it.</p> <p>But my problem is, that the <code>O_NONBLOCK</code> gets lost somewere:</p> <pre><code>ssize_t my_read(struct file *filp, char __user *user_buffer, size_t bytes_requested, loff_t *capture_ptr) { if (filp-&gt;f_flags &amp; O_NONBLOCK){ LOGI("mode: O_NONBLOCK"); } else{ LOGI("mode: BLOCKING"); // &lt;-- this is printed } .. } </code></pre> <p>I also tried</p> <pre><code>pcm-&gt;dfd=open(fname, O_RDONLY|O_NONBLOCK); // O_NONBLOCK does not work :/ int flags = fcntl(pcm-&gt;dfd, F_GETFL, 0); fcntl(pcm-&gt;dfd, F_SETFL, flags | O_NONBLOCK); </code></pre> <p>It's not a logging-problem, the driver also behaves as in blocking-mode.</p> <p>Anyone an idea?</p> <p>EDIT:</p> <p>The code which reads from the opened file is absolutely simple:</p> <pre><code>size=read(pcm-&gt;dfd,inBuffer,inBufferBytes); </code></pre> <p>I also checked the program if there's a <code>fcntl()</code> somewere else, but no..</p> <p>EDIT 2:</p> <p>May it be possible, that the <code>O_NONBLOCK</code> has an other value in my user-program (Android NDK) than in the kernel? I searched for <code>O_NONBLOCK</code> in the kernel-headers and already there are 2 different definitions.</p> <p>I also checked the <code>open</code>-implementation in my kernel module and already there <code>filp-&gt;f_flags</code> is <strong>not</strong> <code>O_NONBLOCK</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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