2005-07-28 Samuel Thibault * ioctl.c (__ioctl): Add handling of parameter-less ioctls. 2005-07-28 Samuel Thibault * ioctls.h (_IOIW): New macro for immediate-write ioctls. --- sysdeps/mach/hurd/bits/ioctls.h | 1 + sysdeps/mach/hurd/ioctl.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) --- a/sysdeps/mach/hurd/ioctl.c +++ b/sysdeps/mach/hurd/ioctl.c @@ -89,7 +89,7 @@ void *p; #endif - void *arg; + void *arg = NULL; error_t err; @@ -140,7 +140,7 @@ in (_IOT_COUNT1 (type), _IOT_TYPE1 (type)); in (_IOT_COUNT2 (type), _IOT_TYPE2 (type)); } - else if (_IOC_INOUT (request) == IOC_VOID) + else if ((_IOC_INOUT (request) == IOC_VOID) && _IOT_COUNT0 (type)) { /* The RPC takes a single integer_t argument. Rather than pointing to the value, ARG is the value itself. */ @@ -209,11 +209,15 @@ return msg.header.RetCode; } - va_list ap; + if (_IOT_COUNT0 (type)) + { + /* Data need either be sent, received, or even both. */ + va_list ap; - va_start (ap, request); - arg = va_arg (ap, void *); - va_end (ap); + va_start (ap, request); + arg = va_arg (ap, void *); + va_end (ap); + } { /* Check for a registered handler for REQUEST. */ --- a/sysdeps/mach/hurd/bits/ioctls.h +++ b/sysdeps/mach/hurd/bits/ioctls.h @@ -158,6 +158,7 @@ _IOT_foobar is defined either in this file, or where struct foobar is defined. */ #define _IO(g, n) _IOC (IOC_VOID, (g), (n), 0) +#define _IOIW(g, n, t) _IOC (IOC_VOID, (g), (n), _IOC_ENCODE_TYPE (t)) #define _IOR(g, n, t) _IOC (IOC_OUT, (g), (n), _IOC_ENCODE_TYPE (t)) #define _IOW(g, n, t) _IOC (IOC_IN, (g), (n), _IOC_ENCODE_TYPE (t)) #define _IOWR(g, n, t) _IOC (IOC_INOUT, (g), (n), _IOC_ENCODE_TYPE (t))