1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
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  * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
24  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 #include <sys/types.h>
28 #include <sys/cmn_err.h>
29 #include <sys/cred.h>
30 #include <sys/kmem.h>
31 #include <sys/systm.h>
32 #include <sys/sysmacros.h>
33 
34 volatile int ncsize = 500;	/* dnlc.h */
35 
36 static major_t devcnt = 0x280;
37 static kmutex_t udevlock;
38 
39 /* os/subr.c */
40 major_t
getudev()41 getudev()
42 {
43 	static major_t next = 0;
44 	major_t ret;
45 
46 	mutex_enter(&udevlock);
47 	if (next == 0)
48 		next = devcnt;
49 	if (next <= L_MAXMAJ32 && next >= devcnt)
50 		ret = next++;
51 	else {
52 		cmn_err(CE_WARN, "out of major numbers");
53 		ret = ((major_t)-1);
54 	}
55 	mutex_exit(&udevlock);
56 	return (ret);
57 }
58 
59 /*
60  * Compress 'long' device number encoding to 32-bit device number
61  * encoding.  If it won't fit, we return failure, but set the
62  * device number to 32-bit NODEV for the sake of our callers.
63  */
64 int
cmpldev(dev32_t * dst,dev_t dev)65 cmpldev(dev32_t *dst, dev_t dev)
66 {
67 #if defined(_LP64)
68 	if (dev == NODEV) {
69 		*dst = (dev32_t)(-1);
70 	} else {
71 		major_t major = dev >> L_BITSMINOR;
72 		minor_t minor = dev & L_MAXMIN;
73 
74 		if (major > L_MAXMAJ32 || minor > L_MAXMIN32) {
75 			*dst = (dev32_t)(-1);
76 			return (0);
77 		}
78 
79 		*dst = (dev32_t)((major << L_BITSMINOR32) | minor);
80 	}
81 #else
82 	*dst = (dev32_t)dev;
83 #endif
84 	return (1);
85 }
86 
87 /* os/cred.c */
88 int
groupmember(gid_t gid,const cred_t * cr)89 groupmember(gid_t gid, const cred_t *cr)
90 {
91 	if (gid == 0 || gid == 1)
92 		return (1);
93 	return (0);
94 }
95 
96 /* os/sig.c */
97 
98 /* ARGSUSED */
99 void
sigintr(k_sigset_t * smask,int intable)100 sigintr(k_sigset_t *smask, int intable)
101 {
102 }
103 
104 /* ARGSUSED */
105 void
sigunintr(k_sigset_t * smask)106 sigunintr(k_sigset_t *smask)
107 {
108 }
109