Add support for a variadic ioctl() function. The ioctl() interface is a non-standard, Unix interface. NuttX has always used the older, three-parameter version. Most contemporary systems now, however, use a variadic form of the ioctl() function. Added an option to insert a shim layer to adapt the three-parameter ioctl() to use the variadic interface form. Internally, the ioctl handling is the same three-parameter logic. The only real complexity to the shim is in how the system calls must be handled.

This commit is contained in:
Gregory Nutt
2014-11-29 10:53:22 -06:00
parent 19d31412f7
commit e31d5125ae
11 changed files with 233 additions and 53 deletions
+34
View File
@@ -624,6 +624,40 @@ int open_blockdriver(FAR const char *pathname, int mountflags,
int close_blockdriver(FAR struct inode *inode);
#endif
/* fs/vfs/fs_ioctl.c ********************************************************/
/****************************************************************************
* Name: fs_ioctl
*
* Description:
* Perform device specific operations.
*
* Parameters:
* fd File/socket descriptor of device
* req The ioctl command
* arg The argument of the ioctl cmd
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
* -1 on failure withi errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.
* EFAULT
* 'arg' references an inaccessible memory area.
* EINVAL
* 'cmd' or 'arg' is not valid.
* ENOTTY
* 'fd' is not associated with a character special device.
* ENOTTY
* The specified request does not apply to the kind of object that the
* descriptor 'fd' references.
*
****************************************************************************/
#ifdef CONFIG_LIBC_IOCTL_VARIADIC
int fs_ioctl(int fd, int req, unsigned long arg);
#endif
/* fs_fdopen.c **************************************************************/
/****************************************************************************
* Name: fs_fdopen
+39 -10
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* include/sys/ioctl.h
*
* Copyright (C) 2007, 2008, 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2008, 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -55,14 +55,6 @@
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Type Definitions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
@@ -72,9 +64,46 @@ extern "C"
#define EXTERN extern
#endif
/* ioctl() is a non-standard UNIX-like API */
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: ioctl/fs_ioctl
*
* Description:
* Perform device specific operations.
*
* ioctl() is a non-standard UNIX-like API
*
* Parameters:
* fd File/socket descriptor of device
* req The ioctl command
* arg The argument of the ioctl cmd
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
* -1 on failure withi errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.
* EFAULT
* 'arg' references an inaccessible memory area.
* EINVAL
* 'cmd' or 'arg' is not valid.
* ENOTTY
* 'fd' is not associated with a character special device.
* ENOTTY
* The specified request does not apply to the kind of object that the
* descriptor 'fd' references.
*
****************************************************************************/
#ifdef CONFIG_LIBC_IOCTL_VARIADIC
int ioctl(int fd, int req, ...);
#else
int ioctl(int fd, int req, unsigned long arg);
#endif
#undef EXTERN
#if defined(__cplusplus)
+5 -1
View File
@@ -229,7 +229,11 @@
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
# define SYS_close (__SYS_descriptors+0)
# define SYS_ioctl (__SYS_descriptors+1)
# ifdef CONFIG_LIBC_IOCTL_VARIADIC
# define SYS_fs_ioctl (__SYS_descriptors+1)
# else
# define SYS_ioctl (__SYS_descriptors+1)
# endif
# define SYS_read (__SYS_descriptors+2)
# define SYS_write (__SYS_descriptors+3)
# define SYS_pread (__SYS_descriptors+4)