syscall: Translate errno to something human-readable

This commit is contained in:
Ben Wiederhake 2021-11-06 23:25:25 +01:00 committed by Andreas Kling
parent c706b2c142
commit 99b8750154
Notes: sideshowbarker 2024-07-18 01:25:19 +09:00

View File

@ -9,6 +9,7 @@
#include <AK/Iterator.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <errno_numbers.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -93,12 +94,14 @@ int main(int argc, char** argv)
dbgln_if(SYSCALL_1_DEBUG, "Calling {} {:p} {:p} {:p}\n", arg[0], arg[1], arg[2], arg[3]);
int rc = syscall(arg[0], arg[1], arg[2], arg[3]);
if (rc == -1)
perror("syscall");
if (output_buffer)
fwrite(outbuf, 1, sizeof(outbuf), stdout);
warnln("Syscall return: {}", rc);
if (-rc >= 0 && -rc < EMAXERRNO) {
warnln("Syscall return: {} ({})", rc, strerror(-rc));
} else {
warnln("Syscall return: {} (?)", rc);
}
return 0;
}