2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2015, Joyent, Inc.
17 * Verify that using MC_INHERIT_ZERO works just fine when applied to a subset of
18 * a region, meaning that we should have created a struct vpage for that region.
19 * Then unmap a hole in the middle, so that way we force subsets of children
20 * that have struct vpage entries.
23 #include <sys/types.h>
40 size_t pgsz
= sysconf(_SC_PAGESIZE
);
41 size_t mapsz
= 10 * pgsz
;
42 size_t clrsz
= 5 * pgsz
;
43 size_t clroff
= 2 * pgsz
;
44 size_t spltsz
= 1 * pgsz
;
45 size_t spltoff
= 3 * pgsz
;
47 buf
= mmap(NULL
, mapsz
, PROT_READ
| PROT_WRITE
,
48 MAP_PRIVATE
| MAP_ANON
, -1, 0);
49 assert(buf
!= MAP_FAILED
);
50 memset(buf
, 'a', mapsz
);
52 ret
= memcntl(buf
+ clroff
, clrsz
, MC_INHERIT_ZERO
, 0, 0, 0);
55 ret
= munmap(buf
+ spltoff
, spltsz
);
61 for (i
= 0; i
< clroff
; i
++)
62 assert(ubuf
[i
] == 'a');
63 for (i
= clroff
; i
< spltoff
; i
++)
65 for (i
= spltoff
+ spltsz
; i
< clroff
+ clrsz
; i
++)
67 for (i
= clrsz
+ clroff
; i
< mapsz
; i
++)
68 assert(ubuf
[i
] == 'a');
74 ret
= waitid(P_PID
, child
, &info
, WEXITED
);
75 } while (ret
== -1 && errno
== EINTR
);
77 assert(info
.si_pid
== child
);
78 assert(info
.si_status
== 0);
81 for (i
= 0; i
< clroff
; i
++)
82 assert(ubuf
[i
] == 'a');
83 for (i
= clroff
; i
< spltoff
; i
++)
84 assert(ubuf
[i
] == 'a');
85 for (i
= spltoff
+ spltsz
; i
< clroff
+ clrsz
; i
++)
86 assert(ubuf
[i
] == 'a');
87 for (i
= clrsz
+ clroff
; i
< mapsz
; i
++)
88 assert(ubuf
[i
] == 'a');