diff options
author | Alex Auvolat <alex@adnab.me> | 2015-03-10 17:18:13 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2015-03-10 17:18:13 +0100 |
commit | ef50c1c0de9e992db9144571e7f08e5badbb9720 (patch) | |
tree | 26c34719e0a93e6f1831aaf14efdb436bc4b9077 /src/kernel/user/syscall.c | |
parent | 1b9ea946b8ec8c71a2bad9a7b2ce253145dcd97c (diff) | |
download | kogata-ef50c1c0de9e992db9144571e7f08e5badbb9720.tar.gz kogata-ef50c1c0de9e992db9144571e7f08e5badbb9720.zip |
Add mk_shm syscall ; replace get_mode by fctl.
Diffstat (limited to 'src/kernel/user/syscall.c')
-rw-r--r-- | src/kernel/user/syscall.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/kernel/user/syscall.c b/src/kernel/user/syscall.c index 67ed317..15b0851 100644 --- a/src/kernel/user/syscall.c +++ b/src/kernel/user/syscall.c @@ -276,11 +276,21 @@ static uint32_t ioctl_sc(sc_args_t args) { return file_ioctl(h, args.b, data); } -static uint32_t get_mode_sc(sc_args_t args) { +static uint32_t fctl_sc(sc_args_t args) { fs_handle_t *h = proc_read_fd(current_process(), args.a); if (h == 0) return 0; - return file_get_mode(h); + if (args.b == FC_GET_MODE) { + return h->mode; + } else if (args.b == FC_SET_BLOCKING) { + h->mode |= FM_BLOCKING; + return 1; + } else if (args.b == FC_SET_NONBLOCKING) { + h->mode &= ~FM_BLOCKING; + return 1; + } else { + return 0; + } } static uint32_t select_sc(sc_args_t args) { @@ -375,6 +385,19 @@ error: return false; } +static uint32_t make_shm_sc(sc_args_t args) { + fs_handle_t *h = make_shm(args.a); + if (h == 0) return 0; + + int fd = proc_add_fd(current_process(), h); + if (fd == 0) { + unref_file(h); + return 0; + } + + return fd; +} + static uint32_t gen_token_sc(sc_args_t args) { fs_handle_t *h = proc_read_fd(current_process(), args.a); if (h == 0) return false; @@ -694,7 +717,7 @@ void setup_syscall_table() { sc_handlers[SC_READDIR] = readdir_sc; sc_handlers[SC_STAT_OPEN] = stat_open_sc; sc_handlers[SC_IOCTL] = ioctl_sc; - sc_handlers[SC_GET_MODE] = get_mode_sc; + sc_handlers[SC_FCTL] = fctl_sc; sc_handlers[SC_SELECT] = select_sc; sc_handlers[SC_MK_CHANNEL] = make_channel_sc; |