public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] bug in read in a device file
@ 2001-05-13 18:36 wangwei
  2001-05-14 11:07 ` Jonathan Larmour
  0 siblings, 1 reply; 3+ messages in thread
From: wangwei @ 2001-05-13 18:36 UTC (permalink / raw)
  To: ecos-discuss

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 :
      read(devfd,buf,3);
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
*uio)
{
    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,
                           iov->iov_base,
                           &len);

        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
NON_BLOCK),but
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 .

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-05-14 23:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-13 18:36 [ECOS] bug in read in a device file wangwei
2001-05-14 11:07 ` Jonathan Larmour
2001-05-14 23:39   ` [ECOS] Bug in read/write in the io.cxx file Boris V. Guzhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).