.\" -*- coding: UTF-8 -*- .\" This manpage is Copyright (C) 1992 Drew Eckhardt; .\" and Copyright (C) 1993 Michael Haardt, Ian Jackson. .\" and Copyright (C) 2007 Michael Kerrisk .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\" Modified Sat Jul 24 13:35:59 1993 by Rik Faith .\" Modified Sun Nov 28 17:19:01 1993 by Rik Faith .\" Modified Sat Jan 13 12:58:08 1996 by Michael Haardt .\" .\" Modified Sun Jul 21 18:59:33 1996 by Andries Brouwer .\" 2001-12-13 added remark by Zack Weinberg .\" 2007-06-18 mtk: .\" Added details about seekable files and file offset. .\" Noted that write() may write less than 'count' bytes, and .\" gave some examples of why this might occur. .\" Noted what happens if write() is interrupted by a signal. .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH write 2 "3 kwietnia 2023 r." "Linux man\-pages 6.05.01" .SH NAZWA write \- zapisuje do deskryptora pliku .SH BIBLIOTEKA Standardowa biblioteka C (\fIlibc\fP, \fI\-lc\fP) .SH SKŁADNIA .nf \fB#include \fP .PP \fBssize_t write(int \fP\fIfd\fP\fB, const void \fP\fIbuf\fP\fB[.\fP\fIliczba\fP\fB], size_t \fP\fIliczba\fP\fB);\fP .fi .SH OPIS \fBwrite\fP() writes up to \fIcount\fP bytes from the buffer starting at \fIbuf\fP to the file referred to by the file descriptor \fIfd\fP. .PP Liczba bajtów zapisanych może być mniejsza niż \fIliczba\fP jeżeli, na przykład nie ma wystarczającej ilości wolnej przestrzeni na urządzeniu fizycznym, lub zasoby \fBRLIMIT_FSIZE\fP zostały wyczerpane (patrz \fBsetrlimit\fP(2)), wywołanie zostało przerwane przez obsługę sygnału po zapisaniu mniej niż \fIliczba\fP bajtów (spójrz również na \fBpipe\fP(7)). .PP Dla przeszukiwalnych plików (np. takie na których można użyć \fBlseek\fP(2), na przykład, pliki zwykłe (regular)) zapis ma miejsce w danym przesunięciu pliku (offsecie), i to przesunięcie jest zwiększane o ilość aktualnie zapisanych danych. Jeżeli plik został otwarty (\fBopen\fP(2)) z \fBO_APPEND\fP, wtedy przesunięciem (offsetem) jest koniec pliku przed zapisem. Dostosowanie przesunięcia pliku i operacja zapisu są wykonywane jako nierozdzielne (atomowe). .PP POSIX requires that a \fBread\fP(2) that can be proved to occur after a \fBwrite\fP() has returned will return the new data. Note that not all filesystems are POSIX conforming. .PP According to POSIX.1, if \fIcount\fP is greater than \fBSSIZE_MAX\fP, the result is implementation\-defined; see NOTES for the upper limit on Linux. .SH "WARTOŚĆ ZWRACANA" On success, the number of bytes written is returned. On error, \-1 is returned, and \fIerrno\fP is set to indicate the error. .PP Note that a successful \fBwrite\fP() may transfer fewer than \fIcount\fP bytes. Such partial writes can occur for various reasons; for example, because there was insufficient space on the disk device to write all of the requested bytes, or because a blocked \fBwrite\fP() to a socket, pipe, or similar was interrupted by a signal handler after it had transferred some, but before it had transferred all of the requested bytes. In the event of a partial write, the caller can make another \fBwrite\fP() call to transfer the remaining bytes. The subsequent call will either transfer further bytes or may result in an error (e.g., if the disk is now full). .PP If \fIcount\fP is zero and \fIfd\fP refers to a regular file, then \fBwrite\fP() may return a failure status if one of the errors below is detected. If no errors are detected, or error detection is not performed, 0 is returned without causing any other effect. If \fIcount\fP is zero and \fIfd\fP refers to a file other than a regular file, the results are not specified. .SH BŁĘDY .TP \fBEAGAIN\fP Deskryptor pliku \fIfd\fP odwołuje się do gniazda i został oznaczony jako nieblokujący (\fBO_NONBLOCK\fP), a zapis go zablokuje. Zob. \fBopen\fP(2) aby dowiedzieć się\ więcej o fladze \fBO_NONBLOCK\fP. .TP \fBEAGAIN\fP lub \fBEWOULDBLOCK\fP .\" Actually EAGAIN on Linux Deskryptor pliku \fIfd\fP odwołuje się do gniazda i został oznaczony jako nieblokujący (\fBO_NONBLOCK\fP), a zapis go zablokuje. POSIX.1\-2001 pozwala w tej sytuacji na zwrócenie błędu ale nie wymaga aby ta stała miała taką samą wartość, portowalna aplikacja powinna sprawdzać obie możliwości. .TP \fBEBADF\fP \fIfd\fP nie jest prawidłowym deskryptorem pliku lub nie jest otwarty do zapisu .TP \fBEDESTADDRREQ\fP \fIfd\fP odwołuje się do gniazda datagramowego dla którego adres nie został ustalony przy użyciu \fBconnect\fP(2). .TP \fBEDQUOT\fP Kwota bloków dyskowych użytkownika dotycząca systemu plików zawierającego plik wskazany przez \fIfd\fP została wyczerpana. .TP \fBEFAULT\fP \fIbuf\fP jest poza dostępną przestrzenią adresową. .TP \fBEFBIG\fP Dokonano próby zapisu pliku który przekracza zdefiniowane w implementacji maksymalne rozmiary pliku, rozmiary pliku procesu lub zapis na pozycję wykraczającą poza maksymalne dozwolone przesunięcie (offset). .TP \fBEINTR\fP Wywołanie zostało przerwane przez sygnał przed zapisaniem jakichkolwiek danych, patrz \fBsignal\fP(7). .TP \fBEINVAL\fP \fIfd\fP jest dołączony do obiektu nieodpowiedniego do zapisu, plik został otwarty z flagą \fBO_DIRECT\fP i adres podany w \fIbuf\fP bądź wartość \fIliczba\fP lub przesunięcie (offset) nie zostały odpowiednio dopasowane. .TP \fBEIO\fP .\" commit 088737f44bbf6378745f5b57b035e57ee3dc4750 A low\-level I/O error occurred while modifying the inode. This error may relate to the write\-back of data written by an earlier \fBwrite\fP(), which may have been issued to a different file descriptor on the same file. Since Linux 4.13, errors from write\-back come with a promise that they \fImay\fP be reported by subsequent. \fBwrite\fP() requests, and \fIwill\fP be reported by a subsequent \fBfsync\fP(2) (whether or not they were also reported by \fBwrite\fP()). An alternate cause of \fBEIO\fP on networked filesystems is when an advisory lock had been taken out on the file descriptor and this lock has been lost. See the \fILost locks\fP section of \fBfcntl\fP(2) for further details. .TP \fBENOSPC\fP Urządzenie zawierające plik wskazany przez \fIfd\fP nie ma miejsca na dane. .TP \fBEPERM\fP Operacja zablokowana przez zakluczenie pliku (ang. file seal); zob. \fBfcntl\fP(2). .TP \fBEPIPE\fP \fIfd\fP jest podłączony do potoku (pipe) lub gniazda (socket) którego końcówka odczytująca jest zamknięta. Gdy taka sytuacja następuje, proces zapisujący również otrzyma sygnał \fBSIGPIPE\fP. (Więc wartość zwracana przez \fBwrite()\fP jest widziana tylko wówczas gdy program obsługuje, blokuje lub ignoruje ten sygnał). .PP Zależnie od obiektu podłączonego do \fIfd\fP, mogą także zajść inne (nieopisane) błędy. .SH STANDARDY POSIX.1\-2008. .SH HISTORIA .\" SVr4 documents additional error .\" conditions EDEADLK, ENOLCK, ENOLNK, ENOSR, ENXIO, or ERANGE. SVr4, 4.3BSD, POSIX.1\-2001. .PP Pod SVr4 \fBEINTR\fP jest zwracane zarówno gdy po przerwaniu wywołania, dane zostały zapisane częściowo lub przed jakimkolwiek zapisem. .SH UWAGI A successful return from \fBwrite\fP() does not make any guarantee that data has been committed to disk. On some filesystems, including NFS, it does not even guarantee that space has successfully been reserved for the data. In this case, some errors might be delayed until a future \fBwrite\fP(), \fBfsync\fP(2), or even \fBclose\fP(2). The only way to be sure is to call \fBfsync\fP(2) after you are done writing all your data. .PP Jeżeli \fBwrite\fP() zostanie przerwany przez obsługe sygnału przed zapisaniem jakichkolwiek danych, wtedy wywołanie nie powiedzie się i zwracany jest błąd \fBEINTR\fP; jeżeli przerwanie nastąpi po zapisaniu co najmniej jednego bajtu danych, wywołanie powiedzie się i zwróci ilość zapisanych bajtów danych. .PP .\" commit e28cc71572da38a5a12c1cfe4d7032017adccf69 W Linuksie, \fBwrite\fP() (i podobne wywołania systemowe) mogą\ dokonać transferu co najwyżej 0x7ffff000 (2 147 479 552) bajtów, zwracając liczbę bajtów rzeczywiście przetransferowanych (jest to prawdziwe zarówno dla systemów 32 jak i 64\-bitowych). .PP An error return value while performing \fBwrite\fP() using direct I/O does not mean the entire write has failed. Partial data may be written and the data at the file offset on which the \fBwrite\fP() was attempted should be considered inconsistent. .SH USTERKI Zgodnie z POSIX.1\-2008/SUSv4 Section XSI 2.9.7 ("Thread Interactions with Regular File Operations"): .PP .RS 4 Wszystkie poniższe funkcje powinny być atomowe w odniesieniu do innych biorąc pod uwagę wyniki określone w POSIX.1\-2008, gdy działają na zwykłych plikach lub dowiązaniach symbolicznych: ... .RE .PP .\" http://thread.gmane.org/gmane.linux.kernel/1649458 .\" From: Michael Kerrisk (man-pages gmail.com> .\" Subject: Update of file offset on write() etc. is non-atomic with I/O .\" Date: 2014-02-17 15:41:37 GMT .\" Newsgroups: gmane.linux.kernel, gmane.linux.file-systems .\" commit 9c225f2655e36a470c4f58dbbc99244c5fc7f2d4 .\" Author: Linus Torvalds .\" Date: Mon Mar 3 09:36:58 2014 -0800 .\" .\" vfs: atomic f_pos accesses as per POSIX Among the APIs subsequently listed are \fBwrite\fP() and \fBwritev\fP(2). And among the effects that should be atomic across threads (and processes) are updates of the file offset. However, before Linux 3.14, this was not the case: if two processes that share an open file description (see \fBopen\fP(2)) perform a \fBwrite\fP() (or \fBwritev\fP(2)) at the same time, then the I/O operations were not atomic with respect to updating the file offset, with the result that the blocks of data output by the two processes might (incorrectly) overlap. This problem was fixed in Linux 3.14. .SH "ZOBACZ TAKŻE" \fBclose\fP(2), \fBfcntl\fP(2), \fBfsync\fP(2), \fBioctl\fP(2), \fBlseek\fP(2), \fBopen\fP(2), \fBpwrite\fP(2), \fBread\fP(2), \fBselect\fP(2), \fBwritev\fP(2), \fBfwrite\fP(3) .PP .SH TŁUMACZENIE Autorami polskiego tłumaczenia niniejszej strony podręcznika są: Artur Kruszewski , Michał Kułach i Robert Luberda . .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 .