summaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_ioctl.h
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>2001-04-09 06:53:46 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>2001-04-09 06:53:46 +0000
commit505a042a913b0e4324612c89276096104be13025 (patch)
treec3faf32a8a7cb93d803bbebe0ad0b7af4973d89b /sys/compat/linux/linux_ioctl.h
parent86de17e962b949dcb8379810350e529762128b3b (diff)
Handle more Linux ioctls; from NetBSD. ok deraadt@
Diffstat (limited to 'sys/compat/linux/linux_ioctl.h')
-rw-r--r--sys/compat/linux/linux_ioctl.h55
1 files changed, 52 insertions, 3 deletions
diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h
index 8dbe87da0a6..5baa519a6b3 100644
--- a/sys/compat/linux/linux_ioctl.h
+++ b/sys/compat/linux/linux_ioctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_ioctl.h,v 1.4 1997/12/07 22:59:15 provos Exp $ */
+/* $OpenBSD: linux_ioctl.h,v 1.5 2001/04/09 06:53:45 tholo Exp $ */
/* $NetBSD: linux_ioctl.h,v 1.4 1996/04/05 00:01:36 christos Exp $ */
/*
@@ -32,8 +32,51 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#define _LINUX_IO(x,y) (((x) << 8) | (y))
-#define LINUX_IOCGROUP(x) (((x) >> 8) & 0xff)
+#define _LINUX_IOC_NRBITS 8
+#define _LINUX_IOC_TYPEBITS 8
+#define _LINUX_IOC_SIZEBITS 14
+#define _LINUX_IOC_DIRBITS 2
+
+#define _LINUX_IOC_NRSHIFT 0
+
+#define _LINUX_IOC_NONE 0U
+#define _LINUX_IOC_WRITE 1U
+#define _LINUX_IOC_READ 2U
+
+#define _LINUX_IOC_NRMASK ((1 << _LINUX_IOC_NRBITS) - 1)
+#define _LINUX_IOC_TYPEMASK ((1 << _LINUX_IOC_TYPEBITS) - 1)
+#define _LINUX_IOC_SIZEMASK ((1 << _LINUX_IOC_SIZEBITS) - 1)
+#define _LINUX_IOC_DIRMASK ((1 << _LINUX_IOC_DIRBITS) - 1)
+
+#define _LINUX_IOC_TYPESHIFT (_LINUX_IOC_NRSHIFT + _LINUX_IOC_NRBITS)
+#define _LINUX_IOC_SIZESHIFT (_LINUX_IOC_TYPESHIFT + _LINUX_IOC_TYPEBITS)
+#define _LINUX_IOC_DIRSHIFT (_LINUX_IOC_SIZESHIFT + _LINUX_IOC_SIZEBITS)
+
+#define _LINUX_IOC(dir,type,nr,size) \
+ (((nr) << _LINUX_IOC_NRSHIFT) | \
+ ((type) << _LINUX_IOC_TYPESHIFT) | \
+ ((size) << _LINUX_IOC_SIZESHIFT) | \
+ ((dir) << _LINUX_IOC_DIRSHIFT))
+
+#define _LINUX_IO(type,nr) \
+ _LINUX_IOC(_LINUX_IOC_NONE,(type),(nr),0)
+#define _LINUX_IOR(type,nr,size) \
+ _LINUX_IOC(_LINUX_IOC_READ,(type),(nr),sizeof(size))
+#define _LINUX_IOW(type,nr,size) \
+ _LINUX_IOC(_LINUX_IOC_WRITE,(type),(nr),sizeof(size))
+#define _LINUX_IOWR(type,nr,size) \
+ _LINUX_IOC(_LINUX_IOC_READ|_LINUX_IOC_WRITE,(type),(nr),sizeof(size))
+
+#define _LINUX_IOC_DIR(nr) \
+ (((nr) >> _LINUX_IOC_DIRSHIFT) & _LINUX_IOC_DIRMASK)
+#define _LINUX_IOC_TYPE(nr) \
+ (((nr) >> _LINUX_IOC_TYPESHIFT) & _LINUX_IOC_TYPEMASK)
+#define _LINUX_IOC_NR(nr) \
+ (((nr) >> _LINUX_IOC_NRSHIFT) & _LINUX_IOC_NRMASK)
+#define _LINUX_IOC_SIZE(nr) \
+ (((nr) >> _LINUX_IOC_SIZESHIFT) & _LINUX_IOC_SIZEMASK)
+
+#define LINUX_IOCGROUP(x) _LINUX_IOC_TYPE(x)
struct linux_sys_ioctl_args;
int linux_ioctl_audio __P((struct proc *, struct linux_sys_ioctl_args *,
@@ -45,3 +88,9 @@ int linux_ioctl_cdrom __P((struct proc *, struct linux_sys_ioctl_args *,
register_t *));
int linux_ioctl_socket __P((struct proc *, struct linux_sys_ioctl_args *,
register_t *));
+int linux_ioctl_hdio __P((struct proc *, struct linux_sys_ioctl_args *,
+ register_t *));
+int linux_ioctl_fdio __P((struct proc *, struct linux_sys_ioctl_args *,
+ register_t *));
+int linux_ioctl_blkio __P((struct proc *, struct linux_sys_ioctl_args *,
+ register_t *));