diff --git a/kernel/syscall/fs.c b/kernel/syscall/fs.c index f363e1e..3218ae4 100644 --- a/kernel/syscall/fs.c +++ b/kernel/syscall/fs.c @@ -224,3 +224,23 @@ int32_t SYSCALL1(sys_fs_mkdir, opath1) { done: return ret; } + +int32_t SYSCALL1(sys_fs_delete, opath1) { + int32_t ret = E_BADIO; + const char *opath = (const char *)opath1; + + if (opath == NULL) { + ret = E_INVALIDARGUMENT; + goto done; + } + + char mp[_MP_MAX]; + char path[_PATH_MAX]; + + path_parse(opath, mp, path); + + ret = vfs_delete(mp, path); + +done: + return ret; +} diff --git a/kernel/syscall/fs.h b/kernel/syscall/fs.h index 2fd33c4..f6e1189 100644 --- a/kernel/syscall/fs.h +++ b/kernel/syscall/fs.h @@ -12,5 +12,6 @@ int32_t SYSCALL4(sys_fs_read, fsh1, buffer1, len1, off1); int32_t SYSCALL2(sys_fs_stat, opath1, fsstat1); int32_t SYSCALL3(sys_fs_fetchdirent, opath1, direntbuf1, idx1); int32_t SYSCALL1(sys_fs_mkdir, opath1); +int32_t SYSCALL1(sys_fs_delete, opath1); #endif // SYSCALL_FS_H_ diff --git a/kernel/syscall/syscall.c b/kernel/syscall/syscall.c index 77e4f31..df2f7c6 100644 --- a/kernel/syscall/syscall.c +++ b/kernel/syscall/syscall.c @@ -47,6 +47,7 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = { [SYS_FS_STAT] = &sys_fs_stat, [SYS_FS_FETCHDIRENT] = &sys_fs_fetchdirent, [SYS_FS_MKDIR] = &sys_fs_mkdir, + [SYS_FS_DELETE] = &sys_fs_delete, [SYS_DEV_GETHANDLE] = &sys_dev_gethandle, [SYS_DEV_LISTSIZE] = &sys_dev_listsize, [SYS_DEV_STAT] = &sys_dev_stat, diff --git a/share/sysdefs/syscall.h b/share/sysdefs/syscall.h index c667921..a1f0db8 100644 --- a/share/sysdefs/syscall.h +++ b/share/sysdefs/syscall.h @@ -29,6 +29,7 @@ #define SYS_FS_WRITE 30 #define SYS_FS_FETCHDIRENT 31 #define SYS_FS_MKDIR 32 +#define SYS_FS_DELETE 37 #define SYS_DEV_GETHANDLE 33 #define SYS_DEV_LISTSIZE 34 #define SYS_DEV_STAT 35