source: rtems/cpukit/libfs/src/imfs/imfs_handlers_device.c

Last change on this file was 67a5936, checked in by Joel Sherrill <joel@…>, on 03/18/22 at 14:43:02

cpukit/libfs/src/imfs: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup IMFS
7 *
8 * @brief Device Operations Table
9 */
10
11/*
12 *  COPYRIGHT (c) 1989-1999.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 *    notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 *    notice, this list of conditions and the following disclaimer in the
22 *    documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifdef HAVE_CONFIG_H
38#include "config.h"
39#endif
40
41#include <rtems/imfs.h>
42
43static int IMFS_stat_device(
44  const rtems_filesystem_location_info_t *loc,
45  struct stat *buf
46)
47{
48  const IMFS_device_t *device = loc->node_access;
49
50  buf->st_rdev = rtems_filesystem_make_dev_t( device->major, device->minor );
51
52  return IMFS_stat( loc, buf );
53}
54
55static const rtems_filesystem_file_handlers_r IMFS_device_handlers = {
56  .open_h = device_open,
57  .close_h = device_close,
58  .read_h = device_read,
59  .write_h = device_write,
60  .ioctl_h = device_ioctl,
61  .lseek_h = rtems_filesystem_default_lseek_file,
62  .fstat_h = IMFS_stat_device,
63  .ftruncate_h = device_ftruncate,
64  .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
65  .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
66  .fcntl_h = rtems_filesystem_default_fcntl,
67  .kqfilter_h = rtems_filesystem_default_kqfilter,
68  .mmap_h = rtems_filesystem_default_mmap,
69  .poll_h = rtems_filesystem_default_poll,
70  .readv_h = rtems_filesystem_default_readv,
71  .writev_h = rtems_filesystem_default_writev
72};
73
74static IMFS_jnode_t *IMFS_node_initialize_device(
75  IMFS_jnode_t *node,
76  void *arg
77)
78{
79  IMFS_device_t *device = (IMFS_device_t *) node;
80  dev_t *dev = arg;
81
82  rtems_filesystem_split_dev_t( *dev, device->major, device->minor );
83
84  return node;
85}
86
87const IMFS_mknod_control IMFS_mknod_control_device = {
88  {
89    .handlers = &IMFS_device_handlers,
90    .node_initialize = IMFS_node_initialize_device,
91    .node_remove = IMFS_node_remove_default,
92    .node_destroy = IMFS_node_destroy_default
93  },
94  .node_size = sizeof( IMFS_device_t )
95};
Note: See TracBrowser for help on using the repository browser.