diff options
author | ps <ps@FreeBSD.org> | 2000-02-28 04:10:35 +0000 |
---|---|---|
committer | ps <ps@FreeBSD.org> | 2000-02-28 04:10:35 +0000 |
commit | c3800346ab46195181630945b2f40e1fee7853d0 (patch) | |
tree | c1fe153aebcc58e892bd5d2eea0b026feb20e562 /sys/vm | |
parent | 1e4770cd942238b5157e2b25cd92594590c69b9d (diff) | |
download | FreeBSD-src-c3800346ab46195181630945b2f40e1fee7853d0.zip FreeBSD-src-c3800346ab46195181630945b2f40e1fee7853d0.tar.gz |
Add MAP_NOCORE to mmap(2), and MADV_NOCORE and MADV_CORE to madvise(2).
This
This feature allows you to specify if mmap'd data is included in
an application's corefile.
Change the type of eflags in struct vm_map_entry from u_char to
vm_eflags_t (an unsigned int).
Reviewed by: dillon,jdp,alfred
Approved by: jkh
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.c | 12 | ||||
-rw-r--r-- | sys/vm/vm_map.h | 41 | ||||
-rw-r--r-- | sys/vm/vm_mmap.c | 4 |
3 files changed, 37 insertions, 20 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 7acaa51..835ed15 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -427,7 +427,7 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, vm_map_entry_t new_entry; vm_map_entry_t prev_entry; vm_map_entry_t temp_entry; - u_char protoeflags; + vm_eflags_t protoeflags; /* * Check that the start and end points are not bogus. @@ -468,6 +468,8 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, } if (cow & MAP_DISABLE_SYNCER) protoeflags |= MAP_ENTRY_NOSYNC; + if (cow & MAP_DISABLE_COREDUMP) + protoeflags |= MAP_ENTRY_NOCOREDUMP; if (object) { /* @@ -1039,6 +1041,8 @@ vm_map_madvise(map, start, end, behav) case MADV_RANDOM: case MADV_NOSYNC: case MADV_AUTOSYNC: + case MADV_NOCORE: + case MADV_CORE: modify_map = 1; vm_map_lock(map); break; @@ -1096,6 +1100,12 @@ vm_map_madvise(map, start, end, behav) case MADV_AUTOSYNC: current->eflags &= ~MAP_ENTRY_NOSYNC; break; + case MADV_NOCORE: + current->eflags |= MAP_ENTRY_NOCOREDUMP; + break; + case MADV_CORE: + current->eflags &= ~MAP_ENTRY_NOCOREDUMP; + break; default: break; } diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 43412cf..f290b2c 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -78,6 +78,8 @@ * vm_map_entry_t an entry in an address map. */ +typedef u_int vm_eflags_t; + /* * Objects which live in maps may be either VM objects, or * another map (called a "sharing map") which denotes read-write @@ -103,7 +105,7 @@ struct vm_map_entry { vm_offset_t avail_ssize; /* amt can grow if this is a stack */ union vm_map_object object; /* object I point to */ vm_ooffset_t offset; /* offset into object */ - u_char eflags; /* map entry flags */ + vm_eflags_t eflags; /* map entry flags */ /* Only in task maps: */ vm_prot_t protection; /* protection code */ vm_prot_t max_protection; /* maximum protection */ @@ -112,19 +114,21 @@ struct vm_map_entry { vm_pindex_t lastr; /* last read */ }; -#define MAP_ENTRY_NOSYNC 0x1 -#define MAP_ENTRY_IS_SUB_MAP 0x2 -#define MAP_ENTRY_COW 0x4 -#define MAP_ENTRY_NEEDS_COPY 0x8 -#define MAP_ENTRY_NOFAULT 0x10 -#define MAP_ENTRY_USER_WIRED 0x20 +#define MAP_ENTRY_NOSYNC 0x0001 +#define MAP_ENTRY_IS_SUB_MAP 0x0002 +#define MAP_ENTRY_COW 0x0004 +#define MAP_ENTRY_NEEDS_COPY 0x0008 +#define MAP_ENTRY_NOFAULT 0x0010 +#define MAP_ENTRY_USER_WIRED 0x0020 + +#define MAP_ENTRY_BEHAV_NORMAL 0x0000 /* default behavior */ +#define MAP_ENTRY_BEHAV_SEQUENTIAL 0x0040 /* expect sequential access */ +#define MAP_ENTRY_BEHAV_RANDOM 0x0080 /* expect random access */ +#define MAP_ENTRY_BEHAV_RESERVED 0x00C0 /* future use */ -#define MAP_ENTRY_BEHAV_NORMAL 0x00 /* default behavior */ -#define MAP_ENTRY_BEHAV_SEQUENTIAL 0x40 /* expect sequential access */ -#define MAP_ENTRY_BEHAV_RANDOM 0x80 /* expect random access */ -#define MAP_ENTRY_BEHAV_RESERVED 0xC0 /* future use */ +#define MAP_ENTRY_BEHAV_MASK 0x00C0 -#define MAP_ENTRY_BEHAV_MASK 0xC0 +#define MAP_ENTRY_NOCOREDUMP 0x0400 /* don't include in a core */ static __inline u_char vm_map_entry_behavior(struct vm_map_entry *entry) @@ -324,12 +328,13 @@ vmspace_resident_count(struct vmspace *vmspace) /* * Copy-on-write flags for vm_map operations */ -#define MAP_UNUSED_01 0x1 -#define MAP_COPY_ON_WRITE 0x2 -#define MAP_NOFAULT 0x4 -#define MAP_PREFAULT 0x8 -#define MAP_PREFAULT_PARTIAL 0x10 -#define MAP_DISABLE_SYNCER 0x20 +#define MAP_UNUSED_01 0x0001 +#define MAP_COPY_ON_WRITE 0x0002 +#define MAP_NOFAULT 0x0004 +#define MAP_PREFAULT 0x0008 +#define MAP_PREFAULT_PARTIAL 0x0010 +#define MAP_DISABLE_SYNCER 0x0020 +#define MAP_DISABLE_COREDUMP 0x0100 /* * vm_fault option flags diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index b42239c..53462f4 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -664,7 +664,7 @@ madvise(p, uap) /* * Check for illegal behavior */ - if (uap->behav < 0 || uap->behav > MADV_AUTOSYNC) + if (uap->behav < 0 || uap->behav > MADV_CORE) return (EINVAL); /* * Check for illegal addresses. Watch out for address wrap... Note @@ -1095,6 +1095,8 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, docow |= MAP_COPY_ON_WRITE; if (flags & MAP_NOSYNC) docow |= MAP_DISABLE_SYNCER; + if (flags & MAP_NOCORE) + docow |= MAP_DISABLE_COREDUMP; #if defined(VM_PROT_READ_IS_EXEC) if (prot & VM_PROT_READ) |