svn commit: r285596 - head/sys/compat/cloudabi
Ed Schouten
ed at FreeBSD.org
Wed Jul 15 09:14:08 UTC 2015
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
More information about the svn-src-all
mailing list