LibC/Kernel: Implement ttyname_r

This commit is contained in:
2025-07-28 14:56:12 +03:00
parent e72e1e4e43
commit cc04bd0f06
3 changed files with 15 additions and 8 deletions

View File

@@ -787,12 +787,19 @@ char* getlogin(void)
char* ttyname(int fildes)
{
static char storage[_POSIX_TTY_NAME_MAX];
if (syscall(SYS_TTYNAME, fildes, storage) == -1)
static char storage[TTY_NAME_MAX];
if (ttyname_r(fildes, storage, sizeof(storage)) != 0)
return nullptr;
return storage;
}
int ttyname_r(int fildes, char* name, size_t namesize)
{
if (syscall(SYS_TTYNAME, fildes, name, namesize))
return errno;
return 0;
}
int access(const char* path, int amode)
{
return syscall(SYS_ACCESS, path, amode);