PERFORCE change 115094 for review

Jung-uk Kim jkim at FreeBSD.org
Tue Feb 27 01:54:26 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=115094

Change 115094 by jkim at jkim_hammer on 2007/02/27 01:54:21

	Linux does not check file descriptor when MAP_ANONYMOUS is set.
	This should fix recent LTP test regressions.

Affected files ...

.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#43 edit
.. //depot/projects/linuxolator/src/sys/i386/linux/linux_machdep.c#34 edit

Differences ...

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#43 (text+ko) ====

@@ -831,7 +831,9 @@
 	if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
 		bsd_args.prot |= PROT_READ | PROT_EXEC;
 
-	if (linux_args->fd != -1) {
+	/* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
+	bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : linux_args->fd;
+	if (bsd_args.fd != -1) {
 		/*
 		 * Linux follows Solaris mmap(2) description:
 		 * The file descriptor fildes is opened with
@@ -839,7 +841,7 @@
 		 * protection options specified.
 		 */
 
-		if ((error = fget(td, linux_args->fd, &fp)) != 0)
+		if ((error = fget(td, bsd_args.fd, &fp)) != 0)
 			return (error);
 		if (fp->f_type != DTYPE_VNODE) {
 			fdrop(fp, td);
@@ -854,7 +856,6 @@
 
 		fdrop(fp, td);
 	}
-	bsd_args.fd = linux_args->fd;
 
 	if (linux_args->flags & LINUX_MAP_GROWSDOWN) {
 		/*

==== //depot/projects/linuxolator/src/sys/i386/linux/linux_machdep.c#34 (text+ko) ====

@@ -669,7 +669,9 @@
 	if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
 		bsd_args.prot |= PROT_READ | PROT_EXEC;
 
-	if (linux_args->fd != -1) {
+	/* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
+	bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : linux_args->fd;
+	if (bsd_args.fd != -1) {
 		/*
 		 * Linux follows Solaris mmap(2) description:
 		 * The file descriptor fildes is opened with
@@ -677,7 +679,7 @@
 		 * protection options specified.
 		 */
 
-		if ((error = fget(td, linux_args->fd, &fp)) != 0)
+		if ((error = fget(td, bsd_args.fd, &fp)) != 0)
 			return (error);
 		if (fp->f_type != DTYPE_VNODE) {
 			fdrop(fp, td);
@@ -692,7 +694,6 @@
 
 		fdrop(fp, td);
 	}
-	bsd_args.fd = linux_args->fd;
 
 	if (linux_args->flags & LINUX_MAP_GROWSDOWN) {
 		/* 


More information about the p4-projects mailing list