File indexing completed on 2025-05-11 08:24:17
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 #ifdef HAVE_CONFIG_H
0037 #include "config.h"
0038 #endif
0039
0040 #include <rtems/imfsimpl.h>
0041
0042 #include <string.h>
0043
0044 IMFS_jnode_t *IMFS_node_initialize_generic(
0045 IMFS_jnode_t *node,
0046 void *arg
0047 )
0048 {
0049 IMFS_generic_t *generic = (IMFS_generic_t *) node;
0050
0051 generic->context = arg;
0052
0053 return node;
0054 }
0055
0056 int IMFS_make_generic_node(
0057 const char *path,
0058 mode_t mode,
0059 const IMFS_node_control *node_control,
0060 void *context
0061 )
0062 {
0063 return IMFS_make_node(
0064 path,
0065 mode,
0066 node_control,
0067 sizeof( IMFS_generic_t ),
0068 context
0069 );
0070 }
0071
0072 int IMFS_make_node(
0073 const char *path,
0074 mode_t mode,
0075 const IMFS_node_control *node_control,
0076 size_t node_size,
0077 void *context
0078 )
0079 {
0080 int rv = 0;
0081
0082 mode &= ~rtems_filesystem_umask;
0083
0084 switch (mode & S_IFMT) {
0085 case S_IFBLK:
0086 case S_IFCHR:
0087 case S_IFIFO:
0088 case S_IFREG:
0089 case S_IFSOCK:
0090 break;
0091 default:
0092 errno = EINVAL;
0093 rv = -1;
0094 break;
0095 }
0096
0097 if ( rv == 0 ) {
0098 rtems_filesystem_eval_path_context_t ctx;
0099 int eval_flags = RTEMS_FS_FOLLOW_LINK
0100 | RTEMS_FS_MAKE
0101 | RTEMS_FS_EXCLUSIVE;
0102 const rtems_filesystem_location_info_t *currentloc =
0103 rtems_filesystem_eval_path_start( &ctx, path, eval_flags );
0104
0105 if ( IMFS_is_imfs_instance( currentloc ) ) {
0106 IMFS_jnode_t *new_node = IMFS_create_node(
0107 currentloc,
0108 node_control,
0109 node_size,
0110 rtems_filesystem_eval_path_get_token( &ctx ),
0111 rtems_filesystem_eval_path_get_tokenlen( &ctx ),
0112 mode,
0113 context
0114 );
0115
0116 if ( new_node != NULL ) {
0117 IMFS_jnode_t *parent = currentloc->node_access;
0118
0119 IMFS_mtime_ctime_update( parent );
0120 } else {
0121 rv = -1;
0122 }
0123 } else {
0124 rtems_filesystem_eval_path_error( &ctx, ENOTSUP );
0125 rv = -1;
0126 }
0127
0128 rtems_filesystem_eval_path_cleanup( &ctx );
0129 }
0130
0131 return rv;
0132 }