1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Device Operations Table |
---|
5 | * @ingroup IMFS |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include "imfs.h" |
---|
22 | |
---|
23 | static int IMFS_stat_device( |
---|
24 | const rtems_filesystem_location_info_t *loc, |
---|
25 | struct stat *buf |
---|
26 | ) |
---|
27 | { |
---|
28 | const IMFS_device_t *device = loc->node_access; |
---|
29 | |
---|
30 | buf->st_rdev = rtems_filesystem_make_dev_t( device->major, device->minor ); |
---|
31 | |
---|
32 | return IMFS_stat( loc, buf ); |
---|
33 | } |
---|
34 | |
---|
35 | static const rtems_filesystem_file_handlers_r IMFS_device_handlers = { |
---|
36 | .open_h = device_open, |
---|
37 | .close_h = device_close, |
---|
38 | .read_h = device_read, |
---|
39 | .write_h = device_write, |
---|
40 | .ioctl_h = device_ioctl, |
---|
41 | .lseek_h = rtems_filesystem_default_lseek_file, |
---|
42 | .fstat_h = IMFS_stat_device, |
---|
43 | .ftruncate_h = device_ftruncate, |
---|
44 | .fsync_h = rtems_filesystem_default_fsync_or_fdatasync, |
---|
45 | .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync, |
---|
46 | .fcntl_h = rtems_filesystem_default_fcntl, |
---|
47 | .kqfilter_h = rtems_filesystem_default_kqfilter, |
---|
48 | .poll_h = rtems_filesystem_default_poll, |
---|
49 | .readv_h = rtems_filesystem_default_readv, |
---|
50 | .writev_h = rtems_filesystem_default_writev |
---|
51 | }; |
---|
52 | |
---|
53 | static IMFS_jnode_t *IMFS_node_initialize_device( |
---|
54 | IMFS_jnode_t *node, |
---|
55 | void *arg |
---|
56 | ) |
---|
57 | { |
---|
58 | IMFS_device_t *device = (IMFS_device_t *) node; |
---|
59 | dev_t *dev = arg; |
---|
60 | |
---|
61 | rtems_filesystem_split_dev_t( *dev, device->major, device->minor ); |
---|
62 | |
---|
63 | return node; |
---|
64 | } |
---|
65 | |
---|
66 | const IMFS_mknod_control IMFS_mknod_control_device = { |
---|
67 | { |
---|
68 | .handlers = &IMFS_device_handlers, |
---|
69 | .node_initialize = IMFS_node_initialize_device, |
---|
70 | .node_remove = IMFS_node_remove_default, |
---|
71 | .node_destroy = IMFS_node_destroy_default |
---|
72 | }, |
---|
73 | .node_size = sizeof( IMFS_device_t ) |
---|
74 | }; |
---|