mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-27 15:04:33 +00:00
Add chdir() syscall implementation
This commit is contained in:
parent
bd0c8d9ad8
commit
ddf6a53412
@ -1890,10 +1890,22 @@ static long linux_getcwd(SysFrm *, char *buf, size_t size)
|
|||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pBuf, cwd, len);
|
static int linux_chdir(SysFrm *, const char *path)
|
||||||
pBuf[len] = '\0';
|
{
|
||||||
debug("cwd: \"%s\" with %ld bytes", cwd, len);
|
PCB *pcb = thisProcess;
|
||||||
return len;
|
Memory::VirtualMemoryArea *vma = pcb->vma;
|
||||||
|
|
||||||
|
const char *pPath = vma->UserCheckAndGetAddress(path);
|
||||||
|
if (!pPath)
|
||||||
|
return -linux_EFAULT;
|
||||||
|
|
||||||
|
FileNode *n = fs->GetByPath(pPath, pcb->CWD);
|
||||||
|
if (!n)
|
||||||
|
return -linux_ENOENT;
|
||||||
|
|
||||||
|
debug("Changed cwd to \"%s\"", n->GetPath().c_str());
|
||||||
|
pcb->CWD = n;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int linux_mkdir(SysFrm *, const char *pathname, mode_t mode)
|
static int linux_mkdir(SysFrm *, const char *pathname, mode_t mode)
|
||||||
@ -2871,7 +2883,7 @@ static SyscallData LinuxSyscallsTableAMD64[] = {
|
|||||||
[__NR_amd64_ftruncate] = {"ftruncate", (void *)nullptr},
|
[__NR_amd64_ftruncate] = {"ftruncate", (void *)nullptr},
|
||||||
[__NR_amd64_getdents] = {"getdents", (void *)nullptr},
|
[__NR_amd64_getdents] = {"getdents", (void *)nullptr},
|
||||||
[__NR_amd64_getcwd] = {"getcwd", (void *)linux_getcwd},
|
[__NR_amd64_getcwd] = {"getcwd", (void *)linux_getcwd},
|
||||||
[__NR_amd64_chdir] = {"chdir", (void *)nullptr},
|
[__NR_amd64_chdir] = {"chdir", (void *)linux_chdir},
|
||||||
[__NR_amd64_fchdir] = {"fchdir", (void *)nullptr},
|
[__NR_amd64_fchdir] = {"fchdir", (void *)nullptr},
|
||||||
[__NR_amd64_rename] = {"rename", (void *)nullptr},
|
[__NR_amd64_rename] = {"rename", (void *)nullptr},
|
||||||
[__NR_amd64_mkdir] = {"mkdir", (void *)linux_mkdir},
|
[__NR_amd64_mkdir] = {"mkdir", (void *)linux_mkdir},
|
||||||
@ -3253,7 +3265,7 @@ static SyscallData LinuxSyscallsTableI386[] = {
|
|||||||
[__NR_i386_link] = {"link", (void *)nullptr},
|
[__NR_i386_link] = {"link", (void *)nullptr},
|
||||||
[__NR_i386_unlink] = {"unlink", (void *)nullptr},
|
[__NR_i386_unlink] = {"unlink", (void *)nullptr},
|
||||||
[__NR_i386_execve] = {"execve", (void *)linux_execve},
|
[__NR_i386_execve] = {"execve", (void *)linux_execve},
|
||||||
[__NR_i386_chdir] = {"chdir", (void *)nullptr},
|
[__NR_i386_chdir] = {"chdir", (void *)linux_chdir},
|
||||||
[__NR_i386_time] = {"time", (void *)nullptr},
|
[__NR_i386_time] = {"time", (void *)nullptr},
|
||||||
[__NR_i386_mknod] = {"mknod", (void *)nullptr},
|
[__NR_i386_mknod] = {"mknod", (void *)nullptr},
|
||||||
[__NR_i386_chmod] = {"chmod", (void *)nullptr},
|
[__NR_i386_chmod] = {"chmod", (void *)nullptr},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user