@@ -251,14 +251,6 @@ struct fsxattr {
#define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */
#endif
-#ifndef HAVE_MAP_SYNC
-#define MAP_SYNC 0
-#define MAP_SHARED_VALIDATE 0
-#else
-#include <asm-generic/mman.h>
-#include <asm-generic/mman-common.h>
-#endif /* HAVE_MAP_SYNC */
-
/*
* Reminder: anything added to this file will be compiled into downstream
* userspace projects!
@@ -58,7 +58,7 @@ typedef struct mmap_region {
size_t length; /* length of mapping */
off64_t offset; /* start offset into backing file */
int prot; /* protection mode of the mapping */
- bool map_sync; /* is this a MAP_SYNC mapping? */
+ int flags; /* MAP_* flags passed to mmap() */
char *name; /* name of backing file */
} mmap_region_t;
@@ -46,8 +46,11 @@ print_mapping(
for (i = 0, p = pflags; p->prot != PROT_NONE; i++, p++)
buffer[i] = (map->prot & p->prot) ? p->mode : '-';
- if (map->map_sync)
+#ifdef HAVE_MAP_SYNC
+ if ((map->flags & (MAP_SYNC | MAP_SHARED_VALIDATE)) ==
+ (MAP_SYNC | MAP_SHARED_VALIDATE))
sprintf(&buffer[i], " S");
+#endif
printf("%c%03d%c 0x%lx - 0x%lx %s %14s (%lld : %ld)\n",
braces? '[' : ' ', index, braces? ']' : ' ',
@@ -139,7 +142,9 @@ mmap_help(void)
" -r -- map with PROT_READ protection\n"
" -w -- map with PROT_WRITE protection\n"
" -x -- map with PROT_EXEC protection\n"
+#ifdef HAVE_MAP_SYNC
" -S -- map with MAP_SYNC and MAP_SHARED_VALIDATE flags\n"
+#endif
" -s <size> -- first do mmap(size)/munmap(size), try to reserve some free space\n"
" If no protection mode is specified, all are used by default.\n"
"\n"));
@@ -193,18 +198,14 @@ mmap_f(
prot |= PROT_EXEC;
break;
case 'S':
+#ifdef HAVE_MAP_SYNC
flags = MAP_SYNC | MAP_SHARED_VALIDATE;
-
- /*
- * If MAP_SYNC and MAP_SHARED_VALIDATE aren't defined
- * in the system headers we will have defined them
- * both as 0.
- */
- if (!flags) {
- printf("MAP_SYNC not supported\n");
- return 0;
- }
break;
+#else
+ printf("MAP_SYNC not supported\n");
+ exitcode = 1;
+ return command_usage(&mmap_cmd);
+#endif
case 's':
length2 = cvtnum(blocksize, sectsize, optarg);
break;
@@ -281,7 +282,7 @@ mmap_f(
mapping->offset = offset;
mapping->name = filename;
mapping->prot = prot;
- mapping->map_sync = (flags == (MAP_SYNC | MAP_SHARED_VALIDATE));
+ mapping->flags = flags;
return 0;
}
@@ -387,8 +387,7 @@ AC_DEFUN([AC_HAVE_MAP_SYNC],
[ AC_MSG_CHECKING([for MAP_SYNC])
AC_COMPILE_IFELSE(
[ AC_LANG_PROGRAM([[
-#include <asm-generic/mman.h>
-#include <asm-generic/mman-common.h>
+#include <sys/mman.h>
]], [[
int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
]])