Throughout, remove extra space after function name from debugging output.

Throughout, change syscalls to report on return values using new %R format
option.
* smallprint.cc (__small_vsprintf): Add parsing for %R to report on return
values and possible errno from syscalls.
* errno.cc (errmap): Add PRIVILEGE_NOT_HELD.
* fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread use
shorter name to reduce debuggging output.
* select.cc (start_thread_pipe): Ditto.
(start_thread_serial): Ditto.
(start_thread_socket): Ditto.
(start_thread_mailslot): Ditto.
* sigproc.cc (talktome): Ditto.
This commit is contained in:
Christopher Faylor 2011-12-03 21:43:27 +00:00
parent 8b25478267
commit b9aa81491f
42 changed files with 224 additions and 188 deletions

View File

@ -1,3 +1,22 @@
2011-12-03 Christopher Faylor <me.cygwin2011@cgf.cx>
Throughout, remove extra space after function name from debugging
output.
Throughout, change syscalls to report on return values using new %R
format option.
* smallprint.cc (__small_vsprintf): Add parsing for %R to report on
return values and possible errno from syscalls.
* errno.cc (errmap): Add PRIVILEGE_NOT_HELD.
* fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread
use shorter name to reduce debuggging output.
* select.cc (start_thread_pipe): Ditto.
(start_thread_serial): Ditto.
(start_thread_socket): Ditto.
(start_thread_mailslot): Ditto.
* sigproc.cc (talktome): Ditto.
2011-12-03 Corinna Vinschen <vinschen@redhat.com> 2011-12-03 Corinna Vinschen <vinschen@redhat.com>
* fhandler.cc (fhandler_base::open): Fix comment a bit more. * fhandler.cc (fhandler_base::open): Fix comment a bit more.

View File

@ -257,7 +257,7 @@ closedir (DIR *dir)
if (dir->__d_cookie != __DIRENT_COOKIE) if (dir->__d_cookie != __DIRENT_COOKIE)
{ {
set_errno (EBADF); set_errno (EBADF);
syscall_printf ("-1 = closedir (%p)", dir); syscall_printf ("%R = closedir(%p)", -1, dir);
return -1; return -1;
} }
@ -271,7 +271,7 @@ closedir (DIR *dir)
free (dir->__d_dirname); free (dir->__d_dirname);
free (dir->__d_dirent); free (dir->__d_dirent);
free (dir); free (dir);
syscall_printf ("%d = closedir (%p)", res); syscall_printf ("%R = closedir(%p)", res);
return res; return res;
} }
@ -320,7 +320,7 @@ mkdir (const char *dir, mode_t mode)
delete fh; delete fh;
done: done:
syscall_printf ("%d = mkdir (%s, %d)", res, dir, mode); syscall_printf ("%R = mkdir(%s, %d)", res, dir, mode);
return res; return res;
} }
@ -353,6 +353,6 @@ rmdir (const char *dir)
delete fh; delete fh;
done: done:
syscall_printf ("%d = rmdir (%s)", res, dir); syscall_printf ("%R = rmdir(%s)", res, dir);
return res; return res;
} }

View File

@ -757,7 +757,7 @@ dtable::dup3 (int oldfd, int newfd, int flags)
done: done:
MALLOC_CHECK; MALLOC_CHECK;
unlock (); unlock ();
syscall_printf ("%d = dup3 (%d, %d, %p)", res, oldfd, newfd, flags); syscall_printf ("%R = dup3(%d, %d, %p)", res, oldfd, newfd, flags);
return res; return res;
} }

View File

@ -156,6 +156,7 @@ static NO_COPY struct
X (WAIT_NO_CHILDREN, ECHILD), X (WAIT_NO_CHILDREN, ECHILD),
X (WORKING_SET_QUOTA, EAGAIN), X (WORKING_SET_QUOTA, EAGAIN),
X (WRITE_PROTECT, EROFS), X (WRITE_PROTECT, EROFS),
X (PRIVILEGE_NOT_HELD, EPERM),
{ 0, NULL, 0} { 0, NULL, 0}
}; };

View File

@ -67,7 +67,7 @@ fcntl64 (int fd, int cmd, ...)
break; break;
} }
done: done:
syscall_printf ("%d = fcntl (%d, %d, %p)", res, fd, cmd, arg); syscall_printf ("%R = fcntl(%d, %d, %p)", res, fd, cmd, arg);
return res; return res;
} }

View File

@ -1679,7 +1679,7 @@ fhandler_pty_master::setup ()
errstr = "pty master control pipe"; errstr = "pty master control pipe";
goto err; goto err;
} }
master_thread = new cygthread (::pty_master_thread, this, "pty_master"); master_thread = new cygthread (::pty_master_thread, this, "ptym");
if (!master_thread) if (!master_thread)
{ {
errstr = "pty master control thread"; errstr = "pty master control thread";

View File

@ -1520,7 +1520,7 @@ flock (int fd, int operation)
if ((res == -1) && ((get_errno () == EAGAIN) || (get_errno () == EACCES))) if ((res == -1) && ((get_errno () == EAGAIN) || (get_errno () == EACCES)))
set_errno (EWOULDBLOCK); set_errno (EWOULDBLOCK);
done: done:
syscall_printf ("%d = flock (%d, %d)", res, fd, operation); syscall_printf ("%R = flock(%d, %d)", res, fd, operation);
return res; return res;
} }
@ -1576,6 +1576,6 @@ lockf (int filedes, int function, _off64_t size)
} }
res = cfd->lock (cmd, &fl); res = cfd->lock (cmd, &fl);
done: done:
syscall_printf ("%d = lockf (%d, %d, %D)", res, filedes, function, size); syscall_printf ("%R = lockf(%d, %d, %D)", res, filedes, function, size);
return res; return res;
} }

