File indexing completed on 2025-05-11 08:24:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #ifdef HAVE_CONFIG_H
0039 #include "config.h"
0040 #endif
0041
0042 #include <sys/stat.h>
0043
0044 #include <rtems/libio_.h>
0045 #include <rtems/score/percpu.h>
0046 #include <rtems/score/thread.h>
0047
0048 static int null_handler_open(
0049 rtems_libio_t *iop,
0050 const char *path,
0051 int oflag,
0052 mode_t mode
0053 )
0054 {
0055 return -1;
0056 }
0057
0058 static int null_handler_fstat(
0059 const rtems_filesystem_location_info_t *pathloc,
0060 struct stat *buf
0061 )
0062 {
0063 return -1;
0064 }
0065
0066 const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers = {
0067 .open_h = null_handler_open,
0068 .close_h = rtems_filesystem_default_close,
0069 .read_h = rtems_filesystem_default_read,
0070 .write_h = rtems_filesystem_default_write,
0071 .ioctl_h = rtems_filesystem_default_ioctl,
0072 .lseek_h = rtems_filesystem_default_lseek,
0073 .fstat_h = null_handler_fstat,
0074 .ftruncate_h = rtems_filesystem_default_ftruncate,
0075 .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
0076 .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
0077 .fcntl_h = rtems_filesystem_default_fcntl,
0078 .kqfilter_h = rtems_filesystem_default_kqfilter,
0079 .mmap_h = rtems_filesystem_default_mmap,
0080 .poll_h = rtems_filesystem_default_poll,
0081 .readv_h = rtems_filesystem_default_readv,
0082 .writev_h = rtems_filesystem_default_writev
0083 };
0084
0085 static void null_op_lock_or_unlock(
0086 const rtems_filesystem_mount_table_entry_t *mt_entry
0087 )
0088 {
0089
0090 }
0091
0092 static int null_op_mknod(
0093 const rtems_filesystem_location_info_t *parentloc,
0094 const char *name,
0095 size_t namelen,
0096 mode_t mode,
0097 dev_t dev
0098 )
0099 {
0100 return -1;
0101 }
0102
0103 static int null_op_rmnod(
0104 const rtems_filesystem_location_info_t *parentloc,
0105 const rtems_filesystem_location_info_t *loc
0106 )
0107 {
0108 return -1;
0109 }
0110
0111 static int null_op_link(
0112 const rtems_filesystem_location_info_t *parentloc,
0113 const rtems_filesystem_location_info_t *targetloc,
0114 const char *name,
0115 size_t namelen
0116 )
0117 {
0118 return -1;
0119 }
0120
0121 static int null_op_fchmod(
0122 const rtems_filesystem_location_info_t *pathloc,
0123 mode_t mode
0124 )
0125 {
0126 return -1;
0127 }
0128
0129 static int null_op_chown(
0130 const rtems_filesystem_location_info_t *loc,
0131 uid_t owner,
0132 gid_t group
0133 )
0134 {
0135 return -1;
0136 }
0137
0138 static int null_op_clonenode(
0139 rtems_filesystem_location_info_t *loc
0140 )
0141 {
0142 return -1;
0143 }
0144
0145 static int null_op_mount(
0146 rtems_filesystem_mount_table_entry_t *mt_entry
0147 )
0148 {
0149 return -1;
0150 }
0151
0152 static int null_op_unmount(
0153 rtems_filesystem_mount_table_entry_t *mt_entry
0154 )
0155 {
0156 return -1;
0157 }
0158
0159 static void null_op_fsunmount_me(
0160 rtems_filesystem_mount_table_entry_t *mt_entry
0161 )
0162 {
0163
0164 }
0165
0166 static int null_op_utimens(
0167 const rtems_filesystem_location_info_t *loc,
0168 struct timespec times[2]
0169 )
0170 {
0171 return -1;
0172 }
0173
0174 static int null_op_symlink(
0175 const rtems_filesystem_location_info_t *parentloc,
0176 const char *name,
0177 size_t namelen,
0178 const char *target
0179 )
0180 {
0181 return -1;
0182 }
0183
0184 static ssize_t null_op_readlink(
0185 const rtems_filesystem_location_info_t *loc,
0186 char *buf,
0187 size_t bufsize
0188 )
0189 {
0190 return -1;
0191 }
0192
0193 static int null_op_rename(
0194 const rtems_filesystem_location_info_t *oldparentloc,
0195 const rtems_filesystem_location_info_t *oldloc,
0196 const rtems_filesystem_location_info_t *newparentloc,
0197 const char *name,
0198 size_t namelen
0199 )
0200 {
0201 return -1;
0202 }
0203
0204 static int null_op_statvfs(
0205 const rtems_filesystem_location_info_t *__restrict loc,
0206 struct statvfs *__restrict buf
0207 )
0208 {
0209 return -1;
0210 }
0211
0212 static const rtems_filesystem_operations_table null_ops = {
0213 .lock_h = null_op_lock_or_unlock,
0214 .unlock_h = null_op_lock_or_unlock,
0215 .eval_path_h = rtems_filesystem_default_eval_path,
0216 .link_h = null_op_link,
0217 .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal,
0218 .mknod_h = null_op_mknod,
0219 .rmnod_h = null_op_rmnod,
0220 .fchmod_h = null_op_fchmod,
0221 .chown_h = null_op_chown,
0222 .clonenod_h = null_op_clonenode,
0223 .freenod_h = rtems_filesystem_default_freenode,
0224 .mount_h = null_op_mount,
0225 .unmount_h = null_op_unmount,
0226 .fsunmount_me_h = null_op_fsunmount_me,
0227 .utimens_h = null_op_utimens,
0228 .symlink_h = null_op_symlink,
0229 .readlink_h = null_op_readlink,
0230 .rename_h = null_op_rename,
0231 .statvfs_h = null_op_statvfs
0232 };
0233
0234 rtems_filesystem_mount_table_entry_t rtems_filesystem_null_mt_entry = {
0235 .location_chain = RTEMS_CHAIN_INITIALIZER_ONE_NODE(
0236 &rtems_filesystem_global_location_null.location.mt_entry_node
0237 ),
0238 .ops = &null_ops,
0239 .mt_point_node = &rtems_filesystem_global_location_null,
0240 .mt_fs_root = &rtems_filesystem_global_location_null,
0241 .mounted = false,
0242 .writeable = false,
0243 .type = ""
0244 };
0245
0246 rtems_filesystem_global_location_t rtems_filesystem_global_location_null = {
0247 .location = {
0248 .mt_entry_node = RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN(
0249 &rtems_filesystem_null_mt_entry.location_chain
0250 ),
0251 .handlers = &rtems_filesystem_null_handlers,
0252 .mt_entry = &rtems_filesystem_null_mt_entry
0253 },
0254
0255
0256
0257
0258
0259
0260
0261
0262 .reference_count = 4
0263 };
0264
0265 rtems_user_env_t rtems_global_user_env = {
0266 .current_directory = &rtems_filesystem_global_location_null,
0267 .root_directory = &rtems_filesystem_global_location_null,
0268 .umask = S_IWGRP | S_IWOTH
0269 };
0270
0271 rtems_user_env_t *rtems_current_user_env_get(void)
0272 {
0273 Thread_Control *executing = _Thread_Get_executing();
0274 rtems_user_env_t *env = executing->user_environment;
0275
0276 if (env == NULL) {
0277 return &rtems_global_user_env;
0278 }
0279
0280 return env;
0281 }