2004-11-03 13:51:07 +00:00
|
|
|
.\" Hey Emacs! This file is -*- nroff -*- source.
|
|
|
|
.\"
|
|
|
|
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" Updated with additions from Mitchum DSouza <m.dsouza@mrc-apu.cam.ac.uk>
|
|
|
|
.\" Portions Copyright 1993 Mitchum DSouza <m.dsouza@mrc-apu.cam.ac.uk>
|
|
|
|
.\"
|
|
|
|
.\" Modified Tue Oct 22 00:22:35 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
|
_exit.2, brk.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, getdtablesize.2, gethostname.2, getpagesize.2, getsid.2, killpg.2, mknod.2, mknodat.2, poll.2, posix_fadvise.2, pread.2, readlink.2, setpgid.2, setreuid.2, sigaltstack.2, stat.2, symlink.2, sync.2, truncate.2, vfork.2, wait.2, wait4.2, a64l.3, abs.3, acos.3, acosh.3, asin.3, asinh.3, atan.3, atan2.3, atoi.3, cbrt.3, ceil.3, copysign.3, cosh.3, dirfd.3, div.3, ecvt.3, erf.3, erfc.3, exp.3, exp2.3, fabs.3, fdim.3, ffs.3, floor.3, fma.3, fmax.3, fmin.3, fmod.3, fpclassify.3, frexp.3, ftw.3, fwide.3, gcvt.3, getcwd.3, getdate.3, getgrent.3, gethostid.3, getpass.3, getpwent.3, getsubopt.3, getw.3, hypot.3, ilogb.3, index.3, isalpha.3, isgreater.3, iswblank.3, j0.3, ldexp.3, lockf.3, log.3, log10.3, log1p.3, logb.3, lrint.3, lround.3, mkstemp.3, mktemp.3, modf.3, mq_receive.3, mq_send.3, nan.3, nextafter.3, posix_fallocate.3, posix_memalign.3, printf.3, qecvt.3, random.3, realpath.3, remainder.3, remquo.3, rint.3, round.3, scalb.3, scalbln.3, scanf.3, siginterrupt.3, signbit.3, sigset.3, sinh.3, sqrt.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strfry.3, strpbrk.3, strsep.3, strspn.3, strstr.3, strtod.3, strtok.3, strtol.3, strtoul.3, strxfrm.3, tanh.3, tgamma.3, trunc.3, ttyslot.3, ualarm.3, usleep.3, wprintf.3, armscii-8.7, cp1251.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-3.7, iso_8859-5.7, iso_8859-6.7, iso_8859-8.7, koi8-u.7: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 17:19:13 +00:00
|
|
|
.TH GETHOSTID 3 2010-09-20 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
gethostid, sethostid \- get or set the unique identifier of the current host
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <unistd.h>
|
|
|
|
.sp
|
|
|
|
.B long gethostid(void);
|
|
|
|
.br
|
|
|
|
.BI "int sethostid(long " hostid );
|
2007-07-08 12:11:40 +00:00
|
|
|
.sp
|
|
|
|
.in -4n
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
.in
|
|
|
|
.sp
|
|
|
|
.ad l
|
2010-09-18 09:08:00 +00:00
|
|
|
.br
|
2010-10-03 15:36:47 +00:00
|
|
|
.BR gethostid ():
|
2010-09-18 09:08:00 +00:00
|
|
|
.RS 4
|
brk.2, chroot.2, faccessat.2, fchmodat.2, fchownat.2, fstatat.2, futimesat.2, getdtablesize.2, getpagesize.2, getsid.2, linkat.2, mkdirat.2, mknodat.2, openat.2, pread.2, readlinkat.2, renameat.2, setpgid.2, sigaltstack.2, symlinkat.2, sync.2, timer_create.2, timer_delete.2, timer_getoverrun.2, timer_settime.2, unlinkat.2, utimensat.2, vfork.2, acosh.3, asinh.3, atanh.3, dirfd.3, dprintf.3, ecvt.3, expm1.3, fexecve.3, fmemopen.3, gcvt.3, getcwd.3, gethostid.3, getpass.3, getsubopt.3, getw.3, mbsnrtowcs.3, mkfifoat.3, mkstemp.3, mktemp.3, opendir.3, posix_memalign.3, rint.3, siginterrupt.3, stpcpy.3, stpncpy.3, strdup.3, strerror.3, strnlen.3, strsignal.3, strtol.3, strtoul.3, ualarm.3, usleep.3, wcpcpy.3, wcpncpy.3, wcscasecmp.3, wcsdup.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 06:02:38 +00:00
|
|
|
_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
|
|
|
|
_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
|
2010-09-18 09:08:00 +00:00
|
|
|
.RE
|
2007-07-08 12:11:40 +00:00
|
|
|
.BR sethostid ():
|
2010-09-18 09:08:00 +00:00
|
|
|
.RS 4
|
2007-07-08 12:11:40 +00:00
|
|
|
_BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE\ <\ 500)
|
2010-09-18 09:08:00 +00:00
|
|
|
.RE
|
2007-07-08 12:11:40 +00:00
|
|
|
.ad b
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
2009-01-12 18:21:35 +00:00
|
|
|
.BR gethostid ()
|
|
|
|
and
|
|
|
|
.BR sethostid ()
|
|
|
|
respectively get or set a unique 32-bit identifier for the current machine.
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
The 32-bit identifier is intended to be unique among all UNIX systems in
|
2007-04-12 22:42:49 +00:00
|
|
|
existence.
|
|
|
|
This normally resembles the Internet address for the local
|
2004-11-03 13:51:07 +00:00
|
|
|
machine, as returned by
|
|
|
|
.BR gethostbyname (3),
|
|
|
|
and thus usually never needs to be set.
|
|
|
|
|
|
|
|
The
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR sethostid ()
|
2004-11-03 13:51:07 +00:00
|
|
|
call is restricted to the superuser.
|
|
|
|
.SH "RETURN VALUE"
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR gethostid ()
|
2004-11-03 13:51:07 +00:00
|
|
|
returns the 32-bit identifier for the current host as set by
|
2007-11-24 10:10:39 +00:00
|
|
|
.BR sethostid ().
|
2009-01-12 18:22:30 +00:00
|
|
|
|
|
|
|
On success,
|
|
|
|
.BR sethostid ()
|
|
|
|
returns 0; on error, \-1 is returned, and
|
|
|
|
.I errno
|
|
|
|
is set to indicate the error.
|
2009-01-12 18:38:09 +00:00
|
|
|
.SH ERRORS
|
|
|
|
.BR sethostid ()
|
|
|
|
can fail with the following errors:
|
|
|
|
.TP
|
|
|
|
.B EACCES
|
|
|
|
The caller did not have permission to write to the file used
|
|
|
|
to store the host ID.
|
|
|
|
.TP
|
|
|
|
.B EPERM
|
|
|
|
The calling process's effective user or group ID is not the same
|
|
|
|
as its corresponding real ID.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "CONFORMING TO"
|
2006-08-03 13:57:17 +00:00
|
|
|
4.2BSD; these functions were dropped in 4.4BSD.
|
2007-04-12 22:42:49 +00:00
|
|
|
SVr4 includes
|
2006-08-03 13:57:17 +00:00
|
|
|
.BR gethostid ()
|
|
|
|
but not
|
|
|
|
.BR sethostid ().
|
2007-04-12 22:42:49 +00:00
|
|
|
POSIX.1-2001 specifies
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR gethostid ()
|
2004-11-03 13:51:07 +00:00
|
|
|
but not
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR sethostid ().
|
2007-06-10 18:08:27 +00:00
|
|
|
.SH NOTES
|
2009-01-12 18:43:44 +00:00
|
|
|
In the glibc implementation, the
|
|
|
|
.I hostid
|
|
|
|
is stored in the file
|
|
|
|
.IR /etc/hostid .
|
|
|
|
(In glibc versions before 2.2, the file
|
|
|
|
.I /var/adm/hostid
|
|
|
|
was used.)
|
|
|
|
.\" libc5 used /etc/hostid; libc4 didn't have these functions
|
|
|
|
|
2007-06-10 18:08:27 +00:00
|
|
|
In the glibc implementation, if
|
|
|
|
.BR gethostid ()
|
2009-01-12 18:43:44 +00:00
|
|
|
cannot open the file containing the host ID,
|
2008-06-27 03:37:56 +00:00
|
|
|
then it obtains the hostname using
|
2007-06-10 18:08:27 +00:00
|
|
|
.BR gethostname (2),
|
2008-06-27 03:37:56 +00:00
|
|
|
passes that hostname to
|
2007-06-11 20:36:00 +00:00
|
|
|
.BR gethostbyname_r (3)
|
2007-06-10 18:08:27 +00:00
|
|
|
in order to obtain the host's IPv4 address,
|
|
|
|
and returns a value obtained by bit-twiddling the IPv4 address.
|
|
|
|
(This value may not be unique.)
|
2009-01-12 18:18:52 +00:00
|
|
|
.SH BUGS
|
|
|
|
It is impossible to ensure that the identifier is globally unique.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR hostid (1),
|
|
|
|
.BR gethostbyname (3)
|