View File

@ -685,7 +685,7 @@ fork ()
set_errno (grouped.this_errno); set_errno (grouped.this_errno);
} }
syscall_printf ("%d = fork()", res); syscall_printf ("%R = fork()", res);
return res; return res;
} }
#ifdef DEBUGGING #ifdef DEBUGGING

View File

@ -1244,7 +1244,7 @@ msync (void *addr, size_t len, int flags)
out: out:
LIST_UNLOCK (); LIST_UNLOCK ();
syscall_printf ("%d = msync()", ret); syscall_printf ("%R = msync()", ret);
return ret; return ret;
} }
@ -1337,7 +1337,7 @@ mprotect (void *addr, size_t len, int prot)
out: out:
syscall_printf ("%d = mprotect ()", ret ? 0 : -1); syscall_printf ("%R = mprotect ()", ret ? 0 : -1);
return ret ? 0 : -1; return ret ? 0 : -1;
} }

View File

@ -1801,7 +1801,7 @@ mount (const char *win32_path, const char *posix_path, unsigned flags)
res = mount_table->add_item (w32_path, posix_path, flags); res = mount_table->add_item (w32_path, posix_path, flags);
} }
syscall_printf ("%d = mount (%s, %s, %p)", res, win32_path, posix_path, flags); syscall_printf ("%R = mount(%s, %s, %p)", res, win32_path, posix_path, flags);
return res; return res;
} }
@ -1836,7 +1836,7 @@ cygwin_umount (const char *path, unsigned flags)
if (!(flags & MOUNT_CYGDRIVE)) if (!(flags & MOUNT_CYGDRIVE))
res = mount_table->del_item (path, flags & ~MOUNT_SYSTEM); res = mount_table->del_item (path, flags & ~MOUNT_SYSTEM);
syscall_printf ("%d = cygwin_umount (%s, %d)", res, path, flags); syscall_printf ("%R = cygwin_umount(%s, %d)", res, path, flags);
return res; return res;
} }

View File

