Skip to content

Commit b9653ab

Browse files
committed
syscalls: stub for mount() syscall
1 parent 4872e10 commit b9653ab

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <kernel/io.h>
1818
#include <kernel/sched.h>
1919

20-
int mount(Thread *t, const char *src, const char *tgt, const char *type, int flags) {
20+
int mount(Thread *t, uint64_t id, const char *src, const char *tgt, const char *type, int flags) {
2121
/* stub */
2222
return -1;
2323
}

src/include/kernel/file.h

+3
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ typedef struct {
2525
size_t position;
2626
struct stat info;
2727
} FileDescriptor;
28+
29+
/* file system syscalls */
30+
int mount(Thread *, uint64_t, const char *, const char *, const char *, int);

src/include/kernel/servers.h

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <stdint.h>
1313
#include <kernel/sched.h>
14+
#include <kernel/file.h>
1415

1516
#define SERVER_MAX_CONNECTIONS 512
1617
#define SERVER_MAX_SIZE 0x80000 // max msg size is 512 KiB
@@ -78,6 +79,15 @@ typedef struct {
7879
uint16_t w, h, pitch, bpp;
7980
} FramebufferResponse;
8081

82+
/* mount command */
83+
typedef struct {
84+
SyscallHeader header;
85+
char source[MAX_FILE_PATH];
86+
char target[MAX_FILE_PATH];
87+
char type[32];
88+
int flags;
89+
} MountCommand;
90+
8191
void serverInit();
8292
void serverIdle();
8393
void handleGeneralRequest(int, const MessageHeader *, void *);

src/syscalls/dispatch.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
#include <stdbool.h>
1010
#include <errno.h>
1111
#include <platform/mmap.h>
12+
#include <platform/platform.h>
1213
#include <kernel/sched.h>
1314
#include <kernel/socket.h>
1415
#include <kernel/syscalls.h>
1516
#include <kernel/logger.h>
1617
#include <kernel/memory.h>
18+
#include <kernel/file.h>
1719

1820
/* This is the dispatcher for system calls, many of which need a wrapper for
1921
* their behavior. This ensures the exposed functionality is always as close
@@ -96,7 +98,19 @@ void syscallDispatchMSleep(SyscallRequest *req) {
9698
req->ret = msleep(req->thread, req->params[0]);
9799
}
98100

99-
/* TODO: Group 2: File System */
101+
/* Group 2: File System */
102+
103+
void syscallDispatchMount(SyscallRequest *req) {
104+
if(syscallVerifyPointer(req, req->params[0], MAX_FILE_PATH) &&
105+
syscallVerifyPointer(req, req->params[1], MAX_FILE_PATH) &&
106+
syscallVerifyPointer(req, req->params[2], 32)) {
107+
uint64_t id = platformRand();
108+
req->requestID = id;
109+
req->external = true;
110+
111+
mount(req->thread, id, (const char *)req->params[0], (const char *)req->params[1], (const char *)req->params[2], req->params[3]);
112+
}
113+
}
100114

101115
/* Group 3: Interprocess Communication */
102116

@@ -240,7 +254,7 @@ void (*syscallDispatchTable[])(SyscallRequest *) = {
240254
NULL, // 25 - rmdir()
241255
NULL, // 26 - utime()
242256
NULL, // 27 - chroot()
243-
NULL, // 28 - mount()
257+
syscallDispatchMount, // 28 - mount()
244258
NULL, // 29 - umount()
245259
NULL, // 30 - fnctl()
246260

0 commit comments

Comments
 (0)