AW: AW: [En-Nut-Discussion] Get file size vom VIRTUALDEVICE(was:Register overwriting in interrupted code)

Harald Kipp harald.kipp at egnite.de
Sun Jul 25 16:26:47 CEST 2004


>I would now also like to use the ioctl from each driver.
>But there is one problem, that we have to discuss about. In device.h the
>ioctl function for the struct NUTDEVICE takes as first parameter a pointer
>to NUTDEVICE. If we want ioctl to perform file dependent functions, such as
>'getfilesize' the first parameter to ioctl needs to be changed to NUTFILE*.
>
>I think there is no big problem to change the affected code, because the
>NUTFILE structure has a pointer to the connected device (nf_dev).
>
>If you are ok with that, I can start to modify the whole code.
>Any further suggestions?

Not really. The problem is, that it will not be backward
compatible. The code needs to distinguish between version
<= 3.4 and >= 3.5.

Fortunately ioctl() may able to tell, wether the first
parameter points to a device or file. nf_next isn't
used yet, so we can redefine it as a magic and set it
to a value, that can't be a pointer. dev_next will
always contain a real pointer, including the NULL pointer.

We can initialize nf_next to (void *)-1. And better replace
nf_next by nf_magic. nf_next may be added, if Nut/OS supports
a list of files...if ever. There is even space for future
enhancements of this procedure, because (void *)-2 up to
(void *)-(sizeof(NUTDEVICE) + 1) and a can't exist either.

Harald




More information about the En-Nut-Discussion mailing list