device driver code that can response to SEEK_END

Fernando RUIZ CASAS fernando.ruiz at
Thu Apr 25 08:04:06 UTC 2002

How many bytes have your device?
In a flash disk device is easy but in a char device (printer, serial, audio
is not easy.

If the offset is biggest that the device size you make a read/write past eof

But in your audio device?

You need place in the file descriptor of rtems the filesize (device size in
this case).
You can see this browsing the open/close/seek implementation of rtems
You can imaginate that you have a regular file and make the same that rtems
when your open device is called like a regular file.
The seek only moves the pointer in the rtems level. Not in the device level.

I'm right?
home:correo at
work:fernando.ruiz at

-----Mensaje original-----
De: Pattara Kiatisevi [mailto:pkiatisevi at]
Enviado el: miercoles, 24 de abril de 2002 16:27
Para: 'RTEMS Users'
CC: oggonachip at
Asunto: device driver code that can response to SEEK_END

Hi all,

I still have problem with this seeking problem with my device driver code.
I found it has problem when there is a call fseek(x,0,SEEK_END). Anybody
has idea how should i write the device driver code to let this SEEK_END
work. I mean how should I update these variables:

typedef struct {
    rtems_libio_t          *iop;
    off_t                   offset;
    unsigned8              *buffer;
    unsigned32              count;
    unsigned32              flags;
    unsigned32              bytes_moved;
} rtems_libio_rw_args_t;

So far I just check if offset > mydatasize then return with bytes_moved =

Thank you very much,
Please avoid sending me Word or PowerPoint attachments.
Ott Pattara Kiatisevi 				   T L W G
M.Sc. INFOTECH Student, Stuttgart, Germany

More information about the users mailing list