uname

Section: System Calls (2)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

uname - 現在稼働中のカーネルについての名前と情報を得る  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <sys/utsname.h>

int uname(struct utsname *buf);
 

説明

uname() は buf で指される構造体にシステム情報を返す。 utsname 構造体は <sys/utsname.h> で以下のように定義されている。

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
};

The length of the arrays in a struct utsname is unspecified (see VERSIONS and HISTORY); the fields are terminated by a null byte ('\0').  

返り値

成功すると、0 を返す。 エラーの場合、-1 を返し、 errno にエラーを示す値を設定する。  

エラー

EFAULT
buf が有効でない。
 

バージョン

domainname メンバー (NIS または YP ドメイン名) は GNU の拡張である。

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 SYS_NMLN or _SYS_NMLN or UTSLEN or _UTSNAME_LENGTH. Clearly, it is a bad idea to use any of these constants; just use sizeof(...). SVr4 uses 257, "to support Internet hostnames" ---this is the largest value likely to be encountered in the wild---.  

標準規格

POSIX.1-2024.  

歴史

POSIX.1-2001, SVr4, 4.4BSD.  

C ライブラリとカーネルの違い

時間の経過とともに、 utsname 構造体のサイズが大きくなり、この影響で uname() には 3つのバージョンが存在する: sys_olduname() (スロットは __NR_oldolduname)、 sys_uname() (スロットは __NR_olduname)、 sys_newuname() (スロットは __NR_uname)。 sys_olduname() はすべてのフィールドが長さ 9 を使っていた。 sys_uname() は長さ 65 を使っていた。 sys_newuname() も長さ 65 を使っているが、 domainname フィールドが追加されている。 glibc の uname() ラッパー関数は、これらの詳細をアプリケーションから隠蔽し、 カーネルが提供しているシステムコールのうち最新のバージョンを起動する。  

注意

The kernel has the name, release, version, and supported machine type built in. Conversely, the nodename field is configured by the administrator to match the network (this is what the BSD historically calls the "hostname", and is set via sethostname(2)). Similarly, the domainname field is set via setdomainname(2).

utsname の情報は、 /proc/sys/kernel/{ostype, hostname, osrelease, version, domainname} を使ってアクセスすることもできる。  

関連項目


 uname(1), getdomainname(2), gethostname(2), uts_namespaces(7)


 

Index

名前
ライブラリ
書式
説明
返り値
エラー
バージョン
標準規格
歴史
C ライブラリとカーネルの違い
注意
関連項目

This document was created by man2html, using the manual pages.