OSDN Git Service

(split) LDP: Update the version to 3.53 in PO files
[linuxjm/LDP_man-pages.git] / release / man2 / gethostname.2
1 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified 1995-07-22 by Michael Chastain <mec@duracef.shout.net>:
26 .\"   'gethostname' is real system call on Linux/Alpha.
27 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2000-06-04, 2001-12-15 by aeb
29 .\" Modified 2004-06-17 by mtk
30 .\" Modified 2008-11-27 by mtk
31 .\"
32 .\"*******************************************************************
33 .\"
34 .\" This file was generated with po4a. Translate the source file.
35 .\"
36 .\"*******************************************************************
37 .TH GETHOSTNAME 2 2010\-09\-26 Linux "Linux Programmer's Manual"
38 .SH 名前
39 gethostname, sethostname \- ホスト名の取得・設定をする
40 .SH 書式
41 \fB#include <unistd.h>\fP
42 .sp
43 \fBint gethostname(char *\fP\fIname\fP\fB, size_t \fP\fIlen\fP\fB);\fP
44 .br
45 \fBint sethostname(const char *\fP\fIname\fP\fB, size_t \fP\fIlen\fP\fB);\fP
46 .sp
47 .in -4n
48 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
49 .in
50 .sp
51 .ad l
52 .PD 0
53 \fBgethostname\fP():
54 .RS 4
55 glibc 2.12 以降: _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
56 .br
57 || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200112L
58 .RE
59 .br
60 \fBsethostname\fP():
61 .RS 4
62 _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE\ <\ 500)
63 .RE
64 .PD
65 .ad
66 .SH 説明
67 これらのシステムコールは、現在のプロセッサのホスト名を取得・変更するために 使用される。
68
69 \fBsethostname\fP()  は、ホスト名を、文字配列 \fIname\fP で指定された値に設定する。 引き数 \fIlen\fP には、 \fIname\fP
70 のバイト数を指定する (そのため、 \fIname\fP では文字列終端の NULL バイトは必要ない)。
71
72 \fBgethostname\fP()  は、NULL 終端されたホスト名を、 \fIlen\fP バイトの長さの文字配列 \fIname\fP に格納して返す。
73 NULL 終端されたホスト名が格納先のバッファよりも長い場合は、 ホスト名は切り詰められ、エラーは返されない (下記の「注意」の節を参照)。
74 POSIX.1\-2001 では、結果の切り詰めが発生した場合に、 返されたバッファに終端の NULL バイトが含まれているかどうかは 規定されていない。
75 .SH 返り値
76 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
77 .SH エラー
78 .TP 
79 \fBEFAULT\fP
80 \fIname\fP が不正なアドレスである。
81 .TP 
82 \fBEINVAL\fP
83 .\" Can't occur for gethostbyname() wrapper, since 'len' has an
84 .\" unsigned type; can occur for the underlying system call.
85 \fIlen\fP が負である。 \fBsethostname\fP()  において \fIlen\fP が許容された最大サイズを越えている。
86 .TP 
87 \fBENAMETOOLONG\fP
88 (glibc \fBgethostname\fP()  で)  \fIlen\fP が実際のホスト名の長さよりも小さい (glibc バージョン 2.1
89 より前では、この状況で \fBEINVAL\fP が使用される)。
90 .TP 
91 \fBEPERM\fP
92 \fBsethostname\fP()  において、呼び出した人が \fBCAP_SYS_ADMIN\fP ケーパビリティ (capability)
93 を持っていなかった。
94 .SH 準拠
95 SVr4, 4.4BSD (これらのインタフェースは 4.2BSD で初めて登場した)。 POSIX.1\-2001 では
96 \fBgethostname\fP()  については規定しているが、 \fBsethostname\fP()  は規定していない。
97 .SH 注意
98 SUSv2 では「ホスト名が 255 バイトに制限される」ことを保証している。 POSIX.1\-2001 では「ホスト名 (終端の NULL
99 バイトは含まない) が \fBHOST_NAME_MAX\fP バイトに制限される」ことを保証している。 Linux では、 \fBHOST_NAME_MAX\fP
100 は 64 に定義されており、 Linux 1.0 以降ではこれが上限となってきた (もっと古いカーネルでは 8 バイトの上限が適用されていた)。
101 .SS "glibc での注意"
102 GNU C ライブラリは、 \fBgethostname\fP()  システムコールを利用していない。その代わり、 \fBgethostname\fP()
103 をライブラリ関数として実装しており、 この関数は \fBuname\fP(2)  を呼び出し、 \fBuname\fP(2)  が返した \fInodename\fP
104 フィールド (の最大 \fIlen\fP バイト) を \fIname\fP にコピーする。 コピーを行った際に、この関数は \fInodename\fP の長さが
105 \fIlen\fP 以上かの確認を行い、 \fIlen\fP 以上の場合には \-1 を返し、 \fIerrno\fP に \fBENAMETOOLONG\fP を設定する。
106 この場合、返された \fIname\fP には終端の NULL バイトは含まれない。
107
108 .\" At least glibc 2.0 and 2.1, older versions not checked
109 バージョン 2.2 より前の glibc では、 \fInodename\fP の長さが \fIlen\fP 以上の場合の扱いが異なる; \fIlen\fP
110 以上の場合には、 \fIname\fP には何もコピーせず、関数は \-1 を返し、 \fIerrno\fP に \fBENAMETOOLONG\fP を設定する。
111 .SH 関連項目
112 \fBgetdomainname\fP(2), \fBsetdomainname\fP(2), \fBuname\fP(2)
113 .SH この文書について
114 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
115 である。プロジェクトの説明とバグ報告に関する情報は
116 http://www.kernel.org/doc/man\-pages/ に書かれている。