Getting 'bad file number' error writing to device driver

Philip Anil-QBW348 anil.philip at motorolasolutions.com
Thu Oct 13 17:52:41 EDT 2011



I am trying to write to mydriver but get a 'Bad file number' error.

int fd = open("/dev/mydriver",O_RDWR);

this opens successfully as fd is not -1.

ssize_t bytesToWrite = strlen(buf);

value is: bytesToWrite 28

ssize_t bytesWritten = write(fd,buf,bytesToWrite);

value is: bytesWritten -1

__android_log_print(ANDROID_LOG_INFO,__FILE__,"ANIL
strerror(errno) %s",  strerror(errno));

value is: strerror(errno) Bad file number

Any help appreciated.

Anil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111013/ac9e429b/attachment.html 


More information about the Kernelnewbies mailing list