diff options
author | Howard Mao <zhehao.mao@gmail.com> | 2015-12-04 16:52:44 -0800 |
---|---|---|
committer | Howard Mao <zhehao.mao@gmail.com> | 2015-12-05 00:24:04 -0800 |
commit | dd7fc844c4059a18ffaeeb3a9573a8d27d30923b (patch) | |
tree | 006dda168d8c18488d3c80bb5efca77fa41dfbf9 /pk/syscall.c | |
parent | 82357114e9eecd3bec9374da9cd6ce4ea77d7e83 (diff) | |
download | pk-dd7fc844c4059a18ffaeeb3a9573a8d27d30923b.zip pk-dd7fc844c4059a18ffaeeb3a9573a8d27d30923b.tar.gz pk-dd7fc844c4059a18ffaeeb3a9573a8d27d30923b.tar.bz2 |
implement open and mmap for device files
Diffstat (limited to 'pk/syscall.c')
-rw-r--r-- | pk/syscall.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pk/syscall.c b/pk/syscall.c index 2d96282..d4785b6 100644 --- a/pk/syscall.c +++ b/pk/syscall.c @@ -102,7 +102,9 @@ static int at_kfd(int dirfd) file_t* dir = file_get(dirfd); if (dir == NULL) return -1; - return dir->kfd; + if (dir->typ != FILE_HOST) + return -1; + return ((host_file_t*) dir)->kfd; } int sys_openat(int dirfd, const char* name, int flags, int mode) @@ -156,9 +158,10 @@ int sys_fcntl(int fd, int cmd, int arg) int r = -EBADF; file_t* f = file_get(fd); - if (f) + if (f && f->typ == FILE_HOST) { - r = frontend_syscall(SYS_fcntl, f->kfd, cmd, arg, 0, 0, 0, 0); + host_file_t *hf = (host_file_t *) f; + r = frontend_syscall(SYS_fcntl, hf->kfd, cmd, arg, 0, 0, 0, 0); file_decref(f); } |