Getting 'bad file number' error writing to device driver

2011-10-13 Thread Philip Anil-QBW348
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 __a

Re: Getting 'bad file number' error writing to device driver

2011-10-13 Thread Daniel Baluta
Hello, > 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); > > valu

RE: Getting 'bad file number' error writing to device driver

2011-10-14 Thread Philip Anil-QBW348
: kernelnewbies@kernelnewbies.org Subject: Re: Getting 'bad file number' error writing to device driver Hello, > 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

Re: Getting 'bad file number' error writing to device driver

2011-10-15 Thread Daniel Baluta
On Sat, Oct 15, 2011 at 2:42 AM, Philip Anil-QBW348 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 Bla

RE: Getting 'bad file number' error writing to device driver

2011-10-17 Thread Philip Anil-QBW348
-Original Message- From: Daniel Baluta [mailto:daniel.bal...@gmail.com] Sent: Saturday, October 15, 2011 3:34 AM To: Philip Anil-QBW348 Cc: kernelnewbies@kernelnewbies.org Subject: Re: Getting 'bad file number' error writing to device driver On Sat, Oct 15, 2011 at 2:42 AM, P

Re: Getting 'bad file number' error writing to device driver

2011-10-17 Thread Daniel Baluta
On Mon, Oct 17, 2011 at 6:49 PM, Philip Anil-QBW348 wrote: > -Original Message- > From: Daniel Baluta [mailto:daniel.bal...@gmail.com] > Sent: Saturday, October 15, 2011 3:34 AM > To: Philip Anil-QBW348 > Cc: kernelnewbies@kernelnewbies.org > Subject: Re: Getting '

RE: Getting 'bad file number' error writing to device driver

2011-10-19 Thread Philip Anil-QBW348
-Original Message- Maybe setuid bit can help you ([1]). When this bit is set, a certain program can run with the privileges of its owner. thanks, Daniel. [1] http://en.wikipedia.org/wiki/Setuid Daniel, Thanks for the link; but this bit has to be set on the original executable

Re: Getting 'bad file number' error writing to device driver

2011-10-19 Thread Mandeep Sandhu
> Thanks for the link; but this bit has to be set on the original executable. > Is there any way a program in user mode can get around this or set the bit > himself? Ummm...now that would be a security violation, don't you think? If a program can elevate it's own privileges, then whats the point o

RE: Getting 'bad file number' error writing to device driver

2011-10-20 Thread Philip Anil-QBW348
> Thanks for the link; but this bit has to be set on the original executable. > Is there any way a program in user mode can get around this or set the bit > himself? Ummm...now that would be a security violation, don't you think? If a program can elevate it's own privileges, then whats the point