OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / draft / man2 / uname.2
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" 2007-07-05 mtk: Added details on underlying system call interfaces
24 .\"
25 .\" Japanese Version Copyright (c) 1997 SUTO, Mitsuaki
26 .\"         all rights reserved.
27 .\" Translated Thu Jun 26 21:23:19 JST 1997
28 .\"         by SUTO, Mitsuaki <suto@av.crl.sony.co.jp>
29 .\" Updated & Modified Thu Feb 14 21:53:41 JST 2002
30 .\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
31 .\" Updated 2007-09-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.64
32 .\"
33 .TH UNAME 2 2008-12-03 "Linux" "Linux Programmer's Manual"
34 .\"O .SH NAME
35 .SH 名前
36 .\"O uname \- get name and information about current kernel
37 uname \- 現在稼働中のカーネルについての名前と情報を得る
38 .\"O .SH SYNOPSIS
39 .SH 書式
40 .B #include <sys/utsname.h>
41 .sp
42 .BI "int uname(struct utsname *" buf );
43 .\"O .SH DESCRIPTION
44 .SH 説明
45 .\"O .BR uname ()
46 .\"O returns system information in the structure pointed to by
47 .\"O .IR buf .
48 .BR uname ()
49
50 .I buf
51 で指される構造体にシステム情報を返す。
52 .\"O The
53 .\"O .I utsname
54 .\"O struct is defined in
55 .\"O .IR <sys/utsname.h> :
56 .I utsname
57 構造体は
58 .I <sys/utsname.h>
59 で以下のように定義されている。
60 .in +4n
61 .nf
62
63 struct utsname {
64 .\"O     char sysname[];    /* Operating system name (e.g., "Linux") */
65 .\"O     char nodename[];   /* Name within "some implementation-defined
66 .\"O                           network" */
67 .\"O     char release[];    /* OS release (e.g., "2.6.28") */
68 .\"O     char version[];    /* OS version */
69 .\"O     char machine[];    /* Hardware identifier */
70     char sysname[];    /* OS の名前 (例: "Linux") */
71     char nodename[];   /* 「実装時に定義された、何らかの
72                           ネットワーク」におけるマシン名 */
73     char release[];    /* OS のリリース (例: "2.6.28") */
74     char version[];    /* OS のバージョン */
75     char machine[];    /* ハードウェア識別子 */
76 #ifdef _GNU_SOURCE
77 .\"O     char domainname[]; /* NIS or YP domain name */
78     char domainname[]; /* NIS や YP のドメイン名 */
79 #endif
80 };
81
82 .fi
83 .in
84 .\"O The length of the arrays in a
85 .\"O .I struct utsname
86 .\"O is unspecified (see NOTES);
87 .\"O the fields are terminated by a null byte (\(aq\\0\(aq).
88 .I struct utsname
89 にある配列の長さは指定されていない (「注意」の節を参照)。
90 フィールドは NULL バイト (\(aq\\0\(aq) で終端される。
91 .\"O .SH "RETURN VALUE"
92 .SH 返り値
93 .\"O On success, zero is returned.
94 .\"O On error, \-1 is returned, and
95 .\"O .I errno
96 .\"O is set appropriately.
97 成功した場合 0 が返る。失敗した場合 \-1 が返り、
98 .I errno
99 がエラーの内容に従って設定される。
100 .\"O .SH ERRORS
101 .SH エラー
102 .TP
103 .B EFAULT
104 .\"O .I buf
105 .\"O is not valid.
106 .I buf
107 が有効でない。
108 .\"O .SH "CONFORMING TO"
109 .SH 準拠
110 SVr4, POSIX.1-2001.
111 .\"O There is no
112 .\"O .BR uname ()
113 .\"O call in 4.3BSD.
114 4.3BSD には
115 .BR uname ()
116 コールがない。
117 .PP
118 .\"O The
119 .\"O .I domainname
120 .\"O member (the NIS or YP domain name) is a GNU extension.
121 .I domainname
122 メンバー (NIS または YP ドメイン名) は GNU の拡張である。
123 .\"O .SH NOTES
124 .SH 注意
125 .\"O This is a system call, and the operating system presumably knows
126 .\"O its name, release and version.
127 .\"O It also knows what hardware it runs on.
128 .\"O So, four of the fields of the struct are meaningful.
129 これはシステムコールであり、OS は名前・リリース・バージョンなどを
130 たぶん分かっているだろう。
131 さらにそれが稼働しているハードウェアも分かっているだろう。
132 よって構造体の 4 つのフィールドには意味がある。
133 .\"O On the other hand, the field \fInodename\fP is meaningless:
134 .\"O it gives the name of the present machine in some undefined
135 .\"O network, but typically machines are in more than one network
136 .\"O and have several names.
137 .\"O Moreover, the kernel has no way of knowing
138 .\"O about such things, so it has to be told what to answer here.
139 .\"O The same holds for the additional \fIdomainname\fP field.
140 一方、\fInodename\fP フィールドには意味がない:
141 このフィールドは現在のマシンの (定義されていない)
142 どこかのネットワークにおける名前を与えるが、
143 通常マシンは複数のネットワークに属し、複数の名前を持つ。
144 さらに、カーネルはこのような情報を知る術を持たないので、
145 ここでの答えは前もって教えてやらなければならない。
146 これは追加フィールドである \fIdomainname\fP についても同様である。
147 .LP
148 .\"O To this end Linux uses the system calls
149 .\"O .BR sethostname (2)
150 .\"O and
151 .\"O .BR setdomainname (2).
152 このため Linux ではシステムコール
153 .BR sethostname (2)
154
155 .BR setdomainname (2)
156 が使われる。
157 .\"O Note that there is no standard that says that the hostname set by
158 .\"O .BR sethostname (2)
159 .\"O is the same string as the \fInodename\fP field of the struct returned by
160 .\"O .BR uname ()
161 .RB 「 sethostname (2)
162 で設定されるホスト名は、
163 .BR uname ()
164 で返される構造体の \fInodename\fP フィールドと同じ文字列である」
165 と規定している標準規格はない
166 .\"O (indeed, some systems allow a 256-byte hostname and an 8-byte nodename),
167 .\"O but this is true on Linux.
168 .\"O The same holds for
169 .\"O .BR setdomainname (2)
170 .\"O and the \fIdomainname\fP field.
171 (実際、256 バイトのホスト名と 8 バイトのノード名を許可しているシステムもある)。
172 しかし、Linux では同じ文字列が返される。
173 .BR setdomainname (2)
174 と \fIdomainname\fP フィールドについても同じことが成り立つ。
175 .LP
176 .\"O The length of the fields in the struct varies.
177 .\"O Some operating systems
178 .\"O or libraries use a hardcoded 9 or 33 or 65 or 257.
179 .\"O Other systems use
180 .\"O .B SYS_NMLN
181 .\"O or
182 .\"O .B _SYS_NMLN
183 .\"O or
184 .\"O .B UTSLEN
185 .\"O or
186 .\"O .BR _UTSNAME_LENGTH .
187 .\"O Clearly, it is a bad
188 .\"O idea to use any of these constants; just use sizeof(...).
189 .\"O Often 257 is chosen in order to have room for an internet hostname.
190 構造体のフィールドの長さはさまざまである。
191 OS やライブラリの中には、
192 ハードコードされた 9, 33, 65, 257 などの値を使っているものもある。
193 また
194 .BR SYS_NMLN ,
195 .BR _SYS_NMLN ,
196 .BR UTSLEN ,
197 .B _UTSNAME_LENGTH
198 などを使っているシステムもある。
199 はっきり言って、これらの定数を使うのは悪い考え方であり、
200 sizeof(...) を使うべきである。
201 インターネットホスト名で使う領域を持たせるために、
202 257 が選ばれることが多い。
203 .LP
204 .\"O Part of the utsname information is also accessible via
205 .\"O .IR /proc/sys/kernel/ { ostype ,
206 .\"O .IR hostname ,
207 .\"O .IR osrelease ,
208 .\"O .IR version ,
209 .\"O .IR domainname }.
210 utsname の情報は、
211 .IR /proc/sys/kernel/ { ostype ,
212 .IR hostname ,
213 .IR osrelease ,
214 .IR version ,
215 .IR domainname }
216 を使ってアクセスすることもできる。
217 .\"O .SS Underlying kernel interface
218 .SS 背後のカーネル・インタフェース
219 .LP
220 .\"O Over time, increases in the size of the
221 .\"O .I utsname
222 .\"O structure have led to three successive versions of
223 .\"O .BR uname ():
224 時間の経過とともに、
225 .I utsname
226 構造体のサイズが大きくなり、この影響で
227 .BR uname ()
228 には 3つのバージョンが存在する:
229 .\"O .IR sys_olduname ()
230 .\"O (slot
231 .\"O .IR __NR_oldolduname ),
232 .\"O .IR sys_uname ()
233 .\"O (slot
234 .\"O .IR __NR_olduname ),
235 .\"O and
236 .\"O .IR sys_newuname ()
237 .\"O (slot
238 .\"O .IR __NR_uname) .
239 .IR sys_olduname ()
240 (スロットは
241 .IR __NR_oldolduname )、
242 .IR sys_uname ()
243 (スロットは
244 .IR __NR_olduname )、
245 .IR sys_newuname ()
246 (スロットは
247 .IR __NR_uname )。
248 .\"O The first one
249 .\"O .\" That was back before Linux 1.0
250 .\"O used length 9 for all fields;
251 .\"O the second
252 .\"O .\" That was also back before Linux 1.0
253 .\"O used 65;
254 .\"O the third also uses 65 but adds the \fIdomainname\fP field.
255 .IR sys_olduname ()
256 .\" これは Linux 1.0 より前に遡る話である。
257 はすべてのフィールドが長さ 9 を使っていた。
258 .IR sys_uname ()
259 .\" これも Linux 1.0 より前に遡る話である。
260 は長さ 65 を使っていた。
261 .IR sys_newuname ()
262 も長さ 65 を使っているが、
263 \fIdomainname\fP フィールドが追加されている。
264 .\"O The glibc
265 .\"O .BR uname ()
266 .\"O wrapper function hides these details from applications,
267 .\"O invoking the most recent version of the system call provided by the kernel.
268 glibc の
269 .BR uname ()
270 ラッパー関数は、これらの詳細をアプリケーションから隠蔽し、
271 カーネルが提供しているシステムコールのうち最新のバージョンを起動する。
272 .\"O .SH "SEE ALSO"
273 .SH 関連項目
274 .BR uname (1),
275 .BR getdomainname (2),
276 .BR gethostname (2)