Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Dec 2011 15:35:00 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r228957 - in head/sys: amd64/linux32 compat/linux i386/linux
Message-ID:  <201112291535.pBTFZ09v061763@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Dec 29 15:34:59 2011
New Revision: 228957
URL: http://svn.freebsd.org/changeset/base/228957

Log:
  Implement linux_fadvise64() and linux_fadvise64_64() using
  kern_posix_fadvise().
  
  Reviewed by:	silence on emulation@
  MFC after:	2 weeks

Modified:
  head/sys/amd64/linux32/linux.h
  head/sys/amd64/linux32/linux32_dummy.c
  head/sys/amd64/linux32/syscalls.master
  head/sys/compat/linux/linux_file.c
  head/sys/i386/linux/linux.h
  head/sys/i386/linux/linux_dummy.c
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/linux.h
==============================================================================
--- head/sys/amd64/linux32/linux.h	Thu Dec 29 15:34:59 2011	(r228956)
+++ head/sys/amd64/linux32/linux.h	Thu Dec 29 15:34:59 2011	(r228957)
@@ -597,6 +597,16 @@ int	linux_ioctl_unregister_handler(struc
 #define	LINUX_F_UNLCK		2
 
 /*
+ * posix_fadvise advice
+ */
+#define	LINUX_POSIX_FADV_NORMAL		0
+#define	LINUX_POSIX_FADV_RANDOM		1
+#define	LINUX_POSIX_FADV_SEQUENTIAL    	2
+#define	LINUX_POSIX_FADV_WILLNEED      	3
+#define	LINUX_POSIX_FADV_DONTNEED      	4
+#define	LINUX_POSIX_FADV_NOREUSE       	5
+
+/*
  * mount flags
  */
 #define	LINUX_MS_RDONLY		0x0001

Modified: head/sys/amd64/linux32/linux32_dummy.c
==============================================================================
--- head/sys/amd64/linux32/linux32_dummy.c	Thu Dec 29 15:34:59 2011	(r228956)
+++ head/sys/amd64/linux32/linux32_dummy.c	Thu Dec 29 15:34:59 2011	(r228957)
@@ -59,7 +59,6 @@ DUMMY(setfsuid);
 DUMMY(setfsgid);
 DUMMY(pivot_root);
 DUMMY(mincore);
-DUMMY(fadvise64);
 DUMMY(ptrace);
 DUMMY(lookup_dcookie);
 DUMMY(epoll_create);
@@ -72,7 +71,6 @@ DUMMY(timer_gettime);
 DUMMY(timer_getoverrun);
 DUMMY(timer_delete);
 DUMMY(fstatfs64);
-DUMMY(fadvise64_64);
 DUMMY(mbind);
 DUMMY(get_mempolicy);
 DUMMY(set_mempolicy);

Modified: head/sys/amd64/linux32/syscalls.master
==============================================================================
--- head/sys/amd64/linux32/syscalls.master	Thu Dec 29 15:34:59 2011	(r228956)
+++ head/sys/amd64/linux32/syscalls.master	Thu Dec 29 15:34:59 2011	(r228957)
@@ -419,7 +419,8 @@
 247	AUE_NULL	UNIMPL	linux_io_getevents
 248	AUE_NULL	UNIMPL	linux_io_submit
 249	AUE_NULL	UNIMPL	linux_io_cancel
-250	AUE_NULL	STD	{ int linux_fadvise64(void); }
+250	AUE_NULL	STD	{ int linux_fadvise64(int fd, l_loff_t offset, \
+					l_size_t len, int advice); }
 251	AUE_NULL	UNIMPL
 252	AUE_EXIT	STD	{ int linux_exit_group(int error_code); }
 253	AUE_NULL	STD	{ int linux_lookup_dcookie(void); }
@@ -443,7 +444,9 @@
 270	AUE_NULL	STD	{ int linux_tgkill(int tgid, int pid, int sig); }
 271	AUE_UTIMES	STD	{ int linux_utimes(char *fname, \
 					struct l_timeval *tptr); }
-272	AUE_NULL	STD	{ int linux_fadvise64_64(void); }
+272	AUE_NULL	STD	{ int linux_fadvise64_64(int fd, \
+					l_loff_t offset, l_loff_t len, \
+					int advice); }
 273	AUE_NULL	UNIMPL
 274	AUE_NULL	STD	{ int linux_mbind(void); }
 275	AUE_NULL	STD	{ int linux_get_mempolicy(void); }

Modified: head/sys/compat/linux/linux_file.c
==============================================================================
--- head/sys/compat/linux/linux_file.c	Thu Dec 29 15:34:59 2011	(r228956)
+++ head/sys/compat/linux/linux_file.c	Thu Dec 29 15:34:59 2011	(r228957)
@@ -1530,3 +1530,48 @@ linux_lchown(struct thread *td, struct l
 	LFREEPATH(path);
 	return (error);
 }
+
+static int
+convert_fadvice(int advice)
+{
+	switch (advice) {
+	case LINUX_POSIX_FADV_NORMAL:
+		return (POSIX_FADV_NORMAL);
+	case LINUX_POSIX_FADV_RANDOM:
+		return (POSIX_FADV_RANDOM);
+	case LINUX_POSIX_FADV_SEQUENTIAL:
+		return (POSIX_FADV_SEQUENTIAL);
+	case LINUX_POSIX_FADV_WILLNEED:
+		return (POSIX_FADV_WILLNEED);
+	case LINUX_POSIX_FADV_DONTNEED:
+		return (POSIX_FADV_DONTNEED);
+	case LINUX_POSIX_FADV_NOREUSE:
+		return (POSIX_FADV_NOREUSE);
+	default:
+		return (-1);
+	}
+}
+
+int
+linux_fadvise64(struct thread *td, struct linux_fadvise64_args *args)
+{
+	int advice;
+
+	advice = convert_fadvice(args->advice);
+	if (advice == -1)
+		return (EINVAL);
+	return (kern_posix_fadvise(td, args->fd, args->offset, args->len,
+	    advice));
+}
+
+int
+linux_fadvise64_64(struct thread *td, struct linux_fadvise64_64_args *args)
+{
+	int advice;
+
+	advice = convert_fadvice(args->advice);
+	if (advice == -1)
+		return (EINVAL);
+	return (kern_posix_fadvise(td, args->fd, args->offset, args->len,
+	    advice));
+}

Modified: head/sys/i386/linux/linux.h
==============================================================================
--- head/sys/i386/linux/linux.h	Thu Dec 29 15:34:59 2011	(r228956)
+++ head/sys/i386/linux/linux.h	Thu Dec 29 15:34:59 2011	(r228957)
@@ -573,6 +573,16 @@ int	linux_ioctl_unregister_handler(struc
 #define	LINUX_F_UNLCK		2
 
 /*
+ * posix_fadvise advice
+ */
+#define	LINUX_POSIX_FADV_NORMAL		0
+#define	LINUX_POSIX_FADV_RANDOM		1
+#define	LINUX_POSIX_FADV_SEQUENTIAL    	2
+#define	LINUX_POSIX_FADV_WILLNEED      	3
+#define	LINUX_POSIX_FADV_DONTNEED      	4
+#define	LINUX_POSIX_FADV_NOREUSE       	5
+
+/*
  * mount flags
  */
 #define	LINUX_MS_RDONLY		0x0001

Modified: head/sys/i386/linux/linux_dummy.c
==============================================================================
--- head/sys/i386/linux/linux_dummy.c	Thu Dec 29 15:34:59 2011	(r228956)
+++ head/sys/i386/linux/linux_dummy.c	Thu Dec 29 15:34:59 2011	(r228957)
@@ -62,14 +62,12 @@ DUMMY(setfsuid);
 DUMMY(setfsgid);
 DUMMY(pivot_root);
 DUMMY(mincore);
-DUMMY(fadvise64);
 DUMMY(lookup_dcookie);
 DUMMY(epoll_create);
 DUMMY(epoll_ctl);
 DUMMY(epoll_wait);
 DUMMY(remap_file_pages);
 DUMMY(fstatfs64);
-DUMMY(fadvise64_64);
 DUMMY(mbind);
 DUMMY(get_mempolicy);
 DUMMY(set_mempolicy);

Modified: head/sys/i386/linux/syscalls.master
==============================================================================
--- head/sys/i386/linux/syscalls.master	Thu Dec 29 15:34:59 2011	(r228956)
+++ head/sys/i386/linux/syscalls.master	Thu Dec 29 15:34:59 2011	(r228957)
@@ -421,7 +421,8 @@
 247	AUE_NULL	UNIMPL	linux_io_getevents
 248	AUE_NULL	UNIMPL	linux_io_submit
 249	AUE_NULL	UNIMPL	linux_io_cancel
-250	AUE_NULL	STD	{ int linux_fadvise64(void); }
+250	AUE_NULL	STD	{ int linux_fadvise64(int fd, l_loff_t offset, \
+					l_size_t len, int advice); }
 251	AUE_NULL	UNIMPL
 252	AUE_EXIT	STD	{ int linux_exit_group(int error_code); }
 253	AUE_NULL	STD	{ int linux_lookup_dcookie(void); }
@@ -447,7 +448,9 @@
 270	AUE_NULL	STD	{ int linux_tgkill(int tgid, int pid, int sig); }
 271	AUE_UTIMES	STD	{ int linux_utimes(char *fname, \
 					struct l_timeval *tptr); }
-272	AUE_NULL	STD	{ int linux_fadvise64_64(void); }
+272	AUE_NULL	STD	{ int linux_fadvise64_64(int fd, \
+					l_loff_t offset, l_loff_t len, \
+					int advice); }
 273	AUE_NULL	UNIMPL
 274	AUE_NULL	STD	{ int linux_mbind(void); }
 275	AUE_NULL	STD	{ int linux_get_mempolicy(void); }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112291535.pBTFZ09v061763>