Merge commit '281819e5f8b19cd8627541a22d261906fd190276' into merges
[unleashed.git] / usr / src / lib / libc / port / sys / uname.c
blob60b50ff12412c27b9e0fe1f39ac9ef997efb966a
1 /*
2 * Copyright 2017 Lauri Tirkkonen <lotheac@iki.fi>
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <errno.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <sys/syscall.h>
21 #include <sys/utsname.h>
22 #include <sys/cfgparam.h>
24 int
25 uname(struct utsname *name)
27 int ret = syscall(SYS_uname, name);
28 int serr = errno;
29 if (ret >= 0 && getenv("UNAME_LEGACY")) {
30 strlcpy(name->sysname, "SunOS", sizeof(name->sysname));
31 strlcpy(name->release, "5.11", sizeof(name->release));
32 strlcpy(name->version, "legacy-uname", sizeof(name->version));
33 strlcpy(name->machine, CONFIG_PLATFORM_STR,
34 sizeof(name->machine));
36 errno = serr;
37 return ret;