[rtems commit] Filesystem: Use ioctl_command_t

Sebastian Huber sebh at rtems.org
Tue May 15 07:59:43 UTC 2012


Module:    rtems
Branch:    master
Commit:    df01da67078b4ed4787680d3987f5b40ac93d080
Changeset: http://git.rtems.org/rtems/commit/?id=df01da67078b4ed4787680d3987f5b40ac93d080

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon May 14 13:16:31 2012 +0200

Filesystem: Use ioctl_command_t

---

 cpukit/libcsupport/include/rtems/libio.h           |   14 +++++++-------
 cpukit/libcsupport/include/sys/ioccom.h            |    7 ++-----
 cpukit/libfs/src/defaults/default_ioctl.c          |   12 +++++++-----
 cpukit/libfs/src/devfs/devfs.h                     |    6 +++---
 cpukit/libfs/src/devfs/devioctl.c                  |    6 +++---
 cpukit/libfs/src/imfs/deviceio.c                   |    6 +++---
 cpukit/libfs/src/imfs/imfs.h                       |   12 +++---------
 cpukit/libfs/src/imfs/imfs_fifo.c                  |    6 +++---
 cpukit/libfs/src/imfs/imfs_handlers_memfile.c      |    2 +-
 cpukit/libfs/src/imfs/memfile.c                    |   16 ----------------
 cpukit/libfs/src/pipe/fifo.c                       |    8 ++++----
 cpukit/libfs/src/pipe/pipe.h                       |    8 ++++----
 cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c         |    6 +++---
 cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c        |   18 +-----------------
 cpukit/libnetworking/rtems/rtems_bsdnet_internal.h |    7 +------
 testsuites/psxtests/psxfile01/test.c               |    4 +---
 16 files changed, 46 insertions(+), 92 deletions(-)

diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index bb6c44f..9268aed 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -832,9 +832,9 @@ typedef ssize_t (*rtems_filesystem_write_t)(
  * @see rtems_filesystem_default_ioctl().
  */
 typedef int (*rtems_filesystem_ioctl_t)(
-  rtems_libio_t *iop,
-  uint32_t       request,
-  void          *buffer
+  rtems_libio_t   *iop,
+  ioctl_command_t  request,
+  void            *buffer
 );
 
 /**
@@ -1008,9 +1008,9 @@ ssize_t rtems_filesystem_default_write(
  * @see rtems_filesystem_ioctl_t.
  */
 int rtems_filesystem_default_ioctl(
-  rtems_libio_t *iop,
-  uint32_t       command,
-  void          *buffer
+  rtems_libio_t   *iop,
+  ioctl_command_t  request,
+  void            *buffer
 );
 
 /**
@@ -1225,7 +1225,7 @@ typedef struct {
  */
 typedef struct {
   rtems_libio_t          *iop;
-  uint32_t                command;
+  ioctl_command_t         command;
   void                   *buffer;
   int                     ioctl_return;
 } rtems_libio_ioctl_args_t;
diff --git a/cpukit/libcsupport/include/sys/ioccom.h b/cpukit/libcsupport/include/sys/ioccom.h
index 054eac7..4bbe1bc 100644
--- a/cpukit/libcsupport/include/sys/ioccom.h
+++ b/cpukit/libcsupport/include/sys/ioccom.h
@@ -83,15 +83,12 @@
 #define FIOSETOWN       _IOW('f', 124, int)     /* set owner */
 #define FIOGETOWN       _IOR('f', 123, int)     /* get owner */
 
+typedef uint32_t ioctl_command_t;
+
 #ifndef _KERNEL
 
 #include <sys/cdefs.h>
 
-#ifndef __ioctl_command_defined
-typedef u_int32_t ioctl_command_t;
-#define __ioctl_command_defined
-#endif
-
 __BEGIN_DECLS
 int	ioctl(int, ioctl_command_t, ...);
 __END_DECLS
diff --git a/cpukit/libfs/src/defaults/default_ioctl.c b/cpukit/libfs/src/defaults/default_ioctl.c
index f86f2bc..edd1c62 100644
--- a/cpukit/libfs/src/defaults/default_ioctl.c
+++ b/cpukit/libfs/src/defaults/default_ioctl.c
@@ -7,14 +7,16 @@
  *  http://www.rtems.com/license/LICENSE.
  */
 
-#include <rtems/libio.h>
+#if HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
 #include <rtems/libio_.h>
-#include <rtems/seterr.h>
 
 int rtems_filesystem_default_ioctl(
-  rtems_libio_t *iop,
-  uint32_t       command,
-  void          *buffer
+  rtems_libio_t   *iop,
+  ioctl_command_t  request,
+  void            *buffer
 )
 {
   rtems_set_errno_and_return_minus_one( ENOTSUP );
diff --git a/cpukit/libfs/src/devfs/devfs.h b/cpukit/libfs/src/devfs/devfs.h
index 64b86d4..60ee7ab 100644
--- a/cpukit/libfs/src/devfs/devfs.h
+++ b/cpukit/libfs/src/devfs/devfs.h
@@ -137,9 +137,9 @@ extern ssize_t devFS_write(
  */
 
 extern int devFS_ioctl(
-  rtems_libio_t *iop,
-  uint32_t       command,
-  void          *buffer
+  rtems_libio_t   *iop,
+  ioctl_command_t  command,
+  void            *buffer
 );
 
 
diff --git a/cpukit/libfs/src/devfs/devioctl.c b/cpukit/libfs/src/devfs/devioctl.c
index 7f9c343..bca8250 100644
--- a/cpukit/libfs/src/devfs/devioctl.c
+++ b/cpukit/libfs/src/devfs/devioctl.c
@@ -14,9 +14,9 @@
 #include "devfs.h"
 
 int devFS_ioctl(
-  rtems_libio_t *iop,
-  uint32_t       command,
-  void          *buffer
+  rtems_libio_t   *iop,
+  ioctl_command_t  command,
+  void            *buffer
 )
 {
   rtems_libio_ioctl_args_t  args;
diff --git a/cpukit/libfs/src/imfs/deviceio.c b/cpukit/libfs/src/imfs/deviceio.c
index e5a4d85..60a66f3 100644
--- a/cpukit/libfs/src/imfs/deviceio.c
+++ b/cpukit/libfs/src/imfs/deviceio.c
@@ -162,9 +162,9 @@ ssize_t device_write(
  */
 
 int device_ioctl(
-  rtems_libio_t *iop,
-  uint32_t       command,
-  void          *buffer
+  rtems_libio_t   *iop,
+  ioctl_command_t  command,
+  void            *buffer
 )
 {
   rtems_libio_ioctl_args_t  args;
diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h
index fc9d50e..7c0cbe5 100644
--- a/cpukit/libfs/src/imfs/imfs.h
+++ b/cpukit/libfs/src/imfs/imfs.h
@@ -435,12 +435,6 @@ extern ssize_t memfile_write(
   size_t         count            /* IN  */
 );
 
-extern int memfile_ioctl(
-  rtems_libio_t *iop,             /* IN  */
-  uint32_t       command,         /* IN  */
-  void          *buffer           /* IN  */
-);
-
 extern int device_open(
   rtems_libio_t *iop,            /* IN  */
   const char    *pathname,       /* IN  */
@@ -465,9 +459,9 @@ extern ssize_t device_write(
 );
 
 extern int device_ioctl(
-  rtems_libio_t *iop,               /* IN  */
-  uint32_t       command,           /* IN  */
-  void          *buffer             /* IN  */
+  rtems_libio_t   *iop,
+  ioctl_command_t  command,
+  void            *buffer
 );
 
 extern int device_ftruncate(
diff --git a/cpukit/libfs/src/imfs/imfs_fifo.c b/cpukit/libfs/src/imfs/imfs_fifo.c
index 943bfed..8601ef7 100644
--- a/cpukit/libfs/src/imfs/imfs_fifo.c
+++ b/cpukit/libfs/src/imfs/imfs_fifo.c
@@ -83,9 +83,9 @@ static ssize_t IMFS_fifo_write(
 }
 
 static int IMFS_fifo_ioctl(
-  rtems_libio_t *iop,
-  uint32_t       command,
-  void          *buffer
+  rtems_libio_t   *iop,
+  ioctl_command_t  command,
+  void            *buffer
 )
 {
   int err;
diff --git a/cpukit/libfs/src/imfs/imfs_handlers_memfile.c b/cpukit/libfs/src/imfs/imfs_handlers_memfile.c
index 6a1466e..6953319 100644
--- a/cpukit/libfs/src/imfs/imfs_handlers_memfile.c
+++ b/cpukit/libfs/src/imfs/imfs_handlers_memfile.c
@@ -33,7 +33,7 @@ static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
   rtems_filesystem_default_close,
   memfile_read,
   memfile_write,
-  memfile_ioctl,
+  rtems_filesystem_default_ioctl,
   rtems_filesystem_default_lseek_file,
   IMFS_stat_file,
   memfile_ftruncate,
diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c
index 2907591..fcbeed9 100644
--- a/cpukit/libfs/src/imfs/memfile.c
+++ b/cpukit/libfs/src/imfs/memfile.c
@@ -152,22 +152,6 @@ ssize_t memfile_write(
 }
 
 /*
- *  memfile_ioctl
- *
- *  This routine processes the ioctl() system call.
- *
- *  NOTE:  No ioctl()'s are supported for in-memory files.
- */
-int memfile_ioctl(
-  rtems_libio_t *iop,
-  uint32_t       command,
-  void          *buffer
-)
-{
-  return 0;
-}
-
-/*
  *  memfile_stat
  *
  *  This IMFS_stat() can be used.
diff --git a/cpukit/libfs/src/pipe/fifo.c b/cpukit/libfs/src/pipe/fifo.c
index 7d990e5..06eacd7 100644
--- a/cpukit/libfs/src/pipe/fifo.c
+++ b/cpukit/libfs/src/pipe/fifo.c
@@ -549,10 +549,10 @@ out_nolock:
  * Interface to file system ioctl.
  */
 int pipe_ioctl(
-  pipe_control_t *pipe,
-  uint32_t        cmd,
-  void           *buffer,
-  rtems_libio_t  *iop
+  pipe_control_t  *pipe,
+  ioctl_command_t  cmd,
+  void            *buffer,
+  rtems_libio_t   *iop
 )
 {
   if (cmd == FIONREAD) {
diff --git a/cpukit/libfs/src/pipe/pipe.h b/cpukit/libfs/src/pipe/pipe.h
index d856a63..29e7542 100644
--- a/cpukit/libfs/src/pipe/pipe.h
+++ b/cpukit/libfs/src/pipe/pipe.h
@@ -96,10 +96,10 @@ extern ssize_t pipe_write(
  * Interface to file system ioctl.
  */
 extern int pipe_ioctl(
-  pipe_control_t *pipe,
-  uint32_t        cmd,
-  void           *buffer,
-  rtems_libio_t  *iop
+  pipe_control_t  *pipe,
+  ioctl_command_t  cmd,
+  void            *buffer,
+  rtems_libio_t   *iop
 );
 
 #ifdef __cplusplus
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c
index 81fdbe3..729d420 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c
@@ -194,9 +194,9 @@ rtems_rfs_rtems_device_write (rtems_libio_t* iop,
  */
 
 static int
-rtems_rfs_rtems_device_ioctl (rtems_libio_t* iop,
-                              uint32_t       command,
-                              void*          buffer)
+rtems_rfs_rtems_device_ioctl (rtems_libio_t*  iop,
+                              ioctl_command_t command,
+                              void*           buffer)
 {
   rtems_libio_ioctl_args_t  args;
   rtems_status_code         status;
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
index cf864c7..525dcee 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
@@ -257,22 +257,6 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop,
 }
 
 /**
- * This routine processes the ioctl() system call.
- *
- * @note  No ioctl()'s are currently supported for RFS files.
- *
- * @param iop
- * @param command
- * @param buffer
- */
-
-static int
-rtems_rfs_rtems_file_ioctl (rtems_libio_t* iop, uint32_t command, void* buffer)
-{
-  return 0;
-}
-
-/**
  * This routine processes the lseek() system call.
  *
  * @param iop
@@ -351,7 +335,7 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_file_handlers = {
   .close_h     = rtems_rfs_rtems_file_close,
   .read_h      = rtems_rfs_rtems_file_read,
   .write_h     = rtems_rfs_rtems_file_write,
-  .ioctl_h     = rtems_rfs_rtems_file_ioctl,
+  .ioctl_h     = rtems_filesystem_default_ioctl,
   .lseek_h     = rtems_rfs_rtems_file_lseek,
   .fstat_h     = rtems_rfs_rtems_fstat,
   .ftruncate_h = rtems_rfs_rtems_file_ftruncate,
diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
index faf601c..d9be5af 100644
--- a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
+++ b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
@@ -22,12 +22,6 @@ typedef	long long		vm_ooffset_t;
 typedef	unsigned int		vm_pindex_t;
 typedef	unsigned int		vm_size_t;
 
-#ifndef __ioctl_command_defined
-typedef u_int32_t ioctl_command_t;
-#define __ioctl_command_defined
-#endif
-
-
 #define _BSD_OFF_T_	int32_t
 #define _BSD_PID_T_	rtems_id
 #define _BSD_VA_LIST_	char *
@@ -38,6 +32,7 @@ typedef u_int32_t ioctl_command_t;
 #include <sys/cdefs.h>
 
 #include <sys/time.h>
+#include <sys/ioctl.h>
 
 struct mdproc {
 	int	md_flags;
diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c
index 20a0792..d817e65 100644
--- a/testsuites/psxtests/psxfile01/test.c
+++ b/testsuites/psxtests/psxfile01/test.c
@@ -334,9 +334,7 @@ int main(
   puts("create /tmp/john");
   fd = open( "/tmp/john", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO );
   rtems_test_assert( fd != -1 );
-
-  puts("tcdrain /tmp/john" );
-  status = tcdrain( fd );
+  status = close( fd );
   rtems_test_assert( status == 0 );
 
   /* 




More information about the vc mailing list