From 0f49f849c8ec985d7a6560f9dd9b04c7100a1c90 Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Tue, 1 Aug 2017 19:16:59 +0300 Subject: [PATCH] control legacy uname with an environment variable this allows us to remove the process flag and move the implementation entirely into libc. it also makes puname(1) trivial; it may be removed later. this removes the sysinfo() return value mangling, and rtld is modified to always receive the real uname information (for the $OSREL and $OSNAME expansions). that's fine, though, because puname is supposed to be a temporary hack anyway. --- bin/puname/Makefile | 1 - bin/puname/puname.1 | 20 +--- bin/puname/puname.c | 150 +++++++------------------- include/sys/procfs.h | 1 - include/sys/user.h | 3 - include/sys/utsname.h | 2 +- kernel/fs/proc/prcontrol.c | 6 +- kernel/fs/proc/prsubr.c | 4 - kernel/os/vers.c | 21 +--- kernel/syscall/systeminfo.c | 9 +- kernel/syscall/uname.c | 2 +- lib/libc/Makefile | 4 +- lib/libc/{uname.2 => uname.3} | 2 +- share/man/man4/proc.4 | 10 -- usr/src/cmd/ptools/pflags/pflags.c | 4 +- usr/src/cmd/sgs/libconv/common/tokens.c | 5 +- usr/src/lib/libc/amd64/Makefile | 2 +- usr/src/lib/libc/amd64/sys/uname.s | 37 ------- usr/src/lib/libc/i386/Makefile.com | 2 +- usr/src/lib/libc/i386/sys/uname.s | 49 --------- usr/src/lib/libc/port/sys/uname.c | 37 +++++++ usr/src/lib/libc/sparc/Makefile.com | 2 +- usr/src/lib/libc/sparc/sys/uname.s | 45 -------- usr/src/lib/libc/sparcv9/Makefile.com | 2 +- usr/src/pkg/manifests/system-kernel.man2.inc | 1 - usr/src/pkg/manifests/system-library.man3.inc | 1 + 26 files changed, 103 insertions(+), 319 deletions(-) rewrite bin/puname/puname.c (92%) rename lib/libc/{uname.2 => uname.3} (99%) delete mode 100644 usr/src/lib/libc/amd64/sys/uname.s delete mode 100644 usr/src/lib/libc/i386/sys/uname.s create mode 100644 usr/src/lib/libc/port/sys/uname.c delete mode 100644 usr/src/lib/libc/sparc/sys/uname.s diff --git a/bin/puname/Makefile b/bin/puname/Makefile index 513c97df4f..11137a51ab 100644 --- a/bin/puname/Makefile +++ b/bin/puname/Makefile @@ -1,4 +1,3 @@ PROG= puname -LDADD= -lproc .include diff --git a/bin/puname/puname.1 b/bin/puname/puname.1 index 71eccc9d29..40d0071de2 100644 --- a/bin/puname/puname.1 +++ b/bin/puname/puname.1 @@ -22,13 +22,11 @@ .Nm .Ar command .Op args -.Nm -.Fl p Ar pid .Sh DESCRIPTION The .Nm utility runs the given command with legacy uname. -.Xr uname 2 +.Xr uname 3 will return the following values for the command and its child processes: .Pp .Bl -tag -width sysnameXXX -offset indent -compact @@ -40,25 +38,11 @@ SunOS legacy-uname .El .Pp -The values returned by the -.Xr sysinfo 2 -commands -.Dv SI_SYSNAME , -.Dv SI_RELEASE , -and -.Dv SI_VERSION -commands are modified accordingly. -.Sh OPTIONS -The following options are supported: -.Bl -tag -width indent -.It Fl p Ar pid -Display the current uname setting for -.Ar pid . .El .Sh EXIT STATUS .Ex -std .Sh SEE ALSO .Xr proc 1 , .Xr sysinfo 2 , -.Xr uname 2 , +.Xr uname 3 , .Xr proc 4 diff --git a/bin/puname/puname.c b/bin/puname/puname.c dissimilarity index 92% index 58db759ff2..0916037a85 100644 --- a/bin/puname/puname.c +++ b/bin/puname/puname.c @@ -1,110 +1,40 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * Portions Copyright 2008 Chad Mynhier - * - * Copyright 2014 Garrett D'Amore - * Copyright 2017 Lauri Tirkkonen - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void -usage() -{ - const char *command = getprogname(); - fprintf(stderr, "usage: %s command [args]\n" - " %s -p pid\n", command, command); - exit(1); -} - -int -main(int argc, char **argv) -{ - char *pidarg = NULL; - int opt; - int gret; - struct ps_prochandle *Pr; - - while ((opt = getopt(argc, argv, "p:")) != EOF) { - switch (opt) { - case 'p': - pidarg = optarg; - break; - default: - usage(); - break; - } - } - - argc -= optind; - argv += optind; - - if (!pidarg && argc < 1) - usage(); - if (pidarg) { - Pr = proc_arg_grab(pidarg, PR_ARG_PIDS, PGRAB_RDONLY, &gret); - if (!Pr) - errx(1, "cannot examine %s: %s", pidarg, - Pgrab_error(gret)); - bool islegacy = Pstatus(Pr)->pr_flags & PR_LUNAME; - printf("%s: %s\n", pidarg, islegacy ? "legacy uname" : - "standard uname"); - Prelease(Pr, 0); - return 0; - } - pid_t pid = fork(); - switch (pid) { - case -1: - err(1, "fork"); - break; - case 0: - Pr = Pgrab(getppid(), 0, &gret); - if (!Pr) - errx(1, "cannot grab parent: %s", Pgrab_error(gret)); - if (Psetflags(Pr, PR_LUNAME) != 0) - err(1, "cannot set legacy flag"); - Prelease(Pr, 0); - return 0; - default: - if (waitpid(pid, &gret, 0) < 0) - err(1, "waitpid"); - if ((!WIFEXITED(gret)) || (WEXITSTATUS(gret) != 0)) - return (1); - execvp(argv[0], argv); - err(1, "execvp"); - break; - } - return 1; -} +/* + * Copyright 2017 Lauri Tirkkonen + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +static void +usage(void) +{ + printf("usage: puname command [args]\n"); + exit(1); +} + +int +main(int argc, char **argv) +{ + if (argc < 2) + usage(); + + if (setenv("UNAME_LEGACY", "", 0) < 0) + err(1, "setenv"); + argv++; + execvp(argv[0], argv); + err(1, "cannot execute %s", argv[0]); + return 1; +} diff --git a/include/sys/procfs.h b/include/sys/procfs.h index f43d9dbd54..1ca122aae1 100644 --- a/include/sys/procfs.h +++ b/include/sys/procfs.h @@ -219,7 +219,6 @@ typedef struct pstatus { #define PR_BPTADJ 0x02000000 /* breakpoint trap pc adjustment is in effect */ #define PR_PTRACE 0x04000000 /* ptrace-compatibility mode is in effect */ #define PR_MSFORK 0x08000000 /* micro-state accounting inherited on fork */ -#define PR_LUNAME 0x10000000 /* legacy utsname in effect */ /* * See for possible values of pr_dmodel. diff --git a/include/sys/user.h b/include/sys/user.h index 1925bf0923..b89962891d 100644 --- a/include/sys/user.h +++ b/include/sys/user.h @@ -247,9 +247,6 @@ typedef struct user { uf_info_t u_finfo; /* open file information */ } user_t; -/* flags for u_flags */ -#define U_FLAG_LEGACYUNAME 1 /* Report legacy utsname fields */ - #include /* cannot include before user defined */ #ifdef _KERNEL diff --git a/include/sys/utsname.h b/include/sys/utsname.h index 98327ebc66..a58d31bf53 100644 --- a/include/sys/utsname.h +++ b/include/sys/utsname.h @@ -76,7 +76,7 @@ extern char *uts_nodename(void); /* * Routines to access parts of the utsname. */ -extern const struct utsname *utsname_get(bool legacy); +extern const struct utsname *utsname_get(); extern void utsname_set_machine(const char *machine); #endif /* !(_KERNEL) */ diff --git a/kernel/fs/proc/prcontrol.c b/kernel/fs/proc/prcontrol.c index f6d84fd788..9d2d583c29 100644 --- a/kernel/fs/proc/prcontrol.c +++ b/kernel/fs/proc/prcontrol.c @@ -1595,7 +1595,7 @@ pr_setentryexit(proc_t *p, sysset_t *sysset, int entry) #define ALLFLAGS \ (PR_FORK|PR_RLC|PR_KLC|PR_ASYNC|PR_BPTADJ|PR_MSACCT|PR_MSFORK|\ - PR_PTRACE|PR_LUNAME) + PR_PTRACE) int pr_set(proc_t *p, long flags) @@ -1627,8 +1627,6 @@ pr_set(proc_t *p, long flags) if (p->p_ppid == 1) sigtoproc(p, NULL, SIGKILL); } - if (flags & PR_LUNAME) - PTOU(p)->u_flags |= U_FLAG_LEGACYUNAME; return (0); } @@ -1658,8 +1656,6 @@ pr_unset(proc_t *p, long flags) p->p_flag &= ~SMSFORK; if (flags & PR_PTRACE) p->p_proc_flag &= ~P_PR_PTRACE; - if (flags & PR_LUNAME) - PTOU(p)->u_flags &= ~U_FLAG_LEGACYUNAME; return (0); } diff --git a/kernel/fs/proc/prsubr.c b/kernel/fs/proc/prsubr.c index 72f384fa5e..b420bf0f22 100644 --- a/kernel/fs/proc/prsubr.c +++ b/kernel/fs/proc/prsubr.c @@ -970,8 +970,6 @@ prgetlwpstatus32(kthread_t *t, lwpstatus32_t *sp, zone_t *zp) flags |= PR_MSFORK; if (p->p_flag & SVFWAIT) flags |= PR_VFORKP; - if (PTOU(p)->u_flags & U_FLAG_LEGACYUNAME) - flags |= PR_LUNAME; sp->pr_flags = flags; if (VSTOPPED(t)) { sp->pr_why = PR_REQUESTED; @@ -1204,8 +1202,6 @@ prgetlwpstatus(kthread_t *t, lwpstatus_t *sp, zone_t *zp) flags |= PR_NOSIGCHLD; if (p->p_pidflag & CLDWAITPID) flags |= PR_WAITPID; - if (PTOU(p)->u_flags & U_FLAG_LEGACYUNAME) - flags |= PR_LUNAME; sp->pr_flags = flags; if (VSTOPPED(t)) { sp->pr_why = PR_REQUESTED; diff --git a/kernel/os/vers.c b/kernel/os/vers.c index e24582c9d8..09c0626155 100644 --- a/kernel/os/vers.c +++ b/kernel/os/vers.c @@ -15,9 +15,7 @@ */ /* - * Template utsname and legacy utsname. - * - * UTS_SYSNAME, UTS_RELEASE, UTS_VERSION and UTS_PLATFORM must defined by + * UTS_VERSION and UTS_PLATFORM must defined by * the build system. */ @@ -32,25 +30,14 @@ struct utsname utsname = { .machine = UTS_PLATFORM, }; -static struct utsname utsname_legacy = { - .sysname = UTS_SYSNAME, - .nodename = "", - .release = UTS_RELEASE, - .version = "legacy-uname", - .machine = UTS_PLATFORM, -}; - - -const struct utsname *utsname_get(bool legacy) +const struct utsname * +utsname_get(void) { - return legacy ? &utsname_legacy : &utsname; + return &utsname; } void utsname_set_machine(const char *machine) { strncpy(utsname.machine, machine, _SYS_NMLN); utsname.machine[_SYS_NMLN - 1] = '\0'; - - strncpy(utsname_legacy.machine, machine, _SYS_NMLN); - utsname_legacy.machine[_SYS_NMLN - 1] = '\0'; } diff --git a/kernel/syscall/systeminfo.c b/kernel/syscall/systeminfo.c index f73756ff73..626effefd7 100644 --- a/kernel/syscall/systeminfo.c +++ b/kernel/syscall/systeminfo.c @@ -54,7 +54,6 @@ static void get_netif_name(char *, char *); long systeminfo(int command, char *buf, long count) { - const bool legacy = (PTOU(curproc)->u_flags & U_FLAG_LEGACYUNAME) != 0; int error = 0; long strcnt, getcnt; const char *kstr; @@ -69,19 +68,19 @@ systeminfo(int command, char *buf, long count) */ switch (command) { case SI_SYSNAME: - kstr = utsname_get(legacy)->sysname; + kstr = utsname_get()->sysname; break; case SI_HOSTNAME: kstr = uts_nodename(); break; case SI_RELEASE: - kstr = utsname_get(legacy)->release; + kstr = utsname_get()->release; break; case SI_VERSION: - kstr = utsname_get(legacy)->version; + kstr = utsname_get()->version; break; case SI_MACHINE: - kstr = utsname_get(legacy)->machine; + kstr = utsname_get()->machine; break; #ifdef _LP64 case SI_ARCHITECTURE_64: diff --git a/kernel/syscall/uname.c b/kernel/syscall/uname.c index b77b5438e5..6a878bec79 100644 --- a/kernel/syscall/uname.c +++ b/kernel/syscall/uname.c @@ -46,7 +46,7 @@ uname(struct utsname *buf) const char *name_to_use = uts_nodename(); const struct utsname *info; - info = utsname_get((PTOU(curproc)->u_flags & U_FLAG_LEGACYUNAME) != 0); + info = utsname_get(); if (copyout(info->sysname, buf->sysname, strlen(info->sysname) + 1)) { return (set_errno(EFAULT)); diff --git a/lib/libc/Makefile b/lib/libc/Makefile index a8c7b68329..7b9eb5d251 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -1,7 +1,7 @@ MAN= accept.2 bind.2 connect.2 getpeername.2 getsockname.2 getsockopt.2 \ - listen.2 recv.2 send.2 shutdown.2 socket.2 socketpair.2 uname.2 \ + listen.2 recv.2 send.2 shutdown.2 socket.2 socketpair.2 \ CMSG_DATA.3 alloca.3 err.3 fts.3 malloc.3 readdir.3 sockatmark.3 \ - posix_memalign.3 valloc.3 unvis.3 vis.3 + posix_memalign.3 valloc.3 uname.3 unvis.3 vis.3 # no source yet. NOOBJ= diff --git a/lib/libc/uname.2 b/lib/libc/uname.3 similarity index 99% rename from lib/libc/uname.2 rename to lib/libc/uname.3 index a1d35ce00c..b5c5b6f536 100644 --- a/lib/libc/uname.2 +++ b/lib/libc/uname.3 @@ -28,7 +28,7 @@ .\" SUCH DAMAGE. .\" .Dd $Mdocdate: January 21 2014 $ -.Dt UNAME 2 +.Dt UNAME 3 .Os .Sh NAME .Nm uname diff --git a/share/man/man4/proc.4 b/share/man/man4/proc.4 index d4b114ac8b..255b5ede67 100644 --- a/share/man/man4/proc.4 +++ b/share/man/man4/proc.4 @@ -361,16 +361,6 @@ process has its ptrace-compatibility mode set (see \fBPCSET\fR). .RE .sp -.ne 2 -.na -\fB\fBPR_LUNAME\fR\fR -.ad -.RS 13n -process will use legacy system identity values for -\fBuname\fR(2) and \fBsysinfo\fR(2) system calls. -.RE - -.sp .LP \fBpr_nlwp\fR is the total number of active lwps in the process. pr_nzomb is the total number of zombie lwps in the process. A zombie lwp is a non-detached diff --git a/usr/src/cmd/ptools/pflags/pflags.c b/usr/src/cmd/ptools/pflags/pflags.c index 8c879470ac..da3e812b5c 100644 --- a/usr/src/cmd/ptools/pflags/pflags.c +++ b/usr/src/cmd/ptools/pflags/pflags.c @@ -70,7 +70,7 @@ static int rflag; /* Show registers? */ #define PROCFLAGS \ (PR_ISSYS|PR_VFORKP|PR_ORPHAN|PR_NOSIGCHLD|PR_WAITPID|PR_FORK|PR_RLC \ - |PR_KLC|PR_ASYNC|PR_BPTADJ|PR_MSACCT|PR_MSFORK|PR_PTRACE|PR_LUNAME) + |PR_KLC|PR_ASYNC|PR_BPTADJ|PR_MSACCT|PR_MSFORK|PR_PTRACE) #define ALLFLAGS (LWPFLAGS|PROCFLAGS) @@ -435,8 +435,6 @@ prflags(int arg) (void) strcat(str, "|MSFORK"); if (arg & PR_PTRACE) (void) strcat(str, "|PTRACE"); - if (arg & PR_LUNAME) - (void) strcat(str, "|LUNAME"); if (*str == '|') str++; diff --git a/usr/src/cmd/sgs/libconv/common/tokens.c b/usr/src/cmd/sgs/libconv/common/tokens.c index ad114cd47e..ca43a176db 100644 --- a/usr/src/cmd/sgs/libconv/common/tokens.c +++ b/usr/src/cmd/sgs/libconv/common/tokens.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include "_conv.h" @@ -116,8 +117,10 @@ conv_uts(void) /* * If we can't get the uname(2) silently ignore. + * XXX We use syscall() here because we can't use the libc + * implementation with the 'legacy uname' feature in rtld. */ - if (uname(&utsname) == -1) + if (syscall(SYS_uname, &utsname) == -1) return (desc); /* diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile index 0ff95cb233..212d91b154 100644 --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -280,6 +280,7 @@ COMSYSOBJS= \ ulimit.o \ umask.o \ umount2.o \ + uname.o \ utssys.o \ uucopy.o \ vhangup.o \ @@ -306,7 +307,6 @@ SYSOBJS= \ tls_get_addr.o \ uadmin.o \ umount.o \ - uname.o \ vforkx.o # Preserved solely to ease maintenance of 32-bit and 64-bit library builds diff --git a/usr/src/lib/libc/amd64/sys/uname.s b/usr/src/lib/libc/amd64/sys/uname.s deleted file mode 100644 index c021d5aecc..0000000000 --- a/usr/src/lib/libc/amd64/sys/uname.s +++ /dev/null @@ -1,37 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - .file "uname.s" - -#include - - ANSI_PRAGMA_WEAK(uname,function) - ANSI_PRAGMA_WEAK2(_nuname,uname,function) - -#include "SYS.h" - - SYSCALL(uname) - RET - SET_SIZE(uname) diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com index 40d06b8e2f..4b03304551 100644 --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -312,6 +312,7 @@ COMSYSOBJS= \ ulimit.o \ umask.o \ umount2.o \ + uname.o \ utssys.o \ uucopy.o \ vhangup.o \ @@ -339,7 +340,6 @@ SYSOBJS= \ tls_get_addr.o \ uadmin.o \ umount.o \ - uname.o \ vforkx.o \ xstat.o diff --git a/usr/src/lib/libc/i386/sys/uname.s b/usr/src/lib/libc/i386/sys/uname.s deleted file mode 100644 index f4824e8230..0000000000 --- a/usr/src/lib/libc/i386/sys/uname.s +++ /dev/null @@ -1,49 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - .file "uname.s" - -#include - - ANSI_PRAGMA_WEAK(uname,function) - ANSI_PRAGMA_WEAK2(_nuname,uname,function) - -#include "SYS.h" - - .set UNAME, 0 - - ENTRY(uname) - pushl $UNAME / type - pushl $0 / mv flag - pushl 12(%esp) / utsname address (retaddr+$UNAME+0) - subl $4, %esp / where return address would be. - SYSTRAP_RVAL1(utssys) - jae 1f - addl $16, %esp - jmp __cerror -1: - addl $16, %esp - ret - SET_SIZE(uname) diff --git a/usr/src/lib/libc/port/sys/uname.c b/usr/src/lib/libc/port/sys/uname.c new file mode 100644 index 0000000000..5e59248b84 --- /dev/null +++ b/usr/src/lib/libc/port/sys/uname.c @@ -0,0 +1,37 @@ +/* + * Copyright 2017 Lauri Tirkkonen + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + +int +uname(struct utsname *name) +{ + int ret = syscall(SYS_uname, name); + int serr = errno; + if (ret >= 0 && getenv("UNAME_LEGACY")) { + strlcpy(name->sysname, "SunOS", sizeof(name->sysname)); + strlcpy(name->release, "5.11", sizeof(name->release)); + strlcpy(name->version, "legacy-uname", sizeof(name->version)); + } + errno = serr; + return ret; +} +/* binary compat alias */ +#pragma weak _nuname = uname diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com index 0515cb0e03..740351af7f 100644 --- a/usr/src/lib/libc/sparc/Makefile.com +++ b/usr/src/lib/libc/sparc/Makefile.com @@ -320,6 +320,7 @@ COMSYSOBJS= \ ulimit.o \ umask.o \ umount2.o \ + uname.o \ utssys.o \ uucopy.o \ vhangup.o \ @@ -343,7 +344,6 @@ SYSOBJS= \ tls_get_addr.o \ uadmin.o \ umount.o \ - uname.o \ vforkx.o # objects under $(LIBCDIR)/port which contain transitional large file interfaces diff --git a/usr/src/lib/libc/sparc/sys/uname.s b/usr/src/lib/libc/sparc/sys/uname.s deleted file mode 100644 index 3ed51c2c06..0000000000 --- a/usr/src/lib/libc/sparc/sys/uname.s +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - - -/* Copyright (c) 1989 by Sun Microsystems, Inc. */ - -.ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8 */ - -/* C library -- uname */ -/* int uname (struct utsname *name); */ - - .file "uname.s" - -#include - - ANSI_PRAGMA_WEAK(uname,function) - ANSI_PRAGMA_WEAK2(_nuname,uname,function) - -#include "SYS.h" - - SYSCALL(uname) - RET - - SET_SIZE(uname) diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com index 68fc9bb7d2..b7f0d205a1 100644 --- a/usr/src/lib/libc/sparcv9/Makefile.com +++ b/usr/src/lib/libc/sparcv9/Makefile.com @@ -301,6 +301,7 @@ COMSYSOBJS= \ ulimit.o \ umask.o \ umount2.o \ + uname.o \ utssys.o \ uucopy.o \ vhangup.o \ @@ -324,7 +325,6 @@ SYSOBJS= \ tls_get_addr.o \ uadmin.o \ umount.o \ - uname.o \ vforkx.o # Preserved solely to ease maintenance of 32-bit and 64-bit library builds diff --git a/usr/src/pkg/manifests/system-kernel.man2.inc b/usr/src/pkg/manifests/system-kernel.man2.inc index e7a2b44eb8..c50a99dd3a 100644 --- a/usr/src/pkg/manifests/system-kernel.man2.inc +++ b/usr/src/pkg/manifests/system-kernel.man2.inc @@ -157,7 +157,6 @@ file path=usr/share/man/man2/uadmin.2 file path=usr/share/man/man2/ulimit.2 file path=usr/share/man/man2/umask.2 file path=usr/share/man/man2/umount.2 -file path=usr/share/man/man2/uname.2 file path=usr/share/man/man2/unlink.2 file path=usr/share/man/man2/ustat.2 file path=usr/share/man/man2/utime.2 diff --git a/usr/src/pkg/manifests/system-library.man3.inc b/usr/src/pkg/manifests/system-library.man3.inc index c502ffc958..992e565c6d 100644 --- a/usr/src/pkg/manifests/system-library.man3.inc +++ b/usr/src/pkg/manifests/system-library.man3.inc @@ -23,6 +23,7 @@ file path=usr/share/man/man3/fts.3 file path=usr/share/man/man3/alloca.3 file path=usr/share/man/man3/malloc.3 file path=usr/share/man/man3/posix_memalign.3 +file path=usr/share/man/man3/uname.3 file path=usr/share/man/man3/unvis.3 file path=usr/share/man/man3/valloc.3 file path=usr/share/man/man3/vis.3 -- 2.11.4.GIT