Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:17

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup IMFS
0007  *
0008  * @brief IMFS Device Node Handlers
0009  */
0010 
0011 /*
0012  *  COPYRIGHT (c) 1989-2012.
0013  *  On-Line Applications Research Corporation (OAR).
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 #ifdef HAVE_CONFIG_H
0038 #include "config.h"
0039 #endif
0040 
0041 #include <rtems/imfs.h>
0042 
0043 #include <rtems/deviceio.h>
0044 
0045 int device_open(
0046   rtems_libio_t *iop,
0047   const char    *pathname,
0048   int            oflag,
0049   mode_t         mode
0050 )
0051 {
0052   const IMFS_device_t *device = IMFS_iop_to_device( iop );
0053 
0054   return rtems_deviceio_open(
0055     iop,
0056     pathname,
0057     oflag,
0058     mode,
0059     device->major,
0060     device->minor
0061   );
0062 }
0063 
0064 int device_close(
0065   rtems_libio_t *iop
0066 )
0067 {
0068   const IMFS_device_t *device = IMFS_iop_to_device( iop );
0069 
0070   return rtems_deviceio_close(
0071     iop,
0072     device->major,
0073     device->minor
0074   );
0075 }
0076 
0077 ssize_t device_read(
0078   rtems_libio_t *iop,
0079   void          *buffer,
0080   size_t         count
0081 )
0082 {
0083   const IMFS_device_t *device = IMFS_iop_to_device( iop );
0084 
0085   return rtems_deviceio_read(
0086     iop,
0087     buffer,
0088     count,
0089     device->major,
0090     device->minor
0091   );
0092 }
0093 
0094 ssize_t device_write(
0095   rtems_libio_t *iop,
0096   const void    *buffer,
0097   size_t         count
0098 )
0099 {
0100   const IMFS_device_t *device = IMFS_iop_to_device( iop );
0101 
0102   return rtems_deviceio_write(
0103     iop,
0104     buffer,
0105     count,
0106     device->major,
0107     device->minor
0108   );
0109 }
0110 
0111 int device_ioctl(
0112   rtems_libio_t   *iop,
0113   ioctl_command_t  command,
0114   void            *buffer
0115 )
0116 {
0117   const IMFS_device_t *device = IMFS_iop_to_device( iop );
0118 
0119   return rtems_deviceio_control(
0120     iop,
0121     command,
0122     buffer,
0123     device->major,
0124     device->minor
0125   );
0126 }
0127 
0128 int device_ftruncate(
0129   rtems_libio_t *iop,
0130   off_t          length
0131 )
0132 {
0133   return 0;
0134 }