@ -661,7 +661,7 @@ cygwin_socket (int af, int type, int protocol)
} }
done: done:
syscall_printf ("%d = socket (%d, %d (flags %p), %d)", syscall_printf ("%R = socket(%d, %d (flags %p), %d)",
res, af, type, flags, protocol); res, af, type, flags, protocol);
return res; return res;
} }
@ -681,7 +681,7 @@ cygwin_sendto (int fd, const void *buf, size_t len, int flags,
else else
res = fh->sendto (buf, len, flags, to, tolen); res = fh->sendto (buf, len, flags, to, tolen);
syscall_printf ("%d = sendto (%d, %p, %d, %x, %p, %d)", syscall_printf ("%R = sendto(%d, %p, %d, %x, %p, %d)",
res, fd, buf, len, flags, to, tolen); res, fd, buf, len, flags, to, tolen);
return res; return res;
} }
@ -701,7 +701,7 @@ cygwin_recvfrom (int fd, void *buf, size_t len, int flags,
else if ((res = len) != 0) else if ((res = len) != 0)
res = fh->recvfrom (buf, len, flags, from, fromlen); res = fh->recvfrom (buf, len, flags, from, fromlen);
syscall_printf ("%d = recvfrom (%d, %p, %d, %x, %p, %p)", syscall_printf ("%R = recvfrom(%d, %p, %d, %x, %p, %p)",
res, fd, buf, len, flags, from, fromlen); res, fd, buf, len, flags, from, fromlen);
return res; return res;
} }
@ -816,7 +816,7 @@ cygwin_setsockopt (int fd, int level, int optname, const void *optval,
} }
} }
syscall_printf ("%d = setsockopt (%d, %d, %x, %p, %d)", syscall_printf ("%R = setsockopt(%d, %d, %x, %p, %d)",
res, fd, level, optname, optval, optlen); res, fd, level, optname, optval, optlen);
return res; return res;
} }
@ -876,7 +876,7 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval,
} }
} }
syscall_printf ("%d = getsockopt (%d, %d, 0x%x, %p, %p)", syscall_printf ("%R = getsockopt(%d, %d, 0x%x, %p, %p)",
res, fd, level, optname, optval, optlen); res, fd, level, optname, optval, optlen);
return res; return res;
} }
@ -904,7 +904,7 @@ cygwin_connect (int fd, const struct sockaddr *name, socklen_t namelen)
else else
res = fh->connect (name, namelen); res = fh->connect (name, namelen);
syscall_printf ("%d = connect (%d, %p, %d)", res, fd, name, namelen); syscall_printf ("%R = connect(%d, %p, %d)", res, fd, name, namelen);
return res; return res;
} }
@ -1280,7 +1280,7 @@ cygwin_accept (int fd, struct sockaddr *peer, socklen_t *len)
else else
res = fh->accept4 (peer, len, fh->is_nonblocking () ? SOCK_NONBLOCK : 0); res = fh->accept4 (peer, len, fh->is_nonblocking () ? SOCK_NONBLOCK : 0);
syscall_printf ("%d = accept (%d, %p, %p)", res, fd, peer, len); syscall_printf ("%R = accept(%d, %p, %p)", res, fd, peer, len);
return res; return res;
} }
@ -1302,7 +1302,7 @@ accept4 (int fd, struct sockaddr *peer, socklen_t *len, int flags)
else else
res = fh->accept4 (peer, len, flags); res = fh->accept4 (peer, len, flags);
syscall_printf ("%d = accept4 (%d, %p, %p, %p)", res, fd, peer, len, flags); syscall_printf ("%R = accept4(%d, %p, %p, %p)", res, fd, peer, len, flags);
return res; return res;
} }
@ -1319,7 +1319,7 @@ cygwin_bind (int fd, const struct sockaddr *my_addr, socklen_t addrlen)
else else
res = fh->bind (my_addr, addrlen); res = fh->bind (my_addr, addrlen);
syscall_printf ("%d = bind (%d, %p, %d)", res, fd, my_addr, addrlen); syscall_printf ("%R = bind(%d, %p, %d)", res, fd, my_addr, addrlen);
return res; return res;
} }
@ -1337,7 +1337,7 @@ cygwin_getsockname (int fd, struct sockaddr *addr, socklen_t *namelen)
else else
res = fh->getsockname (addr, namelen); res = fh->getsockname (addr, namelen);
syscall_printf ("%d = getsockname (%d, %p, %p)", res, fd, addr, namelen); syscall_printf ("%R =getsockname (%d, %p, %p)", res, fd, addr, namelen);
return res; return res;
} }
@ -1353,7 +1353,7 @@ cygwin_listen (int fd, int backlog)
else else
res = fh->listen (backlog); res = fh->listen (backlog);
syscall_printf ("%d = listen (%d, %d)", res, fd, backlog); syscall_printf ("%R = listen(%d, %d)", res, fd, backlog);
return res; return res;
} }
@ -1370,7 +1370,7 @@ cygwin_shutdown (int fd, int how)
else else
res = fh->shutdown (how); res = fh->shutdown (how);
syscall_printf ("%d = shutdown (%d, %d)", res, fd, how); syscall_printf ("%R = shutdown(%d, %d)", res, fd, how);
return res; return res;
} }
@ -1436,7 +1436,7 @@ cygwin_getpeername (int fd, struct sockaddr *name, socklen_t *len)
else else
res = fh->getpeername (name, len); res = fh->getpeername (name, len);
syscall_printf ("%d = getpeername (%d) %d", res, fd, (fh ? fh->get_socket () : -1)); syscall_printf ("%R = getpeername(%d) %d", res, fd, (fh ? fh->get_socket () : -1));
return res; return res;
} }
@ -1454,7 +1454,7 @@ cygwin_recv (int fd, void *buf, size_t len, int flags)
else if ((res = len) != 0) else if ((res = len) != 0)
res = fh->recvfrom (buf, len, flags, NULL, NULL); res = fh->recvfrom (buf, len, flags, NULL, NULL);
syscall_printf ("%d = recv (%d, %p, %d, %x)", res, fd, buf, len, flags); syscall_printf ("%R = recv(%d, %p, %d, %x)", res, fd, buf, len, flags);
return res; return res;
} }
@ -1472,7 +1472,7 @@ cygwin_send (int fd, const void *buf, size_t len, int flags)
else else
res = fh->sendto (buf, len, flags, NULL, 0); res = fh->sendto (buf, len, flags, NULL, 0);
syscall_printf ("%d = send (%d, %p, %d, %x)", res, fd, buf, len, flags); syscall_printf ("%R = send(%d, %p, %d, %x)", res, fd, buf, len, flags);
return res; return res;
} }
@ -2782,7 +2782,7 @@ socketpair (int family, int type, int protocol, int *sb)
} }
done: done:
syscall_printf ("%d = socketpair (...)", res); syscall_printf ("%R = socketpair(...)", res);
return res; return res;
} }
@ -2816,7 +2816,7 @@ cygwin_recvmsg (int fd, struct msghdr *msg, int flags)
res = fh->recvmsg (msg, flags); res = fh->recvmsg (msg, flags);
} }
syscall_printf ("%d = recvmsg (%d, %p, %x)", res, fd, msg, flags); syscall_printf ("%R = recvmsg(%d, %p, %x)", res, fd, msg, flags);
return res; return res;
} }
@ -2838,7 +2838,7 @@ cygwin_sendmsg (int fd, const struct msghdr *msg, int flags)
res = fh->sendmsg (msg, flags); res = fh->sendmsg (msg, flags);
} }
syscall_printf ("%d = sendmsg (%d, %p, %x)", res, fd, msg, flags); syscall_printf ("%R = sendmsg(%d, %p, %x)", res, fd, msg, flags);
return res; return res;
} }

View File

@ -2890,7 +2890,7 @@ chdir (const char *in_dir)
/* Note that we're accessing cwd.posix without a lock here. I didn't think /* Note that we're accessing cwd.posix without a lock here. I didn't think
it was worth locking just for strace. */ it was worth locking just for strace. */
syscall_printf ("%d = chdir() cygheap->cwd.posix '%s' native '%S'", res, syscall_printf ("%R = chdir() cygheap->cwd.posix '%s' native '%S'", res,
cygheap->cwd.get_posix (), path.get_nt_native_path ()); cygheap->cwd.get_posix (), path.get_nt_native_path ());
MALLOC_CHECK; MALLOC_CHECK;
return res; return res;
@ -2906,7 +2906,7 @@ fchdir (int fd)
else else
res = -1; res = -1;
syscall_printf ("%d = fchdir (%d)", res, fd); syscall_printf ("%R = fchdir(%d)", res, fd);
return res; return res;
} }

