xref: /titanic_50/usr/src/uts/common/syscall/sysconfig.c (revision 99ebb4ca412cb0a19d77a3899a87c055b9c30fa8)
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 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved	*/
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/param.h>
33 #include <sys/types.h>
34 #include <sys/sysmacros.h>
35 #include <sys/systm.h>
36 #include <sys/tuneable.h>
37 #include <sys/errno.h>
38 #include <sys/var.h>
39 #include <sys/signal.h>
40 #include <sys/time.h>
41 #include <sys/sysconfig.h>
42 #include <sys/resource.h>
43 #include <sys/ulimit.h>
44 #include <sys/unistd.h>
45 #include <sys/debug.h>
46 #include <sys/cpuvar.h>
47 #include <sys/mman.h>
48 #include <sys/timer.h>
49 #include <sys/zone.h>
50 
51 long
52 sysconfig(int which)
53 {
54 	switch (which) {
55 
56 	/*
57 	 * if it is not handled in mach_sysconfig either
58 	 * it must be EINVAL.
59 	 */
60 	default:
61 		return (mach_sysconfig(which)); /* `uname -i`/os */
62 
63 	case _CONFIG_CLK_TCK:
64 		return ((long)hz);	/* clock frequency per second */
65 
66 	case _CONFIG_PROF_TCK:
67 		return ((long)hz);	/* profiling clock freq per sec */
68 
69 	case _CONFIG_NGROUPS:
70 		/*
71 		 * Maximum number of supplementary groups.
72 		 */
73 		return (ngroups_max);
74 
75 	case _CONFIG_OPEN_FILES:
76 		/*
77 		 * Maximum number of open files (soft limit).
78 		 */
79 		{
80 			rlim64_t fd_ctl;
81 			mutex_enter(&curproc->p_lock);
82 			fd_ctl = rctl_enforced_value(
83 			    rctlproc_legacy[RLIMIT_NOFILE], curproc->p_rctls,
84 			    curproc);
85 			mutex_exit(&curproc->p_lock);
86 			return ((ulong_t)fd_ctl);
87 		}
88 
89 	case _CONFIG_CHILD_MAX:
90 		/*
91 		 * Maximum number of processes.
92 		 */
93 		return (v.v_maxup);
94 
95 	case _CONFIG_POSIX_VER:
96 		return (_POSIX_VERSION); /* current POSIX version */
97 
98 	case _CONFIG_PAGESIZE:
99 		return (PAGESIZE);
100 
101 	case _CONFIG_XOPEN_VER:
102 		return (_XOPEN_VERSION); /* current XOPEN version */
103 
104 	case _CONFIG_NPROC_CONF:
105 		return (zone_ncpus_get(curproc->p_zone));
106 
107 	case _CONFIG_NPROC_ONLN:
108 		return (zone_ncpus_online_get(curproc->p_zone));
109 
110 	case _CONFIG_NPROC_MAX:
111 		return (max_ncpus);
112 
113 	case _CONFIG_STACK_PROT:
114 		return (curproc->p_stkprot & ~PROT_USER);
115 
116 	case _CONFIG_AIO_LISTIO_MAX:
117 		return (_AIO_LISTIO_MAX);
118 
119 	case _CONFIG_AIO_MAX:
120 		return (_AIO_MAX);
121 
122 	case _CONFIG_AIO_PRIO_DELTA_MAX:
123 		return (0);
124 
125 	case _CONFIG_DELAYTIMER_MAX:
126 		return (INT_MAX);
127 
128 	case _CONFIG_MQ_OPEN_MAX:
129 		return (_MQ_OPEN_MAX);
130 
131 	case _CONFIG_MQ_PRIO_MAX:
132 		return (_MQ_PRIO_MAX);
133 
134 	case _CONFIG_RTSIG_MAX:
135 		return (_SIGRTMAX - _SIGRTMIN + 1);
136 
137 	case _CONFIG_SEM_NSEMS_MAX:
138 		return (_SEM_NSEMS_MAX);
139 
140 	case _CONFIG_SEM_VALUE_MAX:
141 		return (_SEM_VALUE_MAX);
142 
143 	case _CONFIG_SIGQUEUE_MAX:
144 		return (_SIGQUEUE_MAX);
145 
146 	case _CONFIG_SIGRT_MIN:
147 		return (_SIGRTMIN);
148 
149 	case _CONFIG_SIGRT_MAX:
150 		return (_SIGRTMAX);
151 
152 	case _CONFIG_TIMER_MAX:
153 		return (timer_max);
154 
155 	case _CONFIG_PHYS_PAGES:
156 		return (physinstalled);
157 
158 	case _CONFIG_AVPHYS_PAGES:
159 		return (freemem);
160 
161 	case _CONFIG_MAXPID:
162 		return (maxpid);
163 
164 	case _CONFIG_CPUID_MAX:
165 		return (max_cpuid);
166 
167 	case _CONFIG_SYMLOOP_MAX:
168 		return (MAXSYMLINKS);
169 	}
170 }
171