#ifndef _SYS_SID_H
#define _SYS_SID_H
#include <sys/types.h>
#include <sys/avl.h>
#if defined(_KERNEL) || defined(_FAKE_KERNEL)
#include <sys/zone.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define SIDSYS_ALLOC_IDS 0
#define SID_EXTEND_RANGE 0
#define SID_NEW_RANGE 1
#define SIDSYS_IDMAP_REG 1
#define SIDSYS_IDMAP_UNREG 2
#define SIDSYS_IDMAP_FLUSH_KCACHE 3
#define SIDSYS_SID2ID 0
#define SIDSYS_ID2SID 1
#if defined(_KERNEL) || defined(_FAKE_KERNEL)
#define KSIDLIST_MEM(n) (sizeof (ksidlist_t) + ((n) - 1) * sizeof (ksid_t))
typedef struct ksiddomain {
uint_t kd_ref;
uint_t kd_len;
char *kd_name;
avl_node_t kd_link;
} ksiddomain_t;
typedef struct ksid {
uid_t ks_id;
uint32_t ks_rid;
uint32_t ks_attr;
ksiddomain_t *ks_domain;
} ksid_t;
typedef enum ksid_index {
KSID_USER,
KSID_GROUP,
KSID_OWNER,
KSID_COUNT
} ksid_index_t;
typedef struct ksidlist {
uint_t ksl_ref;
uint_t ksl_nsid;
uint_t ksl_neid;
ksid_t **ksl_sorted;
ksid_t ksl_sids[1];
} ksidlist_t;
typedef struct credsid {
uint_t kr_ref;
ksid_t kr_sidx[KSID_COUNT];
ksidlist_t *kr_sidlist;
} credsid_t;
const char *ksid_getdomain(ksid_t *);
uint_t ksid_getrid(ksid_t *);
uid_t ksid_getid(ksid_t *);
int ksid_lookupbyuid(zone_t *, uid_t, ksid_t *);
int ksid_lookupbygid(zone_t *, gid_t, ksid_t *);
void ksid_rele(ksid_t *);
credsid_t *kcrsid_alloc(void);
credsid_t *kcrsid_setsid(credsid_t *, ksid_t *, ksid_index_t);
credsid_t *kcrsid_setsidlist(credsid_t *, ksidlist_t *);
void kcrsid_rele(credsid_t *);
void kcrsid_hold(credsid_t *);
void kcrsidcopy_to(const credsid_t *okcr, credsid_t *nkcr);
void ksiddomain_rele(ksiddomain_t *);
void ksiddomain_hold(ksiddomain_t *);
void ksidlist_rele(ksidlist_t *);
void ksidlist_hold(ksidlist_t *);
boolean_t ksidlist_has_sid(ksidlist_t *, const char *, uint32_t);
boolean_t ksidlist_has_pid(ksidlist_t *, uint32_t);
ksiddomain_t *ksid_lookupdomain(const char *);
ksidlist_t *kcrsid_gidstosids(zone_t *, int, gid_t *);
#else
int allocids(int, int, uid_t *, int, gid_t *);
int __idmap_reg(int);
int __idmap_unreg(int);
int __idmap_flush_kcache(void);
#endif
#ifdef __cplusplus
}
#endif
#endif