From: Ben Gras Date: Thu, 12 Dec 2013 16:34:44 +0000 (+0100) Subject: , X-Git-Tag: v3.3.0~448 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/pkcs11-destroy.html?a=commitdiff_plain;h=aae07bc777e7419a729edb336d49f3640929a579;p=minix.git , . use to make ioctls . use netbsd , include minix ioctls . convert to varargs ioctl() like netbsd Change-Id: Id5165780df48172b28bf0003603516d30d7c1abb --- diff --git a/commands/eepromread/eepromread.h b/commands/eepromread/eepromread.h index 60dadc3fe..896162959 100644 --- a/commands/eepromread/eepromread.h +++ b/commands/eepromread/eepromread.h @@ -1,6 +1,10 @@ #ifndef __EEPROMREAD_H #define __EEPROMREAD_H +#include +#include +#include + enum device_types { I2C_DEVICE, EEPROM_DEVICE }; #define DEFAULT_DEVICE I2C_DEVICE diff --git a/include/minix/i2c.h b/include/minix/i2c.h index 4aebb0231..75dfb9c37 100644 --- a/include/minix/i2c.h +++ b/include/minix/i2c.h @@ -9,8 +9,9 @@ * ioctl(2) function will translate to/from the Minix version of the struct. */ -#include +#include #include +#include typedef struct minix_i2c_ioctl_exec { i2c_op_t iie_op; /* operation to perform */ @@ -21,6 +22,6 @@ typedef struct minix_i2c_ioctl_exec { size_t iie_buflen; /* length of data buffer */ } minix_i2c_ioctl_exec_t; -#define MINIX_I2C_IOCTL_EXEC _IORW('I', 1, minix_i2c_ioctl_exec_t) +#define MINIX_I2C_IOCTL_EXEC _IOWR('I', 1, minix_i2c_ioctl_exec_t) #endif /* __MINIX_I2C_H */ diff --git a/include/minix/ioctl.h b/include/minix/ioctl.h index f85c59f27..1de7ae844 100644 --- a/include/minix/ioctl.h +++ b/include/minix/ioctl.h @@ -1,60 +1 @@ -/* minix/ioctl.h - Ioctl helper definitions. Author: Kees J. Bot - * 23 Nov 2002 - * - * This file is included by every header file that defines ioctl codes. - */ - -#ifndef _M_IOCTL_H -#define _M_IOCTL_H - -#include -#include - -/* Ioctls have the command encoded in the low-order word, and the size - * of the parameter in the high-order word. The 3 high bits of the high- - * order word are used to encode the in/out/void status of the parameter. - */ -#define _IOCPARM_MASK 0x0FFF -#define _IOCPARM_MASK_BIG 0x0FFFFF -#define _IOC_VOID 0x20000000 -#define _IOCTYPE_MASK 0xFFFF -#define _IOC_IN 0x40000000 -#define _IOC_OUT 0x80000000 -#define _IOC_INOUT (_IOC_IN | _IOC_OUT) - -/* Flag indicating ioctl format with only one type field, and more bits - * for the size field (using mask _IOCPARM_MASK_BIG). - */ -#define _IOC_BIG 0x10000000 - -#define _IO(x,y) ((x << 8) | y | _IOC_VOID) -#define _IOR(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\ - _IOC_OUT) -#define _IOW(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\ - _IOC_IN) -#define _IORW(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\ - _IOC_INOUT) -#define _IOWR(x,y,t) _IORW(x,y,t) /* NetBSD compatibility */ - -#define _IOW_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \ - | _IOC_IN | _IOC_BIG) -#define _IOR_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \ - | _IOC_OUT | _IOC_BIG) -#define _IORW_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \ - | _IOC_INOUT | _IOC_BIG) - -/* Decode an ioctl call. */ -#define _MINIX_IOCTL_SIZE(i) (((i) >> 16) & _IOCPARM_MASK) -#define _MINIX_IOCTL_IOR(i) ((i) & _IOC_OUT) -#define _MINIX_IOCTL_IORW(i) ((i) & _IOC_INOUT) -#define _MINIX_IOCTL_IOW(i) ((i) & _IOC_IN) - -/* Recognize and decode size of a 'big' ioctl call. */ -#define _MINIX_IOCTL_BIG(i) ((i) & _IOC_BIG) -#define _MINIX_IOCTL_SIZE_BIG(i) (((i) >> 8) & _IOCPARM_MASK_BIG) - -__BEGIN_DECLS -int ioctl(int _fd, unsigned long _request, void *_data); -__END_DECLS - -#endif /* _M_IOCTL_H */ +#include diff --git a/include/sys/ioc_disk.h b/include/sys/ioc_disk.h index f899c4ddf..dc711f7d3 100644 --- a/include/sys/ioc_disk.h +++ b/include/sys/ioc_disk.h @@ -11,7 +11,7 @@ #define DIOCSETP _IOW('d', 3, struct part_geom) #define DIOCGETP _IOR('d', 4, struct part_geom) #define DIOCEJECT _IO ('d', 5) -#define DIOCTIMEOUT _IORW('d', 6, int) +#define DIOCTIMEOUT _IOWR('d', 6, int) #define DIOCOPENCT _IOR('d', 7, int) #define DIOCFLUSH _IO ('d', 8) #define DIOCSETWC _IOW('d', 9, int) diff --git a/include/sys/ioc_fbd.h b/include/sys/ioc_fbd.h index 1aea7481f..4626d827c 100644 --- a/include/sys/ioc_fbd.h +++ b/include/sys/ioc_fbd.h @@ -61,6 +61,6 @@ enum { /* The I/O control requests. */ #define FBDCADDRULE _IOW('B', 1, struct fbd_rule) /* add a rule */ #define FBDCDELRULE _IOW('B', 2, fbd_rulenum_t) /* delete a rule */ -#define FBDCGETRULE _IORW('B', 3, struct fbd_rule) /* retrieve a rule */ +#define FBDCGETRULE _IOWR('B', 3, struct fbd_rule) /* retrieve a rule */ #endif /* _S_I_FBD_H */ diff --git a/include/sys/ioc_net.h b/include/sys/ioc_net.h index 4fe62c38e..dcd88eda7 100644 --- a/include/sys/ioc_net.h +++ b/include/sys/ioc_net.h @@ -30,8 +30,8 @@ struct msg_control #define NWIOGETHOPT _IOR('n', 17, struct nwio_ethopt) #define NWIOGETHSTAT _IOR('n', 18, struct nwio_ethstat) -#define NWIOARPGIP _IORW('n',20, struct nwio_arp) -#define NWIOARPGNEXT _IORW('n',21, struct nwio_arp) +#define NWIOARPGIP _IOWR('n',20, struct nwio_arp) +#define NWIOARPGNEXT _IOWR('n',21, struct nwio_arp) #define NWIOARPSIP _IOW ('n',22, struct nwio_arp) #define NWIOARPDIP _IOW ('n',23, struct nwio_arp) @@ -42,10 +42,10 @@ struct msg_control #define NWIOSIPOPT _IOW('n', 34, struct nwio_ipopt) #define NWIOGIPOPT _IOR('n', 35, struct nwio_ipopt) -#define NWIOGIPOROUTE _IORW('n', 40, struct nwio_route) +#define NWIOGIPOROUTE _IOWR('n', 40, struct nwio_route) #define NWIOSIPOROUTE _IOW ('n', 41, struct nwio_route) #define NWIODIPOROUTE _IOW ('n', 42, struct nwio_route) -#define NWIOGIPIROUTE _IORW('n', 43, struct nwio_route) +#define NWIOGIPIROUTE _IOWR('n', 43, struct nwio_route) #define NWIOSIPIROUTE _IOW ('n', 44, struct nwio_route) #define NWIODIPIROUTE _IOW ('n', 45, struct nwio_route) @@ -79,7 +79,7 @@ struct msg_control #define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */ #define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */ #define NWIOSUDSCTRL _IOW ('n', 78, struct msg_control) /* sendmsg() */ -#define NWIOGUDSCTRL _IORW('n', 79, struct msg_control) /* recvmsg() */ +#define NWIOGUDSCTRL _IOWR('n', 79, struct msg_control) /* recvmsg() */ #define NWIOSPSIPOPT _IOW('n', 80, struct nwio_psipopt) #define NWIOGPSIPOPT _IOR('n', 81, struct nwio_psipopt) diff --git a/include/sys/ioc_sound.h b/include/sys/ioc_sound.h index f875ab3b5..7c1d93857 100644 --- a/include/sys/ioc_sound.h +++ b/include/sys/ioc_sound.h @@ -22,13 +22,13 @@ #define DSPIORESUME _IO ('s', 33) /* Soundcard mixer ioctls. */ -#define MIXIOGETVOLUME _IORW('s', 10, struct volume_level) -#define MIXIOGETINPUTLEFT _IORW('s', 11, struct inout_ctrl) -#define MIXIOGETINPUTRIGHT _IORW('s', 12, struct inout_ctrl) -#define MIXIOGETOUTPUT _IORW('s', 13, struct inout_ctrl) -#define MIXIOSETVOLUME _IORW('s', 20, struct volume_level) -#define MIXIOSETINPUTLEFT _IORW('s', 21, struct inout_ctrl) -#define MIXIOSETINPUTRIGHT _IORW('s', 22, struct inout_ctrl) -#define MIXIOSETOUTPUT _IORW('s', 23, struct inout_ctrl) +#define MIXIOGETVOLUME _IOWR('s', 10, struct volume_level) +#define MIXIOGETINPUTLEFT _IOWR('s', 11, struct inout_ctrl) +#define MIXIOGETINPUTRIGHT _IOWR('s', 12, struct inout_ctrl) +#define MIXIOGETOUTPUT _IOWR('s', 13, struct inout_ctrl) +#define MIXIOSETVOLUME _IOWR('s', 20, struct volume_level) +#define MIXIOSETINPUTLEFT _IOWR('s', 21, struct inout_ctrl) +#define MIXIOSETINPUTRIGHT _IOWR('s', 22, struct inout_ctrl) +#define MIXIOSETOUTPUT _IOWR('s', 23, struct inout_ctrl) #endif /* _S_I_SOUND_H */ diff --git a/lib/libaudiodriver/audio_fw.c b/lib/libaudiodriver/audio_fw.c index 523c1befc..491fb54a6 100644 --- a/lib/libaudiodriver/audio_fw.c +++ b/lib/libaudiodriver/audio_fw.c @@ -24,6 +24,7 @@ #include #include #include +#include static int msg_open(devminor_t minor_dev_nr, int access, @@ -49,7 +50,7 @@ static special_file_t* get_special_file(int minor_dev_nr); static void tell_dev(vir_bytes buf, size_t size, int pci_bus, int pci_dev, int pci_func); -static char io_ctl_buf[_IOCPARM_MASK]; +static char io_ctl_buf[IOCPARM_MASK]; static int irq_hook_id = 0; /* id of irq hook at the kernel */ static int irq_hook_set = FALSE; @@ -369,7 +370,7 @@ static int msg_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt, return EIO; } - if (request & _IOC_IN) { /* if there is data for us, copy it */ + if (request & IOC_IN) { /* if there is data for us, copy it */ len = io_ctl_length(request); if (sys_safecopyfrom(endpt, grant, 0, (vir_bytes)io_ctl_buf, @@ -381,8 +382,8 @@ static int msg_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt, /* all ioctl's are passed to the device specific part of the driver */ status = drv_io_ctl(request, (void *)io_ctl_buf, &len, chan); - /* _IOC_OUT bit -> user expects data */ - if (status == OK && request & _IOC_OUT) { + /* IOC_OUT bit -> user expects data */ + if (status == OK && request & IOC_OUT) { /* copy result back to user */ if (sys_safecopyto(endpt, grant, 0, (vir_bytes)io_ctl_buf, @@ -812,7 +813,7 @@ static int init_buffers(sub_dev_t *sub_dev_ptr) static int io_ctl_length(int io_request) { io_request >>= 16; - return io_request & _IOCPARM_MASK; + return io_request & IOCPARM_MASK; } diff --git a/lib/libc/sys-minix/ioctl.c b/lib/libc/sys-minix/ioctl.c index 4aec91632..55ab9acac 100644 --- a/lib/libc/sys-minix/ioctl.c +++ b/lib/libc/sys-minix/ioctl.c @@ -4,6 +4,9 @@ #include #include +#include +#include +#include #ifdef __weak_alias __weak_alias(ioctl, _ioctl) @@ -44,14 +47,16 @@ static void rewrite_i2c_minix_to_netbsd(i2c_ioctl_exec_t *out, } } -int ioctl(fd, request, data) -int fd; -unsigned long request; -void *data; +int ioctl(int fd, unsigned long request, ...) { int r, request_save; message m; void *addr; + void *data; + va_list ap; + + va_start(ap, request); + data = va_arg(ap, void *); /* * To support compatibility with interfaces on other systems, certain @@ -90,5 +95,7 @@ void *data; break; } + va_end(ap); + return r; } diff --git a/servers/inet/sr.c b/servers/inet/sr.c index fc94f43df..8cf5d950c 100644 --- a/servers/inet/sr.c +++ b/servers/inet/sr.c @@ -240,7 +240,7 @@ static int sr_rwio(sr_req_t *req) break; case SRR_IOCTL: request= m->mq_req.srr_req; - size= (request >> 16) & _IOCPARM_MASK; + size= _MINIX_IOCTL_SIZE(request); if (size>MAX_IOCTL_S) { DBLOCK(1, printf("replying EINVAL\n")); diff --git a/servers/lwip/driver.c b/servers/lwip/driver.c index 2bf1baafc..b0761ee66 100644 --- a/servers/lwip/driver.c +++ b/servers/lwip/driver.c @@ -597,8 +597,7 @@ static int nic_do_ioctl(struct socket * sock, struct nic * nic, debug_print("device /dev/%s req %c %ld %ld", nic->name, (unsigned char) (req->req >> 8), - req->req & 0xff, - (req->req >> 16) & _IOCPARM_MASK); + req->req & 0xff, _MINIX_IOCTL_SIZE(req->req)); debug_drv_print("socket %ld", sock ? get_sock_num(sock) : -1); diff --git a/servers/lwip/raw_ip.c b/servers/lwip/raw_ip.c index d199caac5..c719653d2 100644 --- a/servers/lwip/raw_ip.c +++ b/servers/lwip/raw_ip.c @@ -318,7 +318,7 @@ static int raw_ip_op_ioctl(struct socket * sock, struct sock_req * req, get_sock_num(sock), (unsigned char) (req->req >> 8), req->req & 0xff, - (req->req >> 16) & _IOCPARM_MASK); + _MINIX_IOCTL_SIZE(req->req)); switch (req->req) { case NWIOSIPOPT: diff --git a/servers/lwip/tcp.c b/servers/lwip/tcp.c index 7d0cea26f..82632ce8e 100644 --- a/servers/lwip/tcp.c +++ b/servers/lwip/tcp.c @@ -1035,8 +1035,7 @@ static int tcp_op_ioctl(struct socket * sock, struct sock_req * req, debug_tcp_print("socket num %ld req %c %ld %ld", get_sock_num(sock), (unsigned char) (req->req >> 8), - req->req & 0xff, - (req->req >> 16) & _IOCPARM_MASK); + req->req & 0xff, _MINIX_IOCTL_SIZE(req->req)); switch (req->req) { case NWIOGTCPCONF: diff --git a/servers/lwip/udp.c b/servers/lwip/udp.c index 97326a21b..21c4cf7a0 100644 --- a/servers/lwip/udp.c +++ b/servers/lwip/udp.c @@ -376,8 +376,7 @@ static int udp_op_ioctl(struct socket * sock, struct sock_req * req, debug_udp_print("socket num %ld req %c %ld %ld", get_sock_num(sock), (unsigned char) (req->req >> 8), - req->req & 0xff, - (req->req >> 16) & _IOCPARM_MASK); + req->req & 0xff, _MINIX_IOCTL_SIZE(req->req)); switch (req->req) { case NWIOSUDPOPT: diff --git a/sys/sys/ioccom.h b/sys/sys/ioccom.h index 3cd8174c2..89392322b 100644 --- a/sys/sys/ioccom.h +++ b/sys/sys/ioccom.h @@ -34,6 +34,7 @@ #ifndef _SYS_IOCCOM_H_ #define _SYS_IOCCOM_H_ +#ifndef __minix /* * Ioctl's have the command encoded in the lower word, and the size of * any in or out parameters in the upper word. The high 3 bits of the @@ -45,6 +46,21 @@ * +---------------------------------------------------------------+ */ #define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */ +#else +/* For Minix, reserve one extra flag bit: the 'big' size flag. + * We have big ioctls and can't help it. + * + * 31 28 27 16 15 8 7 0 + * +----------------------------------------------------------------+ + * | I/O/B | Parameter Length | Command Group | Command | + * +----------------------------------------------------------------+ + */ +#define IOC_BIG (unsigned long)0x10000000 +#define IOCPARM_MASK 0xfff /* parameter length, at most 12 bits */ +#define IOCPARM_MASK_BIG 0xFFFFF /* or 20 bits, if IOC_BIG is set */ +#define IOCPARM_SHIFT_BIG 8 +#endif + #define IOCPARM_SHIFT 16 #define IOCGROUP_SHIFT 8 #define IOCPARM_LEN(x) (((x) >> IOCPARM_SHIFT) & IOCPARM_MASK) @@ -59,6 +75,7 @@ /* copy parameters in */ #define IOC_IN (unsigned long)0x80000000 /* copy parameters in and out */ + #define IOC_INOUT (IOC_IN|IOC_OUT) /* mask for IN/OUT/VOID */ #define IOC_DIRMASK (unsigned long)0xe0000000 @@ -72,4 +89,23 @@ /* this should be _IORW, but stdio got there first */ #define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) +#ifdef __minix +#define _IOW_BIG(y,t) (y | ((sizeof(t) & IOCPARM_MASK_BIG) << IOCPARM_SHIFT_BIG) \ + | IOC_IN | IOC_BIG) +#define _IOR_BIG(y,t) (y | ((sizeof(t) & IOCPARM_MASK_BIG) << IOCPARM_SHIFT_BIG) \ + | IOC_OUT | IOC_BIG) +#define _IORW_BIG(y,t) (y | ((sizeof(t) & IOCPARM_MASK_BIG) << IOCPARM_SHIFT_BIG) \ + | IOC_INOUT | IOC_BIG) + +/* Decode an ioctl call. */ +#define _MINIX_IOCTL_SIZE(i) (((i) >> IOCPARM_SHIFT) & IOCPARM_MASK) +#define _MINIX_IOCTL_IOR(i) ((i) & IOC_OUT) +#define _MINIX_IOCTL_IORW(i) ((i) & IOC_INOUT) +#define _MINIX_IOCTL_IOW(i) ((i) & IOC_IN) + +/* Recognize and decode size of a 'big' ioctl call. */ +#define _MINIX_IOCTL_BIG(i) ((i) & IOC_BIG) +#define _MINIX_IOCTL_SIZE_BIG(i) (((i) >> IOCPARM_SHIFT_BIG) & IOCPARM_MASK_BIG) +#endif + #endif /* !_SYS_IOCCOM_H_ */ diff --git a/sys/sys/ioctl.h b/sys/sys/ioctl.h index 9aa867f8e..54a65aeed 100644 --- a/sys/sys/ioctl.h +++ b/sys/sys/ioctl.h @@ -1,19 +1,68 @@ -/* sys/ioctl.h - All ioctl() command codes. Author: Kees J. Bot - * 23 Nov 2002 +/* $NetBSD: ioctl.h,v 1.36 2009/02/13 22:41:04 apb Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * This header file includes all other ioctl command code headers. + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ioctl.h 8.6 (Berkeley) 3/28/94 */ -#ifndef _S_IOCTL_H -#define _S_IOCTL_H +#ifndef _SYS_IOCTL_H_ +#define _SYS_IOCTL_H_ + +#include -/* A driver that uses ioctls claims a character for its series of commands. - * For instance: #define TCGETS _IOR('T', 8, struct termios) - * This is a terminal ioctl that uses the character 'T'. The character(s) - * used in each header file are shown in the comment following. +/* + * Pun for SunOS prior to 3.2. SunOS 3.2 and later support TIOCGWINSZ + * and TIOCSWINSZ (yes, even 3.2-3.5, the fact that it wasn't documented + * nonwithstanding). */ +struct ttysize { + unsigned short ts_lines; + unsigned short ts_cols; + unsigned short ts_xxx; + unsigned short ts_yyy; +}; +#define TIOCGSIZE TIOCGWINSZ +#define TIOCSSIZE TIOCSWINSZ -#include /* 't' */ +#include + +#include +#include +#include + +#ifdef __minix +/* ioctls */ #include /* 'n' */ #include /* 'd' */ #include /* 'f' */ @@ -24,8 +73,63 @@ #include /* 'B' */ #include /* 'V' */ #include /* 'F' */ +#include +#endif + +/* + * Passthrough ioctl commands. These are passed through to devices + * as they are, it is expected that the device (a module, for example), + * will know how to deal with them. One for each emulation, so that + * no namespace clashes will occur between them, for devices that + * may be dealing with specific ioctls for multiple emulations. + */ + +struct ioctl_pt { + unsigned long com; + void *data; +}; + +#define PTIOCNETBSD _IOW('Z', 0, struct ioctl_pt) +#define PTIOCSUNOS _IOW('Z', 1, struct ioctl_pt) +#define PTIOCSVR4 _IOW('Z', 2, struct ioctl_pt) +#define PTIOCLINUX _IOW('Z', 3, struct ioctl_pt) +#define PTIOCFREEBSD _IOW('Z', 4, struct ioctl_pt) +#define PTIOCOSF1 _IOW('Z', 5, struct ioctl_pt) +#define PTIOCULTRIX _IOW('Z', 6, struct ioctl_pt) +#define PTIOCWIN32 _IOW('Z', 7, struct ioctl_pt) + +#ifndef _KERNEL + +#include + +__BEGIN_DECLS +int ioctl(int, unsigned long, ...); +__END_DECLS +#endif /* !_KERNEL */ +#endif /* !_SYS_IOCTL_H_ */ + +#ifndef __minix +/* + * Keep outside _SYS_IOCTL_H_ + * Compatibility with old terminal driver + * + * Source level -> #define USE_OLD_TTY + * Kernel level -> options COMPAT_43 or COMPAT_SUNOS or ... + */ -#define TIOCGSIZE TIOCGWINSZ -#define TIOCSSIZE TIOCSWINSZ +#if defined(_KERNEL_OPT) +#include "opt_compat_freebsd.h" +#include "opt_compat_sunos.h" +#include "opt_compat_svr4.h" +#include "opt_compat_43.h" +#include "opt_compat_osf1.h" +#include "opt_compat_ibcs2.h" +#include "opt_modular.h" +#endif -#endif /* _S_IOCTL_H */ +#if defined(USE_OLD_TTY) || defined(COMPAT_43) || defined(COMPAT_SUNOS) || \ + defined(COMPAT_SVR4) || defined(COMPAT_FREEBSD) || defined(COMPAT_OSF1) || \ + defined(COMPAT_IBCS2) || defined(MODULAR) +#include +#endif +#endif diff --git a/sys/sys/ioctl_compat.h b/sys/sys/ioctl_compat.h index 893e3d13a..34be82d00 100644 --- a/sys/sys/ioctl_compat.h +++ b/sys/sys/ioctl_compat.h @@ -1,3 +1,4 @@ +#ifndef __minix /* $NetBSD: ioctl_compat.h,v 1.15 2005/12/03 17:10:46 christos Exp $ */ /* @@ -163,3 +164,4 @@ struct sgttyb { #define NTTYDISC 2 #endif /* !_SYS_IOCTL_COMPAT_H_ */ +#endif diff --git a/sys/sys/ttycom.h b/sys/sys/ttycom.h index efffe8ffe..cb9df0517 100644 --- a/sys/sys/ttycom.h +++ b/sys/sys/ttycom.h @@ -176,8 +176,8 @@ typedef char linedn_t[TTLINEDNAMELEN]; #define KIOCSMAP _IOW('k', 3, keymap_t) /* /dev/video ioctls. */ -#define TIOCMAPMEM _IORW('v', 1, struct mapreqvm) -#define TIOCUNMAPMEM _IORW('v', 2, struct mapreqvm) +#define TIOCMAPMEM _IOWR('v', 1, struct mapreqvm) +#define TIOCUNMAPMEM _IOWR('v', 2, struct mapreqvm) #endif #endif /* !_SYS_TTYCOM_H_ */ diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index a83a3cc3a..637f1abe3 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include