Getting 'bad file number' error writing to device driver

Daniel Baluta daniel.baluta at gmail.com
Sat Oct 15 04:34:12 EDT 2011


On Sat, Oct 15, 2011 at 2:42 AM, Philip Anil-QBW348
<anil.philip at motorolasolutions.com> wrote:
> I am calling the driver from an Android program (OMAP4/Blaze). It calls a
> c++ program via JNI which then calls the device driver.
> Someone suggested it might be a permissions problem - the program is running
> in user mode.
>
> on Blaze board, /system/bin
> # ls -l
> -rwxrwxrwx system   system       7636 2011-09-30 03:53 mydriver
>
> Will strace still be useful?
> In general, in Linux, how does one enable a user program to call a custom
> device driver?

Please don't top post! :)

strace will be useful to check the parameters for open, write system calls.

EBADF  fd is not a valid file descriptor or is not open for writing.
Ok, so either open fails, or you don't have the permission to write
into /dev/mydriver file.

Another thing that I can think of, is that your driver's write
function is wrong, and returns
-EBADF in some case ?

Can you give us a pointer to your driver?

thanks,
Daniel.



More information about the Kernelnewbies mailing list