root/include/linux/ioctl.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /* $Id: ioctl.h,v 1.2 1992/11/18 01:31:16 root Exp root $
   2  *
   3  * linux/ioctl.h for Linux by H.H. Bergman.
   4  */
   5 
   6 #ifndef _LINUX_IOCTL_H
   7 #define _LINUX_IOCTL_H
   8 
   9 
  10 /* ioctl command encoding: 32 bits total, command in lower 16 bits,
  11  * size of the parameter structure in the upper 14 bits.
  12  * Encoding size in ioctl request is useful for catching old versions
  13  * and to avoid overwriting user space outside the user buffer area.
  14  * The highest 2 bits are reserved.
  15  * NOTE: This limits the max blocksize to 16kB -1 !
  16  */
  17 
  18 #define IOC_VOID        0x00000000      /* param in size field */
  19 #define IOC_IN          0x40000000      /* user --> kernel */
  20 #define IOC_OUT         0x80000000      /* kernel --> user */
  21 #define IOC_INOUT       (IOC_IN | IOC_OUT)      /* both */
  22 #define IOCSIZE_MASK    0x3fff0000      /* size (max 16k-1 bytes) */
  23 #define IOCSIZE_SHIFT   16              /* how to get the size */
  24 #define IOCCMD_MASK     0x0000ffff      /* command code */
  25 #define IOCCMD_SHIFT    0
  26 
  27 #define _IO(c,d)        (IOC_VOID | ((d)<<16) | c) /* param encoded */
  28 /* use _IOXX(magic, subcode, arg_t) where arg_t is the type of the
  29  * (last) argument field in the ioctl call, if present.
  30  */
  31 #define _IOW(c,d,t)     (IOC_IN | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  32                                   (c<<8) | d)
  33 #define _IOR(c,d,t)     (IOC_OUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  34                                    (c<<8) | d)
  35 /* WR rather than RW to avoid conflict with stdio.h */
  36 #define _IOWR(c,d,t)    (IOC_INOUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  37                                      (c<<8) | d)
  38 
  39 #endif /* _LINUX_IOCTL_H */
  40 

/* [previous][next][first][last][top][bottom][index][help] */