.\" -*- coding: UTF-8 -*- .\" Copyright (c) 1980, 1991 Regents of the University of California. .\" All rights reserved. .\" .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB) .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" %%%LICENSE_END .\" .\" @(#)ioctl.2 6.4 (Berkeley) 3/10/91 .\" .\" Modified 1993-07-23 by Rik Faith .\" Modified 1996-10-22 by Eric S. Raymond .\" Modified 1999-06-25 by Rachael Munns .\" Modified 2000-09-21 by Andries Brouwer .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH IOCTL 2 "11 kwietnia 2020 r." Linux "Podręcznik programisty Linuksa" .SH NAZWA ioctl \- sterowanie urządzeniem .SH SKŁADNIA \fB#include \fP .PP .\" POSIX says 'request' is int, but glibc has the above .\" See https://bugzilla.kernel.org/show_bug.cgi?id=42705 \fBint ioctl(int \fP\fIfd\fP\fB, unsigned long \fP\fIrequest\fP\fB, ...);\fP .SH OPIS Wywołanie systemowe \fBioctl\fP manipuluje na podległych jej parametrach urządzeń, do których dostęp odbywa się poprzez pliki specjalne. W szczególności, za pomocą żądań \fBioctl\fP() można kontrolować wiele właściwości operacyjnych specjalnych plików znakowych (np. terminali). Argument \fIfd\fP musi być otwartym deskryptorem pliku. .PP Drugi argument jest zależnym od urządzenia kodem polecenia. Trzeci argument jest pozbawionym typu wskaźnikiem do obszaru pamięci, tradycyjnie \fBchar *\fP\fIargp\fP (pochodzi z okresu zanim \fBvoid *\fP stało się poprawne w C) i tak będzie nazywany w niniejszej dyskusji. .PP \fBIoctl\fP() \fIrequest\fP zawiera w sobie zakodowaną informację czy argument jest parametrem \fIwejściowym\fP czy \fIwyjściowym\fP oraz rozmiar \fIargp\fP tego argumentu w bajtach. Makra i definicje, używane do przekazywania \fIrequest\fP do \fBioctl\fP(), znajdują się w pliku \fI\fP. Zobacz UWAGI .SH "WARTOŚĆ ZWRACANA" Zazwyczaj, po pomyślnym zakończeniu zwracane jest zero. Niektóre żądania \fBioctl\fP() używają zwracanej wartości jako parametru wyjściowego i zwracają wówczas pewną wartość nieujemną. Po błędzie zwracane jest \-1 i odpowiednio ustawiane \fIerrno\fP. .SH BŁĘDY .TP \fBEBADF\fP \fIfd\fP nie jest prawidłowym deskryptorem pliku. .TP \fBEFAULT\fP \fIargp\fP wskazuje na niedostępny obszar pamięci. .TP \fBEINVAL\fP \fIrequest\fP lub \fIargp\fP są nieprawidłowe. .TP \fBENOTTY\fP \fIfd\fP nie jest związane z urządzeniem znakowym. .TP \fBENOTTY\fP Podane żądanie nie ma zastosowania dla obiektu, na który wskazuje deskryptor \fIfd\fP. .SH "ZGODNE Z" Brak jednego standardu. Argumenty, zwracane wartości i semantyka \fBioctl\fP() różnią się w zależności od sterownika urządzenia, którego dotyczą (wywołanie jest używane jako uniwersalne dla operacji, które nie dają się ładnie dopasować do uniksowego modelu strumieni we/wy). .PP Funkcja \fBioctl\fP() pojawiła się w wersji 7 AT&T UNIX. .SH UWAGI .\" In order to use this call, one needs an open file descriptor. Often the \fBopen\fP(2) call has unwanted side effects, that can be avoided under Linux by giving it the \fBO_NONBLOCK\fP flag. .SS "ioctl structure" .\" added two sections - aeb Ioctl command values are 32\-bit constants. In principle these constants are completely arbitrary, but people have tried to build some structure into them. .PP The old Linux situation was that of mostly 16\-bit constants, where the last byte is a serial number, and the preceding byte(s) give a type indicating the driver. Sometimes the major number was used: 0x03 for the \fBHDIO_*\fP ioctls, 0x06 for the \fBLP*\fP ioctls. And sometimes one or more ASCII letters were used. For example, \fBTCGETS\fP has value 0x00005401, with 0x54 = \(aqT\(aq indicating the terminal driver, and \fBCYGETTIMEOUT\fP has value 0x00435906, with 0x43 0x59 = \(aqC\(aq \(aqY\(aq indicating the cyclades driver. .PP Later (0.98p5) some more information was built into the number. One has 2 direction bits (00: none, 01: write, 10: read, 11: read/write) followed by 14 size bits (giving the size of the argument), followed by an 8\-bit type (collecting the ioctls in groups for a common purpose or a common driver), and an 8\-bit serial number. .PP The macros describing this structure live in \fI\fP and are \fB_IO(type,nr)\fP and \fB{_IOR,_IOW,_IOWR}(type,nr,size)\fP. They use \fIsizeof(size)\fP so that size is a misnomer here: this third argument is a data type. .PP Note that the size bits are very unreliable: in lots of cases they are wrong, either because of buggy macros using \fIsizeof(sizeof(struct))\fP, or because of legacy values. .PP Thus, it seems that the new structure only gave disadvantages: it does not help in checking, but it causes varying values for the various architectures. .SH "ZOBACZ TAKŻE" .\" .BR mt (4), \fBexecve\fP(2), \fBfcntl\fP(2), \fBioctl_console\fP(2), \fBioctl_fat\fP(2), \fBioctl_ficlonerange\fP(2), \fBioctl_fideduperange\fP(2), \fBioctl_fslabel\fP(2), \fBioctl_getfsmap\fP(2), \fBioctl_iflags\fP(2), \fBioctl_ns\fP(2), \fBioctl_tty\fP(2), \fBioctl_userfaultfd\fP(2), \fBopen\fP(2), \fBsd\fP(4), \fBtty\fP(4) .SH "O STRONIE" Angielska wersja tej strony pochodzi z wydania 5.10 projektu Linux \fIman\-pages\fP. Opis projektu, informacje dotyczące zgłaszania błędów oraz najnowszą wersję oryginału można znaleźć pod adresem \%https://www.kernel.org/doc/man\-pages/. .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 .