public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "wangwei" <wangw@start.com.cn>
To: <ecos-discuss@sources.redhat.com>
Subject: [ECOS] bug in read in a device file
Date: Sun, 13 May 2001 18:36:00 -0000	[thread overview]
Message-ID: <003801c0dc15$87d549a0$592da8c0@start.com.cn> (raw)

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 .

             reply	other threads:[~2001-05-13 18:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-13 18:36 wangwei [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='003801c0dc15$87d549a0$592da8c0@start.com.cn' \
    --to=wangw@start.com.cn \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).