diff options
Diffstat (limited to 'src/kernel/user')
-rw-r--r-- | src/kernel/user/nullfs.c | 4 | ||||
-rw-r--r-- | src/kernel/user/syscall.c | 29 | ||||
-rw-r--r-- | src/kernel/user/vfs.c | 17 |
3 files changed, 6 insertions, 44 deletions
diff --git a/src/kernel/user/nullfs.c b/src/kernel/user/nullfs.c index c3f83cf..0ca0073 100644 --- a/src/kernel/user/nullfs.c +++ b/src/kernel/user/nullfs.c @@ -53,7 +53,6 @@ static fs_node_ops_t nullfs_d_ops = { .move = nullfs_d_move, .create = nullfs_d_create, .dispose = nullfs_d_dispose, - .ioctl = 0, }; static fs_handle_ops_t nullfs_dh_ops = { @@ -61,6 +60,7 @@ static fs_handle_ops_t nullfs_dh_ops = { .close = nullfs_dh_close, .read = 0, .write = 0, + .ioctl = 0, }; static fs_node_ops_t nullfs_f_ops = { @@ -71,7 +71,6 @@ static fs_node_ops_t nullfs_f_ops = { .create = 0, .delete = 0, .move = 0, - .ioctl =0, }; static fs_handle_ops_t nullfs_fh_ops = { @@ -79,6 +78,7 @@ static fs_handle_ops_t nullfs_fh_ops = { .write = nullfs_fh_write, .close = nullfs_fh_close, .readdir = 0, + .ioctl =0, }; diff --git a/src/kernel/user/syscall.c b/src/kernel/user/syscall.c index f1f5f86..bcf6ef4 100644 --- a/src/kernel/user/syscall.c +++ b/src/kernel/user/syscall.c @@ -175,30 +175,6 @@ end_stat: return ret; } -static uint32_t ioctl_sc(sc_args_t args) { - int ret = -1; - - char* fn = sc_copy_string(args.a, args.b); - if (fn == 0) goto end_ioctl; - - char* sep = strchr(fn, ':'); - if (sep == 0) goto end_ioctl; - - *sep = 0; - char* file = sep + 1; - - fs_t *fs = proc_find_fs(current_process(), fn); - if (fs == 0) goto end_ioctl; - - void* data = (void*)args.d; - if (data >= (void*)K_HIGHHALF_ADDR) goto end_ioctl; - ret = fs_ioctl(fs, file, args.c, data); - -end_ioctl: - if (fn) free(fn); - return ret; -} - static uint32_t open_sc(sc_args_t args) { int ret = 0; @@ -268,7 +244,7 @@ static uint32_t stat_open_sc(sc_args_t args) { return file_stat(h, o); } -static uint32_t ioctl_open_sc(sc_args_t args) { +static uint32_t ioctl_sc(sc_args_t args) { fs_handle_t *h = proc_read_fd(current_process(), args.a); if (h == 0) return -1; @@ -303,7 +279,6 @@ void setup_syscall_table() { sc_handlers[SC_DELETE] = delete_sc; sc_handlers[SC_MOVE] = move_sc; sc_handlers[SC_STAT] = stat_sc; - sc_handlers[SC_IOCTL] = ioctl_sc; sc_handlers[SC_OPEN] = open_sc; sc_handlers[SC_CLOSE] = close_sc; @@ -311,7 +286,7 @@ void setup_syscall_table() { sc_handlers[SC_WRITE] = write_sc; sc_handlers[SC_READDIR] = readdir_sc; sc_handlers[SC_STAT_OPEN] = stat_open_sc; - sc_handlers[SC_IOCTL_OPEN] = ioctl_open_sc; + sc_handlers[SC_IOCTL] = ioctl_sc; sc_handlers[SC_GET_MODE] = get_mode_sc; } diff --git a/src/kernel/user/vfs.c b/src/kernel/user/vfs.c index 31f162a..a5f03ca 100644 --- a/src/kernel/user/vfs.c +++ b/src/kernel/user/vfs.c @@ -354,18 +354,6 @@ bool fs_stat(fs_t *fs, const char* file, stat_t *st) { return ret; } -int fs_ioctl(fs_t *fs, const char* file, int command, void* data) { - fs_node_t* n = fs_walk_path(&fs->root, file); - if (n == 0) return -1; - - mutex_lock(&n->lock); - int ret = (n->ops->ioctl ? n->ops->ioctl(n->data, command, data) : -1); - mutex_unlock(&n->lock); - - unref_fs_node(n); - return ret; -} - // =================== // // OPERATIONS ON FILES // // =================== // @@ -446,10 +434,9 @@ bool file_stat(fs_handle_t *f, stat_t *st) { int file_ioctl(fs_handle_t *f, int command, void* data) { if (!(f->mode & FM_IOCTL)) return -1; - int ret = -1; - if (f->node->ops->ioctl) ret = f->node->ops->ioctl(f->node->data, command, data); + if (f->ops->ioctl == 0) return -1; - return ret; + return f->ops->ioctl(f->data, command, data); } bool file_readdir(fs_handle_t *f, dirent_t *d) { |