diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-19 20:18:39 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-19 20:18:39 +0100 |
commit | f876e66e717c4dd853da12892048262afe47ffdf (patch) | |
tree | bc7aa8ebfbb86bfa0a443fda718569a6c9e51e82 /src/kernel/user/vfs.c | |
parent | 7b27ab493b56f9e77d805c4f44a1717f3a79231e (diff) | |
download | kogata-f876e66e717c4dd853da12892048262afe47ffdf.tar.gz kogata-f876e66e717c4dd853da12892048262afe47ffdf.zip |
Add syscall for ioctl on open handle
Diffstat (limited to 'src/kernel/user/vfs.c')
-rw-r--r-- | src/kernel/user/vfs.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/kernel/user/vfs.c b/src/kernel/user/vfs.c index a5d56ef..ab49553 100644 --- a/src/kernel/user/vfs.c +++ b/src/kernel/user/vfs.c @@ -356,7 +356,7 @@ bool fs_stat(fs_t *fs, const char* file, stat_t *st) { 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 false; + if (n == 0) return -1; mutex_lock(&n->lock); int ret = (n->ops->ioctl ? n->ops->ioctl(n->data, command, data) : -1); @@ -461,6 +461,17 @@ bool file_stat(fs_handle_t *f, stat_t *st) { return ret; } +int file_ioctl(fs_handle_t *f, int command, void* data) { + if (!(f->mode & FM_IOCTL)) return -1; + + mutex_lock(&f->node->lock); + int ret = -1; + if (f->node->ops->ioctl) ret = f->node->ops->ioctl(f->node->data, command, data); + mutex_unlock(&f->node->lock); + + return ret; +} + bool file_readdir(fs_handle_t *f, dirent_t *d) { if (!(f->mode & FM_READDIR)) return 0; |