1*eda14cbcSMatt Macy /*
2*eda14cbcSMatt Macy * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3*eda14cbcSMatt Macy * All rights reserved.
4*eda14cbcSMatt Macy *
5*eda14cbcSMatt Macy * Redistribution and use in source and binary forms, with or without
6*eda14cbcSMatt Macy * modification, are permitted provided that the following conditions
7*eda14cbcSMatt Macy * are met:
8*eda14cbcSMatt Macy * 1. Redistributions of source code must retain the above copyright
9*eda14cbcSMatt Macy * notice, this list of conditions and the following disclaimer.
10*eda14cbcSMatt Macy * 2. Redistributions in binary form must reproduce the above copyright
11*eda14cbcSMatt Macy * notice, this list of conditions and the following disclaimer in the
12*eda14cbcSMatt Macy * documentation and/or other materials provided with the distribution.
13*eda14cbcSMatt Macy *
14*eda14cbcSMatt Macy * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15*eda14cbcSMatt Macy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*eda14cbcSMatt Macy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*eda14cbcSMatt Macy * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18*eda14cbcSMatt Macy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*eda14cbcSMatt Macy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*eda14cbcSMatt Macy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*eda14cbcSMatt Macy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*eda14cbcSMatt Macy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*eda14cbcSMatt Macy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*eda14cbcSMatt Macy * SUCH DAMAGE.
25*eda14cbcSMatt Macy *
26*eda14cbcSMatt Macy * $FreeBSD$
27*eda14cbcSMatt Macy */
28*eda14cbcSMatt Macy
29*eda14cbcSMatt Macy #ifndef _OPENSOLARIS_SYS_SID_H_
30*eda14cbcSMatt Macy #define _OPENSOLARIS_SYS_SID_H_
31*eda14cbcSMatt Macy #include <sys/idmap.h>
32*eda14cbcSMatt Macy
33*eda14cbcSMatt Macy typedef struct ksiddomain {
34*eda14cbcSMatt Macy char *kd_name; /* Domain part of SID */
35*eda14cbcSMatt Macy uint_t kd_len;
36*eda14cbcSMatt Macy } ksiddomain_t;
37*eda14cbcSMatt Macy typedef void ksid_t;
38*eda14cbcSMatt Macy
39*eda14cbcSMatt Macy static __inline ksiddomain_t *
ksid_lookupdomain(const char * domain)40*eda14cbcSMatt Macy ksid_lookupdomain(const char *domain)
41*eda14cbcSMatt Macy {
42*eda14cbcSMatt Macy ksiddomain_t *kd;
43*eda14cbcSMatt Macy size_t len;
44*eda14cbcSMatt Macy
45*eda14cbcSMatt Macy len = strlen(domain) + 1;
46*eda14cbcSMatt Macy kd = kmem_alloc(sizeof (*kd), KM_SLEEP);
47*eda14cbcSMatt Macy kd->kd_len = (uint_t)len;
48*eda14cbcSMatt Macy kd->kd_name = kmem_alloc(len, KM_SLEEP);
49*eda14cbcSMatt Macy strcpy(kd->kd_name, domain);
50*eda14cbcSMatt Macy return (kd);
51*eda14cbcSMatt Macy }
52*eda14cbcSMatt Macy
53*eda14cbcSMatt Macy static __inline void
ksiddomain_rele(ksiddomain_t * kd)54*eda14cbcSMatt Macy ksiddomain_rele(ksiddomain_t *kd)
55*eda14cbcSMatt Macy {
56*eda14cbcSMatt Macy
57*eda14cbcSMatt Macy kmem_free(kd->kd_name, kd->kd_len);
58*eda14cbcSMatt Macy kmem_free(kd, sizeof (*kd));
59*eda14cbcSMatt Macy }
60*eda14cbcSMatt Macy
61*eda14cbcSMatt Macy #endif /* _OPENSOLARIS_SYS_SID_H_ */
62