* fhandler_clipboard.cc (fhandler_dev_clipboard::write): Never set
errno to 0. (fhandler_dev_clipboard::read): Ditto. * fhandler_windows.cc (fhandler_windows::read): Ditto. * scandir.cc (scandir): Ditto. * syscalls.cc (_fstat64_r): Ditto. (_fstat_r): Ditto. (_stat64_r): Ditto. (_stat_r): Ditto. * mmap.cc (mmap64): Fix /dev/zero mapping.
This commit is contained in:
parent
93c60b6d6a
commit
4717214c20
|
@ -1,3 +1,17 @@
|
||||||
|
2005-03-01 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* fhandler_clipboard.cc (fhandler_dev_clipboard::write): Never set
|
||||||
|
errno to 0.
|
||||||
|
(fhandler_dev_clipboard::read): Ditto.
|
||||||
|
* fhandler_windows.cc (fhandler_windows::read): Ditto.
|
||||||
|
* scandir.cc (scandir): Ditto.
|
||||||
|
* syscalls.cc (_fstat64_r): Ditto.
|
||||||
|
(_fstat_r): Ditto.
|
||||||
|
(_stat64_r): Ditto.
|
||||||
|
(_stat_r): Ditto.
|
||||||
|
|
||||||
|
* mmap.cc (mmap64): Fix /dev/zero mapping.
|
||||||
|
|
||||||
2005-02-28 Corinna Vinschen <corinna@vinschen.de>
|
2005-02-28 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler.h (class fhandler_socket): Declare new method
|
* fhandler.h (class fhandler_socket): Declare new method
|
||||||
|
|
|
@ -174,7 +174,6 @@ fhandler_dev_clipboard::write (const void *buf, size_t len)
|
||||||
|
|
||||||
pos = msize;
|
pos = msize;
|
||||||
|
|
||||||
set_errno (0);
|
|
||||||
eof = false;
|
eof = false;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +204,6 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
|
||||||
#if 0
|
#if 0
|
||||||
system_printf ("a non-accepted format! %d", format);
|
system_printf ("a non-accepted format! %d", format);
|
||||||
#endif
|
#endif
|
||||||
set_errno (0);
|
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -238,7 +236,6 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
|
||||||
GlobalUnlock (hglb);
|
GlobalUnlock (hglb);
|
||||||
}
|
}
|
||||||
CloseClipboard ();
|
CloseClipboard ();
|
||||||
set_errno (0);
|
|
||||||
len = ret;
|
len = ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,6 @@ fhandler_windows::read (void *buf, size_t& len)
|
||||||
|
|
||||||
if ((ssize_t) len == -1)
|
if ((ssize_t) len == -1)
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
else
|
|
||||||
set_errno (0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -538,6 +538,33 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
|
||||||
if (flags & MAP_ANONYMOUS)
|
if (flags & MAP_ANONYMOUS)
|
||||||
fd = -1;
|
fd = -1;
|
||||||
|
|
||||||
|
fhandler_base *fh;
|
||||||
|
|
||||||
|
/* Get fhandler and convert /dev/zero mapping to MAP_ANONYMOUS mapping. */
|
||||||
|
if (fd != -1)
|
||||||
|
{
|
||||||
|
/* Ensure that fd is open */
|
||||||
|
cygheap_fdget cfd (fd);
|
||||||
|
if (cfd < 0)
|
||||||
|
{
|
||||||
|
syscall_printf ("-1 = mmap(): EBADF");
|
||||||
|
ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
||||||
|
return MAP_FAILED;
|
||||||
|
}
|
||||||
|
fh = cfd;
|
||||||
|
if (fh->get_device () == FH_ZERO)
|
||||||
|
{
|
||||||
|
/* mmap /dev/zero is like MAP_ANONYMOUS. */
|
||||||
|
fd = -1;
|
||||||
|
flags |= MAP_ANONYMOUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
fh_paging_file.set_io_handle (INVALID_HANDLE_VALUE);
|
||||||
|
fh = &fh_paging_file;
|
||||||
|
}
|
||||||
|
|
||||||
/* 9x only: If MAP_FIXED is requested on a non-granularity boundary,
|
/* 9x only: If MAP_FIXED is requested on a non-granularity boundary,
|
||||||
change request so that this looks like a request with offset
|
change request so that this looks like a request with offset
|
||||||
addr % granularity. */
|
addr % granularity. */
|
||||||
|
@ -554,20 +581,8 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
|
||||||
gran_len = howmany (off + len, granularity) * granularity - gran_off;
|
gran_len = howmany (off + len, granularity) * granularity - gran_off;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *fh;
|
/* File mappings needs some extra care. */
|
||||||
|
if (fd != -1 && fh->get_device () == FH_FS)
|
||||||
if (fd != -1)
|
|
||||||
{
|
|
||||||
/* Ensure that fd is open */
|
|
||||||
cygheap_fdget cfd (fd);
|
|
||||||
if (cfd < 0)
|
|
||||||
{
|
|
||||||
syscall_printf ("-1 = mmap(): EBADF");
|
|
||||||
ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
|
|
||||||
return MAP_FAILED;
|
|
||||||
}
|
|
||||||
fh = cfd;
|
|
||||||
if (fh->get_device () == FH_FS)
|
|
||||||
{
|
{
|
||||||
DWORD high;
|
DWORD high;
|
||||||
DWORD low = GetFileSize (fh->get_handle (), &high);
|
DWORD low = GetFileSize (fh->get_handle (), &high);
|
||||||
|
@ -582,22 +597,12 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
|
||||||
"mmap");
|
"mmap");
|
||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
}
|
}
|
||||||
|
/* Don't map beyond EOF. Windows would change the file to the
|
||||||
|
new length otherwise, in contrast to POSIX. */
|
||||||
fsiz -= gran_off;
|
fsiz -= gran_off;
|
||||||
if (gran_len > fsiz)
|
if (gran_len > fsiz)
|
||||||
gran_len = fsiz;
|
gran_len = fsiz;
|
||||||
}
|
}
|
||||||
else if (fh->get_device () == FH_ZERO)
|
|
||||||
{
|
|
||||||
/* mmap /dev/zero is like MAP_ANONYMOUS. */
|
|
||||||
fd = -1;
|
|
||||||
flags |= MAP_ANONYMOUS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fd == -1)
|
|
||||||
{
|
|
||||||
fh_paging_file.set_io_handle (INVALID_HANDLE_VALUE);
|
|
||||||
fh = &fh_paging_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD access = (prot & PROT_WRITE) ? FILE_MAP_WRITE : FILE_MAP_READ;
|
DWORD access = (prot & PROT_WRITE) ? FILE_MAP_WRITE : FILE_MAP_READ;
|
||||||
/* copy-on-write doesn't work at all on 9x using anonymous maps.
|
/* copy-on-write doesn't work at all on 9x using anonymous maps.
|
||||||
|
|
|
@ -946,7 +946,6 @@ cygwin_gethostname (char *name, size_t len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug_printf ("name %s", name);
|
debug_printf ("name %s", name);
|
||||||
h_errno = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,7 +995,6 @@ cygwin_gethostbyname (const char *name)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
|
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
|
||||||
h_errno = 0;
|
|
||||||
}
|
}
|
||||||
return _my_tls.locals.hostent_buf;
|
return _my_tls.locals.hostent_buf;
|
||||||
}
|
}
|
||||||
|
@ -1020,7 +1018,6 @@ cygwin_gethostbyaddr (const char *addr, int len, int type)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
|
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
|
||||||
h_errno = 0;
|
|
||||||
}
|
}
|
||||||
return _my_tls.locals.hostent_buf;
|
return _my_tls.locals.hostent_buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,11 @@ scandir (const char *dir,
|
||||||
struct dirent *ent, *etmp, **nl = NULL, **ntmp;
|
struct dirent *ent, *etmp, **nl = NULL, **ntmp;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int allocated = 0;
|
int allocated = 0;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
if (!(dirp = opendir (dir)))
|
if (!(dirp = opendir (dir)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int prior_errno = get_errno ();
|
|
||||||
set_errno (0);
|
|
||||||
if (!compar)
|
if (!compar)
|
||||||
compar = alphasort;
|
compar = alphasort;
|
||||||
|
|
||||||
|
@ -44,10 +43,6 @@ scandir (const char *dir,
|
||||||
{
|
{
|
||||||
if (!select || select (ent))
|
if (!select || select (ent))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Ignore error from readdir/select. See POSIX specs. */
|
|
||||||
set_errno (0);
|
|
||||||
|
|
||||||
if (count == allocated)
|
if (count == allocated)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -59,7 +54,7 @@ scandir (const char *dir,
|
||||||
ntmp = (struct dirent **) realloc (nl, allocated * sizeof *nl);
|
ntmp = (struct dirent **) realloc (nl, allocated * sizeof *nl);
|
||||||
if (!ntmp)
|
if (!ntmp)
|
||||||
{
|
{
|
||||||
set_errno (ENOMEM);
|
err = ENOMEM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nl = ntmp;
|
nl = ntmp;
|
||||||
|
@ -67,7 +62,7 @@ scandir (const char *dir,
|
||||||
|
|
||||||
if (!(etmp = (struct dirent *) malloc (sizeof *ent)))
|
if (!(etmp = (struct dirent *) malloc (sizeof *ent)))
|
||||||
{
|
{
|
||||||
set_errno (ENOMEM);
|
err = ENOMEM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*etmp = *ent;
|
*etmp = *ent;
|
||||||
|
@ -75,7 +70,7 @@ scandir (const char *dir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prior_errno = get_errno ()) != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
closedir (dirp);
|
closedir (dirp);
|
||||||
if (nl)
|
if (nl)
|
||||||
|
@ -85,12 +80,11 @@ scandir (const char *dir,
|
||||||
free (nl);
|
free (nl);
|
||||||
}
|
}
|
||||||
/* Ignore errors from closedir() and what not else. */
|
/* Ignore errors from closedir() and what not else. */
|
||||||
set_errno (prior_errno);
|
set_errno (err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir (dirp);
|
closedir (dirp);
|
||||||
set_errno (prior_errno);
|
|
||||||
|
|
||||||
qsort (nl, count, sizeof *nl, (int (*)(const void *, const void *)) compar);
|
qsort (nl, count, sizeof *nl, (int (*)(const void *, const void *)) compar);
|
||||||
if (namelist)
|
if (namelist)
|
||||||
|
|
|
@ -879,8 +879,7 @@ _fstat64_r (struct _reent *ptr, int fd, struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
set_errno (0);
|
if ((ret = fstat64 (fd, buf)) == -1)
|
||||||
if ((ret = fstat64 (fd, buf)) == -1 && get_errno () != 0)
|
|
||||||
ptr->_errno = get_errno ();
|
ptr->_errno = get_errno ();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -900,8 +899,7 @@ _fstat_r (struct _reent *ptr, int fd, struct __stat32 *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
set_errno (0);
|
if ((ret = fstat (fd, buf)) == -1)
|
||||||
if ((ret = fstat (fd, buf)) == -1 && get_errno () != 0)
|
|
||||||
ptr->_errno = get_errno ();
|
ptr->_errno = get_errno ();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1039,8 +1037,7 @@ _stat64_r (struct _reent *ptr, const char *name, struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
set_errno (0);
|
if ((ret = stat64 (name, buf)) == -1)
|
||||||
if ((ret = stat64 (name, buf)) == -1 && get_errno () != 0)
|
|
||||||
ptr->_errno = get_errno ();
|
ptr->_errno = get_errno ();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1060,8 +1057,7 @@ _stat_r (struct _reent *ptr, const char *name, struct __stat32 *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
set_errno (0);
|
if ((ret = stat (name, buf)) == -1)
|
||||||
if ((ret = stat (name, buf)) == -1 && get_errno () != 0)
|
|
||||||
ptr->_errno = get_errno ();
|
ptr->_errno = get_errno ();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue