xref: /onnv-gate/usr/src/uts/common/sys/corectl.h (revision 7482:3754c100a656)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7482SEdward.Pilatowicz@Sun.COM  * Common Development and Distribution License (the "License").
6*7482SEdward.Pilatowicz@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*7482SEdward.Pilatowicz@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_CORECTL_H
270Sstevel@tonic-gate #define	_SYS_CORECTL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/zone.h>
310Sstevel@tonic-gate #include <sys/refstr.h>
320Sstevel@tonic-gate #include <sys/mutex.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * Definitions for corectl() system call.
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /* subcodes */
430Sstevel@tonic-gate #define	CC_SET_OPTIONS		1
440Sstevel@tonic-gate #define	CC_GET_OPTIONS		2
450Sstevel@tonic-gate #define	CC_SET_GLOBAL_PATH	3
460Sstevel@tonic-gate #define	CC_GET_GLOBAL_PATH	4
470Sstevel@tonic-gate #define	CC_SET_PROCESS_PATH	5
480Sstevel@tonic-gate #define	CC_GET_PROCESS_PATH	6
490Sstevel@tonic-gate #define	CC_SET_GLOBAL_CONTENT	7
500Sstevel@tonic-gate #define	CC_GET_GLOBAL_CONTENT	8
510Sstevel@tonic-gate #define	CC_SET_PROCESS_CONTENT	9
520Sstevel@tonic-gate #define	CC_GET_PROCESS_CONTENT	10
530Sstevel@tonic-gate #define	CC_SET_DEFAULT_PATH	11
540Sstevel@tonic-gate #define	CC_GET_DEFAULT_PATH	12
550Sstevel@tonic-gate #define	CC_SET_DEFAULT_CONTENT	13
560Sstevel@tonic-gate #define	CC_GET_DEFAULT_CONTENT	14
570Sstevel@tonic-gate 
580Sstevel@tonic-gate /* options */
590Sstevel@tonic-gate #define	CC_GLOBAL_PATH		0x01	/* enable global core files */
600Sstevel@tonic-gate #define	CC_PROCESS_PATH		0x02	/* enable per-process core files */
610Sstevel@tonic-gate #define	CC_GLOBAL_SETID		0x04	/* allow global setid core files */
620Sstevel@tonic-gate #define	CC_PROCESS_SETID	0x08	/* allow per-process setid core files */
630Sstevel@tonic-gate #define	CC_GLOBAL_LOG		0x10	/* log global core dumps to syslog */
640Sstevel@tonic-gate 
650Sstevel@tonic-gate /* all of the above */
660Sstevel@tonic-gate #define	CC_OPTIONS	\
670Sstevel@tonic-gate 	(CC_GLOBAL_PATH | CC_PROCESS_PATH | \
680Sstevel@tonic-gate 	CC_GLOBAL_SETID | CC_PROCESS_SETID | CC_GLOBAL_LOG)
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /* contents */
710Sstevel@tonic-gate #define	CC_CONTENT_STACK	0x0001ULL /* process stack */
720Sstevel@tonic-gate #define	CC_CONTENT_HEAP		0x0002ULL /* process heap */
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /* MAP_SHARED file mappings */
750Sstevel@tonic-gate #define	CC_CONTENT_SHFILE	0x0004ULL /* file-backed shared mapping */
760Sstevel@tonic-gate #define	CC_CONTENT_SHANON	0x0008ULL /* anonymous shared mapping */
770Sstevel@tonic-gate 
780Sstevel@tonic-gate /* MAP_PRIVATE file mappings */
790Sstevel@tonic-gate #define	CC_CONTENT_TEXT		0x0010ULL /* read/exec file mappings */
800Sstevel@tonic-gate #define	CC_CONTENT_DATA		0x0020ULL /* writable file mappings */
810Sstevel@tonic-gate #define	CC_CONTENT_RODATA	0x0040ULL /* read-only file mappings */
820Sstevel@tonic-gate #define	CC_CONTENT_ANON		0x0080ULL /* anonymous mappings (MAP_ANON) */
830Sstevel@tonic-gate 
840Sstevel@tonic-gate #define	CC_CONTENT_SHM		0x0100ULL /* System V shared memory */
850Sstevel@tonic-gate #define	CC_CONTENT_ISM		0x0200ULL /* intimate shared memory */
860Sstevel@tonic-gate #define	CC_CONTENT_DISM		0x0400ULL /* dynamic intimate shared memory */
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #define	CC_CONTENT_CTF		0x0800ULL /* CTF data */
890Sstevel@tonic-gate #define	CC_CONTENT_SYMTAB	0x1000ULL /* symbol table */
900Sstevel@tonic-gate 
910Sstevel@tonic-gate #define	CC_CONTENT_ALL		0x1fffULL
920Sstevel@tonic-gate #define	CC_CONTENT_NONE		0ULL
930Sstevel@tonic-gate #define	CC_CONTENT_DEFAULT	(CC_CONTENT_STACK | CC_CONTENT_HEAP | \
940Sstevel@tonic-gate 	CC_CONTENT_ISM | CC_CONTENT_DISM | CC_CONTENT_SHM | \
950Sstevel@tonic-gate 	CC_CONTENT_SHANON | CC_CONTENT_TEXT | CC_CONTENT_DATA | \
96*7482SEdward.Pilatowicz@Sun.COM 	CC_CONTENT_RODATA | CC_CONTENT_ANON | CC_CONTENT_CTF | \
97*7482SEdward.Pilatowicz@Sun.COM 	CC_CONTENT_SYMTAB)
980Sstevel@tonic-gate #define	CC_CONTENT_INVALID	(-1ULL)
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate typedef u_longlong_t	core_content_t;
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate typedef struct corectl_content {
1030Sstevel@tonic-gate 	core_content_t	ccc_content;
1040Sstevel@tonic-gate 	kmutex_t	ccc_mtx;
1050Sstevel@tonic-gate 	uint32_t	ccc_refcnt;
1060Sstevel@tonic-gate } corectl_content_t;
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate typedef struct corectl_path {
1090Sstevel@tonic-gate 	refstr_t	*ccp_path;
1100Sstevel@tonic-gate 	kmutex_t	ccp_mtx;
1110Sstevel@tonic-gate 	uint32_t	ccp_refcnt;
1120Sstevel@tonic-gate } corectl_path_t;
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate #ifdef _KERNEL
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate struct core_globals {
1170Sstevel@tonic-gate 	kmutex_t		core_lock;
1180Sstevel@tonic-gate 	refstr_t		*core_file;
1190Sstevel@tonic-gate 	uint32_t		core_options;
1200Sstevel@tonic-gate 	core_content_t		core_content;
1210Sstevel@tonic-gate 	rlim64_t		core_rlimit;
1220Sstevel@tonic-gate 	corectl_path_t		*core_default_path;
1230Sstevel@tonic-gate 	corectl_content_t	*core_default_content;
1240Sstevel@tonic-gate };
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate extern	zone_key_t	core_zone_key;
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate extern void init_core(void);
1290Sstevel@tonic-gate extern void set_core_defaults(void);
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate extern core_content_t corectl_content_value(corectl_content_t *);
1320Sstevel@tonic-gate extern void corectl_content_hold(corectl_content_t *);
1330Sstevel@tonic-gate extern void corectl_content_rele(corectl_content_t *);
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate extern refstr_t *corectl_path_value(corectl_path_t *);
1360Sstevel@tonic-gate extern void corectl_path_hold(corectl_path_t *);
1370Sstevel@tonic-gate extern void corectl_path_rele(corectl_path_t *);
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate #else	/* _KERNEL */
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate extern	int	core_set_options(int);
1420Sstevel@tonic-gate extern	int	core_get_options(void);
1430Sstevel@tonic-gate extern	int	core_set_global_path(const char *, size_t);
1440Sstevel@tonic-gate extern	int	core_get_global_path(char *, size_t);
1450Sstevel@tonic-gate extern	int	core_set_default_path(const char *, size_t);
1460Sstevel@tonic-gate extern	int	core_get_default_path(char *, size_t);
1470Sstevel@tonic-gate extern	int	core_set_process_path(const char *, size_t, pid_t);
1480Sstevel@tonic-gate extern	int	core_get_process_path(char *, size_t, pid_t);
1490Sstevel@tonic-gate extern	int	core_set_global_content(const core_content_t *);
1500Sstevel@tonic-gate extern	int	core_get_global_content(core_content_t *);
1510Sstevel@tonic-gate extern	int	core_set_default_content(const core_content_t *);
1520Sstevel@tonic-gate extern	int	core_get_default_content(core_content_t *);
1530Sstevel@tonic-gate extern	int	core_set_process_content(const core_content_t *, pid_t);
1540Sstevel@tonic-gate extern	int	core_get_process_content(core_content_t *, pid_t);
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate #endif	/* _KERNEL */
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate #ifdef	__cplusplus
1590Sstevel@tonic-gate }
1600Sstevel@tonic-gate #endif
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #endif	/* _SYS_CORECTL_H */
163