1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

Implement sys$chdir() and teach sh+ls to cd around and browse different dirs.

This commit is contained in:
Andreas Kling 2018-10-26 14:24:11 +02:00
parent ac738b03d6
commit 2749e7f1c2
16 changed files with 147 additions and 33 deletions

View file

@ -46,7 +46,7 @@ dirent* readdir(DIR* dirp)
dirp->nextptr = dirp->buffer;
}
if (dirp->nextptr > (dirp->buffer + dirp->buffer_size))
if (dirp->nextptr >= (dirp->buffer + dirp->buffer_size))
return nullptr;
auto* sys_ent = (sys_dirent*)dirp->nextptr;

View file

@ -69,6 +69,7 @@ const char* strerror(int errnum)
case ERANGE: return "Math result not representable";
case ENAMETOOLONG: return "Name too long";
case EOVERFLOW: return "Value too large for data type";
case ENOTIMPL: return "Not implemented";
}
printf("strerror() missing string for errnum=%d\n", errnum);
return "Unknown error";

View file

@ -51,6 +51,12 @@ int lstat(const char* path, stat* statbuf)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int chdir(const char* path)
{
int rc = Syscall::invoke(Syscall::PosixChdir, (dword)path);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
char* getcwd(char* buffer, size_t size)
{
int rc = Syscall::invoke(Syscall::PosixGetcwd, (dword)buffer, (dword)size);

View file

@ -11,6 +11,7 @@ int open(const char* path);
ssize_t read(int fd, void* buf, size_t count);
int close(int fd);
pid_t waitpid(pid_t);
int chdir(const char* path);
char* getcwd(char* buffer, size_t size);
int lstat(const char* path, stat* statbuf);
int sleep(unsigned seconds);