int ttyname(int fd, char *buffer, size_t size);
This syscall fetches the name of the filesystem entity backing a TTY and writes
it to buffer with a NULL terminator.
The syscall returns 0 on success or -1 on failure, with the
following errno:
EINVALsize is less than needed and/or fd is not a TTY.
EBADFfd is not opened to anything.
EFAULTbuffer points to invalid memory.