📄 syscalls_17.html
字号:
<!-- This HTML file has been created by texi2html 1.29
from syscalls.texi on 4 June 1994 -->
<TITLE>Syscall specifications of Linux - ioctl</TITLE>
<P>Go to the <A HREF="syscalls_16.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_16.html">previous</A>, <A HREF="syscalls_18.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_18.html">next</A> section.<P>
<H2><A NAME="SEC17" HREF="syscalls_toc.html#SEC17" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_toc.html#SEC17">ioctl</A></H2>
<P>
<H3>SYNOPSIS</H3>
<P>
<CODE>int ioctl(int <VAR>d</VAR>, int <VAR>cmd</VAR>, ...);</CODE>
<P>
The third argument is called <CODE>char *<VAR>argp</VAR></CODE>.
<P>
<H3>PARAMETERS</H3>
<P>
<VAR>d</VAR>: [in] the file descriptor of the file to manipulate.
<P>
<VAR>cmd</VAR>: [in] the type of request.
<P>
<VAR>argp</VAR>: depends on the request.
<P>
<H3>DESCRIPTION</H3>
<P>
Controls the io parameters of character special devices (tty, mt, etc.).
The values that <VAR>cmd</VAR> may take for file operations are:
<P>
<DL COMPACT>
<DT><CODE>FIOCLEX</CODE>
<DD>Sets the close-on-exec flag of the file.
<P>
<DT><CODE>FIONCLEX</CODE>
<DD>Clears the close-on-exec flag of the file.
<P>
<DT><CODE>FIONBIO</CODE>
<DD>If <VAR>argp</VAR> is true, sets the file <CODE>O_NONBLOCK</CODE> flag, otherwise it
clears the flag.
<P>
<DT><CODE>FIOASYNC</CODE>
<DD>If <VAR>argp</VAR> is true, sets the file <CODE>O_SYNC</CODE> flag, otherwise it
clears the flag. (This flag is not used as of Linux 1.0.)
<P>
<DT><CODE>FIONREAD</CODE>
<DD>Returns to a buffer pointed to by <VAR>argp</VAR>, the number of bytes
immediately readable from the file.
<P>
<DT><CODE>FIOSETOWN</CODE>
<DD>Sets the owner of the file to <VAR>argp</VAR> (a pid). The owner is the one
that receives the <CODE>SIGURG</CODE> and <CODE>SIGIO</CODE> signals. (Only for
sockets.)
<P>
<DT><CODE>FIOGETOWN</CODE>
<DD>Returns the owner of the file to a buffer pointed to by <VAR>argp</VAR>.
(Only for sockets.)
<P>
<DT><CODE>FIGETBSZ</CODE>
<DD>Returns the block size of the file to a buffer pointed to by <VAR>argp</VAR>.
(Seems non-standard.)
<P>
<DT><CODE>FIBMAP</CODE>
<DD>Returns the block number in the fs corresponding to the <VAR>argp</VAR>'th
block in the file. (I have guessed right? Anyway, this is non-standard.)
</DL>
The values for magnetic tape operations are:
<P>
<DL COMPACT>
<DT><CODE>MTIOCTOP</CODE>
<DD>Perform an operation on a magnetic tape. <VAR>argp</VAR> is a pointer to a
<CODE>mtop</CODE> structure.
<P>
<DT><CODE>MTIOCGET</CODE>
<DD>Get magnetic tape status. <VAR>argp</VAR> is a pointer to a <CODE>mtget</CODE>
structure.
<P>
<DT><CODE>MTIOCPOS</CODE>
<DD>Set magnetic tape position. <VAR>argp</VAR> points to a long integer
specifying the block number to go to.
</DL>
<P>
The section on magnetic tapes will remain incomplete for a while... I
don't have a clue how it is supposed to work.
<P>
The values for sockets operations are:
<P>
<DL COMPACT>
<DT><CODE>SIOCSPGRP</CODE>
<DD>Same as <CODE>FIOSETOWN</CODE>.
<P>
<DT><CODE>SIOCGPGRP</CODE>
<DD>Same as <CODE>FIOGETOWN</CODE>.
<P>
<DT><CODE>SIOCATMARK</CODE>
<DD>Not supported.
<P>
<DT><CODE>SIOCADDRT</CODE>
<DD>Adds a routing entry in the routing table of the system. The task must
have superuser privileges to perform that operation. <VAR>argp</VAR> points
to a <CODE>rtentry</CODE> structure.
<P>
<DT><CODE>SIOCDELRT</CODE>
<DD>Removes a routing entry from the routing table of the system. The task
must have superuser privileges to perform that operation. <VAR>argp</VAR>
points to a <CODE>rtentry</CODE> structure.
<P>
<DT><CODE>SIOCADDRTOLD</CODE>
<DD>Same as <CODE>SIOCADDRT</CODE> but uses an <CODE>old_rtentry</CODE> structure.
Obsolete. Do not use.
<P>
<DT><CODE>SIOCDELRTOLD</CODE>
<DD>Same as <CODE>SIOCDELRT</CODE> but uses an <CODE>old_rtentry</CODE> structure.
Obsolete. Do not use.
<P>
<DT><CODE>SIOCDARP</CODE>
<DD>Deletes an ARP entry. The calling task must have superuser privileges.
<VAR>argp</VAR> points to an <CODE>arpreq</CODE> structure.
<P>
<DT><CODE>SIOCGARP</CODE>
<DD>Retreive an ARP entry. The calling task must have superuser privileges.
<VAR>argp</VAR> points to an <CODE>arpreq</CODE> structure.
<P>
<DT><CODE>SIOCSARP</CODE>
<DD>Sets an ARP entry. The calling task must have superuser privileges.
<VAR>argp</VAR> points to an <CODE>arpreq</CODE> structure.
<P>
<DT><CODE>IP_SET_DEV</CODE>
<DD>Not supported.
<P>
<DT><CODE>SIOCGIFCONF</CODE>
<DD>Reteives the network interface configuration list in a <CODE>ifconf</CODE>
structure.
<P>
<DT><CODE>SIOCGIFFLAGS</CODE>
<DD>Gets the interface flags. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure.
<P>
<DT><CODE>SIOCSIFFLAGS</CODE>
<DD>Sets the interface flags. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure. The calling task must have superuser privileges.
<P>
<DT><CODE>SIOCGIFADDR</CODE>
<DD>Gets the interface address. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure.
<P>
<DT><CODE>SIOCSIFADDR</CODE>
<DD>Sets the interface address. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure. The calling task must have superuser privileges.
<P>
<DT><CODE>SIOCGIFDSTADDR</CODE>
<DD>Gets the interface remote address. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure.
<P>
<DT><CODE>SIOCSIFDSTADDR</CODE>
<DD>Sets the interface remote address. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure. The calling task must have superuser privileges.
<P>
<DT><CODE>SIOCGIFBRDADDR</CODE>
<DD>Gets the interface broadcast address. <VAR>argp</VAR> points to an
<CODE>ifreq</CODE> structure.
<P>
<DT><CODE>SIOCSIFBRDADDR</CODE>
<DD>Sets the interface broadcast address. <VAR>argp</VAR> points to an
<CODE>ifreq</CODE> structure. The calling task must have superuser privileges.
<P>
<DT><CODE>SIOCGIFNETMASK</CODE>
<DD>Gets the interface network mask. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure.
<P>
<DT><CODE>SIOCSIFNETMASK</CODE>
<DD>Sets the interface network mask. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure. The calling task must have superuser privileges.
<P>
<DT><CODE>SIOCGIFMETRIC</CODE>
<DD>Gets the interface routing metric. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure.
<P>
<DT><CODE>SIOCSIFMETRIC</CODE>
<DD>Sets the interface routing metric. <VAR>argp</VAR> points to an <CODE>ifreq</CODE>
structure. The calling task must have superuser privileges.
<P>
<DT><CODE>SIOCGIFMEM or SIOCSIFMEM</CODE>
<DD>Not supported.
<P>
<DT><CODE>SIOCGIFMTU</CODE>
<DD>Gets the interface maximum transmission unit. <VAR>argp</VAR> points to an
<CODE>ifreq</CODE> structure.
<P>
<DT><CODE>SIOCSIFMTU</CODE>
<DD>Sets the interface maximum transmission unit. <VAR>argp</VAR> points to an
<CODE>ifreq</CODE> structure. The calling task must have superuser privileges.
<P>
<DT><CODE>SIOCSIFLINK</CODE>
<DD>Links in an I/O driver into the operating system kernel.
<P>
<DT><CODE>SIOCGIFHWADDR</CODE>
<DD>Gets the interface hardware address. <VAR>argp</VAR> points to an
<CODE>ifreq</CODE> structure.
<P>
<DT><CODE>SIOCSIFHWADDR</CODE>
<DD>Not supported.
<P>
<DT><CODE>SIOCGIFNAME</CODE>
<DD>Not supported.
<P>
<DT><CODE>DDIOCSDBG:</CODE>
<DD>Set the DDI debug level.
</DL>
<P>
<PRE>
struct rtentry {
unsigned long rt_hash; /* hash key for lookups */
struct sockaddr rt_dst; /* target address */
struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
struct sockaddr rt_genmask; /* target network mask (IP) */
short rt_flags;
short rt_refcnt;
unsigned long rt_use;
struct ifnet *rt_ifp;
short rt_metric; /* +1 for binary compatibility! */
char *rt_dev; /* forcing the device at add */
};
</PRE>
<P>
<PRE>
struct old_rtentry {
unsigned long rt_genmask;
struct sockaddr rt_dst;
struct sockaddr rt_gateway;
short rt_flags;
short rt_refcnt;
unsigned long rt_use;
char *rt_dev;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -