2.9.2 Exercise: Displaying More Information About System Call Errors

Adapt errno.d to display the name of the error instead of its number for any failed system call.

  • The numeric values of errors such as EACCES and EEXIST are defined in /usr/include/asm-generic/errno-base.h and /usr/include/asm-generic/errno.h. DTrace defines inline names (which are effectively constants) for the numeric error values in /usr/lib64/dtrace/kernel-version/errno.d. Use an associative array named error[] to store the mapping between the inline names and the error names that are defined in /usr/include/asm-generic/errno-base.h.

  • Use printf() to display the user ID, the process ID, the program name, the error name, and the name of the system call.

  • Use the BEGIN probe to print column headings.

  • Use the value of errno rather than arg0 to test whether an error from the range of mapped names has occurred in a system call.

(Estimated completion time: 30 minutes)