From ef50c1c0de9e992db9144571e7f08e5badbb9720 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 10 Mar 2015 17:18:13 +0100 Subject: Add mk_shm syscall ; replace get_mode by fctl. --- src/kernel/user/syscall.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/kernel/user/syscall.c') 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; -- cgit v1.2.3