[d40da79b] | 1 | /* |
---|
| 2 | * COPYRIGHT (c) 1989-2008. |
---|
| 3 | * On-Line Applications Research Corporation (OAR). |
---|
| 4 | * |
---|
[3b7c123] | 5 | * Modifications to support reference counting in the file system are |
---|
| 6 | * Copyright (c) 2012 embedded brains GmbH. |
---|
| 7 | * |
---|
[d40da79b] | 8 | * The license and distribution terms for this file may be |
---|
| 9 | * found in the file LICENSE in this distribution or at |
---|
| 10 | * http://www.rtems.com/license/LICENSE. |
---|
| 11 | */ |
---|
| 12 | |
---|
| 13 | #if HAVE_CONFIG_H |
---|
[3b7c123] | 14 | #include "config.h" |
---|
[d40da79b] | 15 | #endif |
---|
| 16 | |
---|
[3b7c123] | 17 | #include <sys/stat.h> |
---|
| 18 | |
---|
[d40da79b] | 19 | #include <rtems/libio_.h> |
---|
| 20 | |
---|
[3b7c123] | 21 | static int null_handler_open( |
---|
| 22 | rtems_libio_t *iop, |
---|
| 23 | const char *path, |
---|
| 24 | int oflag, |
---|
| 25 | mode_t mode |
---|
| 26 | ) |
---|
| 27 | { |
---|
| 28 | return -1; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | static int null_handler_fstat( |
---|
| 32 | const rtems_filesystem_location_info_t *pathloc, |
---|
| 33 | struct stat *buf |
---|
| 34 | ) |
---|
| 35 | { |
---|
| 36 | return -1; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers = { |
---|
| 40 | .open_h = null_handler_open, |
---|
| 41 | .close_h = rtems_filesystem_default_close, |
---|
| 42 | .read_h = rtems_filesystem_default_read, |
---|
| 43 | .write_h = rtems_filesystem_default_write, |
---|
| 44 | .ioctl_h = rtems_filesystem_default_ioctl, |
---|
| 45 | .lseek_h = rtems_filesystem_default_lseek, |
---|
| 46 | .fstat_h = null_handler_fstat, |
---|
| 47 | .ftruncate_h = rtems_filesystem_default_ftruncate, |
---|
[4116fce6] | 48 | .fsync_h = rtems_filesystem_default_fsync_or_fdatasync, |
---|
| 49 | .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync, |
---|
[3b7c123] | 50 | .fcntl_h = rtems_filesystem_default_fcntl |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | static void null_op_lock_or_unlock( |
---|
[7666afc] | 54 | const rtems_filesystem_mount_table_entry_t *mt_entry |
---|
[3b7c123] | 55 | ) |
---|
| 56 | { |
---|
| 57 | /* Do nothing */ |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | static int null_op_mknod( |
---|
| 61 | const rtems_filesystem_location_info_t *parentloc, |
---|
| 62 | const char *name, |
---|
| 63 | size_t namelen, |
---|
| 64 | mode_t mode, |
---|
| 65 | dev_t dev |
---|
| 66 | ) |
---|
| 67 | { |
---|
| 68 | return -1; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | static int null_op_rmnod( |
---|
| 72 | const rtems_filesystem_location_info_t *parentloc, |
---|
| 73 | const rtems_filesystem_location_info_t *loc |
---|
| 74 | ) |
---|
| 75 | { |
---|
| 76 | return -1; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | static int null_op_link( |
---|
| 80 | const rtems_filesystem_location_info_t *parentloc, |
---|
| 81 | const rtems_filesystem_location_info_t *targetloc, |
---|
| 82 | const char *name, |
---|
| 83 | size_t namelen |
---|
| 84 | ) |
---|
| 85 | { |
---|
| 86 | return -1; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | static int null_op_fchmod( |
---|
| 90 | const rtems_filesystem_location_info_t *pathloc, |
---|
| 91 | mode_t mode |
---|
| 92 | ) |
---|
| 93 | { |
---|
| 94 | return -1; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | static int null_op_chown( |
---|
| 98 | const rtems_filesystem_location_info_t *loc, |
---|
| 99 | uid_t owner, |
---|
| 100 | gid_t group |
---|
| 101 | ) |
---|
| 102 | { |
---|
| 103 | return -1; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | static int null_op_clonenode( |
---|
| 107 | rtems_filesystem_location_info_t *loc |
---|
| 108 | ) |
---|
| 109 | { |
---|
| 110 | return -1; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | static int null_op_mount( |
---|
| 114 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
| 115 | ) |
---|
| 116 | { |
---|
| 117 | return -1; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | static int null_op_fsmount_me( |
---|
| 121 | rtems_filesystem_mount_table_entry_t *mt_entry, |
---|
| 122 | const void *data |
---|
| 123 | ) |
---|
| 124 | { |
---|
| 125 | return -1; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | static int null_op_unmount( |
---|
| 129 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
| 130 | ) |
---|
| 131 | { |
---|
| 132 | return -1; |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | static void null_op_fsunmount_me( |
---|
| 136 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
| 137 | ) |
---|
| 138 | { |
---|
| 139 | /* Do nothing */ |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | static int null_op_utime( |
---|
| 143 | const rtems_filesystem_location_info_t *loc, |
---|
| 144 | time_t actime, |
---|
| 145 | time_t modtime |
---|
| 146 | ) |
---|
| 147 | { |
---|
| 148 | return -1; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | static int null_op_symlink( |
---|
| 152 | const rtems_filesystem_location_info_t *parentloc, |
---|
| 153 | const char *name, |
---|
| 154 | size_t namelen, |
---|
| 155 | const char *target |
---|
| 156 | ) |
---|
| 157 | { |
---|
| 158 | return -1; |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | static ssize_t null_op_readlink( |
---|
| 162 | const rtems_filesystem_location_info_t *loc, |
---|
| 163 | char *buf, |
---|
| 164 | size_t bufsize |
---|
| 165 | ) |
---|
| 166 | { |
---|
| 167 | return -1; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | static int null_op_rename( |
---|
| 171 | const rtems_filesystem_location_info_t *oldparentloc, |
---|
| 172 | const rtems_filesystem_location_info_t *oldloc, |
---|
| 173 | const rtems_filesystem_location_info_t *newparentloc, |
---|
| 174 | const char *name, |
---|
| 175 | size_t namelen |
---|
| 176 | ) |
---|
| 177 | { |
---|
| 178 | return -1; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | static int null_op_statvfs( |
---|
| 182 | const rtems_filesystem_location_info_t *loc, |
---|
| 183 | struct statvfs *buf |
---|
| 184 | ) |
---|
| 185 | { |
---|
| 186 | return -1; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | static const rtems_filesystem_operations_table null_ops = { |
---|
| 190 | .lock_h = null_op_lock_or_unlock, |
---|
| 191 | .unlock_h = null_op_lock_or_unlock, |
---|
| 192 | .eval_path_h = rtems_filesystem_default_eval_path, |
---|
| 193 | .link_h = null_op_link, |
---|
| 194 | .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, |
---|
| 195 | .node_type_h = rtems_filesystem_default_node_type, |
---|
| 196 | .mknod_h = null_op_mknod, |
---|
| 197 | .rmnod_h = null_op_rmnod, |
---|
| 198 | .fchmod_h = null_op_fchmod, |
---|
| 199 | .chown_h = null_op_chown, |
---|
| 200 | .clonenod_h = null_op_clonenode, |
---|
| 201 | .freenod_h = rtems_filesystem_default_freenode, |
---|
| 202 | .mount_h = null_op_mount, |
---|
| 203 | .fsmount_me_h = null_op_fsmount_me, |
---|
| 204 | .unmount_h = null_op_unmount, |
---|
| 205 | .fsunmount_me_h = null_op_fsunmount_me, |
---|
| 206 | .utime_h = null_op_utime, |
---|
| 207 | .symlink_h = null_op_symlink, |
---|
| 208 | .readlink_h = null_op_readlink, |
---|
| 209 | .rename_h = null_op_rename, |
---|
| 210 | .statvfs_h = null_op_statvfs |
---|
| 211 | }; |
---|
| 212 | |
---|
| 213 | rtems_filesystem_mount_table_entry_t rtems_filesystem_null_mt_entry = { |
---|
| 214 | .location_chain = { |
---|
| 215 | .Head = { |
---|
| 216 | .Node = { |
---|
| 217 | .next = &rtems_filesystem_global_location_null.location.mt_entry_node, |
---|
| 218 | .previous = NULL |
---|
| 219 | }, |
---|
| 220 | .fill = &rtems_filesystem_global_location_null.location.mt_entry_node, |
---|
| 221 | } |
---|
| 222 | }, |
---|
[da154e14] | 223 | .ops = &null_ops, |
---|
[3b7c123] | 224 | .mt_point_node = &rtems_filesystem_global_location_null, |
---|
| 225 | .mt_fs_root = &rtems_filesystem_global_location_null, |
---|
| 226 | .mounted = false, |
---|
| 227 | .writeable = false |
---|
| 228 | }; |
---|
| 229 | |
---|
| 230 | rtems_filesystem_global_location_t rtems_filesystem_global_location_null = { |
---|
| 231 | .location = { |
---|
| 232 | .mt_entry_node = { |
---|
| 233 | .next = &rtems_filesystem_null_mt_entry.location_chain.Tail.Node, |
---|
| 234 | .previous = &rtems_filesystem_null_mt_entry.location_chain.Head.Node |
---|
| 235 | }, |
---|
| 236 | .handlers = &rtems_filesystem_null_handlers, |
---|
| 237 | .mt_entry = &rtems_filesystem_null_mt_entry |
---|
| 238 | }, |
---|
[d40da79b] | 239 | |
---|
[3b7c123] | 240 | /* |
---|
| 241 | * The initial reference count accounts for the following references |
---|
| 242 | * o the root directory of the user environment, |
---|
| 243 | * o the current directory of the user environment, |
---|
| 244 | * o the root node of the null file system instance, and |
---|
| 245 | * o the mount point node of the null file system instance. |
---|
| 246 | */ |
---|
| 247 | .reference_count = 4 |
---|
| 248 | }; |
---|
[d40da79b] | 249 | |
---|
[3b7c123] | 250 | rtems_user_env_t rtems_global_user_env = { |
---|
| 251 | .current_directory = &rtems_filesystem_global_location_null, |
---|
| 252 | .root_directory = &rtems_filesystem_global_location_null, |
---|
| 253 | .umask = S_IWGRP | S_IWOTH |
---|
| 254 | }; |
---|
[d40da79b] | 255 | |
---|
[3b7c123] | 256 | rtems_user_env_t *rtems_current_user_env = &rtems_global_user_env; |
---|