View File

@ -348,7 +348,7 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode)
res = 0; res = 0;
} }
syscall_printf ("%d = pipe ([%p, %p], %d, %p)", res, fhs[0], fhs[1], psize, mode); syscall_printf ("%R = pipe([%p, %p], %d, %p)", res, fhs[0], fhs[1], psize, mode);
return res; return res;
} }

View File

@ -108,7 +108,7 @@ getrusage (int intwho, struct rusage *rusage_in)
res = -1; res = -1;
} }
syscall_printf ("%d = getrusage (%d, %p)", res, intwho, rusage_in); syscall_printf ("%R = getrusage(%d, %p)", res, intwho, rusage_in);
return res; return res;
} }

View File

@ -440,7 +440,7 @@ getacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp)
aclbufp[i].a_perm &= ~(DENY_R | DENY_W | DENY_X); aclbufp[i].a_perm &= ~(DENY_R | DENY_W | DENY_X);
aclsort32 (pos, 0, aclbufp); aclsort32 (pos, 0, aclbufp);
} }
syscall_printf ("%d = getacl (%S)", pos, pc.get_nt_native_path ()); syscall_printf ("%R = getacl(%S)", pos, pc.get_nt_native_path ());
return pos; return pos;
} }
@ -462,7 +462,7 @@ acl32 (const char *path, int cmd, int nentries, __aclent32_t *aclbufp)
res = fh->facl (cmd, nentries, aclbufp); res = fh->facl (cmd, nentries, aclbufp);
delete fh; delete fh;
syscall_printf ("%d = acl (%s)", res, path); syscall_printf ("%R = acl(%s)", res, path);
return res; return res;
} }
@ -484,7 +484,7 @@ facl32 (int fd, int cmd, int nentries, __aclent32_t *aclbufp)
return -1; return -1;
} }
int res = cfd->facl (cmd, nentries, aclbufp); int res = cfd->facl (cmd, nentries, aclbufp);
syscall_printf ("%d = facl (%s) )", res, cfd->get_name ()); syscall_printf ("%R = facl(%s) )", res, cfd->get_name ());
return res; return res;
} }

View File

@ -169,7 +169,7 @@ cygwin_logon_user (const struct passwd *pw, const char *password)
hToken = INVALID_HANDLE_VALUE; hToken = INVALID_HANDLE_VALUE;
} }
cygheap->user.reimpersonate (); cygheap->user.reimpersonate ();
debug_printf ("%d = logon_user(%s,...)", hToken, pw->pw_name); debug_printf ("%R = logon_user(%s,...)", hToken, pw->pw_name);
return hToken; return hToken;
} }

View File

@ -654,7 +654,7 @@ start_thread_pipe (select_record *me, select_stuff *stuff)
{ {
pi->start = &stuff->start; pi->start = &stuff->start;
pi->stop_thread = false; pi->stop_thread = false;
pi->thread = new cygthread (thread_pipe, pi, "select_pipe"); pi->thread = new cygthread (thread_pipe, pi, "pipesel");
me->h = *pi->thread; me->h = *pi->thread;
if (!me->h) if (!me->h)
return 0; return 0;
@ -1138,7 +1138,7 @@ start_thread_serial (select_record *me, select_stuff *stuff)
select_serial_info *si = new select_serial_info; select_serial_info *si = new select_serial_info;
si->start = &stuff->start; si->start = &stuff->start;
si->stop_thread = false; si->stop_thread = false;
si->thread = new cygthread (thread_serial, si, "select_serial"); si->thread = new cygthread (thread_serial, si, "sersel");
me->h = *si->thread; me->h = *si->thread;
stuff->device_specific_serial = si; stuff->device_specific_serial = si;
} }
@ -1407,7 +1407,7 @@ start_thread_socket (select_record *me, select_stuff *stuff)
stuff->device_specific_socket = si; stuff->device_specific_socket = si;
si->start = &stuff->start; si->start = &stuff->start;
select_printf ("stuff_start %p", &stuff->start); select_printf ("stuff_start %p", &stuff->start);
si->thread = new cygthread (thread_socket, si, "select_socket"); si->thread = new cygthread (thread_socket, si, "socksel");
me->h = *si->thread; me->h = *si->thread;
return 1; return 1;
} }
@ -1645,7 +1645,7 @@ start_thread_mailslot (select_record *me, select_stuff *stuff)
select_mailslot_info *mi = new select_mailslot_info; select_mailslot_info *mi = new select_mailslot_info;
mi->start = &stuff->start; mi->start = &stuff->start;
mi->stop_thread = false; mi->stop_thread = false;
mi->thread = new cygthread (thread_mailslot, mi, "select_mailslot"); mi->thread = new cygthread (thread_mailslot, mi, "mailsel");
me->h = *mi->thread; me->h = *mi->thread;
if (!me->h) if (!me->h)
return 0; return 0;

View File

