Fill in missing (default) mmap(2) flags.

This commit is contained in:
mycroft 1998-02-20 09:27:18 +00:00
parent f49407ea34
commit 4462053ab3
18 changed files with 61 additions and 56 deletions

View File

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $NetBSD: inject.c,v 1.3 1998/01/06 04:45:24 perry Exp $
* $NetBSD: inject.c,v 1.4 1998/02/20 09:27:18 mycroft Exp $
*/
#include <stdio.h>
@ -66,7 +66,7 @@ void *map(char *file, int mode, int *len)
/* Now map the file */
p = mmap(NULL, *len, PROT_READ | (mode == O_RDWR ? PROT_WRITE : 0),
MAP_SHARED, fd, 0);
MAP_FILE | MAP_SHARED, fd, 0);
if (p == NULL) {
perror("mmap");
exit(1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rdsetroot.c,v 1.5 1998/01/06 04:45:36 perry Exp $ */
/* $NetBSD: rdsetroot.c,v 1.6 1998/02/20 09:27:18 mycroft Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
@ -26,7 +26,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $NetBSD: rdsetroot.c,v 1.5 1998/01/06 04:45:36 perry Exp $
* $NetBSD: rdsetroot.c,v 1.6 1998/02/20 09:27:18 mycroft Exp $
*/
/*
@ -131,7 +131,7 @@ main(argc,argv)
dataseg = mmap(NULL, /* any address is ok */
data_len, /* length */
PROT_READ | PROT_WRITE,
MAP_SHARED,
MAP_FILE | MAP_SHARED,
fd, data_off);
if ((long)dataseg == -1) {
printf("%s: can not map data seg\n", file);

View File

@ -18,7 +18,7 @@
Written July 1992 by Mike Haertel. */
#ifndef lint
static char rcsid[] = "$Id: grep.c,v 1.4 1995/02/27 16:48:13 cgd Exp $";
static char rcsid[] = "$Id: grep.c,v 1.5 1998/02/20 09:27:18 mycroft Exp $";
#endif /* not lint */
#include <errno.h>
@ -286,7 +286,7 @@ fillbuf(save)
{
maddr = buffer + bufsalloc;
maddr = mmap(maddr, bufalloc - bufsalloc, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_FIXED, bufdesc, bufoffset);
MAP_FILE | MAP_PRIVATE | MAP_FIXED, bufdesc, bufoffset);
if (maddr == (caddr_t) -1)
{
fprintf(stderr, "%s: warning: %s: %s\n", filename,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldconfig.c,v 1.18 1997/08/26 19:29:57 thorpej Exp $ */
/* $NetBSD: ldconfig.c,v 1.19 1998/02/20 09:27:19 mycroft Exp $ */
/*
* Copyright (c) 1993,1995 Paul Kranenburg
@ -483,7 +483,7 @@ readhints()
}
msize = PAGSIZ;
addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
addr = mmap(0, msize, PROT_READ, MAP_FILE|MAP_COPY, fd, 0);
if (addr == (caddr_t)-1) {
warn("%s", _PATH_LD_HINTS);
@ -504,7 +504,7 @@ readhints()
if (hdr->hh_ehints > msize) {
if (mmap(addr+msize, hdr->hh_ehints - msize,
PROT_READ, MAP_COPY|MAP_FIXED,
PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED,
fd, msize) != (caddr_t)(addr+msize)) {
warn("%s", _PATH_LD_HINTS);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtld.c,v 1.53 1998/02/17 23:07:33 pk Exp $ */
/* $NetBSD: rtld.c,v 1.54 1998/02/20 09:27:19 mycroft Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@ -674,7 +674,7 @@ again:
if ((addr = mmap(0, hdr.a_text + hdr.a_data + hdr.a_bss,
PROT_READ|PROT_EXEC,
MAP_COPY, fd, 0)) == (caddr_t)-1) {
MAP_FILE|MAP_COPY, fd, 0)) == (caddr_t)-1) {
(void)close(fd);
return NULL;
}
@ -1228,7 +1228,7 @@ maphints()
}
hsize = PAGSIZ;
addr = mmap(0, hsize, PROT_READ, MAP_COPY, hfd, 0);
addr = mmap(0, hsize, PROT_READ, MAP_FILE|MAP_COPY, hfd, 0);
if (addr == (caddr_t)-1) {
close(hfd);
@ -1254,7 +1254,7 @@ maphints()
if (hheader->hh_ehints > hsize) {
if (mmap(addr+hsize, hheader->hh_ehints - hsize,
PROT_READ, MAP_COPY|MAP_FIXED,
PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED,
hfd, hsize) != (caddr_t)(addr+hsize)) {
munmap((caddr_t)hheader, hsize);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcslex.c,v 1.5 1996/10/15 07:00:23 veego Exp $ */
/* $NetBSD: rcslex.c,v 1.6 1998/02/20 09:27:19 mycroft Exp $ */
/* lexical analysis of RCS files */
@ -42,6 +42,9 @@ Report problems and direct all questions to:
/*
* $Log: rcslex.c,v $
* Revision 1.6 1998/02/20 09:27:19 mycroft
* Fill in missing (default) mmap(2) flags.
*
* Revision 1.5 1996/10/15 07:00:23 veego
* Merge rcs 5.7.
*
@ -1002,7 +1005,7 @@ fd2RILE(fd, name, type, status)
if (!f->base) {
catchmmapints();
f->base = (unsigned char *) mmap(
(char *)0, s, PROT_READ, MAP_SHARED,
(char *)0, s, PROT_READ, MAP_FILE|MAP_SHARED,
fd, (off_t)0
);
# ifndef MAP_FAILED

View File

@ -1,4 +1,4 @@
/* $NetBSD: common.c,v 1.7 1998/02/03 20:01:32 perry Exp $ */
/* $NetBSD: common.c,v 1.8 1998/02/20 09:27:19 mycroft Exp $ */
/*
* Copyright (c) 1993,1995 Paul Kranenburg
@ -86,7 +86,7 @@ __load_rtld(dp)
/* Map in ld.so */
crt.crt_ba = mmap(0, hdr.a_text+hdr.a_data+hdr.a_bss,
PROT_READ|PROT_EXEC,
MAP_COPY,
MAP_FILE|MAP_COPY,
crt.crt_ldfd, N_TXTOFF(hdr));
if (crt.crt_ba == -1) {
_FATAL("Cannot map ld.so\n");
@ -106,7 +106,7 @@ __load_rtld(dp)
/* Map in data segment of ld.so writable */
if (mmap(crt.crt_ba+N_DATADDR(hdr), hdr.a_data,
PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_COPY,
MAP_FILE|MAP_COPY|MAP_FIXED,
crt.crt_ldfd, N_DATOFF(hdr)) == -1) {
_FATAL("Cannot map ld.so\n");
}
@ -114,7 +114,7 @@ __load_rtld(dp)
/* Map bss segment of ld.so zero */
if (hdr.a_bss && mmap(crt.crt_ba+N_BSSADDR(hdr), hdr.a_bss,
PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_ANON|MAP_COPY,
MAP_ANON|MAP_COPY|MAP_FIXED,
crt.crt_dzfd, 0) == -1) {
_FATAL("Cannot map ld.so\n");
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: common.c,v 1.7 1998/02/03 20:01:32 perry Exp $ */
/* $NetBSD: common.c,v 1.8 1998/02/20 09:27:19 mycroft Exp $ */
/*
* Copyright (c) 1993,1995 Paul Kranenburg
@ -86,7 +86,7 @@ __load_rtld(dp)
/* Map in ld.so */
crt.crt_ba = mmap(0, hdr.a_text+hdr.a_data+hdr.a_bss,
PROT_READ|PROT_EXEC,
MAP_COPY,
MAP_FILE|MAP_COPY,
crt.crt_ldfd, N_TXTOFF(hdr));
if (crt.crt_ba == -1) {
_FATAL("Cannot map ld.so\n");
@ -106,7 +106,7 @@ __load_rtld(dp)
/* Map in data segment of ld.so writable */
if (mmap(crt.crt_ba+N_DATADDR(hdr), hdr.a_data,
PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_COPY,
MAP_FILE|MAP_COPY|MAP_FIXED,
crt.crt_ldfd, N_DATOFF(hdr)) == -1) {
_FATAL("Cannot map ld.so\n");
}
@ -114,7 +114,7 @@ __load_rtld(dp)
/* Map bss segment of ld.so zero */
if (hdr.a_bss && mmap(crt.crt_ba+N_BSSADDR(hdr), hdr.a_bss,
PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_ANON|MAP_COPY,
MAP_ANON|MAP_COPY|MAP_FIXED,
crt.crt_dzfd, 0) == -1) {
_FATAL("Cannot map ld.so\n");
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rec_open.c,v 1.9 1997/07/21 14:06:45 jtc Exp $ */
/* $NetBSD: rec_open.c,v 1.10 1998/02/20 09:27:20 mycroft Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94";
#else
__RCSID("$NetBSD: rec_open.c,v 1.9 1997/07/21 14:06:45 jtc Exp $");
__RCSID("$NetBSD: rec_open.c,v 1.10 1998/02/20 09:27:20 mycroft Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -177,7 +177,7 @@ slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
*/
t->bt_msize = sb.st_size;
if ((t->bt_smap = mmap(NULL, t->bt_msize,
PROT_READ, MAP_PRIVATE, rfd,
PROT_READ, MAP_FILE | MAP_PRIVATE, rfd,
(off_t)0)) == (caddr_t)-1)
goto slow;
t->bt_cmap = t->bt_smap;

View File

@ -1,4 +1,4 @@
/* $NetBSD: catopen.c,v 1.12 1997/07/30 23:49:51 jtc Exp $ */
/* $NetBSD: catopen.c,v 1.13 1998/02/20 09:27:20 mycroft Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -145,7 +145,8 @@ load_msgcat(path)
return (nl_catd)-1;
}
data = mmap(0, (size_t)st.st_size, PROT_READ, MAP_SHARED, fd, 0);
data = mmap(0, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd,
0);
close (fd);
if (data == (void *)-1) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtld.c,v 1.53 1998/02/17 23:07:33 pk Exp $ */
/* $NetBSD: rtld.c,v 1.54 1998/02/20 09:27:19 mycroft Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@ -674,7 +674,7 @@ again:
if ((addr = mmap(0, hdr.a_text + hdr.a_data + hdr.a_bss,
PROT_READ|PROT_EXEC,
MAP_COPY, fd, 0)) == (caddr_t)-1) {
MAP_FILE|MAP_COPY, fd, 0)) == (caddr_t)-1) {
(void)close(fd);
return NULL;
}
@ -1228,7 +1228,7 @@ maphints()
}
hsize = PAGSIZ;
addr = mmap(0, hsize, PROT_READ, MAP_COPY, hfd, 0);
addr = mmap(0, hsize, PROT_READ, MAP_FILE|MAP_COPY, hfd, 0);
if (addr == (caddr_t)-1) {
close(hfd);
@ -1254,7 +1254,7 @@ maphints()
if (hheader->hh_ehints > hsize) {
if (mmap(addr+hsize, hheader->hh_ehints - hsize,
PROT_READ, MAP_COPY|MAP_FIXED,
PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED,
hfd, hsize) != (caddr_t)(addr+hsize)) {
munmap((caddr_t)hheader, hsize);

View File

@ -1,4 +1,4 @@
/* $NetBSD: map_object.c,v 1.2 1996/12/17 03:42:44 jonathan Exp $ */
/* $NetBSD: map_object.c,v 1.3 1998/02/20 09:27:20 mycroft Exp $ */
/*
* Copyright 1996 John D. Polstra.
@ -194,7 +194,7 @@ _rtld_map_object(
#endif
mapbase = mmap(base_addr, mapsize, protflags(segs[0]->p_flags),
MAP_PRIVATE, fd, base_offset);
MAP_FILE|MAP_PRIVATE, fd, base_offset);
if (mapbase == (caddr_t) -1) {
_rtld_error("mmap of entire address space failed: %s", xstrerror(errno));
return NULL;
@ -212,7 +212,7 @@ _rtld_map_object(
data_vlimit = round_up(segs[1]->p_vaddr + segs[1]->p_filesz);
data_addr = mapbase + (data_vaddr - base_vaddr);
if (mmap(data_addr, data_vlimit - data_vaddr, protflags(segs[1]->p_flags),
MAP_PRIVATE|MAP_FIXED, fd, data_offset) == (caddr_t) -1) {
MAP_FILE|MAP_PRIVATE|MAP_FIXED, fd, data_offset) == (caddr_t) -1) {
_rtld_error("mmap of data failed: %s", xstrerror(errno));
return NULL;
}
@ -230,7 +230,7 @@ _rtld_map_object(
bss_addr = mapbase + (bss_vaddr - base_vaddr);
if (bss_vlimit > bss_vaddr) { /* There is something to do */
if (mmap(bss_addr, bss_vlimit - bss_vaddr, protflags(segs[1]->p_flags),
MAP_PRIVATE|MAP_FIXED|MAP_ANON, -1, 0) == (caddr_t) -1) {
MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0) == (caddr_t) -1) {
_rtld_error("mmap of bss failed: %s", xstrerror(errno));
return NULL;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: library.c,v 1.4 1997/10/07 13:39:59 mrg Exp $ */
/* $NetBSD: library.c,v 1.5 1998/02/20 09:27:20 mycroft Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)library.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: library.c,v 1.4 1997/10/07 13:39:59 mrg Exp $");
__RCSID("$NetBSD: library.c,v 1.5 1998/02/20 09:27:20 mycroft Exp $");
#endif
#endif /* not lint */
@ -213,7 +213,7 @@ get_ifile (fsp, use_mmap)
if (fsp->fi_cip)
munmap((caddr_t)fsp->fi_cip, fsp->fi_ifile_length);
ifp = mmap ((caddr_t)0, file_stat.st_size,
PROT_READ|PROT_WRITE, 0, fid, (off_t)0);
PROT_READ|PROT_WRITE, MAP_FILE|MAP_PRIVATE, fid, (off_t)0);
if (ifp == (caddr_t)(-1))
err(1, "get_ifile: mmap failed");
} else {
@ -564,7 +564,7 @@ mmap_segment (fsp, segment, segbuf, use_mmap)
if (use_mmap) {
*segbuf = mmap ((caddr_t)0, seg_size(lfsp), PROT_READ,
0, fid, seg_byte);
MAP_FILE|MAP_SHARED, fid, seg_byte);
if (*(long *)segbuf < 0) {
err(0, "mmap_segment: mmap failed");
return (0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.c,v 1.31 1998/02/06 19:30:14 perry Exp $ */
/* $NetBSD: init.c,v 1.32 1998/02/20 09:27:20 mycroft Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n"
#if 0
static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: init.c,v 1.31 1998/02/06 19:30:14 perry Exp $");
__RCSID("$NetBSD: init.c,v 1.32 1998/02/20 09:27:20 mycroft Exp $");
#endif
#endif /* not lint */
@ -1388,7 +1388,8 @@ msdosfs_root()
if (fstat(fd, &st) == -1)
goto done;
if ((ptr = mmap(0, st.st_size, PROT_READ, 0, fd, 0)) == (void *) -1)
if ((ptr = mmap(0,
st.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0)) == (void *) -1)
goto done;
(void) close(fd);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldconfig.c,v 1.18 1997/08/26 19:29:57 thorpej Exp $ */
/* $NetBSD: ldconfig.c,v 1.19 1998/02/20 09:27:19 mycroft Exp $ */
/*
* Copyright (c) 1993,1995 Paul Kranenburg
@ -483,7 +483,7 @@ readhints()
}
msize = PAGSIZ;
addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
addr = mmap(0, msize, PROT_READ, MAP_FILE|MAP_COPY, fd, 0);
if (addr == (caddr_t)-1) {
warn("%s", _PATH_LD_HINTS);
@ -504,7 +504,7 @@ readhints()
if (hdr->hh_ehints > msize) {
if (mmap(addr+msize, hdr->hh_ehints - msize,
PROT_READ, MAP_COPY|MAP_FIXED,
PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED,
fd, msize) != (caddr_t)(addr+msize)) {
warn("%s", _PATH_LD_HINTS);

View File

@ -1,4 +1,4 @@
/* $NetBSD: strip.c,v 1.18 1997/10/19 23:30:41 lukem Exp $ */
/* $NetBSD: strip.c,v 1.19 1998/02/20 09:27:20 mycroft Exp $ */
/*
* Copyright (c) 1988, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\
#if 0
static char sccsid[] = "@(#)strip.c 8.3 (Berkeley) 5/16/95";
#else
__RCSID("$NetBSD: strip.c,v 1.18 1997/10/19 23:30:41 lukem Exp $");
__RCSID("$NetBSD: strip.c,v 1.19 1998/02/20 09:27:20 mycroft Exp $");
#endif
#endif /* not lint */
@ -122,7 +122,7 @@ main(argc, argv)
ERROR(EFTYPE);
}
if ((ep = (EXEC *)mmap(NULL, sb.st_size, PROT_READ|PROT_WRITE,
MAP_SHARED, fd, (off_t)0)) == (EXEC *)-1) {
MAP_FILE|MAP_SHARED, fd, (off_t)0)) == (EXEC *)-1) {
(void)close(fd);
ERROR(errno);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: xinstall.c,v 1.24 1997/12/01 21:11:39 chuck Exp $ */
/* $NetBSD: xinstall.c,v 1.25 1998/02/20 09:27:21 mycroft Exp $ */
/*
* Copyright (c) 1987, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
#if 0
static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93";
#else
__RCSID("$NetBSD: xinstall.c,v 1.24 1997/12/01 21:11:39 chuck Exp $");
__RCSID("$NetBSD: xinstall.c,v 1.25 1998/02/20 09:27:21 mycroft Exp $");
#endif
#endif /* not lint */
@ -422,7 +422,7 @@ copy(from_fd, from_name, to_fd, to_name, size)
*/
if (size <= 8 * 1048576) {
if ((p = mmap(NULL, (size_t)size, PROT_READ,
MAP_PRIVATE, from_fd, (off_t)0)) == (char *)-1)
MAP_FILE|MAP_SHARED, from_fd, (off_t)0)) == (char *)-1)
err(1, "%s", from_name);
if (write(to_fd, p, size) != size)
err(1, "%s", to_name);

View File

@ -24,12 +24,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $NetBSD: dbsym.c,v 1.13 1997/10/25 10:49:36 fvdl Exp $
* $NetBSD: dbsym.c,v 1.14 1998/02/20 09:27:21 mycroft Exp $
*/
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: dbsym.c,v 1.13 1997/10/25 10:49:36 fvdl Exp $");
__RCSID("$NetBSD: dbsym.c,v 1.14 1998/02/20 09:27:21 mycroft Exp $");
#endif
/* Copy the symbol table into the space reserved for it. */
@ -123,7 +123,7 @@ main(argc,argv)
dataseg = mmap(NULL, /* any address is ok */
file_len - data_off, /* length */
PROT_READ | PROT_WRITE,
MAP_SHARED,
MAP_FILE | MAP_SHARED,
fd, data_off);
if ((long)dataseg == -1) {
printf("%s: can not map data seg\n", file);