if ((sb.st_size & pgmask) == 0)
need_guard = true;
-#ifndef __minix
mf->poimf_xml = mmap(NULL, need_guard ? mf->poimf_mapsize + pgsize
: mf->poimf_mapsize,
PROT_READ, MAP_FILE|MAP_SHARED, fd, (off_t)0);
-#else
- mf->poimf_xml = MAP_FAILED;
-#endif
(void) close(fd);
if (mf->poimf_xml == MAP_FAILED) {
_PROP_FREE(mf, M_TEMP);
#include <string.h>
#include <unistd.h>
-#if defined(__minix) && !defined(MAP_SHARED)
-#define MAP_SHARED MAP_PRIVATE /* LSC: We lose some memory, but it's OK as this is RO. */
-#endif /* defined(__minix) && !defined(MAP_SHARED) */
-
#ifdef __weak_alias
__weak_alias(cdbr_close,_cdbr_close)
__weak_alias(cdbr_find,_cdbr_find)
#define NLS_DEFAULT_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L"
#define NLS_DEFAULT_LANG "C"
-#if defined(__minix) && !defined(MAP_SHARED)
-#define MAP_SHARED MAP_PRIVATE /* LSC: We lose some memory, but it's OK as this is RO. */
-#endif /* defined(__minix) && !defined(MAP_SHARED) */
-
__weak_alias(catopen, _catopen)
__weak_alias(catopen_l, _catopen_l)
(void)gettimeofday(&then, NULL);
} else
bufrem = winsize;
-#if !defined(__minix)
while (1) {
mapsize = MIN(filesize - off, winsize);
if (mapsize == 0)
goto try_read;
return (SS_FILE_ERROR);
}
+#ifndef __minix
(void) madvise(win, mapsize, MADV_SEQUENTIAL);
+#endif
error = write_data(netfd, win, mapsize, &bufrem, &then,
isdata);
+#ifndef __minix
(void) madvise(win, mapsize, MADV_DONTNEED);
+#endif
munmap(win, mapsize);
if (urgflag && handleoobcmd())
return (SS_ABORTED);
}
return (SS_SUCCESS);
-#endif /* !defined(__minix) */
try_read:
return (send_data_with_read(filefd, netfd, st, isdata));
}
#if defined(__minix)
#define MINIXVERBOSE 0
-#ifndef MAP_SHARED
-#define MAP_SHARED MAP_PRIVATE /* minix: MAP_SHARED should be MAP_PRIVATE */
-#endif
-
#if MINIXVERBOSE
#include <stdio.h>
#endif
static Search_Path *_rtld_find_path(Search_Path *, const char *, size_t);
static Search_Path **_rtld_append_path(Search_Path **, Search_Path **,
const char *, const char *, const char *);
-#if !defined(__minix)
static void _rtld_process_mapping(Library_Xform **, const char *,
const char *);
-#endif /* !defined(__minix) */
static char *exstrdup(const char *, const char *);
-#if !defined(__minix)
static const char *getstr(const char **, const char *, const char *);
static const char *getcstr(const char **, const char *, const char *);
static const char *getword(const char **, const char *, const char *);
+#if !defined(__minix)
static int matchstr(const char *, const char *, const char *);
#endif /* !defined(__minix) */
return (cp);
}
-#if !defined(__minix)
/*
* Like strsep(), but takes end of string and doesn't put any NUL. To
* detect empty string, compare `*p' and return value.
return (getstr(p, ep, delim));
}
+#if !defined(__minix)
/*
* Match `bp' against NUL terminated string pointed by `p'.
*/
}
}
-#if !defined(__minix)
/*
* Process library mappings of the form:
* <library_name> <machdep_variable> <value,...:library_name,...> ...
xfree(hwptr->name);
xfree(hwptr);
}
-#endif /* !defined(__minix) */
void
_rtld_process_hints(const char *execname, Search_Path **path_p,
Library_Xform **lib_p, const char *fname)
{
-
-#if defined(__minix)
- /* Minix doesn't support MAP_SHARED. */
- return;
-#else
int fd;
char *buf, small[128];
const char *b, *ep, *ptr;
if (buf != small)
(void)munmap(buf, sz);
-#endif /* defined(__minix) */
}
#if !defined(__minix)
/* File mapping might be disabled */
if(!enable_filemap) return ENXIO;
- /* files get private copies of pages on writes. */
- if(!(m->VMM_FLAGS & MAP_PRIVATE)) {
- printf("VM: mmap file must MAP_PRIVATE\n");
+ /* For files, we only can't accept writable MAP_SHARED
+ * mappings.
+ */
+ if((m->VMM_FLAGS & MAP_SHARED) && (m->VMM_PROT & PROT_WRITE)) {
return ENXIO;
}
* Flags contain sharing type and options.
* Sharing types; choose one.
*/
-#if !defined(__minix)
#define MAP_SHARED 0x0001 /* share changes */
-#endif /* !defined(__minix) */
#define MAP_PRIVATE 0x0002 /* changes are private */
#ifdef _KERNEL
fd2 = open("../testsh2", O_RDONLY);
if(fd1 < 0 || fd2 < 0) { e(2); }
+ /* just check that we can't mmap() a file writable */
+ if(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FILE, fd1, 0) != MAP_FAILED) {
+ e(1);
+ }
+
+ /* check that we can mmap() a file MAP_SHARED readonly */
+ if(mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED | MAP_FILE, fd1, 0) == MAP_FAILED) {
+ e(1);
+ }
+
/* clear cache of files before mmap so pages won't be present already */
if(fcntl(fd1, F_FLUSH_FS_CACHE) < 0) { e(1); }
if(fcntl(fd2, F_FLUSH_FS_CACHE) < 0) { e(1); }
if (fd == -1)
return -1;
msgmapsz = lseek(fd, 0, SEEK_END);
-#ifdef __minix
- msgmap = mmap(0, msgmapsz, PROT_READ, MAP_PRIVATE, fd, 0);
-#else /* ! __minix */
msgmap = mmap(0, msgmapsz, PROT_READ, MAP_SHARED, fd, 0);
-#endif /* ! __minix */
close(fd);
if (msgmap == MAP_FAILED)
return -1;
{
ssize_t nr, nw;
int serrno;
-#if !defined(__minix)
u_char *p;
-#endif /* !defined(__minix) */
u_char buf[MAXBSIZE];
MD5_CTX ctxMD5;
RMD160_CTX ctxRMD160;
*/
if (size <= 8 * 1048576) {
-#if defined(__minix)
- goto mmap_failed;
-#else
if ((p = mmap(NULL, (size_t)size, PROT_READ,
MAP_FILE|MAP_SHARED, from_fd, (off_t)0))
== MAP_FAILED) {
goto mmap_failed;
}
-#if defined(MADV_SEQUENTIAL) && !defined(__APPLE__)
+#if defined(MADV_SEQUENTIAL) && !defined(__APPLE__) && !defined(__minix)
if (madvise(p, (size_t)size, MADV_SEQUENTIAL) == -1
&& errno != EOPNOTSUPP)
warnx("madvise: %s", strerror(errno));
break;
}
(void)munmap(p, size);
-#endif /* defined(__minix) */
} else {
mmap_failed:
while ((nr = read(from_fd, buf, sizeof(buf))) > 0) {