Kernel/LibC: Implement fchdir, cleanup chdir and getcwd

This commit is contained in:
2025-04-19 21:28:31 +03:00
parent 7edfae8583
commit 6f9dc2a9b8
4 changed files with 36 additions and 17 deletions

View File

@@ -32,8 +32,9 @@ __BEGIN_DECLS
O(SYS_GET_GID, getgid) \
O(SYS_GET_EUID, geteuid) \
O(SYS_GET_EGID, getegid) \
O(SYS_GET_PWD, getpwd) \
O(SYS_SET_PWD, setpwd) \
O(SYS_GETCWD, getcwd) \
O(SYS_CHDIR, chdir) \
O(SYS_FCHDIR, fchdir) \
O(SYS_CLOCK_GETTIME, clock_gettime) \
O(SYS_PIPE, pipe) \
O(SYS_DUP2, dup2) \

View File

@@ -426,7 +426,7 @@ char* getcwd(char* buf, size_t size)
return nullptr;
}
if (syscall(SYS_GET_PWD, buf, size) == 0)
if (syscall(SYS_GETCWD, buf, size) == 0)
return nullptr;
return buf;
@@ -434,7 +434,12 @@ char* getcwd(char* buf, size_t size)
int chdir(const char* path)
{
return syscall(SYS_SET_PWD, path);
return syscall(SYS_CHDIR, path);
}
int fchdir(int fildes)
{
return syscall(SYS_FCHDIR, fildes);
}
int chown(const char* path, uid_t owner, gid_t group)