vfs: add syscall layer skeleton
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
cd916f624b
commit
09116d65ea
5 changed files with 59 additions and 2 deletions
|
|
@ -5,3 +5,4 @@ obj-y += inode.o
|
|||
obj-y += ramfs.o
|
||||
obj-y += devfs.o
|
||||
obj-y += initcpio.o
|
||||
obj-y += uapi.o
|
||||
|
|
|
|||
44
fs/vfs/uapi.c
Normal file
44
fs/vfs/uapi.c
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/syscall.h>
|
||||
#include <lib/errno.h>
|
||||
|
||||
static ssize_t sys_pread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static ssize_t sys_read(int fd, void *buf, size_t nbyte)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static ssize_t sys_pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static ssize_t sys_write(int fd, const void *buf, size_t nbyte)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int sys_open(const char *path, int flags)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int sys_close(int fd)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
void vfs_uapi_init()
|
||||
{
|
||||
syscall_insert(sys_pread, SYS_pread);
|
||||
syscall_insert(sys_read, SYS_read);
|
||||
syscall_insert(sys_pwrite, SYS_pwrite);
|
||||
syscall_insert(sys_write, SYS_write);
|
||||
syscall_insert(sys_open, SYS_open);
|
||||
syscall_insert(sys_close, SYS_close);
|
||||
}
|
||||
|
|
@ -315,4 +315,7 @@ void vfs_init(void)
|
|||
{
|
||||
inode_init();
|
||||
list_create(&fs_type_list);
|
||||
|
||||
void vfs_uapi_init();
|
||||
vfs_uapi_init();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,17 @@
|
|||
|
||||
#include <kernel/types.h>
|
||||
|
||||
#define SYS_read 0
|
||||
#define SYS_write 1
|
||||
#define SYS_open 2
|
||||
#define SYS_close 3
|
||||
#define SYS_pread 4
|
||||
#define SYS_pwrite 5
|
||||
|
||||
typedef ssize_t (*syscall_t)(u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6);
|
||||
|
||||
syscall_t get_syscall(u64 no);
|
||||
int syscall_insert(void *fun, u64 no);
|
||||
int syscall_remove(u64 no);
|
||||
|
||||
#endif /* _SYSCALL_H_ */
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ syscall_t get_syscall(u64 no)
|
|||
return syscalls[no];
|
||||
}
|
||||
|
||||
int syscall_insert(syscall_t fun, u64 no)
|
||||
int syscall_insert(void *fun, u64 no)
|
||||
{
|
||||
if (no >= ARRAY_SIZE(syscalls))
|
||||
return -EINVAL;
|
||||
|
|
@ -21,7 +21,7 @@ int syscall_insert(syscall_t fun, u64 no)
|
|||
if (syscalls[no])
|
||||
return -EEXIST;
|
||||
|
||||
syscalls[no] = fun;
|
||||
syscalls[no] = (syscall_t)fun;
|
||||
return no;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue