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 2009-01-13 "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)
62 _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE\ <\ 500)
69 .\"O respectively get or set a unique 32-bit identifier for the current machine.
70 .\"O The 32-bit identifier is intended to be unique among all Unix systems in
72 .\"O This normally resembles the Internet address for the local
73 .\"O machine, as returned by
74 .\"O .BR gethostbyname (3),
75 .\"O and thus usually never needs to be set.
79 ¤Ï¡¢¤½¤ì¤¾¤ì¡¢¸½ºß»ÈÍѤ·¤Æ¤¤¤ë¥Û¥¹¥È¤Ë¸ÇͤΠ32 ¥Ó¥Ã¥È¤Î¼±Ê̻ҤÎ
81 ¤³¤Î 32 ¥Ó¥Ã¥È¤Î¼±Ê̻Ҥϡ¢¸½ºß¸ºß¤·¤Æ¤¤¤ëÁ´¤Æ¤Î Unix ¥·¥¹¥Æ¥à
82 ¤ÎÃæ¤ÇÍ£°ì¤Ë¤Ê¤ë¤è¤¦¤Ë·è¤á¤é¤ì¤ë¡£Ä̾ï¤Ï
84 ¤Ë¤è¤êÊÖ¤µ¤ì¤ë¥í¡¼¥«¥ë¥Þ¥·¥ó¤Î Internet ¥¢¥É¥ì¥¹¤¬Âå¤ï¤ê¤Ë»ÈÍѤµ¤ì¡¢
85 ÉáÄ̤ϼ±Ê̻Ҥò¤¢¤¨¤ÆÀßÄꤹ¤ëɬÍפϤʤ¤¡£
89 .\"O call is restricted to the superuser.
91 ¤Ï¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤·¤«»ÈÍѤǤ¤Ê¤¤¡£
92 .\"O .SH "RETURN VALUE"
95 .\"O returns the 32-bit identifier for the current host as set by
96 .\"O .BR sethostid ().
100 ¤Ë¤è¤Ã¤ÆÀßÄꤵ¤ì¤¿¡¢¸½ºß»ÈÍѤ·¤Æ¤¤¤ë¥Û¥¹¥È¤Î 32 ¥Ó¥Ã¥È¤Î¼±Ê̻ҤÎÃͤòÊÖ¤¹¡£
103 .\"O .BR sethostid ()
104 .\"O returns 0; on error, \-1 is returned, and
106 .\"O is set to indicate the error.
110 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
112 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
115 .\"O .BR sethostid ()
116 .\"O can fail with the following errors:
118 ¤Ï°Ê²¼¤Î¥¨¥é¡¼¤Ç¼ºÇÔ¤¹¤ë²ÄǽÀ¤¬¤¢¤ë¡£
121 .\"O The caller did not have permission to write to the file used
122 .\"O to store the host ID.
123 ¸Æ¤Ó½Ð¤·¸µ¤¬¥Û¥¹¥È ID ¤òÊݸ¤¹¤ë¤Î¤Ë»ÈÍѤµ¤ì¤ë¥Õ¥¡¥¤¥ë¤Ø¤Î
124 ½ñ¤¹þ¤ßµö²Ä¤ò»ý¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
127 .\"O The calling process's effective user or group ID is not the same
128 .\"O as its corresponding real ID.
129 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¼Â¸ú UID/GID ¤¬Âбþ¤¹¤ë¼Â UID/GID ¤ÈƱ¤¸¤Ç¤Ï¤Ê¤¤¡£
130 .\"O .SH "CONFORMING TO"
132 .\"O 4.2BSD; these functions were dropped in 4.4BSD.
134 .\"O .BR gethostid ()
136 .\"O .BR sethostid ().
137 .\"O POSIX.1-2001 specifies
138 .\"O .BR gethostid ()
140 .\"O .BR sethostid ().
141 4.2BSD¡£4.4BSD ¤Ç¤Ï¤³¤ì¤é¤Î´Ø¿ô¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£
154 .\"O In the glibc implementation, the
156 .\"O is stored in the file
157 .\"O .IR /etc/hostid .
158 .\"O (In glibc versions before 2.2, the file
159 .\"O .I /var/adm/hostid
166 (¥Ð¡¼¥¸¥ç¥ó 2.2 ¤è¤êÁ°¤Î glibc ¤Ç¤Ï¡¢
169 .\" libc5 used /etc/hostid; libc4 didn't have these functions
171 .\"O In the glibc implementation, if
172 .\"O .BR gethostid ()
173 .\"O cannot open the file containing the host ID,
174 .\"O then it obtains the hostname using
175 .\"O .BR gethostname (2),
176 .\"O passes that hostname to
177 .\"O .BR gethostbyname_r (3)
178 .\"O in order to obtain the host's IPv4 address,
179 .\"O and returns a value obtained by bit-twiddling the IPv4 address.
180 .\"O (This value may not be unique.)
181 glibc ¤Î¼ÂÁõ¤Ç¤Ï¡¢¥Û¥¹¥È ID ¤òÊݸ¤·¤¿¥Õ¥¡¥¤¥ë¤ò
182 ¥ª¡¼¥×¥ó¤Ç¤¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
186 ¤ò»È¤Ã¤Æ¥Û¥¹¥È̾¤òÆþ¼ê¤·¡¢¤½¤Î¥Û¥¹¥È̾¤ò
187 .BR gethostbyname_r (3)
188 ¤ËÅϤ·¥Û¥¹¥È¤Î IPv4 ¥¢¥É¥ì¥¹¤ò¼èÆÀ¤·¤Æ¡¢
189 ¤½¤Î IPv4 ¥¢¥É¥ì¥¹¤Î¥Ó¥Ã¥ÈÆþ¤ìÂؤ¨¤ò¹Ô¤Ã¤¿ÃͤòÊÖ¤¹¡£
192 .\"O It is impossible to ensure that the identifier is globally unique.
193 ¼±Ê̻Ҥ¬À¤³¦Ãæ¤Ç°ì°Õ¤Ç¤¢¤ë¤³¤È¤òÊݾڤ¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
197 .BR gethostbyname (3)