unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (HP-UX-11.11)
Page:
Section:
Apropos / Subsearch:
optional field



 ioctl(2)							    ioctl(2)




 NAME
      ioctl - control device

 SYNOPSIS
      #include <&lt&lt&lt;stropts.h>&gt&gt&gt;

      int ioctl(int fildes, int request, ... /* arg */);

    Remarks
      The ANSI C ", ..." construct denotes a variable length argument list
      whose optional [or required] members are given in the associated
      comment (/* */).

 DESCRIPTION
      ioctl() performs a variety of functions on character special files
      (devices), or regular files and directories on VxFS file systems.	 The
      write-ups of various devices in Section (7) discuss how ioctl()
      applies to them.	The type of arg is dependent on the specific ioctl()
      call, as described in Section (7).

      request is made up of several fields which encode the size and
      direction of the argument (referenced by arg), as well as the desired
      command.	An enumeration of the request fields are:

	   IOC_IN	       Argument is read by the driver (meaning that
			       the argument is copied from the application
			       to the driver).

	   IOC_OUT	       Argument is written by the driver (meaning
			       that the argument is copied from the driver
			       to the application).  Ignored if an error
			       occurs.

	   IOCSIZE_MASK	       Number of bytes in the passed argument.	A
			       nonzero size indicates that arg is a pointer
			       to the passed argument.	A zero size
			       indicates that arg is the passed argument (if
			       the driver wants to use it), and is not
			       treated as a pointer.

	   IOCCMD_MASK	       The request command itself.

      When both IOC_IN and IOC_OUT are zero, it can be assumed that request
      is not encoded for size and direction, for compatibility purposes.
      Requests that do not require any data to be passed and requests that
      use arg as a value (as opposed to a pointer), have the IOC_IN bit set
      to one and the IOCSIZE_MASK field set to zero.

      The following macros are used to create the request argument.  x and y
      are concatenated ((x<&lt&lt&lt;<&lt&lt&lt;8) | y) to form IOCCMD and shifted into the
      proper location according to IOCCMD_MASK.	 t is the type (e.g.  struct



 Hewlett-Packard Company	    - 1 -   HP-UX Release 11i: November 2000






 ioctl(2)							    ioctl(2)




      routeaddrs) of the actual argument that the request references, and
      its size is taken and shifted into the appropriate place according to
      IOCSIZE_MASK.

	   _IOR(x,y,t)	       Sets IOC_OUT and initializes the values at
			       IOCCMD_MASK and IOCSIZE_MASK accordingly.

	   _IOW(x,y,t)	       Sets IOC_IN and initializes the values at
			       IOCCMD_MASK and IOCSIZE_MASK accordingly.

	   _IOWR(x,y,t)	       Sets both IOC_IN and IOC_OUT and initializes
			       the values at IOCCMD_MASK and IOCSIZE_MASK.

      Note: any data structure referenced by arg must not contain any
      pointers.

 RETURN VALUE
      If an error has occurred, a value of -1 is returned and errno is set
      to indicate the error.

      ioctl() fails if one or more of the following are true: IOC_OUT is
      ignored if an error occurs.

	   [EBADF]	  fildes is not a valid open file descriptor.

	   [ENOTTY]	  The request is not appropriate to the selected
			  device.

	   [EINVAL]	  request or arg is not valid.

	   [EINTR]	  A signal was caught during the ioctl() system
			  call.

	   [EPERM]	  Typically this error indicates that an ioctl
			  request was attempted that is forbidden in some
			  way to the calling process.

 WARNINGS
      Check all references to signal(5) for appropriateness on systems that
      support sigvector(2).  sigvector(2) can affect the behavior described
      on this page.

 AUTHOR
      ioctl() was developed by AT&T and HP.

 SEE ALSO
      ioctl(5), arp(7P), socket(7), termio(7).

 STANDARDS CONFORMANCE
      ioctl(): SVID2, SVID3, XPG2




 Hewlett-Packard Company	    - 2 -   HP-UX Release 11i: November 2000