Add creat()/unlink()/mkdir()
This commit is contained in:
@@ -7,11 +7,15 @@ ssize_t sys_read(int fd, void *buf, size_t lim);
|
||||
ssize_t sys_write(int fd, const void *buf, size_t lim);
|
||||
int sys_open(const char *filename, int flags, int mode);
|
||||
void sys_close(int fd);
|
||||
int sys_creat(const char *pathname, int mode);
|
||||
|
||||
ssize_t sys_readdir(int fd, struct dirent *ent);
|
||||
int sys_getcwd(char *buf, size_t lim);
|
||||
int sys_chdir(const char *filename);
|
||||
|
||||
int sys_mkdir(const char *pathname, int mode);
|
||||
int sys_unlink(const char *pathname);
|
||||
|
||||
int sys_stat(const char *filename, struct stat *st);
|
||||
int sys_access(const char *path, int mode);
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#define SYSCALL_NR_ACCESS 21
|
||||
#define SYSCALL_NR_GETCWD 79
|
||||
#define SYSCALL_NR_CHDIR 80
|
||||
#define SYSCALL_NR_MKDIR 83
|
||||
#define SYSCALL_NR_CREAT 85
|
||||
#define SYSCALL_NR_UNLINK 87
|
||||
#define SYSCALL_NR_READDIR 89
|
||||
|
||||
#define SYSCALL_NR_BRK 12
|
||||
|
||||
@@ -66,6 +66,24 @@ ssize_t sys_readdir(int fd, struct dirent *ent) {
|
||||
return src->d_reclen;
|
||||
}
|
||||
|
||||
int sys_creat(const char *pathname, int mode) {
|
||||
return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
|
||||
}
|
||||
|
||||
int sys_mkdir(const char *pathname, int mode) {
|
||||
struct thread *thr = get_cpu()->thread;
|
||||
_assert(thr);
|
||||
|
||||
return vfs_mkdir(&thr->ioctx, pathname, mode);
|
||||
}
|
||||
|
||||
int sys_unlink(const char *pathname) {
|
||||
struct thread *thr = get_cpu()->thread;
|
||||
_assert(thr);
|
||||
|
||||
return vfs_unlink(&thr->ioctx, pathname);
|
||||
}
|
||||
|
||||
int sys_chdir(const char *filename) {
|
||||
struct thread *thr = get_cpu()->thread;
|
||||
_assert(thr);
|
||||
|
||||
@@ -22,6 +22,9 @@ const void *amd64_syscall_jmp_table[256] = {
|
||||
[SYSCALL_NR_STAT] = sys_stat,
|
||||
[SYSCALL_NR_ACCESS] = sys_access,
|
||||
[SYSCALL_NRX_OPENPTY] = sys_openpty,
|
||||
[SYSCALL_NR_UNLINK] = sys_unlink,
|
||||
[SYSCALL_NR_MKDIR] = sys_mkdir,
|
||||
[SYSCALL_NR_CREAT] = sys_creat,
|
||||
|
||||
// Process
|
||||
[SYSCALL_NR_EXIT] = sys_exit,
|
||||
|
||||
Reference in New Issue
Block a user