Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/usr.bin/grep Pull up revision 1.2 (requested by mlelstv i...



details:   https://anonhg.NetBSD.org/src/rev/5a34bc59e16f
branches:  netbsd-3
changeset: 576476:5a34bc59e16f
user:      tron <tron%NetBSD.org@localhost>
date:      Sun Jul 03 21:22:03 2005 +0000

description:
Pull up revision 1.2 (requested by mlelstv in ticket #527):
trying to map a 4G file does not work nicely. Limit mmap to 64M.

diffstat:

 usr.bin/grep/mmfile.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 9582d47594ed -r 5a34bc59e16f usr.bin/grep/mmfile.c
--- a/usr.bin/grep/mmfile.c     Sun Jul 03 21:17:21 2005 +0000
+++ b/usr.bin/grep/mmfile.c     Sun Jul 03 21:22:03 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mmfile.c,v 1.1.1.2 2004/01/02 15:00:34 cjep Exp $      */
+/*     $NetBSD: mmfile.c,v 1.1.1.2.6.1 2005/07/03 21:22:03 tron Exp $  */
 
 /*-
  * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mmfile.c,v 1.1.1.2 2004/01/02 15:00:34 cjep Exp $");
+__RCSID("$NetBSD: mmfile.c,v 1.1.1.2.6.1 2005/07/03 21:22:03 tron Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -43,7 +43,7 @@
 
 #include "grep.h"
 
-#define MAX_MAP_LEN 1048576
+#define MAX_MAP_LEN (SIZE_T_MAX / 64)  /* ~70M is reasonable size */
 
 mmf_t *
 mmopen(char *fn, char *mode)
@@ -59,7 +59,7 @@
                goto ouch1;
        if (fstat(mmf->fd, &st) == -1)
                goto ouch2;
-       if (st.st_size > SIZE_T_MAX)            /* too big to mmap */           
+       if (st.st_size > MAX_MAP_LEN)           /* too big to mmap */           
                goto ouch2;
        if ((st.st_mode & S_IFREG) == 0)        /* only mmap regular files */
                goto ouch2;



Home | Main Index | Thread Index | Old Index