]> www.infradead.org Git - users/jedix/linux-maple.git/commit
dtrace: provide a corrected implementation of the 'errno' D variable
authorKris Van Hees <kris.van.hees@oracle.com>
Thu, 31 Oct 2013 09:22:56 +0000 (05:22 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Wed, 6 Nov 2013 21:40:33 +0000 (16:40 -0500)
commitdc418e098977a97bcbb74839b42dba68f95cc110
tree752b9a206a02949a879c24479a21b1db33246600
parenta179be25e32383ed8dabdca47300029506b0b602
dtrace: provide a corrected implementation of the 'errno' D variable

This commit provides a corrected implementation for the 'errno' D variable.
It is defined as holding the error code (if non-zero) during the current
system call execution.  If the system call is successful, or if no system
call is being executed, its value is to be 0.  On (Open)Solaris, this was
retrieved from a task variable that is assigned an error code as soon as
an error is encountered during the processing of a system call, i.e. system
calls use a task variable to store any error code encountered during
execution, and this is used upon return from the system call to alert
userspace of the error code status of the system call.  In Linux, system
calls are implemented in the more regular fashion (for Linux at least)
of returning error codes as return values of functions, and therefore
there is no task level variable to consult.  So, instead we recognize that
at this point) 'errno' only has meaning during the processing of syscall
return probes, which are handled from the system call wrapper, after the
system call implementation has been executed.

It would therefore be sufficient and correct to assign the value of 'errno'
at that point, but that would require a task variable to be added to the
task struct in order for this value to be recorded.

In order to avoid adding a member to the task struct, we (ab)use the fact
that we can recognize whether we are executing a D action for a syscall
return probe, and if we are *and* if 'errno' is being retrieved, we look
at the arg0 value for the probe (which is defined as the return value of
the syscall), and if the value is between 0 and -2048, we return the error
code it represents as errno.

Orabug: 17704568

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Chuck Anderson <chuck.anderson@oracle.com>
dtrace/dtrace_dif.c