#ifndef _SYS_CORECTL_H
#define _SYS_CORECTL_H
#include <sys/types.h>
#include <sys/zone.h>
#include <sys/refstr.h>
#include <sys/mutex.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CC_SET_OPTIONS 1
#define CC_GET_OPTIONS 2
#define CC_SET_GLOBAL_PATH 3
#define CC_GET_GLOBAL_PATH 4
#define CC_SET_PROCESS_PATH 5
#define CC_GET_PROCESS_PATH 6
#define CC_SET_GLOBAL_CONTENT 7
#define CC_GET_GLOBAL_CONTENT 8
#define CC_SET_PROCESS_CONTENT 9
#define CC_GET_PROCESS_CONTENT 10
#define CC_SET_DEFAULT_PATH 11
#define CC_GET_DEFAULT_PATH 12
#define CC_SET_DEFAULT_CONTENT 13
#define CC_GET_DEFAULT_CONTENT 14
#define CC_GLOBAL_PATH 0x01
#define CC_PROCESS_PATH 0x02
#define CC_GLOBAL_SETID 0x04
#define CC_PROCESS_SETID 0x08
#define CC_GLOBAL_LOG 0x10
#define CC_OPTIONS \
(CC_GLOBAL_PATH | CC_PROCESS_PATH | \
CC_GLOBAL_SETID | CC_PROCESS_SETID | CC_GLOBAL_LOG)
#define CC_CONTENT_STACK 0x0001ULL
#define CC_CONTENT_HEAP 0x0002ULL
#define CC_CONTENT_SHFILE 0x0004ULL
#define CC_CONTENT_SHANON 0x0008ULL
#define CC_CONTENT_TEXT 0x0010ULL
#define CC_CONTENT_DATA 0x0020ULL
#define CC_CONTENT_RODATA 0x0040ULL
#define CC_CONTENT_ANON 0x0080ULL
#define CC_CONTENT_SHM 0x0100ULL
#define CC_CONTENT_ISM 0x0200ULL
#define CC_CONTENT_DISM 0x0400ULL
#define CC_CONTENT_CTF 0x0800ULL
#define CC_CONTENT_SYMTAB 0x1000ULL
#define CC_CONTENT_DEBUG 0x2000ULL
#define CC_CONTENT_ALL 0x3fffULL
#define CC_CONTENT_NONE 0ULL
#define CC_CONTENT_DEFAULT (CC_CONTENT_STACK | CC_CONTENT_HEAP | \
CC_CONTENT_ISM | CC_CONTENT_DISM | CC_CONTENT_SHM | \
CC_CONTENT_SHANON | CC_CONTENT_TEXT | CC_CONTENT_DATA | \
CC_CONTENT_RODATA | CC_CONTENT_ANON | CC_CONTENT_CTF | \
CC_CONTENT_SYMTAB)
#define CC_CONTENT_INVALID (-1ULL)
typedef u_longlong_t core_content_t;
typedef struct corectl_content {
core_content_t ccc_content;
kmutex_t ccc_mtx;
uint32_t ccc_refcnt;
} corectl_content_t;
typedef struct corectl_path {
refstr_t *ccp_path;
kmutex_t ccp_mtx;
uint32_t ccp_refcnt;
} corectl_path_t;
#ifdef _KERNEL
struct core_globals {
kmutex_t core_lock;
refstr_t *core_file;
uint32_t core_options;
core_content_t core_content;
rlim64_t core_rlimit;
corectl_path_t *core_default_path;
corectl_content_t *core_default_content;
};
extern zone_key_t core_zone_key;
extern void init_core(void);
extern void set_core_defaults(void);
extern core_content_t corectl_content_value(corectl_content_t *);
extern void corectl_content_hold(corectl_content_t *);
extern void corectl_content_rele(corectl_content_t *);
extern refstr_t *corectl_path_value(corectl_path_t *);
extern void corectl_path_hold(corectl_path_t *);
extern void corectl_path_rele(corectl_path_t *);
#else
extern int core_set_options(int);
extern int core_get_options(void);
extern int core_set_global_path(const char *, size_t);
extern int core_get_global_path(char *, size_t);
extern int core_set_default_path(const char *, size_t);
extern int core_get_default_path(char *, size_t);
extern int core_set_process_path(const char *, size_t, pid_t);
extern int core_get_process_path(char *, size_t, pid_t);
extern int core_set_global_content(const core_content_t *);
extern int core_get_global_content(core_content_t *);
extern int core_set_default_content(const core_content_t *);
extern int core_get_default_content(core_content_t *);
extern int core_set_process_content(const core_content_t *, pid_t);
extern int core_get_process_content(core_content_t *, pid_t);
#endif
#ifdef __cplusplus
}
#endif
#endif