@ -376,7 +376,7 @@ kill_pgrp (pid_t pid, siginfo_t& si)
set_errno (ESRCH); set_errno (ESRCH);
res = -1; res = -1;
} }
syscall_printf ("%d = kill (%d, %d)", res, pid, si.si_signo); syscall_printf ("%R = kill(%d, %d)", res, pid, si.si_signo);
return res; return res;
} }

View File

@ -1241,7 +1241,7 @@ talktome (siginfo_t *si)
pinfo pi (si->si_pid); pinfo pi (si->si_pid);
if (pi) if (pi)
new cygthread (commune_process, size, si, "commune_process"); new cygthread (commune_process, size, si, "commune");
} }
void void

View File

@ -73,6 +73,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
DWORD err = GetLastError (); DWORD err = GetLastError ();
long Rval = 0;
while (*fmt) while (*fmt)
{ {
int i, n = 0x7fff; int i, n = 0x7fff;
@ -146,8 +147,14 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
strcpy (dst, "Win32 error "); strcpy (dst, "Win32 error ");
dst = __rn (dst + sizeof ("Win32 error"), 10, 0, err, len, pad, LMASK); dst = __rn (dst + sizeof ("Win32 error"), 10, 0, err, len, pad, LMASK);
break; break;
case 'R':
case 'd': case 'd':
dst = rnarg (dst, 10, addsign, len, pad); {
long val = va_arg (ap, long);
dst = __rn (dst, 10, addsign, val, len, pad, LMASK);
if (c == 'R')
Rval = val;
}
break; break;
case 'D': case 'D':
dst = rnargLL (dst, 10, addsign, len, pad); dst = rnargLL (dst, 10, addsign, len, pad);
@ -241,6 +248,12 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
} }
} }
} }
if (Rval < 0)
{
strcpy (dst, ", errno ");
dst += strlen (", errno ");
dst = __rn (dst, 10, false, get_errno (), 0, 0, LMASK);
}
*dst = 0; *dst = 0;
SetLastError (err); SetLastError (err);
return dst - orig; return dst - orig;

View File

