Date: Wed, 15 Jul 2015 09:14:07 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285596 - head/sys/compat/cloudabi Message-ID: <201507150914.t6F9E7dg070051@svnmir.geo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Wed Jul 15 09:14:06 2015 New Revision: 285596 URL: https://svnweb.freebsd.org/changeset/base/285596 Log: 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. Modified: head/sys/compat/cloudabi/cloudabi_file.c Modified: head/sys/compat/cloudabi/cloudabi_file.c ============================================================================== --- head/sys/compat/cloudabi/cloudabi_file.c Wed Jul 15 06:14:04 2015 (r285595) +++ head/sys/compat/cloudabi/cloudabi_file.c Wed Jul 15 09:14:06 2015 (r285596) @@ -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) { + int advice; - /* Not implemented. */ - return (ENOSYS); + 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 struct cloudabi_sys_file_allocate_args *uap) { - /* Not implemented. */ - return (ENOSYS); + return (kern_posix_fallocate(td, uap->fd, uap->offset, uap->len)); } int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507150914.t6F9E7dg070051>