1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_CORECTL_H 27 #define _SYS_CORECTL_H 28 29 #include <sys/types.h> 30 #include <sys/zone.h> 31 #include <sys/refstr.h> 32 #include <sys/mutex.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /* 39 * Definitions for corectl() system call. 40 */ 41 42 /* subcodes */ 43 #define CC_SET_OPTIONS 1 44 #define CC_GET_OPTIONS 2 45 #define CC_SET_GLOBAL_PATH 3 46 #define CC_GET_GLOBAL_PATH 4 47 #define CC_SET_PROCESS_PATH 5 48 #define CC_GET_PROCESS_PATH 6 49 #define CC_SET_GLOBAL_CONTENT 7 50 #define CC_GET_GLOBAL_CONTENT 8 51 #define CC_SET_PROCESS_CONTENT 9 52 #define CC_GET_PROCESS_CONTENT 10 53 #define CC_SET_DEFAULT_PATH 11 54 #define CC_GET_DEFAULT_PATH 12 55 #define CC_SET_DEFAULT_CONTENT 13 56 #define CC_GET_DEFAULT_CONTENT 14 57 58 /* options */ 59 #define CC_GLOBAL_PATH 0x01 /* enable global core files */ 60 #define CC_PROCESS_PATH 0x02 /* enable per-process core files */ 61 #define CC_GLOBAL_SETID 0x04 /* allow global setid core files */ 62 #define CC_PROCESS_SETID 0x08 /* allow per-process setid core files */ 63 #define CC_GLOBAL_LOG 0x10 /* log global core dumps to syslog */ 64 65 /* all of the above */ 66 #define CC_OPTIONS \ 67 (CC_GLOBAL_PATH | CC_PROCESS_PATH | \ 68 CC_GLOBAL_SETID | CC_PROCESS_SETID | CC_GLOBAL_LOG) 69 70 /* contents */ 71 #define CC_CONTENT_STACK 0x0001ULL /* process stack */ 72 #define CC_CONTENT_HEAP 0x0002ULL /* process heap */ 73 74 /* MAP_SHARED file mappings */ 75 #define CC_CONTENT_SHFILE 0x0004ULL /* file-backed shared mapping */ 76 #define CC_CONTENT_SHANON 0x0008ULL /* anonymous shared mapping */ 77 78 /* MAP_PRIVATE file mappings */ 79 #define CC_CONTENT_TEXT 0x0010ULL /* read/exec file mappings */ 80 #define CC_CONTENT_DATA 0x0020ULL /* writable file mappings */ 81 #define CC_CONTENT_RODATA 0x0040ULL /* read-only file mappings */ 82 #define CC_CONTENT_ANON 0x0080ULL /* anonymous mappings (MAP_ANON) */ 83 84 #define CC_CONTENT_SHM 0x0100ULL /* System V shared memory */ 85 #define CC_CONTENT_ISM 0x0200ULL /* intimate shared memory */ 86 #define CC_CONTENT_DISM 0x0400ULL /* dynamic intimate shared memory */ 87 88 #define CC_CONTENT_CTF 0x0800ULL /* CTF data */ 89 #define CC_CONTENT_SYMTAB 0x1000ULL /* symbol table */ 90 #define CC_CONTENT_DEBUG 0x2000ULL /* debug information */ 91 92 #define CC_CONTENT_ALL 0x3fffULL 93 #define CC_CONTENT_NONE 0ULL 94 #define CC_CONTENT_DEFAULT (CC_CONTENT_STACK | CC_CONTENT_HEAP | \ 95 CC_CONTENT_ISM | CC_CONTENT_DISM | CC_CONTENT_SHM | \ 96 CC_CONTENT_SHANON | CC_CONTENT_TEXT | CC_CONTENT_DATA | \ 97 CC_CONTENT_RODATA | CC_CONTENT_ANON | CC_CONTENT_CTF | \ 98 CC_CONTENT_SYMTAB) 99 #define CC_CONTENT_INVALID (-1ULL) 100 101 typedef u_longlong_t core_content_t; 102 103 typedef struct corectl_content { 104 core_content_t ccc_content; 105 kmutex_t ccc_mtx; 106 uint32_t ccc_refcnt; 107 } corectl_content_t; 108 109 typedef struct corectl_path { 110 refstr_t *ccp_path; 111 kmutex_t ccp_mtx; 112 uint32_t ccp_refcnt; 113 } corectl_path_t; 114 115 #ifdef _KERNEL 116 117 struct core_globals { 118 kmutex_t core_lock; 119 refstr_t *core_file; 120 uint32_t core_options; 121 core_content_t core_content; 122 rlim64_t core_rlimit; 123 corectl_path_t *core_default_path; 124 corectl_content_t *core_default_content; 125 }; 126 127 extern zone_key_t core_zone_key; 128 129 extern void init_core(void); 130 extern void set_core_defaults(void); 131 132 extern core_content_t corectl_content_value(corectl_content_t *); 133 extern void corectl_content_hold(corectl_content_t *); 134 extern void corectl_content_rele(corectl_content_t *); 135 136 extern refstr_t *corectl_path_value(corectl_path_t *); 137 extern void corectl_path_hold(corectl_path_t *); 138 extern void corectl_path_rele(corectl_path_t *); 139 140 #else /* _KERNEL */ 141 142 extern int core_set_options(int); 143 extern int core_get_options(void); 144 extern int core_set_global_path(const char *, size_t); 145 extern int core_get_global_path(char *, size_t); 146 extern int core_set_default_path(const char *, size_t); 147 extern int core_get_default_path(char *, size_t); 148 extern int core_set_process_path(const char *, size_t, pid_t); 149 extern int core_get_process_path(char *, size_t, pid_t); 150 extern int core_set_global_content(const core_content_t *); 151 extern int core_get_global_content(core_content_t *); 152 extern int core_set_default_content(const core_content_t *); 153 extern int core_get_default_content(core_content_t *); 154 extern int core_set_process_content(const core_content_t *, pid_t); 155 extern int core_get_process_content(core_content_t *, pid_t); 156 157 #endif /* _KERNEL */ 158 159 #ifdef __cplusplus 160 } 161 #endif 162 163 #endif /* _SYS_CORECTL_H */ 164