3.3p1 patch for Solaris 2.6

IWAMOTO Toshihiro iwamoto at sat.t.u-tokyo.ac.jp
Wed Jun 26 01:07:29 EST 2002


At Tue, 25 Jun 2002 23:52:53 +0900,
Jun-ichiro itojun Hagino wrote:
> 
> 	here's a patch to 3.3p1 for Solaris 2.6 - it does not handle
> 	mmap() with fd = -1.  does it look okay?

If open() fails, mmap() should fail because of an invalid file
descriptor.  So I think retval check of open() can be omitted.
I'm not perfectly sure this usage of /dev/zero is correct, although
comments in NetBSD's sys/uvm/uvm_mmap.c suggests so.


> @@ -87,6 +90,13 @@
>  #if  defined(HAVE_MMAP) && defined(MAP_ANON)
>  	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
>  	    -1, 0);
> +	if (address == MAP_FAILED)
> +		fatal("mmap(%lu): %s", (u_long)size, strerror(errno));
> +#elif defined(HAVE_MMAP) && !defined(MAP_ANON)
> +	fd = open("/dev/zero", O_RDWR);
> +	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
> +	    fd, 0);

This should be as follows, because MAP_ANON isn't defined.

+	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED,
+	    fd, 0);

> +	close(fd);
>  	if (address == MAP_FAILED)
>  		fatal("mmap(%lu): %s", (u_long)size, strerror(errno));
>  #else

--
IWAMOTO Toshihiro



More information about the openssh-unix-dev mailing list