1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 1991 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <errno.h>
30*0Sstevel@tonic-gate #include <string.h>
31*0Sstevel@tonic-gate #include <sys/utsname.h>
32*0Sstevel@tonic-gate #include <sys/syscall.h>
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gate /*
35*0Sstevel@tonic-gate * utsname structure has a different format in SVr4/SunOS 5.0.
36*0Sstevel@tonic-gate * The data needs to be mapped before returning to the user.
37*0Sstevel@tonic-gate */
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gate /*
40*0Sstevel@tonic-gate * The following values and structure are from the SVR4 utsname.h.
41*0Sstevel@tonic-gate */
42*0Sstevel@tonic-gate #define NEW_SYS_NMLN 257
43*0Sstevel@tonic-gate #define SYS_NMLN 9
44*0Sstevel@tonic-gate #define SYS_NDLN 65
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate struct n_utsname {
47*0Sstevel@tonic-gate char sysname[NEW_SYS_NMLN];
48*0Sstevel@tonic-gate char nodename[NEW_SYS_NMLN];
49*0Sstevel@tonic-gate char release[NEW_SYS_NMLN];
50*0Sstevel@tonic-gate char version[NEW_SYS_NMLN];
51*0Sstevel@tonic-gate char machine[NEW_SYS_NMLN];
52*0Sstevel@tonic-gate };
53*0Sstevel@tonic-gate
uname(uts)54*0Sstevel@tonic-gate int uname( uts )
55*0Sstevel@tonic-gate register struct utsname *uts; /* where to put results */
56*0Sstevel@tonic-gate {
57*0Sstevel@tonic-gate return(bc_uname(uts));
58*0Sstevel@tonic-gate }
59*0Sstevel@tonic-gate
bc_uname(uts)60*0Sstevel@tonic-gate int bc_uname( uts )
61*0Sstevel@tonic-gate struct utsname *uts;
62*0Sstevel@tonic-gate {
63*0Sstevel@tonic-gate struct n_utsname n_uts;
64*0Sstevel@tonic-gate int ret;
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate if ((ret = _syscall(SYS_uname, &n_uts)) != -1) {
67*0Sstevel@tonic-gate memcpy(uts->sysname, n_uts.sysname, SYS_NMLN);
68*0Sstevel@tonic-gate if (strlen(n_uts.sysname) > SYS_NMLN)
69*0Sstevel@tonic-gate uts->sysname[SYS_NMLN-1] = '\0';
70*0Sstevel@tonic-gate memcpy(uts->nodename, n_uts.nodename, SYS_NDLN);
71*0Sstevel@tonic-gate if (strlen(n_uts.nodename) > SYS_NDLN)
72*0Sstevel@tonic-gate uts->nodename[SYS_NDLN-1] = '\0';
73*0Sstevel@tonic-gate memcpy(uts->release, n_uts.release, SYS_NMLN);
74*0Sstevel@tonic-gate if (strlen(n_uts.release) > SYS_NMLN)
75*0Sstevel@tonic-gate uts->release[SYS_NMLN-1] = '\0';
76*0Sstevel@tonic-gate memcpy(uts->version, n_uts.version, SYS_NMLN);
77*0Sstevel@tonic-gate if (strlen(n_uts.version) > SYS_NMLN)
78*0Sstevel@tonic-gate uts->version[SYS_NMLN-1] = '\0';
79*0Sstevel@tonic-gate memcpy(uts->machine, n_uts.machine, SYS_NMLN);
80*0Sstevel@tonic-gate if (strlen(n_uts.machine) > SYS_NMLN)
81*0Sstevel@tonic-gate uts->machine[SYS_NMLN-1] = '\0';
82*0Sstevel@tonic-gate }
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate return(ret);
85*0Sstevel@tonic-gate }
86