@ -137,10 +137,10 @@ dup2 (int oldfd, int newfd)
cygheap_fdget cfd (oldfd); cygheap_fdget cfd (oldfd);
if (cfd < 0) if (cfd < 0)
{ {
syscall_printf ("-1 = dup2 (%d, %d) (oldfd not open)", oldfd, newfd); syscall_printf ("%R = dup2(%d,%d) (oldfd not open)", -1, oldfd, newfd);
return -1; return -1;
} }
syscall_printf ("%d = dup2 (%d, %d) (newfd==oldfd)", oldfd, oldfd, newfd); syscall_printf ("%R = dup2(%d, %d) (newfd==oldfd)", oldfd, oldfd, newfd);
return oldfd; return oldfd;
} }
return cygheap->fdtab.dup3 (oldfd, newfd, 0); return cygheap->fdtab.dup3 (oldfd, newfd, 0);
@ -934,7 +934,7 @@ unlink (const char *ourname)
__seterrno_from_nt_status (status); __seterrno_from_nt_status (status);
done: done:
syscall_printf ("%d = unlink (%s)", res, ourname); syscall_printf ("%R = unlink(%s)", res, ourname);
return res; return res;
} }
@ -946,7 +946,7 @@ _remove_r (struct _reent *, const char *ourname)
if (win32_name.error) if (win32_name.error)
{ {
set_errno (win32_name.error); set_errno (win32_name.error);
syscall_printf ("-1 = remove (%s)", ourname); syscall_printf ("%R = remove(%s)",-1, ourname);
return -1; return -1;
} }
@ -1074,8 +1074,7 @@ read (int fd, void *ptr, size_t len)
cfd->read (ptr, res = len); cfd->read (ptr, res = len);
done: done:
syscall_printf ("%d = read (%d, %p, %d), errno %d", res, fd, ptr, len, syscall_printf ("%R = read(%d, %p, %d)", res, fd, ptr, len);
get_errno ());
MALLOC_CHECK; MALLOC_CHECK;
return (ssize_t) res; return (ssize_t) res;
} }
@ -1119,8 +1118,7 @@ readv (int fd, const struct iovec *const iov, const int iovcnt)
res = cfd->readv (iov, iovcnt, tot); res = cfd->readv (iov, iovcnt, tot);
done: done:
syscall_printf ("%d = readv (%d, %p, %d), errno %d", res, fd, iov, iovcnt, syscall_printf ("%R = readv(%d, %p, %d)", res, fd, iov, iovcnt);
get_errno ());
MALLOC_CHECK; MALLOC_CHECK;
return res; return res;
} }
@ -1137,8 +1135,7 @@ pread (int fd, void *ptr, size_t len, _off64_t off)
else else
res = cfd->pread (ptr, len, off); res = cfd->pread (ptr, len, off);
syscall_printf ("%d = pread (%d, %p, %d, %d), errno %d", syscall_printf ("%R = pread(%d, %p, %d, %d)", res, fd, ptr, len, off);
res, fd, ptr, len, off, get_errno ());
return res; return res;
} }
@ -1173,11 +1170,9 @@ write (int fd, const void *ptr, size_t len)
done: done:
if (fd == 1 || fd == 2) if (fd == 1 || fd == 2)
paranoid_printf ("%d = write (%d, %p, %d), errno %d", paranoid_printf ("%R = write(%d, %p, %d)", res, fd, ptr, len);
res, fd, ptr, len, get_errno ());
else else
syscall_printf ("%d = write (%d, %p, %d), errno %d", syscall_printf ("%R = write(%d, %p, %d)", res, fd, ptr, len);
res, fd, ptr, len, get_errno ());
MALLOC_CHECK; MALLOC_CHECK;
return res; return res;
@ -1223,11 +1218,9 @@ writev (const int fd, const struct iovec *const iov, const int iovcnt)
done: done:
if (fd == 1 || fd == 2) if (fd == 1 || fd == 2)
paranoid_printf ("%d = writev (%d, %p, %d), errno %d", paranoid_printf ("%R = writev(%d, %p, %d)", res, fd, iov, iovcnt);
res, fd, iov, iovcnt, get_errno ());
else else
syscall_printf ("%d = writev (%d, %p, %d), errno %d", syscall_printf ("%R = writev(%d, %p, %d)", res, fd, iov, iovcnt);
res, fd, iov, iovcnt, get_errno ());
MALLOC_CHECK; MALLOC_CHECK;
return res; return res;
@ -1245,8 +1238,7 @@ pwrite (int fd, void *ptr, size_t len, _off64_t off)
else else
res = cfd->pwrite (ptr, len, off); res = cfd->pwrite (ptr, len, off);
syscall_printf ("%d = pwrite (%d, %p, %d, %d), errno %d", syscall_printf ("%R = pwrite(%d, %p, %d, %d)", res, fd, ptr, len, off);
res, fd, ptr, len, off, get_errno ());
return res; return res;
} }
@ -1328,7 +1320,7 @@ open (const char *unix_path, int flags, ...)
} }
} }
syscall_printf ("%d = open (%s, %p)", res, unix_path, flags); syscall_printf ("%R = open(%s, %p)", res, unix_path, flags);
return res; return res;
} }
@ -1387,7 +1379,7 @@ close (int fd)
cfd.release (); cfd.release ();
} }
syscall_printf ("%d = close (%d)", res, fd); syscall_printf ("%R = close(%d)", res, fd);
MALLOC_CHECK; MALLOC_CHECK;
return res; return res;
} }
@ -1404,7 +1396,7 @@ isatty (int fd)
res = 0; res = 0;
else else
res = cfd->is_tty (); res = cfd->is_tty ();
syscall_printf ("%d = isatty (%d)", res, fd); syscall_printf ("%R = isatty(%d)", res, fd);
return res; return res;
} }
EXPORT_ALIAS (isatty, _isatty) EXPORT_ALIAS (isatty, _isatty)
@ -1433,7 +1425,7 @@ link (const char *oldpath, const char *newpath)
delete fh; delete fh;
error: error:
syscall_printf ("%d = link (%s, %s)", res, oldpath, newpath); syscall_printf ("%R = link(%s, %s)", res, oldpath, newpath);
return res; return res;
} }
@ -1461,7 +1453,7 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
delete fh; delete fh;
error: error:
syscall_printf ("%d = %schown (%s,...)", syscall_printf ("%R = %schown(%s,...)",
res, (fmode & PC_SYM_NOFOLLOW) ? "l" : "", name); res, (fmode & PC_SYM_NOFOLLOW) ? "l" : "", name);
return res; return res;
} }
@ -1504,7 +1496,7 @@ fchown32 (int fd, __uid32_t uid, __gid32_t gid)
int res = cfd->fchown (uid, gid); int res = cfd->fchown (uid, gid);
syscall_printf ("%d = fchown (%s,...)", res, cfd->get_name ()); syscall_printf ("%R = fchown(%s,...)", res, cfd->get_name ());
return res; return res;
} }
@ -1553,7 +1545,7 @@ chmod (const char *path, mode_t mode)
delete fh; delete fh;
error: error:
syscall_printf ("%d = chmod (%s, %p)", res, path, mode); syscall_printf ("%R = chmod(%s, %p)", res, path, mode);
return res; return res;
} }
@ -1613,7 +1605,7 @@ fstat64 (int fd, struct __stat64 *buf)
} }
} }
syscall_printf ("%d = fstat (%d, %p)", res, fd, buf); syscall_printf ("%R = fstat(%d, %p)", res, fd, buf);
return res; return res;
} }
@ -2397,7 +2389,7 @@ out:
NtClose (fh); NtClose (fh);
if (wincap.has_transactions () && trans) if (wincap.has_transactions () && trans)
stop_transaction (status, old_trans, trans); stop_transaction (status, old_trans, trans);
syscall_printf ("%d = rename (%s, %s)", res, oldpath, newpath); syscall_printf ("%R = rename(%s, %s)", res, oldpath, newpath);
return res; return res;
} }
@ -2674,7 +2666,7 @@ posix_fadvise (int fd, _off64_t offset, _off64_t len, int advice)
res = cfd->fadvise (offset, len, advice); res = cfd->fadvise (offset, len, advice);
else else
set_errno (EBADF); set_errno (EBADF);
syscall_printf ("%d = posix_fadvice (%d, %D, %D, %d)", syscall_printf ("%R = posix_fadvice(%d, %D, %D, %d)",
res, fd, offset, len, advice); res, fd, offset, len, advice);
return res; return res;
} }
@ -2693,7 +2685,7 @@ posix_fallocate (int fd, _off64_t offset, _off64_t len)
else else
set_errno (EBADF); set_errno (EBADF);
} }
syscall_printf ("%d = posix_fallocate (%d, %D, %D)", res, fd, offset, len); syscall_printf ("%R = posix_fallocate(%d, %D, %D)", res, fd, offset, len);
return res; return res;
} }
@ -2706,7 +2698,7 @@ ftruncate64 (int fd, _off64_t length)
res = cfd->ftruncate (length, true); res = cfd->ftruncate (length, true);
else else
set_errno (EBADF); set_errno (EBADF);
syscall_printf ("%d = ftruncate (%d, %D)", res, fd, length); syscall_printf ("%R = ftruncate(%d, %D)", res, fd, length);
return res; return res;
} }
@ -2731,7 +2723,7 @@ truncate64 (const char *pathname, _off64_t length)
res = ftruncate64 (fd, length); res = ftruncate64 (fd, length);
close (fd); close (fd);
} }
syscall_printf ("%d = truncate (%s, %D)", res, pathname, length); syscall_printf ("%R = truncate(%s, %D)", res, pathname, length);
return res; return res;
} }
@ -2754,7 +2746,7 @@ get_osfhandle (int fd)
else else
res = -1; res = -1;
syscall_printf ("%d = get_osfhandle (%d)", res, fd); syscall_printf ("%R = get_osfhandle(%d)", res, fd);
return res; return res;
} }
@ -2800,7 +2792,7 @@ statvfs (const char *name, struct statvfs *sfs)
delete fh; delete fh;
error: error:
MALLOC_CHECK; MALLOC_CHECK;
syscall_printf ("%d = (%s, %p)", res, name, sfs); syscall_printf ("%R = statvfs(%s,%p)", res, name, sfs);
return res; return res;
} }
@ -3402,8 +3394,7 @@ chroot (const char *newroot)
ret = 0; ret = 0;
} }
syscall_printf ("%d = chroot (%s)", ret ? get_errno () : 0, syscall_printf ("%R = chroot(%s)", ret, newroot ?: "NULL");
newroot ? newroot : "NULL");
return ret; return ret;
} }

