[ECOS] bug in read in a device file

wangwei wangw@start.com.cn
Sun May 13 18:36:00 GMT 2001

I think I found a bug in read() when a device file is set to NON_BLOCK
When I use read() to get more than one data from device ,such as :
it will read nothing for ever .

The reason is :
    in file io/fileio/src/devfs.cxx, linenumber 324


static int dev_fo_read      (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG
    Cyg_ErrNo err = 0;
    int i;

    // Now loop over the iovecs until they are all done, or
    // we get an error.
    for( i = 0; i < uio->uio_iovcnt; i++ )
        cyg_iovec *iov = &uio->uio_iov[i];
        cyg_uint32 len = iov->iov_len;

        err = cyg_io_read( (cyg_io_handle_t)fp->f_data,

        if( err < 0 ) break;

        uio->uio_resid -= len;

    return -err;

now len=3, if just one byte in the read buffer of drivers . after called
cyg_io_read ,
,it will return one byte in iov->iov_base,and len =1(because set
err < 0,
so the byte will lost .
I use function "select" and "read" to get device data , and the device speed
isn't quick
enough , when function select decide there are some data in device driver,
function "read"
will be call, but only one byte in the read buffer now .so the read function
will return
failure always .

More information about the Ecos-discuss mailing list