diff options
author | ed <ed@FreeBSD.org> | 2015-07-15 09:14:06 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2015-07-15 09:14:06 +0000 |
commit | a62316f79b810f1f34f80a2bb9e01965e025de77 (patch) | |
tree | efa7fe8afd7e90651166126d7ebd5c8d8b5d5459 /sys/compat/cloudabi | |
parent | 9bde258984f54fc570ad8807cbc7b0fb154c34ec (diff) | |
download | FreeBSD-src-a62316f79b810f1f34f80a2bb9e01965e025de77.zip FreeBSD-src-a62316f79b810f1f34f80a2bb9e01965e025de77.tar.gz |
Make posix_fallocate() and posix_fadvise() work.
We can map these system calls directly to the FreeBSD counterparts. The
other filesystem related system calls will be sent out for review
separately, as they are a bit more complex to get right.
Diffstat (limited to 'sys/compat/cloudabi')
-rw-r--r-- | sys/compat/cloudabi/cloudabi_file.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/sys/compat/cloudabi/cloudabi_file.c b/sys/compat/cloudabi/cloudabi_file.c index 46e5792..034cf01 100644 --- a/sys/compat/cloudabi/cloudabi_file.c +++ b/sys/compat/cloudabi/cloudabi_file.c @@ -26,15 +26,43 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/param.h> +#include <sys/fcntl.h> +#include <sys/syscallsubr.h> + #include <compat/cloudabi/cloudabi_proto.h> +#include <compat/cloudabi/cloudabi_syscalldefs.h> int cloudabi_sys_file_advise(struct thread *td, struct cloudabi_sys_file_advise_args *uap) { - - /* Not implemented. */ - return (ENOSYS); + int advice; + + switch (uap->advice) { + case CLOUDABI_ADVICE_DONTNEED: + advice = POSIX_FADV_DONTNEED; + break; + case CLOUDABI_ADVICE_NOREUSE: + advice = POSIX_FADV_NOREUSE; + break; + case CLOUDABI_ADVICE_NORMAL: + advice = POSIX_FADV_NORMAL; + break; + case CLOUDABI_ADVICE_RANDOM: + advice = POSIX_FADV_RANDOM; + break; + case CLOUDABI_ADVICE_SEQUENTIAL: + advice = POSIX_FADV_SEQUENTIAL; + break; + case CLOUDABI_ADVICE_WILLNEED: + advice = POSIX_FADV_WILLNEED; + break; + default: + return (EINVAL); + } + + return (kern_posix_fadvise(td, uap->fd, uap->offset, uap->len, advice)); } int @@ -42,8 +70,7 @@ cloudabi_sys_file_allocate(struct thread *td, struct cloudabi_sys_file_allocate_args *uap) { - /* Not implemented. */ - return (ENOSYS); + return (kern_posix_fallocate(td, uap->fd, uap->offset, uap->len)); } int |