xref: /titanic_50/usr/src/uts/common/syscall/sysconfig.c (revision 733a5356058ae0150a67d61f0ad8e5260d2acae3)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 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 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include <sys/param.h>
34 #include <sys/types.h>
35 #include <sys/sysmacros.h>
36 #include <sys/systm.h>
37 #include <sys/tuneable.h>
38 #include <sys/errno.h>
39 #include <sys/var.h>
40 #include <sys/signal.h>
41 #include <sys/time.h>
42 #include <sys/sysconfig.h>
43 #include <sys/resource.h>
44 #include <sys/ulimit.h>
45 #include <sys/unistd.h>
46 #include <sys/debug.h>
47 #include <sys/cpuvar.h>
48 #include <sys/mman.h>
49 #include <sys/timer.h>
50 #include <sys/zone.h>
51 
52 long
53 sysconfig(int which)
54 {
55 	switch (which) {
56 
57 	/*
58 	 * if it is not handled in mach_sysconfig either
59 	 * it must be EINVAL.
60 	 */
61 	default:
62 		return (mach_sysconfig(which)); /* `uname -i`/os */
63 
64 	case _CONFIG_CLK_TCK:
65 		return ((long)hz);	/* clock frequency per second */
66 
67 	case _CONFIG_PROF_TCK:
68 		return ((long)hz);	/* profiling clock freq per sec */
69 
70 	case _CONFIG_NGROUPS:
71 		/*
72 		 * Maximum number of supplementary groups.
73 		 */
74 		return (ngroups_max);
75 
76 	case _CONFIG_OPEN_FILES:
77 		/*
78 		 * Maximum number of open files (soft limit).
79 		 */
80 		{
81 			rlim64_t fd_ctl;
82 			mutex_enter(&curproc->p_lock);
83 			fd_ctl = rctl_enforced_value(
84 			    rctlproc_legacy[RLIMIT_NOFILE], curproc->p_rctls,
85 			    curproc);
86 			mutex_exit(&curproc->p_lock);
87 			return ((ulong_t)fd_ctl);
88 		}
89 
90 	case _CONFIG_CHILD_MAX:
91 		/*
92 		 * Maximum number of processes.
93 		 */
94 		return (v.v_maxup);
95 
96 	case _CONFIG_POSIX_VER:
97 		return (_POSIX_VERSION); /* current POSIX version */
98 
99 	case _CONFIG_PAGESIZE:
100 		return (PAGESIZE);
101 
102 	case _CONFIG_XOPEN_VER:
103 		return (_XOPEN_VERSION); /* current XOPEN version */
104 
105 	case _CONFIG_NPROC_CONF:
106 		return (zone_ncpus_get(curproc->p_zone));
107 
108 	case _CONFIG_NPROC_ONLN:
109 		return (zone_ncpus_online_get(curproc->p_zone));
110 
111 	case _CONFIG_NPROC_MAX:
112 		return (max_ncpus);
113 
114 	case _CONFIG_STACK_PROT:
115 		return (curproc->p_stkprot & ~PROT_USER);
116 
117 	case _CONFIG_AIO_LISTIO_MAX:
118 		return (_AIO_LISTIO_MAX);
119 
120 	case _CONFIG_AIO_MAX:
121 		return (_AIO_MAX);
122 
123 	case _CONFIG_AIO_PRIO_DELTA_MAX:
124 		return (0);
125 
126 	case _CONFIG_DELAYTIMER_MAX:
127 		return (INT_MAX);
128 
129 	case _CONFIG_MQ_OPEN_MAX:
130 		return (_MQ_OPEN_MAX);
131 
132 	case _CONFIG_MQ_PRIO_MAX:
133 		return (_MQ_PRIO_MAX);
134 
135 	case _CONFIG_RTSIG_MAX:
136 		return (_SIGRTMAX - _SIGRTMIN + 1);
137 
138 	case _CONFIG_SEM_NSEMS_MAX:
139 		return (_SEM_NSEMS_MAX);
140 
141 	case _CONFIG_SEM_VALUE_MAX:
142 		return (_SEM_VALUE_MAX);
143 
144 	case _CONFIG_SIGQUEUE_MAX:
145 		return (_SIGQUEUE_MAX);
146 
147 	case _CONFIG_SIGRT_MIN:
148 		return (_SIGRTMIN);
149 
150 	case _CONFIG_SIGRT_MAX:
151 		return (_SIGRTMAX);
152 
153 	case _CONFIG_TIMER_MAX:
154 		return (_TIMER_MAX);
155 
156 	case _CONFIG_PHYS_PAGES:
157 		return (physinstalled);
158 
159 	case _CONFIG_AVPHYS_PAGES:
160 		return (freemem);
161 
162 	case _CONFIG_MAXPID:
163 		return (maxpid);
164 
165 	case _CONFIG_CPUID_MAX:
166 		return (max_cpuid);
167 
168 	case _CONFIG_SYMLOOP_MAX:
169 		return (MAXSYMLINKS);
170 	}
171 }
172