[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: file/device i/o in the kernel
On Fri, Jun 16, 2000 at 11:13:59AM +0530, Sharad Joshi wrote:
> Any idea how to do file i/o in kernel? Typically, i am opening a device
> file (/dev/ttyS0) with sys_open(). Now i do sys_read/write on the returned
> fd. But the problem is, if i try to do it again after some time (uh... i
> come back to do read/write) both these return with 'Bad file Descriptor'
> error. If i try to do sys_open() again (ok, i close the former fd), it
> returns 0. I have scanned thru all the relevent source of the kernel, but
> find no clue as to why this happens. Any idea?
Are you sure that the "current" process was the same at open() and
read() ? If not, that is your problem.
> What is the better way to do device i/o above the driver? If a kernel
> module wants to do some device i/o using underlying driver, is the above
> method ok, or i need to do something else?
Not use file descriptors and do IO at a lower level ? struct file or
whatever it is that linux implements.