1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Updated with additions from Mitchum DSouza <m.dsouza@mrc-apu.cam.ac.uk>
26 .\" Portions Copyright 1993 Mitchum DSouza <m.dsouza@mrc-apu.cam.ac.uk>
28 .\" Modified Tue Oct 22 00:22:35 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
30 .\" (Previously this file is gethostid.2)
31 .\" Japanese Version Copyright (c) 1997 SUTO, Mitsuaki
32 .\" all rights reserved.
33 .\" Translated 1997-06-27, SUTO, Mitsuaki <suto@av.crl.sony.co.jp>
34 .\" Modified 1999-05-21, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
36 .\" (Move to section 3 in LDP v3.16 since the interfaces are purely glibc)
37 .\" Updated 2009-01-16, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.16
39 .TH GETHOSTID 3 2010-09-20 "Linux" "Linux Programmer's Manual"
42 .\"O gethostid, sethostid \- get or set the unique identifier of the current host
43 gethostid, sethostid \- ¸½ºß¤Î¥Û¥¹¥È¤Î¸Çͤμ±Ê̻Ҥò¼èÆÀ/ÀßÄꤹ¤ë
46 .B #include <unistd.h>
48 .B long gethostid(void);
50 .BI "int sethostid(long " hostid );
53 .\"O Feature Test Macro Requirements for glibc (see
54 .\"O .BR feature_test_macros (7)):
55 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
56 .RB ( feature_test_macros (7)
64 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
65 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
69 _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE\ <\ 500)
77 .\"O respectively get or set a unique 32-bit identifier for the current machine.
78 .\"O The 32-bit identifier is intended to be unique among all UNIX systems in
80 .\"O This normally resembles the Internet address for the local
81 .\"O machine, as returned by
82 .\"O .BR gethostbyname (3),
83 .\"O and thus usually never needs to be set.
87 ¤Ï¡¢¤½¤ì¤¾¤ì¡¢¸½ºß»ÈÍѤ·¤Æ¤¤¤ë¥Û¥¹¥È¤Ë¸ÇͤΠ32 ¥Ó¥Ã¥È¤Î¼±Ê̻ҤÎ
89 ¤³¤Î 32 ¥Ó¥Ã¥È¤Î¼±Ê̻Ҥϡ¢¸½ºß¸ºß¤·¤Æ¤¤¤ëÁ´¤Æ¤Î UNIX ¥·¥¹¥Æ¥à
90 ¤ÎÃæ¤ÇÍ£°ì¤Ë¤Ê¤ë¤è¤¦¤Ë·è¤á¤é¤ì¤ë¡£Ä̾ï¤Ï
92 ¤Ë¤è¤êÊÖ¤µ¤ì¤ë¥í¡¼¥«¥ë¥Þ¥·¥ó¤Î Internet ¥¢¥É¥ì¥¹¤¬Âå¤ï¤ê¤Ë»ÈÍѤµ¤ì¡¢
93 ÉáÄ̤ϼ±Ê̻Ҥò¤¢¤¨¤ÆÀßÄꤹ¤ëɬÍפϤʤ¤¡£
97 .\"O call is restricted to the superuser.
99 ¤Ï¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤·¤«»ÈÍѤǤ¤Ê¤¤¡£
100 .\"O .SH "RETURN VALUE"
102 .\"O .BR gethostid ()
103 .\"O returns the 32-bit identifier for the current host as set by
104 .\"O .BR sethostid ().
108 ¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤¿¡¢¸½ºß»ÈÍѤ·¤Æ¤¤¤ë¥Û¥¹¥È¤Î 32 ¥Ó¥Ã¥È¤Î¼±Ê̻ҤÎÃͤòÊÖ¤¹¡£
111 .\"O .BR sethostid ()
112 .\"O returns 0; on error, \-1 is returned, and
114 .\"O is set to indicate the error.
118 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
120 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
123 .\"O .BR sethostid ()
124 .\"O can fail with the following errors:
126 ¤Ï°Ê²¼¤Î¥¨¥é¡¼¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ¤¬¤¢¤ë¡£
129 .\"O The caller did not have permission to write to the file used
130 .\"O to store the host ID.
131 ¸Æ¤Ó½Ð¤·¸µ¤¬¥Û¥¹¥È ID ¤òÊݸ¤¹¤ë¤Î¤Ë»ÈÍѤµ¤ì¤ë¥Õ¥¡¥¤¥ë¤Ø¤Î
132 ½ñ¤¹þ¤ßµö²Ä¤ò»ý¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
135 .\"O The calling process's effective user or group ID is not the same
136 .\"O as its corresponding real ID.
137 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¼Â¸ú UID/GID ¤¬Âбþ¤¹¤ë¼Â UID/GID ¤ÈƱ¤¸¤Ç¤Ï¤Ê¤¤¡£
138 .\"O .SH "CONFORMING TO"
140 .\"O 4.2BSD; these functions were dropped in 4.4BSD.
142 .\"O .BR gethostid ()
144 .\"O .BR sethostid ().
145 .\"O POSIX.1-2001 specifies
146 .\"O .BR gethostid ()
148 .\"O .BR sethostid ().
149 4.2BSD¡£4.4BSD ¤Ç¤Ï¤³¤ì¤é¤Î´Ø¿ô¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£
162 .\"O In the glibc implementation, the
164 .\"O is stored in the file
165 .\"O .IR /etc/hostid .
166 .\"O (In glibc versions before 2.2, the file
167 .\"O .I /var/adm/hostid
174 (¥Ð¡¼¥¸¥ç¥ó 2.2 ¤è¤êÁ°¤Î glibc ¤Ç¤Ï¡¢
177 .\" libc5 used /etc/hostid; libc4 didn't have these functions
179 .\"O In the glibc implementation, if
180 .\"O .BR gethostid ()
181 .\"O cannot open the file containing the host ID,
182 .\"O then it obtains the hostname using
183 .\"O .BR gethostname (2),
184 .\"O passes that hostname to
185 .\"O .BR gethostbyname_r (3)
186 .\"O in order to obtain the host's IPv4 address,
187 .\"O and returns a value obtained by bit-twiddling the IPv4 address.
188 .\"O (This value may not be unique.)
189 glibc ¤Î¼ÂÁõ¤Ç¤Ï¡¢¥Û¥¹¥È ID ¤òÊݸ¤·¤¿¥Õ¥¡¥¤¥ë¤ò
190 ¥ª¡¼¥×¥ó¤Ç¤¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
194 ¤ò»È¤Ã¤Æ¥Û¥¹¥È̾¤òÆþ¼ê¤·¡¢¤½¤Î¥Û¥¹¥È̾¤ò
195 .BR gethostbyname_r (3)
196 ¤ËÅϤ·¥Û¥¹¥È¤Î IPv4 ¥¢¥É¥ì¥¹¤ò¼èÆÀ¤·¤Æ¡¢
197 ¤½¤Î IPv4 ¥¢¥É¥ì¥¹¤Î¥Ó¥Ã¥ÈÆþ¤ìÂؤ¨¤ò¹Ô¤Ã¤¿ÃͤòÊÖ¤¹¡£
200 .\"O It is impossible to ensure that the identifier is globally unique.
201 ¼±Ê̻Ҥ¬À¤³¦Ãæ¤Ç°ì°Õ¤Ç¤¢¤ë¤³¤È¤òÊݾڤ¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
205 .BR gethostbyname (3)