gethostname(2) | System Calls Manual | gethostname(2) |
NAAM
gethostname, sethostname - krijg/zet machinenaam
BIBLIOTHEEK
Standard C library (libc, -lc)
SAMENVATTING
#include <unistd.h>
int gethostname(char *name, size_t size); int sethostname(const char *name, size_t size);
gethostname():
_XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L || /* glibc 2.19 en eerder */ _BSD_SOURCE
sethostname():
Vanaf glibc 2.21: _DEFAULT_SOURCE In glibc 2.19 en 2.20: _DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500) Tot en met glibc 2.19: _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
BESCHRIJVING
Deze systeem aanroepen worden gebruikt om de machinenaam van het systeem op te vragen of te veranderen. Preciezer gezegd, ze werken op de machinenaam die geassocieerd is met de UTS naamruimte van het aanroepende proces.
sethostname() sets the hostname to the value given in the character array name. The size argument specifies the number of bytes in name. (Thus, name does not require a terminating null byte.)
gethostname() returns the null-terminated hostname in the character array name, which has a size of size bytes. If the null-terminated hostname is too large to fit, then the name is truncated, and no error is returned (but see VERSIONS below). POSIX.1 says that if such truncation occurs, then it is unspecified whether the returned buffer includes a terminating null byte.
EIND WAARDE
Bij succes wordt nul teruggegeven. Bij falen wordt -1 teruggegeven en wordt errno overeenkomstig gezet.
FOUTEN
- EFAULT
- naam is een ongeldig adres.
- EINVAL
- size is negative or, for sethostname(), size is larger than the maximum allowed size.
- ENAMETOOLONG
- (glibc gethostname()) size is smaller than the actual size. (Before glibc 2.1, glibc uses EINVAL for this case.)
- EPERM
- Met sethostname() had de aanroeper niet de benodigde CAP_SYS_ADMIN capaciteit in de gebruiker naamruimte geassocieerd met zijn UTS naamruimte (zie namespaces(7)).
VERSIES
SUSv2 garandeert dat "Machinenamen beperkt zijn tot 255 bytes". POSIX.1 garandeert dat "Machinenamen (exclusief het afsluitende NULL byte) beperkt zijn tot HOST_NAME_MAX bytes". Op Linux, is HOST_NAME_MAX is gedefinieerd met de waarde 64, hetgeen de limiet is geweest sinds Linux 1.0 (eerdere kernels kenden een limiet van 8 bytes).
C library/kernel verschillen
The GNU C library does not employ the gethostname() system call; instead, it implements gethostname() as a library function that calls uname(2) and copies up to size bytes from the returned nodename field into name. Having performed the copy, the function then checks if the length of the nodename was greater than or equal to size, and if it is, then the function returns -1 with errno set to ENAMETOOLONG; in this case, a terminating null byte is not included in the returned name.
VOLDOET AAN
- gethostname()
- POSIX.1-2008.
- sethostname()
- Geen.
GESCHIEDENIS
SVr4, 4.4BSD (deze functie verscheen voor het eerst in 4.2BSD).POSIX.1-2001 en POSIX.1-2008 bepalen gethostname(), maar niet sethostname().
Versions of glibc before glibc 2.2 handle the case where the length of the nodename was greater than or equal to size differently: nothing is copied into name and the function returns -1 with errno set to ENAMETOOLONG.
ZIE OOK
hostname(1), getdomainname(2), setdomainname(2), uname(2), uts_namespaces(7)
VERTALING
De Nederlandse vertaling van deze handleiding is geschreven door Jos Boersema <joshb@xs4all.nl>, Mario Blättermann <mario.blaettermann@gmail.com> en Luc Castermans <luc.castermans@gmail.com>
Deze vertaling is vrije documentatie; lees de GNU General Public License Version 3 of later over de Copyright-voorwaarden. Er is geen AANSPRAKELIJKHEID.
Indien U fouten in de vertaling van deze handleiding zou vinden, stuur een e-mail naar debian-l10n-dutch@lists.debian.org.
17 november 2024 | Linux man-pagina's 6.12 |