View File

@ -40,7 +40,7 @@ tcsendbreak (int fd, int duration)
res = cfd->tcsendbreak (duration); res = cfd->tcsendbreak (duration);
out: out:
syscall_printf ("%d = tcsendbreak (%d, %d)", res, fd, duration); syscall_printf ("%R = tcsendbreak(%d, %d)", res, fd, duration);
return res; return res;
} }
@ -64,7 +64,7 @@ tcdrain (int fd)
res = cfd->tcdrain (); res = cfd->tcdrain ();
out: out:
syscall_printf ("%d = tcdrain (%d)", res, fd); syscall_printf ("%R = tcdrain(%d)", res, fd);
return res; return res;
} }
@ -86,7 +86,7 @@ tcflush (int fd, int queue)
res = cfd->tcflush (queue); res = cfd->tcflush (queue);
out: out:
termios_printf ("%d = tcflush (%d, %d)", res, fd, queue); termios_printf ("%R = tcflush(%d, %d)", res, fd, queue);
return res; return res;
} }
@ -106,7 +106,7 @@ tcflow (int fd, int action)
res = cfd->tcflow (action); res = cfd->tcflow (action);
out: out:
syscall_printf ("%d = tcflow (%d, %d)", res, fd, action); syscall_printf ("%R = tcflow(%d, %d)", res, fd, action);
return res; return res;
} }
@ -162,7 +162,7 @@ tcsetattr (int fd, int a, const struct termios *t)
termios_printf ("iflag %p, oflag %p, cflag %p, lflag %p, VMIN %d, VTIME %d", termios_printf ("iflag %p, oflag %p, cflag %p, lflag %p, VMIN %d, VTIME %d",
t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN], t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN],
t->c_cc[VTIME]); t->c_cc[VTIME]);
termios_printf ("%d = tcsetattr (%d, %d, %x)", res, fd, a, t); termios_printf ("%R = tcsetattr(%d, %d, %x)", res, fd, a, t);
return res; return res;
} }
@ -182,7 +182,7 @@ tcgetattr (int fd, struct termios *in_t)
__toapp_termios (in_t, t); __toapp_termios (in_t, t);
if (res) if (res)
termios_printf ("%d = tcgetattr (%d, %p)", res, fd, in_t); termios_printf ("%R = tcgetattr(%d, %p)", res, fd, in_t);
else else
termios_printf ("iflag %x, oflag %x, cflag %x, lflag %x, VMIN %d, VTIME %d", termios_printf ("iflag %x, oflag %x, cflag %x, lflag %x, VMIN %d, VTIME %d",
t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN], t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN],
@ -203,7 +203,7 @@ tcgetpgrp (int fd)
else else
res = cfd->tcgetpgrp (); res = cfd->tcgetpgrp ();
termios_printf ("%d = tcgetpgrp (%d)", res, fd); termios_printf ("%R = tcgetpgrp(%d)", res, fd);
return res; return res;
} }
@ -218,7 +218,7 @@ tcgetsid (int fd)
else else
res = cfd->tcgetsid (); res = cfd->tcgetsid ();
termios_printf ("%d = tcgetsid (%d)", res, fd); termios_printf ("%R = tcgetsid(%d)", res, fd);
return res; return res;
} }
@ -236,7 +236,7 @@ tcsetpgrp (int fd, pid_t pgid)
else else
res = cfd->tcsetpgrp (pgid); res = cfd->tcsetpgrp (pgid);
termios_printf ("%d = tcsetpgrp (%d, %d)", res, fd, pgid); termios_printf ("%R = tcsetpgrp(%d, %d)", res, fd, pgid);
return res; return res;
} }

