.\" -*- coding: UTF-8 -*- .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\" Modified 1995-07-22 by Michael Chastain : .\" 'gethostname' is real system call on Linux/Alpha. .\" Modified 1997-01-31 by Eric S. Raymond .\" Modified 2000-06-04, 2001-12-15 by aeb .\" Modified 2004-06-17 by mtk .\" Modified 2008-11-27 by mtk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH gethostname 2 "17 listopada 2024 r." "Linux man\-pages 6.12" .SH NAZWA gethostname, sethostname \- pobiera/ustawia nazwę stacji .SH BIBLIOTEKA Standardowa biblioteka C (\fIlibc\fP,\ \fI\-lc\fP) .SH SKŁADNIA .nf \fB#include \fP .P \fBint gethostname(char *\fP\fIname\fP\fB, size_t \fP\fIsize\fP\fB);\fP \fBint sethostname(const char *\fP\fIname\fP\fB, size_t \fP\fIsize\fP\fB);\fP .fi .P .RS -4 Wymagane ustawienia makr biblioteki glibc (patrz \fBfeature_test_macros\fP(7)): .RE .P \fBgethostname\fP(): .nf .\" The above is something of a simplification .\" also before glibc 2.3 there was a bit churn _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L || /* glibc 2.19 i wcześniejsze */ _BSD_SOURCE .fi .P \fBsethostname\fP(): .nf .\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 Od glibc 2.21: _DEFAULT_SOURCE W glibc 2.19 i 2.20: _DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500) Do glibc 2.19 włącznie: _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500) .fi .SH OPIS Wywołania systemowe służą do uzyskania dostępu lub zmiany systemowej nazwy komputera. Mówiąc precyzyjniej, działają na nazwie komputera, związanej z przestrzenią nazw UTS procesu wywołującego. .P \fBsethostname\fP() sets the hostname to the value given in the character array \fIname\fP. The \fIsize\fP argument specifies the number of bytes in \fIname\fP. (Thus, \fIname\fP does not require a terminating null byte.) .P \fBgethostname\fP() returns the null\-terminated hostname in the character array \fIname\fP, which has a size of \fIsize\fP 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. .SH "WARTOŚĆ ZWRACANA" Po pomyślnym zakończeniu zwracane jest zero. Po błędzie zwracane jest \-1 i ustawiane \fIerrno\fP, wskazując błąd. .SH BŁĘDY .TP \fBEFAULT\fP \fIname\fP jest nieprawidłowym adresem. .TP \fBEINVAL\fP .\" Can't occur for gethostbyname() wrapper, since 'size' has an .\" unsigned type; can occur for the underlying system call. \fIsize\fP is negative or, for \fBsethostname\fP(), \fIsize\fP is larger than the maximum allowed size. .TP \fBENAMETOOLONG\fP (glibc \fBgethostname\fP()) \fIsize\fP is smaller than the actual size. (Before glibc 2.1, glibc uses \fBEINVAL\fP for this case.) .TP \fBEPERM\fP W przypadku \fBsethostname\fP(), wywołujący nie posiadał przywileju (ang. capability) \fBCAP_SYS_ADMIN\fP w przestrzeni nazw użytkownika związanej z jego przestrzenią nazw UTS (zob. \fBnamespaces\fP(7)). .SH WERSJE SUSv2 gwarantuje, że \[Bq]nazwy stacji są ograniczone do 255 bajtów\[rq]. POSIX 1003.1\-2001 gwarantuje, że \[Bq]nazwy stacji (bez kończącego NUL) są ograniczone do \fBHOST_NAME_MAX\fP bajtów\[rq]. W Linuksie \fBHOST_NAME_MAX\fP jest zdefiniowane z wartością 64, co stanowiło limit od Linuksa 1.0 (wcześniejsze jądra narzucały limit 8 bajtów). .SS "Różnice biblioteki C/jądra" The GNU C library does not employ the \fBgethostname\fP() system call; instead, it implements \fBgethostname\fP() as a library function that calls \fBuname\fP(2) and copies up to \fIsize\fP bytes from the returned \fInodename\fP field into \fIname\fP. Having performed the copy, the function then checks if the length of the \fInodename\fP was greater than or equal to \fIsize\fP, and if it is, then the function returns \-1 with \fIerrno\fP set to \fBENAMETOOLONG\fP; in this case, a terminating null byte is not included in the returned \fIname\fP. .SH STANDARDY .TP \fBgethostname\fP() POSIX.1\-2008. .TP \fBsethostname\fP() Brak. .SH HISTORIA SVr4, 4.4BSD (interfejsy te pierwotnie pojawiły się w 4.2BSD). POSIX.1\-2001 i POSIX.1\-2008 definiuje \fBgethostname\fP() ale nie \fBsethostname\fP(). .P .\" At least glibc 2.0 and glibc 2.1, older versions not checked Versions of glibc before glibc 2.2 handle the case where the length of the \fInodename\fP was greater than or equal to \fIsize\fP differently: nothing is copied into \fIname\fP and the function returns \-1 with \fIerrno\fP set to \fBENAMETOOLONG\fP. .SH "ZOBACZ TAKŻE" \fBhostname\fP(1), \fBgetdomainname\fP(2), \fBsetdomainname\fP(2), \fBuname\fP(2), \fButs_namespaces\fP(7) .PP .SH TŁUMACZENIE Autorami polskiego tłumaczenia niniejszej strony podręcznika są: Przemek Borys , Andrzej Krzysztofowicz i Michał Kułach . .PP Niniejsze tłumaczenie jest wolną dokumentacją. Bliższe informacje o warunkach licencji można uzyskać zapoznając się z .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License w wersji 3 .UE lub nowszej. Nie przyjmuje się ŻADNEJ ODPOWIEDZIALNOŚCI. .PP Błędy w tłumaczeniu strony podręcznika prosimy zgłaszać na adres listy dyskusyjnej .MT manpages-pl-list@lists.sourceforge.net .ME .