1 | /* |
---|
2 | * Device Operations Table for the IMFS |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-1999. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | */ |
---|
11 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include "imfs.h" |
---|
17 | |
---|
18 | static int IMFS_stat_device( |
---|
19 | const rtems_filesystem_location_info_t *loc, |
---|
20 | struct stat *buf |
---|
21 | ) |
---|
22 | { |
---|
23 | const IMFS_jnode_t *node = loc->node_access; |
---|
24 | const IMFS_device_t *io = &node->info.device; |
---|
25 | |
---|
26 | buf->st_rdev = rtems_filesystem_make_dev_t( io->major, io->minor ); |
---|
27 | |
---|
28 | return IMFS_stat( loc, buf ); |
---|
29 | } |
---|
30 | |
---|
31 | static const rtems_filesystem_file_handlers_r IMFS_device_handlers = { |
---|
32 | device_open, |
---|
33 | device_close, |
---|
34 | device_read, |
---|
35 | device_write, |
---|
36 | device_ioctl, |
---|
37 | rtems_filesystem_default_lseek_file, |
---|
38 | IMFS_stat_device, |
---|
39 | device_ftruncate, |
---|
40 | rtems_filesystem_default_fsync_or_fdatasync, |
---|
41 | rtems_filesystem_default_fsync_or_fdatasync, |
---|
42 | rtems_filesystem_default_fcntl |
---|
43 | }; |
---|
44 | |
---|
45 | static IMFS_jnode_t *IMFS_node_initialize_device( |
---|
46 | IMFS_jnode_t *node, |
---|
47 | const IMFS_types_union *info |
---|
48 | ) |
---|
49 | { |
---|
50 | node->info.device.major = info->device.major; |
---|
51 | node->info.device.minor = info->device.minor; |
---|
52 | |
---|
53 | return node; |
---|
54 | } |
---|
55 | |
---|
56 | const IMFS_node_control IMFS_node_control_device = { |
---|
57 | .imfs_type = IMFS_DEVICE, |
---|
58 | .handlers = &IMFS_device_handlers, |
---|
59 | .node_initialize = IMFS_node_initialize_device, |
---|
60 | .node_remove = IMFS_node_remove_default, |
---|
61 | .node_destroy = IMFS_node_destroy_default |
---|
62 | }; |
---|