summaryrefslogtreecommitdiffstats
path: root/man2/uname.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/uname.2')
-rw-r--r--man2/uname.2134
1 files changed, 134 insertions, 0 deletions
diff --git a/man2/uname.2 b/man2/uname.2
new file mode 100644
index 0000000..e84f3e7
--- /dev/null
+++ b/man2/uname.2
@@ -0,0 +1,134 @@
+.\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.\" 2007-07-05 mtk: Added details on underlying system call interfaces
+.\"
+.TH uname 2 2023-03-30 "Linux man-pages 6.05.01"
+.SH NAME
+uname \- get name and information about current kernel
+.SH LIBRARY
+Standard C library
+.RI ( libc ", " \-lc )
+.SH SYNOPSIS
+.nf
+.B #include <sys/utsname.h>
+.PP
+.BI "int uname(struct utsname *" buf );
+.fi
+.SH DESCRIPTION
+.BR uname ()
+returns system information in the structure pointed to by
+.IR buf .
+The
+.I utsname
+struct is defined in
+.IR <sys/utsname.h> :
+.PP
+.in +4n
+.EX
+struct utsname {
+ char sysname[]; /* Operating system name (e.g., "Linux") */
+ char nodename[]; /* Name within communications network
+ to which the node is attached, if any */
+ char release[]; /* Operating system release
+ (e.g., "2.6.28") */
+ char version[]; /* Operating system version */
+ char machine[]; /* Hardware type identifier */
+#ifdef _GNU_SOURCE
+ char domainname[]; /* NIS or YP domain name */
+#endif
+};
+.EE
+.in
+.PP
+The length of the arrays in a
+.I struct utsname
+is unspecified (see NOTES);
+the fields are terminated by a null byte (\[aq]\e0\[aq]).
+.SH RETURN VALUE
+On success, zero is returned.
+On error, \-1 is returned, and
+.I errno
+is set to indicate the error.
+.SH ERRORS
+.TP
+.B EFAULT
+.I buf
+is not valid.
+.SH VERSIONS
+The
+.I domainname
+member (the NIS or YP domain name) is a GNU extension.
+.PP
+The length of the fields in the struct varies.
+Some operating systems
+or libraries use a hardcoded 9 or 33 or 65 or 257.
+Other systems use
+.B SYS_NMLN
+or
+.B _SYS_NMLN
+or
+.B UTSLEN
+or
+.BR _UTSNAME_LENGTH .
+Clearly, it is a bad
+idea to use any of these constants; just use sizeof(...).
+SVr4 uses 257, "to support Internet hostnames"
+\[em] this is the largest value likely to be encountered in the wild.
+.SH STANDARDS
+POSIX.1-2008.
+.SH HISTORY
+POSIX.1-2001, SVr4, 4.4BSD.
+.SS C library/kernel differences
+Over time, increases in the size of the
+.I utsname
+structure have led to three successive versions of
+.BR uname ():
+.IR sys_olduname ()
+(slot
+.IR __NR_oldolduname ),
+.IR sys_uname ()
+(slot
+.IR __NR_olduname ),
+and
+.IR sys_newuname ()
+(slot
+.IR __NR_uname) .
+The first one
+.\" That was back before Linux 1.0
+used length 9 for all fields;
+the second
+.\" That was also back before Linux 1.0
+used 65;
+the third also uses 65 but adds the
+.I domainname
+field.
+The glibc
+.BR uname ()
+wrapper function hides these details from applications,
+invoking the most recent version of the system call provided by the kernel.
+.SH NOTES
+The kernel has the name, release, version, and supported machine type built in.
+Conversely, the
+.I nodename
+field is configured by the administrator to match the network
+(this is what the BSD historically calls the "hostname",
+and is set via
+.BR sethostname (2)).
+Similarly, the
+.I domainname
+field is set via
+.BR setdomainname (2).
+.PP
+Part of the utsname information is also accessible via
+.IR /proc/sys/kernel/ { ostype ,
+.IR hostname ,
+.IR osrelease ,
+.IR version ,
+.IR domainname }.
+.SH SEE ALSO
+.BR uname (1),
+.BR getdomainname (2),
+.BR gethostname (2),
+.BR uts_namespaces (7)