Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. File I/O: The Universal I/O Model > Operations Outside the Universal I/O Mod...

Operations Outside the Universal I/O Model: ioctl()

The ioctl() system call is a general-purpose mechanism for performing file and device operations that fall outside the universal I/O model described earlier in this chapter.

#include <sys/ioctl.h>

int ioctl(int fd, int request, ... /* argp */);

Note

Value returned on success depends on request, or -1 on error

The fd argument is an open file descriptor for the device or file upon which the control operation specified by request is to be performed. Device-specific header files define constants that can be passed in the request argument.

As indicated by the standard C ellipsis (...) notation, the third argument to ioctl(), which we label argp, can be of any type. The value of the request argument enables ioctl() to determine what type of value to expect in argp. Typically, argp is a pointer to either an integer or a structure; in some cases, it is unused.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint