1*eda14cbcSMatt Macy /*
2*eda14cbcSMatt Macy * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3*eda14cbcSMatt Macy * Copyright (C) 2007 The Regents of the University of California.
4*eda14cbcSMatt Macy * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5*eda14cbcSMatt Macy * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6*eda14cbcSMatt Macy * UCRL-CODE-235197
7*eda14cbcSMatt Macy *
8*eda14cbcSMatt Macy * This file is part of the SPL, Solaris Porting Layer.
9*eda14cbcSMatt Macy *
10*eda14cbcSMatt Macy * The SPL is free software; you can redistribute it and/or modify it
11*eda14cbcSMatt Macy * under the terms of the GNU General Public License as published by the
12*eda14cbcSMatt Macy * Free Software Foundation; either version 2 of the License, or (at your
13*eda14cbcSMatt Macy * option) any later version.
14*eda14cbcSMatt Macy *
15*eda14cbcSMatt Macy * The SPL is distributed in the hope that it will be useful, but WITHOUT
16*eda14cbcSMatt Macy * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17*eda14cbcSMatt Macy * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18*eda14cbcSMatt Macy * for more details.
19*eda14cbcSMatt Macy *
20*eda14cbcSMatt Macy * You should have received a copy of the GNU General Public License along
21*eda14cbcSMatt Macy * with the SPL. If not, see <http://www.gnu.org/licenses/>.
22*eda14cbcSMatt Macy */
23*eda14cbcSMatt Macy
24*eda14cbcSMatt Macy #ifndef _SPL_SID_H
25*eda14cbcSMatt Macy #define _SPL_SID_H
26*eda14cbcSMatt Macy
27*eda14cbcSMatt Macy typedef struct ksiddomain {
28*eda14cbcSMatt Macy char *kd_name;
29*eda14cbcSMatt Macy } ksiddomain_t;
30*eda14cbcSMatt Macy
31*eda14cbcSMatt Macy typedef enum ksid_index {
32*eda14cbcSMatt Macy KSID_USER,
33*eda14cbcSMatt Macy KSID_GROUP,
34*eda14cbcSMatt Macy KSID_OWNER,
35*eda14cbcSMatt Macy KSID_COUNT
36*eda14cbcSMatt Macy } ksid_index_t;
37*eda14cbcSMatt Macy
38*eda14cbcSMatt Macy typedef int ksid_t;
39*eda14cbcSMatt Macy
40*eda14cbcSMatt Macy static inline ksiddomain_t *
ksid_lookupdomain(const char * dom)41*eda14cbcSMatt Macy ksid_lookupdomain(const char *dom)
42*eda14cbcSMatt Macy {
43*eda14cbcSMatt Macy ksiddomain_t *kd;
44*eda14cbcSMatt Macy int len = strlen(dom);
45*eda14cbcSMatt Macy
46*eda14cbcSMatt Macy kd = kmem_zalloc(sizeof (ksiddomain_t), KM_SLEEP);
47*eda14cbcSMatt Macy kd->kd_name = kmem_zalloc(len + 1, KM_SLEEP);
48*eda14cbcSMatt Macy memcpy(kd->kd_name, dom, len);
49*eda14cbcSMatt Macy
50*eda14cbcSMatt Macy return (kd);
51*eda14cbcSMatt Macy }
52*eda14cbcSMatt Macy
53*eda14cbcSMatt Macy static inline void
ksiddomain_rele(ksiddomain_t * ksid)54*eda14cbcSMatt Macy ksiddomain_rele(ksiddomain_t *ksid)
55*eda14cbcSMatt Macy {
56*eda14cbcSMatt Macy kmem_free(ksid->kd_name, strlen(ksid->kd_name) + 1);
57*eda14cbcSMatt Macy kmem_free(ksid, sizeof (ksiddomain_t));
58*eda14cbcSMatt Macy }
59*eda14cbcSMatt Macy
60*eda14cbcSMatt Macy #endif /* _SPL_SID_H */
61