svn commit: r270691 - head/sys/compat/freebsd32

Konstantin Belousov kib at FreeBSD.org
Wed Aug 27 01:02:03 UTC 2014


Author: kib
Date: Wed Aug 27 01:02:02 2014
New Revision: 270691
URL: http://svnweb.freebsd.org/changeset/base/270691

Log:
  Fix handling of the third argument for fcntl(2).  The native syscall
  uses long for arg, which needs translation.
  
  Discussed with and tested by:	mjg
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/compat/freebsd32/syscalls.master

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_misc.c	Wed Aug 27 00:57:45 2014	(r270690)
+++ head/sys/compat/freebsd32/freebsd32_misc.c	Wed Aug 27 01:02:02 2014	(r270691)
@@ -2980,3 +2980,28 @@ freebsd32_procctl(struct thread *td, str
 	return (kern_procctl(td, uap->idtype, PAIR32TO64(id_t, uap->id),
 	    uap->com, data));
 }
+
+int
+freebsd32_fcntl(struct thread *td, struct freebsd32_fcntl_args *uap)
+{
+	intptr_t tmp;
+
+	switch (uap->cmd) {
+	/*
+	 * Do unsigned conversion for arg when operation
+	 * interprets it as flags or pointer.
+	 */
+	case F_SETLK_REMOTE:
+	case F_SETLKW:
+	case F_SETLK:
+	case F_GETLK:
+	case F_SETFD:
+	case F_SETFL:
+		tmp = (unsigned int)(uap->arg);
+		break;
+	default:
+		tmp = uap->arg;
+		break;
+	}
+	return (kern_fcntl(td, uap->fd, uap->cmd, tmp));
+}

Modified: head/sys/compat/freebsd32/syscalls.master
==============================================================================
--- head/sys/compat/freebsd32/syscalls.master	Wed Aug 27 00:57:45 2014	(r270690)
+++ head/sys/compat/freebsd32/syscalls.master	Wed Aug 27 01:02:02 2014	(r270691)
@@ -200,7 +200,8 @@
 89	AUE_GETDTABLESIZE	NOPROTO	{ int getdtablesize(void); }
 90	AUE_DUP2	NOPROTO	{ int dup2(u_int from, u_int to); }
 91	AUE_NULL	UNIMPL	getdopt
-92	AUE_FCNTL	NOPROTO	{ int fcntl(int fd, int cmd, long arg); }
+92	AUE_FCNTL	STD	{ int freebsd32_fcntl(int fd, int cmd, \
+				    int arg); }
 93	AUE_SELECT	STD	{ int freebsd32_select(int nd, fd_set *in, \
 				    fd_set *ou, fd_set *ex, \
 				    struct timeval32 *tv); }


More information about the svn-src-head mailing list