Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libc/port/gen/sysconf.c
+++ new/usr/src/lib/libc/port/gen/sysconf.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 + * Copyright (c) 2013 Gary Mills
24 + *
23 25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 26 * Use is subject to license terms.
25 27 */
26 28
27 29 /* Copyright (c) 1988 AT&T */
28 30 /* All Rights Reserved */
29 31
30 32 /* sysconf(3C) - returns system configuration information */
31 33
32 34 #pragma weak _sysconf = sysconf
33 35
34 36 #include "lint.h"
35 37 #include <mtlib.h>
36 38 #include <sys/types.h>
37 39 #include <unistd.h>
38 40 #include <sys/sysconfig.h>
39 41 #include <limits.h>
40 42 #include <time.h>
41 43 #include <errno.h>
42 44 #include <nss_dbdefs.h>
43 45 #include <thread.h>
44 46 #include <xti.h>
45 47 #include "libc.h"
46 48 #include "xpg6.h"
47 49
48 50 /* from nss_common.c */
49 51 extern size_t _nss_get_bufsizes(int);
50 52
51 53 long
52 54 sysconf(int name)
53 55 {
54 56 static int _pagesize = 0;
55 57 static int _hz = 0;
56 58 static pid_t _maxpid = 0;
57 59 static int _stackprot = 0;
58 60 static int _ngroups_max;
59 61 extern int __xpg4;
60 62
61 63 switch (name) {
62 64 default:
63 65 errno = EINVAL;
64 66 return (-1L);
65 67
66 68 case _SC_ARG_MAX:
67 69 return ((long)ARG_MAX);
68 70
69 71 case _SC_CLK_TCK:
70 72 if (_hz <= 0)
71 73 _hz = _sysconfig(_CONFIG_CLK_TCK);
72 74 return (_hz);
73 75
74 76 case _SC_JOB_CONTROL:
75 77 return ((long)_POSIX_JOB_CONTROL);
76 78
77 79 case _SC_SAVED_IDS:
78 80 return ((long)_POSIX_SAVED_IDS);
79 81
80 82 case _SC_CHILD_MAX:
81 83 return (_sysconfig(_CONFIG_CHILD_MAX));
82 84
83 85 case _SC_NGROUPS_MAX:
84 86 if (_ngroups_max <= 0)
85 87 _ngroups_max = _sysconfig(_CONFIG_NGROUPS);
86 88 return (_ngroups_max);
87 89
88 90 case _SC_OPEN_MAX:
89 91 return (_sysconfig(_CONFIG_OPEN_FILES));
90 92
91 93 case _SC_VERSION:
92 94 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
93 95 return (200112L);
94 96 else
95 97 return (199506L);
96 98
97 99 case _SC_PAGESIZE:
98 100 if (_pagesize <= 0)
99 101 _pagesize = _sysconfig(_CONFIG_PAGESIZE);
100 102 return (_pagesize);
101 103
102 104 case _SC_XOPEN_VERSION:
103 105 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
104 106 return (600L);
105 107 else if (__xpg4 == 0)
106 108 return (_sysconfig(_CONFIG_XOPEN_VER));
107 109 else
108 110 return (4L);
109 111
110 112 case _SC_XOPEN_XCU_VERSION:
111 113 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
112 114 return (600L);
113 115 else
114 116 return (4L);
115 117
116 118 /*
117 119 * old value for pre XPG5 conformant systems to match
118 120 * getpass() length.
119 121 * XPG5 special cased with __sysconf_xpg5()
120 122 * new value for default and modern XPG systems.
121 123 */
122 124 case _SC_PASS_MAX:
123 125 if ((__xpg4 == 1) &&
124 126 (!(__xpg6 & _C99SUSv3_XPG6_sysconf_version)))
125 127 return ((long)_PASS_MAX_XPG);
126 128 else
127 129 return ((long)_PASS_MAX);
128 130
129 131 case _SC_LOGNAME_MAX:
130 132 return ((long)LOGNAME_MAX);
131 133
132 134 case _SC_STREAM_MAX:
133 135 return (_sysconfig(_CONFIG_OPEN_FILES));
134 136
135 137 case _SC_TZNAME_MAX:
136 138 return (-1L);
137 139
138 140 case _SC_NPROCESSORS_CONF:
139 141 return (_sysconfig(_CONFIG_NPROC_CONF));
140 142
141 143 case _SC_NPROCESSORS_ONLN:
142 144 return (_sysconfig(_CONFIG_NPROC_ONLN));
143 145
144 146 case _SC_NPROCESSORS_MAX:
145 147 return (_sysconfig(_CONFIG_NPROC_MAX));
146 148
147 149 case _SC_STACK_PROT:
148 150 if (_stackprot == 0)
149 151 _stackprot = _sysconfig(_CONFIG_STACK_PROT);
150 152 return (_stackprot);
151 153
152 154 /* POSIX.4 names */
153 155
154 156 /*
155 157 * Each of the following also have _POSIX_* symbols
156 158 * defined in <unistd.h>. Values here should align
157 159 * with values in the header. Up until the SUSv3 standard
158 160 * we defined these simply as 1. With the introduction
159 161 * of the new revision, these were changed to 200112L.
160 162 * The standard allows us to change the value, however,
161 163 * we have kept both values in case application programs
162 164 * are relying on the previous value even though an
163 165 * application doing so is technically wrong.
164 166 */
165 167 case _SC_ASYNCHRONOUS_IO:
166 168 case _SC_FSYNC:
167 169 case _SC_MAPPED_FILES:
168 170 case _SC_MEMLOCK:
169 171 case _SC_MEMLOCK_RANGE:
170 172 case _SC_MEMORY_PROTECTION:
171 173 case _SC_MESSAGE_PASSING:
172 174 case _SC_PRIORITY_SCHEDULING:
173 175 case _SC_REALTIME_SIGNALS:
174 176 case _SC_SEMAPHORES:
175 177 case _SC_SHARED_MEMORY_OBJECTS:
176 178 case _SC_SYNCHRONIZED_IO:
177 179 case _SC_TIMERS:
178 180 if (__xpg6 & _C99SUSv3_mode_ON)
179 181 return (200112L);
180 182 else
181 183 return (1L);
182 184
183 185 case _SC_PRIORITIZED_IO:
184 186 #ifdef _POSIX_PRIORITIZED_IO
185 187 return (1L);
186 188 #else
187 189 return (-1L);
188 190 #endif
189 191
190 192 case _SC_AIO_LISTIO_MAX:
191 193 return (_sysconfig(_CONFIG_AIO_LISTIO_MAX));
192 194
193 195 case _SC_AIO_MAX:
194 196 return (_sysconfig(_CONFIG_AIO_MAX));
195 197
196 198 case _SC_AIO_PRIO_DELTA_MAX:
197 199 return (_sysconfig(_CONFIG_AIO_PRIO_DELTA_MAX));
198 200
199 201 case _SC_DELAYTIMER_MAX:
200 202 return (_sysconfig(_CONFIG_DELAYTIMER_MAX));
201 203
202 204 case _SC_MQ_OPEN_MAX:
203 205 return (_sysconfig(_CONFIG_MQ_OPEN_MAX));
204 206
205 207 case _SC_MQ_PRIO_MAX:
206 208 return (_sysconfig(_CONFIG_MQ_PRIO_MAX));
207 209
208 210 case _SC_RTSIG_MAX:
209 211 return (_sysconfig(_CONFIG_RTSIG_MAX));
210 212
211 213 case _SC_SEM_NSEMS_MAX:
212 214 return (_sysconfig(_CONFIG_SEM_NSEMS_MAX));
213 215
214 216 case _SC_SEM_VALUE_MAX:
215 217 return (_sysconfig(_CONFIG_SEM_VALUE_MAX));
216 218
217 219 case _SC_SIGQUEUE_MAX:
218 220 return (_sysconfig(_CONFIG_SIGQUEUE_MAX));
219 221
220 222 case _SC_SIGRT_MAX:
221 223 return (_sysconfig(_CONFIG_SIGRT_MAX));
222 224
223 225 case _SC_SIGRT_MIN:
224 226 return (_sysconfig(_CONFIG_SIGRT_MIN));
225 227
226 228 case _SC_TIMER_MAX:
227 229 return (_sysconfig(_CONFIG_TIMER_MAX));
228 230
229 231 case _SC_PHYS_PAGES:
230 232 return (_sysconfig(_CONFIG_PHYS_PAGES));
231 233
232 234 case _SC_AVPHYS_PAGES:
233 235 return (_sysconfig(_CONFIG_AVPHYS_PAGES));
234 236
235 237 /* XPG4/POSIX.1-1990/POSIX.2-1992 names */
236 238 case _SC_2_C_BIND:
237 239 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
238 240 return (200112L);
239 241 else
240 242 return (1L);
241 243
242 244 case _SC_2_CHAR_TERM:
243 245 return ((long)_POSIX2_CHAR_TERM);
244 246
245 247 case _SC_2_C_DEV:
246 248 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
247 249 return (200112L);
248 250 else
249 251 return (1L);
250 252
251 253 case _SC_2_C_VERSION:
252 254 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
253 255 return (200112L);
254 256 else
255 257 return (199209L);
256 258
257 259 case _SC_2_FORT_DEV:
258 260 return (-1L);
259 261
260 262 case _SC_2_FORT_RUN:
261 263 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
262 264 return (200112L);
263 265 else
264 266 return (1L);
265 267
266 268 case _SC_2_LOCALEDEF:
267 269 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
268 270 return (200112L);
269 271 else
270 272 return (1L);
271 273
272 274 case _SC_2_SW_DEV:
273 275 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
274 276 return (200112L);
275 277 else
276 278 return (1L);
277 279
278 280 case _SC_2_UPE:
279 281 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
280 282 return (200112L);
281 283 else
282 284 return (1L);
283 285
284 286 case _SC_2_VERSION:
285 287 if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
286 288 return (200112L);
287 289 else
288 290 return (199209L);
289 291
290 292 case _SC_BC_BASE_MAX:
291 293 return ((long)BC_BASE_MAX);
292 294
293 295 case _SC_BC_DIM_MAX:
294 296 return ((long)BC_DIM_MAX);
295 297
296 298 case _SC_BC_SCALE_MAX:
297 299 return ((long)BC_SCALE_MAX);
298 300
299 301 case _SC_BC_STRING_MAX:
300 302 return ((long)BC_STRING_MAX);
301 303
302 304 case _SC_COLL_WEIGHTS_MAX:
303 305 return ((long)COLL_WEIGHTS_MAX);
304 306
305 307 case _SC_EXPR_NEST_MAX:
306 308 return ((long)EXPR_NEST_MAX);
307 309
308 310 case _SC_LINE_MAX:
309 311 return ((long)LINE_MAX);
310 312
311 313 case _SC_RE_DUP_MAX:
312 314 return ((long)RE_DUP_MAX);
313 315
314 316 case _SC_XOPEN_CRYPT:
315 317 return (1L);
316 318
317 319 case _SC_XOPEN_ENH_I18N:
318 320 return ((long)_XOPEN_ENH_I18N);
319 321
320 322 case _SC_XOPEN_SHM:
321 323 return ((long)_XOPEN_SHM);
322 324
323 325 /* XPG4v2 (SUS) names */
324 326 case _SC_XOPEN_UNIX:
325 327 return (1L);
326 328
327 329 case _SC_XOPEN_LEGACY:
328 330 return (1L);
329 331
330 332 case _SC_ATEXIT_MAX:
331 333 return (-1L);
332 334
333 335 case _SC_IOV_MAX:
334 336 return ((long)IOV_MAX);
335 337
336 338 case _SC_T_IOV_MAX:
337 339 return ((long)T_IOV_MAX);
338 340
339 341 /* XPG5 (SUSv2) names */
340 342 case _SC_XOPEN_REALTIME:
341 343 return (1L);
342 344
343 345 case _SC_XOPEN_REALTIME_THREADS:
344 346 #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && \
345 347 defined(_POSIX_THREAD_PRIO_INHERIT) && \
346 348 defined(_POSIX_THREAD_PRIO_PROTECT)
347 349 return (1L);
348 350 #else
349 351 return (-1L);
350 352 #endif
351 353
352 354 case _SC_XBS5_ILP32_OFF32:
353 355 return (1L);
354 356
355 357 case _SC_XBS5_ILP32_OFFBIG:
356 358 return (1L);
357 359
358 360 case _SC_XBS5_LP64_OFF64:
359 361 return (1L);
360 362
361 363 case _SC_XBS5_LPBIG_OFFBIG:
362 364 return (1L);
363 365
364 366 /* POSIX.1c names */
↓ open down ↓ |
332 lines elided |
↑ open up ↑ |
365 367 case _SC_THREAD_DESTRUCTOR_ITERATIONS:
366 368 return (-1L);
367 369
368 370 case _SC_GETGR_R_SIZE_MAX:
369 371 return ((long)_nss_get_bufsizes(_SC_GETGR_R_SIZE_MAX));
370 372
371 373 case _SC_GETPW_R_SIZE_MAX:
372 374 return ((long)NSS_BUFLEN_PASSWD);
373 375
374 376 case _SC_LOGIN_NAME_MAX:
375 - return ((long)(LOGNAME_MAX + 1));
377 + return ((long)(LOGIN_NAME_MAX));
376 378
377 379 case _SC_THREAD_KEYS_MAX:
378 380 return (-1L);
379 381
380 382 case _SC_THREAD_STACK_MIN:
381 383 return ((long)thr_min_stack());
382 384
383 385 case _SC_THREAD_THREADS_MAX:
384 386 return (-1L);
385 387
386 388 case _SC_TTY_NAME_MAX:
387 389 return ((long)TTYNAME_MAX);
388 390
389 391 case _SC_BARRIERS:
390 392 return ((long)_POSIX_BARRIERS);
391 393
392 394 case _SC_CLOCK_SELECTION:
393 395 return ((long)_POSIX_CLOCK_SELECTION);
394 396
395 397 case _SC_MONOTONIC_CLOCK:
396 398 return ((long)_POSIX_MONOTONIC_CLOCK);
397 399
398 400 case _SC_SPAWN:
399 401 return ((long)_POSIX_SPAWN);
400 402
401 403 case _SC_SPIN_LOCKS:
402 404 return ((long)_POSIX_SPIN_LOCKS);
403 405
404 406 case _SC_THREADS:
405 407 case _SC_THREAD_ATTR_STACKADDR:
406 408 case _SC_THREAD_ATTR_STACKSIZE:
407 409 case _SC_THREAD_PRIORITY_SCHEDULING:
408 410 case _SC_THREAD_PRIO_INHERIT:
409 411 case _SC_THREAD_PRIO_PROTECT:
410 412 case _SC_THREAD_PROCESS_SHARED:
411 413 case _SC_THREAD_SAFE_FUNCTIONS:
412 414 if (__xpg6 & _C99SUSv3_mode_ON)
413 415 return (200112L);
414 416 else
415 417 return (1L);
416 418
417 419 case _SC_TIMEOUTS:
418 420 return ((long)_POSIX_TIMEOUTS);
419 421
420 422 /* 1216676 - cache info */
421 423 case _SC_COHER_BLKSZ:
422 424 return (_sysconfig(_CONFIG_COHERENCY));
423 425
424 426 case _SC_SPLIT_CACHE:
425 427 return (_sysconfig(_CONFIG_SPLIT_CACHE));
426 428
427 429 case _SC_ICACHE_SZ:
428 430 return (_sysconfig(_CONFIG_ICACHESZ));
429 431
430 432 case _SC_DCACHE_SZ:
431 433 return (_sysconfig(_CONFIG_DCACHESZ));
432 434
433 435 case _SC_ICACHE_LINESZ:
434 436 return (_sysconfig(_CONFIG_ICACHELINESZ));
435 437
436 438 case _SC_DCACHE_LINESZ:
437 439 return (_sysconfig(_CONFIG_DCACHELINESZ));
438 440
439 441 case _SC_ICACHE_BLKSZ:
440 442 return (_sysconfig(_CONFIG_ICACHEBLKSZ));
441 443
442 444 case _SC_DCACHE_BLKSZ:
443 445 return (_sysconfig(_CONFIG_DCACHEBLKSZ));
444 446
445 447 case _SC_DCACHE_TBLKSZ:
446 448 return (_sysconfig(_CONFIG_DCACHETBLKSZ));
447 449
448 450 case _SC_ICACHE_ASSOC:
449 451 return (_sysconfig(_CONFIG_ICACHE_ASSOC));
450 452
451 453 case _SC_DCACHE_ASSOC:
452 454 return (_sysconfig(_CONFIG_DCACHE_ASSOC));
453 455
454 456 case _SC_MAXPID:
455 457 if (_maxpid <= 0)
456 458 _maxpid = _sysconfig(_CONFIG_MAXPID);
457 459 return (_maxpid);
458 460
459 461 case _SC_CPUID_MAX:
460 462 return (_sysconfig(_CONFIG_CPUID_MAX));
461 463
462 464 case _SC_EPHID_MAX:
463 465 return (_sysconfig(_CONFIG_EPHID_MAX));
464 466
465 467 /* UNIX 03 names - XPG6/SUSv3/POSIX.1-2001 */
466 468
467 469 case _SC_REGEXP:
468 470 return ((long)_POSIX_REGEXP);
469 471
470 472 case _SC_SHELL:
471 473 return ((long)_POSIX_SHELL);
472 474
473 475 case _SC_ADVISORY_INFO:
474 476 return ((long)_POSIX_ADVISORY_INFO);
475 477
476 478 case _SC_HOST_NAME_MAX:
477 479 return ((long)_POSIX_HOST_NAME_MAX);
478 480
479 481 case _SC_READER_WRITER_LOCKS:
480 482 return ((long)_POSIX_READER_WRITER_LOCKS);
481 483
482 484 case _SC_IPV6:
483 485 return ((long)_POSIX_IPV6);
484 486
485 487 case _SC_RAW_SOCKETS:
486 488 return ((long)_POSIX_RAW_SOCKETS);
487 489
488 490 case _SC_XOPEN_STREAMS:
489 491 return ((long)_XOPEN_STREAMS);
490 492
491 493 case _SC_SYMLOOP_MAX:
492 494 return (_sysconfig(_CONFIG_SYMLOOP_MAX));
493 495
494 496 case _SC_V6_ILP32_OFF32:
495 497 return (1L);
496 498
497 499 case _SC_V6_ILP32_OFFBIG:
498 500 return (1L);
499 501
500 502 case _SC_V6_LP64_OFF64:
501 503 return (1L);
502 504
503 505 case _SC_V6_LPBIG_OFFBIG:
504 506 return (1L);
505 507
506 508 /* Unsupported UNIX 03 options */
507 509 case _SC_2_PBS:
508 510 case _SC_2_PBS_ACCOUNTING:
509 511 case _SC_2_PBS_CHECKPOINT:
510 512 case _SC_2_PBS_LOCATE:
511 513 case _SC_2_PBS_MESSAGE:
512 514 case _SC_2_PBS_TRACK:
513 515 case _SC_CPUTIME:
514 516 case _SC_SPORADIC_SERVER:
515 517 case _SC_SS_REPL_MAX:
516 518 case _SC_THREAD_CPUTIME:
517 519 case _SC_THREAD_SPORADIC_SERVER:
518 520 case _SC_TRACE:
519 521 case _SC_TRACE_EVENT_FILTER:
520 522 case _SC_TRACE_EVENT_NAME_MAX:
521 523 case _SC_TRACE_INHERIT:
522 524 case _SC_TRACE_LOG:
523 525 case _SC_TRACE_NAME_MAX:
524 526 case _SC_TRACE_SYS_MAX:
525 527 case _SC_TRACE_USER_EVENT_MAX:
526 528 case _SC_TYPED_MEMORY_OBJECTS:
527 529 return (-1L);
528 530 }
529 531 }
530 532
531 533 /*
532 534 * UNIX 98 version of sysconf needed in order to set _XOPEN_VERSION to 500.
533 535 */
534 536
535 537 long
536 538 __sysconf_xpg5(int name)
537 539 {
538 540 switch (name) {
539 541 default:
540 542 return (sysconf(name));
541 543 case _SC_XOPEN_VERSION:
542 544 return (500L);
543 545 case _SC_PASS_MAX:
544 546 return ((long)_PASS_MAX_XPG);
545 547 }
546 548 }
↓ open down ↓ |
161 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX