5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2011 Joyent Inc. All rights reserved.
26 */
27
28 #include "lint.h"
29 #include "thr_uberdata.h"
30 #include <sys/types.h>
31 #include <sys/syscall.h>
32 #include <sys/zone.h>
33 #include <sys/priv.h>
34 #include <priv_private.h>
35 #include <zone.h>
36 #include <sys/tsol/label.h>
37 #include <dlfcn.h>
38 #include <stdlib.h>
39 #include <errno.h>
40
41 zoneid_t
42 zone_create(const char *name, const char *root, const struct priv_set *privs,
43 const char *rctls, size_t rctlsz, const char *zfs, size_t zfssz,
44 int *extended_error, int match, int doi, const bslabel_t *label, int flags,
45 zoneid_t req_zoneid)
46 {
47 zone_def zd;
48 priv_data_t *d;
49
50 LOADPRIVDATA(d);
51
52 zd.zone_name = name;
53 zd.zone_root = root;
54 zd.zone_privs = privs;
55 zd.zone_privssz = d->pd_setsize;
56 zd.rctlbuf = rctls;
57 zd.rctlbufsz = rctlsz;
58 zd.zfsbuf = zfs;
59 zd.zfsbufsz = zfssz;
60 zd.extended_error = extended_error;
61 zd.match = match;
62 zd.doi = doi;
63 zd.label = label;
64 zd.flags = flags;
65 zd.zoneid = req_zoneid;
66
67 return ((zoneid_t)syscall(SYS_zone, ZONE_CREATE, &zd));
68 }
69
70 int
71 zone_boot(zoneid_t zoneid)
72 {
73 return (syscall(SYS_zone, ZONE_BOOT, zoneid));
74 }
75
76 int
77 zone_shutdown(zoneid_t zoneid)
78 {
79 return (syscall(SYS_zone, ZONE_SHUTDOWN, zoneid));
80 }
81
82 int
83 zone_destroy(zoneid_t zoneid)
84 {
85 return (syscall(SYS_zone, ZONE_DESTROY, zoneid));
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include "lint.h"
28 #include "thr_uberdata.h"
29 #include <sys/types.h>
30 #include <sys/syscall.h>
31 #include <sys/zone.h>
32 #include <sys/priv.h>
33 #include <priv_private.h>
34 #include <zone.h>
35 #include <sys/tsol/label.h>
36 #include <dlfcn.h>
37 #include <stdlib.h>
38 #include <errno.h>
39
40 zoneid_t
41 zone_create(const char *name, const char *root, const struct priv_set *privs,
42 const char *rctls, size_t rctlsz, const char *zfs, size_t zfssz,
43 int *extended_error, int match, int doi, const bslabel_t *label, int flags)
44 {
45 zone_def zd;
46 priv_data_t *d;
47
48 LOADPRIVDATA(d);
49
50 zd.zone_name = name;
51 zd.zone_root = root;
52 zd.zone_privs = privs;
53 zd.zone_privssz = d->pd_setsize;
54 zd.rctlbuf = rctls;
55 zd.rctlbufsz = rctlsz;
56 zd.zfsbuf = zfs;
57 zd.zfsbufsz = zfssz;
58 zd.extended_error = extended_error;
59 zd.match = match;
60 zd.doi = doi;
61 zd.label = label;
62 zd.flags = flags;
63
64 return ((zoneid_t)syscall(SYS_zone, ZONE_CREATE, &zd));
65 }
66
67 int
68 zone_boot(zoneid_t zoneid)
69 {
70 return (syscall(SYS_zone, ZONE_BOOT, zoneid));
71 }
72
73 int
74 zone_shutdown(zoneid_t zoneid)
75 {
76 return (syscall(SYS_zone, ZONE_SHUTDOWN, zoneid));
77 }
78
79 int
80 zone_destroy(zoneid_t zoneid)
81 {
82 return (syscall(SYS_zone, ZONE_DESTROY, zoneid));
|