check_iovec cleanup

Corinna Vinschen
Thu Jul 27 20:29:00 GMT 2006

On Jul 26 21:36, Brian Ford wrote:
> Ok, patch withdrawn to avoid arguing over a not very important change.
> I've moved the discussion to cygwin-developers because I had a few more
> questions.  If anyone feels kind enough to educate me, I'd appreciate it.
> On Wed, 26 Jul 2006, Christopher Faylor wrote:
> > On Wed, Jul 26, 2006 at 07:15:43PM -0500, Brian Ford wrote:
> > >Doesn't it need to check a byte on every system page to be complete
> > >(because buffers could start in or span across invalid/protected
> > >virtual addresses)?
> This is still valid, right?  I know it is a fairly corner case.

Yes it is valid, and a corner case as long as MAP_NORESERVE doesn't come
into play.

I assume you're working towards getting MAP_NORESERVE for all read/write
cases?  If we implement the EFAULT stuff in all read/write cases, it
might actually be possible to do without this test in check_iovec.

However, it would also be nice if the test as you implemented in
fhandler_base::raw_read is not just duplicated to all other cases, but
instead we could get a more generalized method like a wrapper macro,
inline function, whatever, which encapsulate most of the
mmap_is_attached_or_noreserve handling.  For instance a macro like this:

  #define _MMWRAP(__ptr, __len, __func) \
  ({ \
    BOOL __res = __func; \
    for (int i = 0; i < 2; i++) \
      { \
	if ((__res = __func)) \
	  break; \
	if (ERROR_NOACCESS && i == 0) \
	  switch (mmap_is_attached_or_noreserve (__ptr, __len)) \
      } \
    __res; \


    BOOL res = _MMWRAP (ptr, len,
			ReadFile (get_handle (), ptr, len, (DWORD *) &ulen, 0));


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

More information about the Cygwin-developers mailing list