PR1245 device lseek
Till Straumann
strauman at slac.stanford.edu
Wed Aug 8 03:53:32 UTC 2007
Victor Vengerov wrote:
> Hi,
>
> Hard disk etc. represented in RTEMS device driver with
> open/close/read/write/control interface. rtems_libio_rw_args_t argument
> is passed to device read/write primitives, which contains the offset
> attribute. offset filled in device_write (deviceio.c) from iop->offset.
>
> May be I've missed something, but it looks for me you just need to
> adjust iop->offset
That's already done in libcsupport/src/lseek.c.
However, the iop->offset adjustment is undone if
iop->handlers->lseek_h()
returns -1.
I can see two valid scenarios:
a) a device for which adjusting iop->offset is all that's needed.
In this case, the lseek_h() method (in the case discussed here
this is 'device_lseek()') should return the current offset (not 0).
b) non-seekable device should return -1 (not 0) and set errno
If we assume that currently only a) is implemented [and we don't want
to break existing code that assumes these semantics] then
either device_lseek() should return the current offset or
lseek.c should be fixed to return the current offset if lseek_h
returns 0.
-- Till
> in device_lseek in accordance to offset and whence
> arguments.
>
> Regards,
> Victor
>
> Joel Sherrill wrote:
>
>> Hi,
>>
>> This PR notes that device_lseek() always succeeds but
>> does nothing. According to OpenGroup
>> http://www.opengroup.org/onlinepubs/000095399/functions/lseek.html,
>> lseek() should return ESPIPE for ttys, sockets, and pipes.
>>
>> I may be having a brain freeze, but right now, I don't
>> see how to implement a seek on a block device like
>> a hard disk. I know you have to be able to do it.
>>
>> Any thoughts?
>>
>> --joel
>> _______________________________________________
>> rtems-users mailing list
>> rtems-users at rtems.com
>> http://rtems.rtems.org/mailman/listinfo/rtems-users
>>
>>
>
>
More information about the users
mailing list