Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jun 2006 13:34:20 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Bruno Haible <bruno@clisp.org>
Cc:        Vasil Dimov <vd@freebsd.org>, hackers@freebsd.org
Subject:   Re: valid VMA ranges and mincore()
Message-ID:  <20060614103420.GA86300@deviant.kiev.zoral.com.ua>
In-Reply-To: <200606101822.46437.bruno@clisp.org>
References:  <200606101822.46437.bruno@clisp.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jun 10, 2006 at 06:22:46PM +0200, Bruno Haible wrote:
> Proposal 1: Change mincore() to behave like the one on NetBSD, Linux,
> Solaris.

Please, evaluate the patch. If it does what you need, I will
push it for review.

Index: vm_mmap.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/local/arch/ncvs/src/sys/vm/vm_mmap.c,v
retrieving revision 1.205
diff -u -r1.205 vm_mmap.c
--- vm_mmap.c	21 Apr 2006 07:17:25 -0000	1.205
+++ vm_mmap.c	14 Jun 2006 10:32:11 -0000
@@ -907,6 +907,40 @@
 		++lastvecindex;
 	}
=20
+	/* Mark unmapped areas of the queried address
+	 * space with -1.
+	 */
+	for (addr =3D first_addr; addr < end; ) {
+		vm_offset_t saddr, eaddr;
+
+		vm_map_lock_read(map);
+		if (vm_map_lookup_entry(map, addr, &entry)) {
+			addr =3D entry->end;
+			vm_map_unlock_read(map);
+			continue;
+		}
+		entry =3D entry->next;
+		if (entry->start < addr) {
+			/* past the last entry in the map */
+			saddr =3D eaddr =3D end;
+		} else {
+			saddr =3D entry->start;
+			eaddr =3D entry->end;
+		}
+		vm_map_unlock_read(map);
+
+		while (addr < saddr) {
+			vecindex =3D OFF_TO_IDX(addr - first_addr);
+			error =3D subyte(vec + vecindex, -1);
+			if (error) {
+				error =3D EFAULT;
+				goto done2;
+			}
+			addr +=3D PAGE_SIZE;
+		}
+		addr =3D eaddr;
+	}
+
 	/*
 	 * If the map has changed, due to the subyte, the previous
 	 * output may be invalid.

--x+6KMIRAuhnl3hBn
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (FreeBSD)

iD8DBQFEj+YsC3+MBN1Mb4gRAllsAJ9tTfcBapLXj9FhxrMu+Thz9Ia4VQCg21YU
W8evbRThZZeWi827tB6T61g=
=YmSo
-----END PGP SIGNATURE-----

--x+6KMIRAuhnl3hBn--



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