[prev] 12 [next]

Devices on Unix/Linux (cont)

int ioctl(int FileDesc, int Request, void *Arg)
  • manipulates parameters of special files (behind open FileDesc)
  • Request is a device-specific request code,
  • Arg is either an integer modifier or pointer to data block
  • requires  #include <sys/ioctl.h>, returns 0 if ok, -1 if error

Example: SCSI disk driver
  • HDIO_GETGEO ... get disk info in (heads,sectors,cylinders,...)
  • BLKGETSIZE ... get device size in sectors
  • in both cases, Arg is a pointer to an appropriate object