diff options
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -7966,6 +7966,29 @@ do_ioctl(int fd, ioctl_req_t cmd, long narg) return retval; } +#define DEFULT_IOCTL_NARG_LEN (256) + +#ifdef __linux__ +static long +linux_iocparm_len(ioctl_req_t cmd) +{ + long len; + + if ((cmd & 0xFFFF0000) == 0) { + /* legacy and unstructured ioctl number. */ + return DEFULT_IOCTL_NARG_LEN; + } + + len = _IOC_SIZE(cmd); + + /* paranoia check for silly drivers which don't keep ioctl convention */ + if (len < DEFULT_IOCTL_NARG_LEN) + len = DEFULT_IOCTL_NARG_LEN; + + return len; +} +#endif + static long ioctl_narg_len(ioctl_req_t cmd) { @@ -7978,8 +8001,11 @@ ioctl_narg_len(ioctl_req_t cmd) #endif #ifdef IOCPARM_LEN len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */ +#elif defined(__linux__) + len = linux_iocparm_len(cmd); #else - len = 256; /* otherwise guess at what's safe */ + /* otherwise guess at what's safe */ + len = DEFULT_IOCTL_NARG_LEN; #endif return len; |