View File

@ -377,26 +377,31 @@ fixup_timers_after_fork ()
extern "C" int extern "C" int
setitimer (int which, const struct itimerval *value, struct itimerval *ovalue) setitimer (int which, const struct itimerval *value, struct itimerval *ovalue)
{ {
int ret;
if (which != ITIMER_REAL) if (which != ITIMER_REAL)
{ {
set_errno (EINVAL); set_errno (EINVAL);
return -1; ret = -1;
} }
else
{
struct itimerspec spec_value, spec_ovalue; struct itimerspec spec_value, spec_ovalue;
int ret;
spec_value.it_interval.tv_sec = value->it_interval.tv_sec; spec_value.it_interval.tv_sec = value->it_interval.tv_sec;
spec_value.it_interval.tv_nsec = value->it_interval.tv_usec * 1000; spec_value.it_interval.tv_nsec = value->it_interval.tv_usec * 1000;
spec_value.it_value.tv_sec = value->it_value.tv_sec; spec_value.it_value.tv_sec = value->it_value.tv_sec;
spec_value.it_value.tv_nsec = value->it_value.tv_usec * 1000; spec_value.it_value.tv_nsec = value->it_value.tv_usec * 1000;
ret = timer_settime ((timer_t) &ttstart, 0, &spec_value, &spec_ovalue); ret = timer_settime ((timer_t) &ttstart, 0, &spec_value, &spec_ovalue);
if (!ret && ovalue) if (ret)
ret = -1;
else if (ovalue)
{ {
ovalue->it_interval.tv_sec = spec_ovalue.it_interval.tv_sec; ovalue->it_interval.tv_sec = spec_ovalue.it_interval.tv_sec;
ovalue->it_interval.tv_usec = spec_ovalue.it_interval.tv_nsec / 1000; ovalue->it_interval.tv_usec = spec_ovalue.it_interval.tv_nsec / 1000;
ovalue->it_value.tv_sec = spec_ovalue.it_value.tv_sec; ovalue->it_value.tv_sec = spec_ovalue.it_value.tv_sec;
ovalue->it_value.tv_usec = spec_ovalue.it_value.tv_nsec / 1000; ovalue->it_value.tv_usec = spec_ovalue.it_value.tv_nsec / 1000;
} }
syscall_printf ("%d = setitimer ()", ret); }
syscall_printf ("%R = setitimer()", ret);
return ret; return ret;
} }
@ -404,24 +409,33 @@ setitimer (int which, const struct itimerval *value, struct itimerval *ovalue)
extern "C" int extern "C" int
getitimer (int which, struct itimerval *ovalue) getitimer (int which, struct itimerval *ovalue)
{ {
int ret;
if (which != ITIMER_REAL) if (which != ITIMER_REAL)
{ {
set_errno (EINVAL); set_errno (EINVAL);
return -1; ret = -1;
} }
else
{
myfault efault; myfault efault;
if (efault.faulted (EFAULT)) if (efault.faulted (EFAULT))
return -1; ret = -1;
else
{
struct itimerspec spec_ovalue; struct itimerspec spec_ovalue;
int ret = timer_gettime ((timer_t) &ttstart, &spec_ovalue); int ret = timer_gettime ((timer_t) &ttstart, &spec_ovalue);
if (!ret) if (ret)
ret = -1;
else
{ {
ovalue->it_interval.tv_sec = spec_ovalue.it_interval.tv_sec; ovalue->it_interval.tv_sec = spec_ovalue.it_interval.tv_sec;
ovalue->it_interval.tv_usec = spec_ovalue.it_interval.tv_nsec / 1000; ovalue->it_interval.tv_usec = spec_ovalue.it_interval.tv_nsec / 1000;
ovalue->it_value.tv_sec = spec_ovalue.it_value.tv_sec; ovalue->it_value.tv_sec = spec_ovalue.it_value.tv_sec;
ovalue->it_value.tv_usec = spec_ovalue.it_value.tv_nsec / 1000; ovalue->it_value.tv_usec = spec_ovalue.it_value.tv_nsec / 1000;
} }
syscall_printf ("%d = getitimer ()", ret); }
}
syscall_printf ("%R = getitimer()", ret);
return ret; return ret;
} }

View File

@ -130,11 +130,10 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
res = -!SetSystemTime (&st); res = -!SetSystemTime (&st);
gtod.reset (); gtod.reset ();
syscall_printf ("%d = settimeofday (%x, %x)", res, tv, tz); if (res)
if (res != 0)
set_errno (EPERM); set_errno (EPERM);
syscall_printf ("%R = settimeofday(%x, %x)", res, tv, tz);
return res; return res;
} }
@ -380,8 +379,7 @@ utimens_worker (path_conv &win32, const struct timespec *tvp)
} }
error: error:
syscall_printf ("%d = utimes (%S, %p)", syscall_printf ("%R = utimes(%S, %p)", res, win32.get_nt_native_path (), tvp);
res, win32.get_nt_native_path (), tvp);
return res; return res;
} }