Changeset cf36b70 in rtems
- Timestamp:
- 12/31/14 09:56:05 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 29fa241
- Parents:
- 369328f0
- git-author:
- Sebastian Huber <sebastian.huber@…> (12/31/14 09:56:05)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (01/27/15 05:54:22)
- Files:
-
- 1 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/dev/i2c/i2c-bus.c
r369328f0 rcf36b70 224 224 }; 225 225 226 static IMFS_jnode_t *i2c_bus_node_destroy(IMFS_jnode_t *node)226 static void i2c_bus_node_destroy(IMFS_jnode_t *node) 227 227 { 228 228 i2c_bus *bus; … … 231 231 (*bus->destroy)(bus); 232 232 233 return node; 234 } 235 236 static const IMFS_node_control i2c_bus_node_control = { 237 .imfs_type = IMFS_GENERIC, 238 .handlers = &i2c_bus_handler, 239 .node_initialize = IMFS_node_initialize_generic, 240 .node_remove = IMFS_node_remove_default, 241 .node_destroy = i2c_bus_node_destroy 242 }; 233 IMFS_node_destroy_default(node); 234 } 235 236 static const IMFS_node_control i2c_bus_node_control = IMFS_GENERIC_INITIALIZER( 237 &i2c_bus_handler, 238 IMFS_node_initialize_generic, 239 i2c_bus_node_destroy 240 ); 243 241 244 242 int i2c_bus_register( -
cpukit/dev/i2c/i2c-dev.c
r369328f0 rcf36b70 117 117 }; 118 118 119 static IMFS_jnode_t *i2c_dev_node_destroy(IMFS_jnode_t *node)119 static void i2c_dev_node_destroy(IMFS_jnode_t *node) 120 120 { 121 121 i2c_dev *dev; … … 124 124 (*dev->destroy)(dev); 125 125 126 return node; 127 } 128 129 static const IMFS_node_control i2c_dev_node_control = { 130 .imfs_type = IMFS_GENERIC, 131 .handlers = &i2c_dev_handler, 132 .node_initialize = IMFS_node_initialize_generic, 133 .node_remove = IMFS_node_remove_default, 134 .node_destroy = i2c_dev_node_destroy 135 }; 126 IMFS_node_destroy_default(node); 127 } 128 129 static const IMFS_node_control i2c_dev_node_control = IMFS_GENERIC_INITIALIZER( 130 &i2c_dev_handler, 131 IMFS_node_initialize_generic, 132 i2c_dev_node_destroy 133 ); 136 134 137 135 int i2c_dev_register( -
cpukit/libblock/src/blkdev-imfs.c
r369328f0 rcf36b70 230 230 static IMFS_jnode_t *rtems_blkdev_imfs_initialize( 231 231 IMFS_jnode_t *node, 232 const IMFS_types_union *info232 void *arg 233 233 ) 234 234 { … … 236 236 rtems_disk_device *dd; 237 237 238 node = IMFS_node_initialize_generic(node, info);238 node = IMFS_node_initialize_generic(node, arg); 239 239 240 240 ctx = IMFS_generic_get_context_by_node(node); … … 245 245 } 246 246 247 static IMFS_jnode_t *rtems_blkdev_imfs_destroy(IMFS_jnode_t *node)247 static void rtems_blkdev_imfs_destroy(IMFS_jnode_t *node) 248 248 { 249 249 rtems_blkdev_imfs_context *ctx = IMFS_generic_get_context_by_node(node); … … 261 261 free(ctx); 262 262 263 return node; 264 } 265 266 static const IMFS_node_control rtems_blkdev_imfs_control = { 267 .imfs_type = IMFS_GENERIC, 268 .handlers = &rtems_blkdev_imfs_node, 269 .node_initialize = rtems_blkdev_imfs_initialize, 270 .node_remove = IMFS_node_remove_default, 271 .node_destroy = rtems_blkdev_imfs_destroy 272 }; 263 IMFS_node_destroy_default(node); 264 } 265 266 static const IMFS_node_control rtems_blkdev_imfs_control = 267 IMFS_GENERIC_INITIALIZER( 268 &rtems_blkdev_imfs_node, 269 rtems_blkdev_imfs_initialize, 270 rtems_blkdev_imfs_destroy 271 ); 273 272 274 273 rtems_status_code rtems_blkdev_create( -
cpukit/libfs/Makefile.am
r369328f0 rcf36b70 43 43 libimfs_a_SOURCES += src/imfs/deviceio.c \ 44 44 src/imfs/fifoimfs_init.c src/imfs/imfs_chown.c src/imfs/imfs_config.c \ 45 src/imfs/imfs_creat.c src/imfs/imfs_d ebug.c src/imfs/imfs_directory.c \45 src/imfs/imfs_creat.c src/imfs/imfs_directory.c \ 46 46 src/imfs/imfs_eval.c src/imfs/imfs_fchmod.c \ 47 47 src/imfs/imfs_fifo.c \ -
cpukit/libfs/src/imfs/deviceio.c
r369328f0 rcf36b70 30 30 ) 31 31 { 32 IMFS_jnode_t *the_jnode; 33 34 the_jnode = iop->pathinfo.node_access; 32 const IMFS_device_t *device = IMFS_iop_to_device( iop ); 35 33 36 34 return rtems_deviceio_open( … … 39 37 oflag, 40 38 mode, 41 the_jnode->info.device.major,42 the_jnode->info.device.minor39 device->major, 40 device->minor 43 41 ); 44 42 } … … 48 46 ) 49 47 { 50 IMFS_jnode_t *the_jnode; 51 52 the_jnode = iop->pathinfo.node_access; 48 const IMFS_device_t *device = IMFS_iop_to_device( iop ); 53 49 54 50 return rtems_deviceio_close( 55 51 iop, 56 the_jnode->info.device.major,57 the_jnode->info.device.minor52 device->major, 53 device->minor 58 54 ); 59 55 } … … 65 61 ) 66 62 { 67 IMFS_jnode_t *the_jnode; 68 69 the_jnode = iop->pathinfo.node_access; 63 const IMFS_device_t *device = IMFS_iop_to_device( iop ); 70 64 71 65 return rtems_deviceio_read( … … 73 67 buffer, 74 68 count, 75 the_jnode->info.device.major,76 the_jnode->info.device.minor69 device->major, 70 device->minor 77 71 ); 78 72 } … … 84 78 ) 85 79 { 86 IMFS_jnode_t *the_jnode; 87 88 the_jnode = iop->pathinfo.node_access; 80 const IMFS_device_t *device = IMFS_iop_to_device( iop ); 89 81 90 82 return rtems_deviceio_write( … … 92 84 buffer, 93 85 count, 94 the_jnode->info.device.major,95 the_jnode->info.device.minor86 device->major, 87 device->minor 96 88 ); 97 89 } … … 103 95 ) 104 96 { 105 IMFS_jnode_t *the_jnode; 106 107 the_jnode = iop->pathinfo.node_access; 97 const IMFS_device_t *device = IMFS_iop_to_device( iop ); 108 98 109 99 return rtems_deviceio_control( … … 111 101 command, 112 102 buffer, 113 the_jnode->info.device.major,114 the_jnode->info.device.minor103 device->major, 104 device->minor 115 105 ); 116 106 } -
cpukit/libfs/src/imfs/imfs.h
r369328f0 rcf36b70 41 41 struct IMFS_jnode_tt; 42 42 typedef struct IMFS_jnode_tt IMFS_jnode_t; 43 44 typedef struct {45 rtems_chain_control Entries;46 rtems_filesystem_mount_table_entry_t *mt_fs;47 } IMFS_directory_t;48 49 typedef struct {50 rtems_device_major_number major;51 rtems_device_minor_number minor;52 } IMFS_device_t;53 54 typedef struct {55 IMFS_jnode_t *link_node;56 } IMFS_link_t;57 58 typedef struct {59 char *name;60 } IMFS_sym_link_t;61 62 typedef struct {63 pipe_control_t *pipe;64 } IMFS_fifo_t;65 66 typedef struct {67 void *context;68 } IMFS_generic_t;69 43 70 44 /** … … 101 75 typedef block_p *block_ptr; 102 76 103 typedef struct {104 off_t size; /* size of file in bytes */105 block_ptr indirect; /* array of 128 data blocks pointers */106 block_ptr doubly_indirect; /* 128 indirect blocks */107 block_ptr triply_indirect; /* 128 doubly indirect blocks */108 } IMFS_memfile_t;109 110 typedef struct {111 off_t size; /* size of file in bytes */112 block_p direct; /* pointer to file image */113 } IMFS_linearfile_t;114 115 77 /* 116 78 * Important block numbers for "memfiles" … … 143 105 IMFS_MEMORY_FILE, 144 106 IMFS_LINEAR_FILE, 145 IMFS_FIFO, 146 IMFS_GENERIC, 147 IMFS_INVALID_NODE 107 IMFS_FIFO 148 108 } IMFS_jnode_types_t; 149 109 150 /* The IMFS_GENERIC does not count */151 110 #define IMFS_TYPE_COUNT (IMFS_FIFO + 1) 152 111 153 typedef union {154 IMFS_directory_t directory;155 IMFS_device_t device;156 IMFS_link_t hard_link;157 IMFS_sym_link_t sym_link;158 IMFS_memfile_t file;159 IMFS_linearfile_t linearfile;160 IMFS_fifo_t fifo;161 IMFS_generic_t generic;162 } IMFS_types_union;163 164 112 /** @} */ 165 113 … … 172 120 * @brief Initializes an IMFS node. 173 121 * 174 * @param[in,out] node The IMFS node. 175 * @param[in] info The IMFS type information. 122 * @param[in] node The IMFS node. 123 * @param[in] arg The user provided argument pointer. It may contain node 124 * specific initialization information. 176 125 * 177 126 * @retval node Successful operation. … … 184 133 typedef IMFS_jnode_t *(*IMFS_node_control_initialize)( 185 134 IMFS_jnode_t *node, 186 const IMFS_types_union *info135 void *arg 187 136 ); 188 137 … … 190 139 * @brief Returns the node and does nothing else. 191 140 * 192 * @param[in ,out] node The IMFS node.193 * @param[in] info The IMFS type information.141 * @param[in] node The IMFS node. 142 * @param[in] arg The user provided argument pointer. It is not used. 194 143 * 195 144 * @retval node Returns always the node passed as parameter. … … 199 148 IMFS_jnode_t *IMFS_node_initialize_default( 200 149 IMFS_jnode_t *node, 201 const IMFS_types_union *info150 void *arg 202 151 ); 203 152 … … 205 154 * @brief Returns the node and sets the generic node context. 206 155 * 207 * @param[in,out] node The IMFS node. 208 * @param[in] info The IMFS type information. 156 * @param[in] node The IMFS node. 157 * @param[in] arg The user provided argument pointer. It must contain the 158 * generic context. 209 159 * 210 160 * @retval node Returns always the node passed as parameter. … … 214 164 IMFS_jnode_t *IMFS_node_initialize_generic( 215 165 IMFS_jnode_t *node, 216 const IMFS_types_union *info166 void *arg 217 167 ); 218 168 … … 220 170 * @brief Prepares the removal of an IMFS node from its parent directory. 221 171 * 222 * @param[in ,out] node The IMFS node.172 * @param[in] node The IMFS node. 223 173 * 224 174 * @retval node Successful operation. … … 235 185 * @brief Returns the node and does nothing else. 236 186 * 237 * @param[in ,out] node The IMFS node.187 * @param[in] node The IMFS node. 238 188 * 239 189 * @retval node Returns always the node passed as parameter. … … 248 198 * @brief Destroys an IMFS node. 249 199 * 250 * @param[in,out] node The IMFS node. 251 * 252 * @retval node Returns always the node passed as parameter. 200 * @param[in] node The IMFS node. 253 201 * 254 202 * @see IMFS_node_control and IMFS_node_destroy_default(). 255 203 */ 256 typedef IMFS_jnode_t *(*IMFS_node_control_destroy)( IMFS_jnode_t *node ); 257 258 /** 259 * @brief Returns the node and does nothing else. 260 * 261 * @param[in,out] node The IMFS node. 262 * 263 * @retval node Returns always the node passed as parameter. 204 typedef void (*IMFS_node_control_destroy)( IMFS_jnode_t *node ); 205 206 /** 207 * @brief Frees the node. 208 * 209 * @param[in] node The IMFS node. 264 210 * 265 211 * @see IMFS_node_control. 266 212 */ 267 IMFS_jnode_t *IMFS_node_destroy_default( IMFS_jnode_t *node );213 void IMFS_node_destroy_default( IMFS_jnode_t *node ); 268 214 269 215 /** … … 271 217 */ 272 218 typedef struct { 273 IMFS_jnode_types_t imfs_type;274 219 const rtems_filesystem_file_handlers_r *handlers; 220 size_t node_size; 275 221 IMFS_node_control_initialize node_initialize; 276 222 IMFS_node_control_remove node_remove; … … 324 270 time_t stat_ctime; /* Time of last status change */ 325 271 const IMFS_node_control *control; 326 IMFS_types_union info;327 272 }; 273 274 typedef struct { 275 IMFS_jnode_t Node; 276 rtems_chain_control Entries; 277 rtems_filesystem_mount_table_entry_t *mt_fs; 278 } IMFS_directory_t; 279 280 typedef struct { 281 IMFS_jnode_t Node; 282 rtems_device_major_number major; 283 rtems_device_minor_number minor; 284 } IMFS_device_t; 285 286 typedef struct { 287 IMFS_jnode_t Node; 288 IMFS_jnode_t *link_node; 289 } IMFS_link_t; 290 291 typedef struct { 292 IMFS_jnode_t Node; 293 char *name; 294 } IMFS_sym_link_t; 295 296 typedef struct { 297 IMFS_jnode_t Node; 298 size_t size; /* size of file in bytes */ 299 } IMFS_filebase_t; 300 301 typedef struct { 302 IMFS_filebase_t File; 303 block_ptr indirect; /* array of 128 data blocks pointers */ 304 block_ptr doubly_indirect; /* 128 indirect blocks */ 305 block_ptr triply_indirect; /* 128 doubly indirect blocks */ 306 } IMFS_memfile_t; 307 308 typedef struct { 309 IMFS_filebase_t File; 310 block_p direct; /* pointer to file image */ 311 } IMFS_linearfile_t; 312 313 /* Support copy on write for linear files */ 314 typedef union { 315 IMFS_jnode_t Node; 316 IMFS_filebase_t File; 317 IMFS_memfile_t Memfile; 318 IMFS_linearfile_t Linearfile; 319 } IMFS_file_t; 320 321 typedef struct { 322 IMFS_jnode_t Node; 323 pipe_control_t *pipe; 324 } IMFS_fifo_t; 325 326 typedef struct { 327 IMFS_jnode_t Node; 328 void *context; 329 } IMFS_generic_t; 330 331 static inline IMFS_directory_t *IMFS_iop_to_directory( 332 const rtems_libio_t *iop 333 ) 334 { 335 return (IMFS_directory_t *) iop->pathinfo.node_access; 336 } 337 338 static inline IMFS_device_t *IMFS_iop_to_device( const rtems_libio_t *iop ) 339 { 340 return (IMFS_device_t *) iop->pathinfo.node_access; 341 } 342 343 static inline IMFS_file_t *IMFS_iop_to_file( const rtems_libio_t *iop ) 344 { 345 return (IMFS_file_t *) iop->pathinfo.node_access; 346 } 347 348 static inline IMFS_memfile_t *IMFS_iop_to_memfile( const rtems_libio_t *iop ) 349 { 350 return (IMFS_memfile_t *) iop->pathinfo.node_access; 351 } 328 352 329 353 static inline void IMFS_update_atime( IMFS_jnode_t *jnode ) … … 481 505 482 506 /** 483 * @brief Dump the entire IMFS.484 *485 * This routine dumps the entire IMFS that is mounted at the root486 * directory.487 *488 * NOTE: Assuming the "/" directory is bad.489 * Not checking that the starting directory is in an IMFS is bad.490 */491 extern void IMFS_dump( void );492 493 /**494 * @brief Get the size of the largest file which can be created495 * using the IMFS memory file type.496 *497 * Return the size of the largest file which can be created498 * using the IMFS memory file type.499 */500 extern int IMFS_memfile_maximum_size( void );501 502 /**503 507 * @brief Destroy an IMFS node. 504 508 */ … … 582 586 size_t namelen, 583 587 mode_t mode, 584 const IMFS_types_union *info588 void *arg 585 589 ); 586 590 … … 597 601 size_t namelen, 598 602 mode_t mode, 599 const IMFS_types_union *info603 void *arg 600 604 ); 601 605 … … 618 622 * use the reference counting of the IMFS. This provides automatic node 619 623 * destruction when the last reference vanishes. 620 */ 621 /**@{*/ 624 * 625 * @{ 626 */ 627 628 /** 629 * @brief Initializer for a generic node control. 630 * 631 * @param[in] handlers The file system node handlers. 632 * @param[in] init The node initialization method. 633 * @param[in] destroy The node destruction method. 634 */ 635 #define IMFS_GENERIC_INITIALIZER( handlers, init, destroy ) \ 636 { \ 637 ( handlers ), \ 638 sizeof( IMFS_generic_t ), \ 639 ( init ), \ 640 IMFS_node_remove_default, \ 641 ( destroy ) \ 642 } 622 643 623 644 /** … … 639 660 * #include <rtems/imfs.h> 640 661 * 641 * static const IMFS_node_control some_node_control = { 642 * .imfs_type = IMFS_GENERIC, 643 * .handlers = &some_node_handlers, 644 * .node_initialize = IMFS_node_initialize_generic, 645 * .node_remove = IMFS_node_remove_default, 646 * .node_destroy = some_node_destroy 662 * static const rtems_filesystem_file_handlers_r some_node_handlers = { 663 * ... 647 664 * }; 665 * 666 * static IMFS_jnode_t *some_node_init(IMFS_jnode_t *node, void *arg) 667 * { 668 * void *context; 669 * 670 * node = IMFS_node_initialize_generic(node, arg); 671 * context = IMFS_generic_get_context_by_node(node); 672 * 673 * return node; 674 * } 675 * 676 * static void some_node_destroy(IMFS_jnode_t *node) 677 * { 678 * void *context = IMFS_generic_get_context_by_node(node); 679 * 680 * IMFS_node_destroy_default(node); 681 * } 682 * 683 * static const IMFS_node_control some_node_control = IMFS_GENERIC_INITIALIZER( 684 * &some_node_handlers, 685 * some_node_init, 686 * some_node_destroy 687 * ); 648 688 * 649 689 * void example(void *some_node_context) … … 689 729 ); 690 730 691 extern IMFS_jnode_t *IMFS_memfile_remove(731 extern void IMFS_memfile_remove( 692 732 IMFS_jnode_t *the_jnode /* IN/OUT */ 693 733 ); … … 735 775 736 776 /** 737 * @brief Open a memory file. 738 * 739 * This routine processes the open() system call. Note that there is 740 * nothing special to be done at open() time. 741 */ 742 extern int memfile_open( 777 * @brief Open a linear file. 778 * 779 * Transforms the file into a memfile if opened for writing. 780 */ 781 extern int IMFS_linfile_open( 743 782 rtems_libio_t *iop, /* IN */ 744 783 const char *pathname, /* IN */ 745 784 int oflag, /* IN */ 746 785 mode_t mode /* IN */ 786 ); 787 788 extern ssize_t IMFS_linfile_read( 789 rtems_libio_t *iop, 790 void *buffer, 791 size_t count 747 792 ); 748 793 … … 906 951 907 952 static inline void IMFS_add_to_directory( 908 IMFS_jnode_t *dir ,909 IMFS_jnode_t * node953 IMFS_jnode_t *dir_node, 954 IMFS_jnode_t *entry_node 910 955 ) 911 956 { 912 node->Parent = dir; 913 rtems_chain_append_unprotected( &dir->info.directory.Entries, &node->Node ); 957 IMFS_directory_t *dir = (IMFS_directory_t *) dir_node; 958 959 entry_node->Parent = dir_node; 960 rtems_chain_append_unprotected( &dir->Entries, &entry_node->Node ); 914 961 } 915 962 … … 921 968 } 922 969 923 static inline IMFS_jnode_types_t IMFS_type( const IMFS_jnode_t *node )924 {925 return node->control->imfs_type;926 }927 928 970 static inline bool IMFS_is_directory( const IMFS_jnode_t *node ) 929 971 { 930 return node->control->imfs_type == IMFS_DIRECTORY; 972 return S_ISDIR( node->st_mode ); 973 } 974 975 #define IMFS_STAT_FMT_HARD_LINK 0 976 977 static inline bool IMFS_is_hard_link( mode_t mode ) 978 { 979 return ( mode & S_IFMT ) == IMFS_STAT_FMT_HARD_LINK; 931 980 } 932 981 … … 937 986 size_t namelen, 938 987 mode_t mode, 939 const IMFS_types_union *info988 void *arg 940 989 ) 941 990 { … … 949 998 namelen, 950 999 mode, 951 info1000 arg 952 1001 ); 953 1002 } … … 964 1013 ) 965 1014 { 966 return node->info.generic.context; 1015 const IMFS_generic_t *generic = (const IMFS_generic_t *) node; 1016 1017 return generic->context; 967 1018 } 968 1019 -
cpukit/libfs/src/imfs/imfs_creat.c
r369328f0 rcf36b70 29 29 size_t namelen, 30 30 mode_t mode, 31 const IMFS_types_union *info31 void *arg 32 32 ) 33 33 { … … 47 47 * Allocate an IMFS jnode 48 48 */ 49 node = calloc( 1, sizeof( IMFS_jnode_t ));49 node = calloc( 1, node_control->node_size ); 50 50 if ( !node ) { 51 51 errno = ENOMEM; … … 79 79 node->st_ino = ++fs_info->ino_count; 80 80 81 initialized_node = (*node->control->node_initialize)( node, info);81 initialized_node = (*node->control->node_initialize)( node, arg ); 82 82 if ( initialized_node == NULL ) { 83 83 free( node ); … … 93 93 size_t namelen, 94 94 mode_t mode, 95 const IMFS_types_union *info95 void *arg 96 96 ) 97 97 { … … 103 103 namelen, 104 104 mode, 105 info105 arg 106 106 ); 107 107 -
cpukit/libfs/src/imfs/imfs_directory.c
r369328f0 rcf36b70 34 34 * imfs_jnode_t struct for this file descriptor. 35 35 */ 36 rtems_chain_node *the_node;37 rtems_chain_control *the_chain;38 IMFS_jnode_t *the_jnode;39 int bytes_transferred;40 int current_entry;41 int first_entry;42 int last_entry;43 struct dirent tmp_dirent;36 const IMFS_directory_t *dir; 37 const rtems_chain_node *node; 38 const rtems_chain_control *entries; 39 struct dirent *dir_ent; 40 ssize_t bytes_transferred; 41 off_t current_entry; 42 off_t first_entry; 43 off_t last_entry; 44 44 45 45 rtems_filesystem_instance_lock( &iop->pathinfo ); 46 46 47 the_jnode = (IMFS_jnode_t *)iop->pathinfo.node_access;48 the_chain = &the_jnode->info.directory.Entries;47 dir = IMFS_iop_to_directory( iop ); 48 entries = &dir->Entries; 49 49 50 50 /* Move to the first of the desired directory entries */ … … 55 55 /* -dirent- size. These could result in unexpected results */ 56 56 last_entry = first_entry 57 + (count / sizeof( struct dirent )) * sizeof( struct dirent );57 + (count / sizeof( *dir_ent )) * sizeof( *dir_ent ); 58 58 59 59 /* The directory was not empty so try to move to the desired entry in chain*/ 60 60 for ( 61 61 current_entry = 0, 62 the_node = rtems_chain_first( the_chain);62 node = rtems_chain_immutable_first( entries ); 63 63 current_entry < last_entry 64 && !rtems_chain_is_tail( the_chain, the_node );65 current_entry += sizeof( struct dirent ),66 the_node = rtems_chain_next( the_node )64 && !rtems_chain_is_tail( entries, node ); 65 current_entry += sizeof( *dir_ent ), 66 node = rtems_chain_immutable_next( node ) 67 67 ) { 68 68 if( current_entry >= first_entry ) { 69 const IMFS_jnode_t *imfs_node = (const IMFS_jnode_t *) node; 70 71 dir_ent = (struct dirent *) ((char *) buffer + bytes_transferred); 72 69 73 /* Move the entry to the return buffer */ 70 tmp_dirent.d_off = current_entry; 71 tmp_dirent.d_reclen = sizeof( struct dirent ); 72 the_jnode = (IMFS_jnode_t *) the_node; 73 tmp_dirent.d_ino = the_jnode->st_ino; 74 tmp_dirent.d_namlen = strlen( the_jnode->name ); 75 strcpy( tmp_dirent.d_name, the_jnode->name ); 76 memcpy( 77 buffer + bytes_transferred, 78 (void *)&tmp_dirent, 79 sizeof( struct dirent ) 80 ); 81 iop->offset += sizeof( struct dirent ); 82 bytes_transferred += sizeof( struct dirent ); 74 dir_ent->d_off = current_entry; 75 dir_ent->d_reclen = sizeof( *dir_ent ); 76 dir_ent->d_ino = imfs_node->st_ino; 77 dir_ent->d_namlen = strlen( imfs_node->name ); 78 memcpy( dir_ent->d_name, imfs_node->name, dir_ent->d_namlen + 1 ); 79 80 iop->offset += sizeof( *dir_ent ); 81 bytes_transferred += (ssize_t) sizeof( *dir_ent ); 83 82 } 84 83 } -
cpukit/libfs/src/imfs/imfs_eval.c
r369328f0 rcf36b70 39 39 40 40 static IMFS_jnode_t *IMFS_search_in_directory( 41 IMFS_ jnode_t *dir,41 IMFS_directory_t *dir, 42 42 const char *token, 43 43 size_t tokenlen … … 45 45 { 46 46 if ( rtems_filesystem_is_current_directory( token, tokenlen ) ) { 47 return dir;47 return &dir->Node; 48 48 } else { 49 49 if ( rtems_filesystem_is_parent_directory( token, tokenlen ) ) { 50 return dir-> Parent;50 return dir->Node.Parent; 51 51 } else { 52 rtems_chain_control *entries = &dir-> info.directory.Entries;52 rtems_chain_control *entries = &dir->Entries; 53 53 rtems_chain_node *current = rtems_chain_first( entries ); 54 54 rtems_chain_node *tail = rtems_chain_tail( entries ); … … 73 73 static rtems_filesystem_global_location_t **IMFS_is_mount_point( 74 74 IMFS_jnode_t *node, 75 IMFS_jnode_types_t type75 mode_t mode 76 76 ) 77 77 { 78 78 rtems_filesystem_global_location_t **fs_root_ptr = NULL; 79 79 80 if ( type == IMFS_DIRECTORY ) { 81 if ( node->info.directory.mt_fs != NULL ) { 82 fs_root_ptr = &node->info.directory.mt_fs->mt_fs_root; 80 if ( S_ISDIR( mode ) ) { 81 IMFS_directory_t *dir = (IMFS_directory_t *) node; 82 83 if ( dir->mt_fs != NULL ) { 84 fs_root_ptr = &dir->mt_fs->mt_fs_root; 83 85 } 84 86 } … … 98 100 rtems_filesystem_location_info_t *currentloc = 99 101 rtems_filesystem_eval_path_get_currentloc( ctx ); 100 IMFS_ jnode_t *dir = currentloc->node_access;102 IMFS_directory_t *dir = currentloc->node_access; 101 103 bool access_ok = rtems_filesystem_eval_path_check_access( 102 104 ctx, 103 105 RTEMS_FS_PERMS_EXEC, 104 dir-> st_mode,105 dir-> st_uid,106 dir-> st_gid106 dir->Node.st_mode, 107 dir->Node.st_uid, 108 dir->Node.st_gid 107 109 ); 108 110 … … 115 117 bool follow_hard_link = (eval_flags & RTEMS_FS_FOLLOW_HARD_LINK) != 0; 116 118 bool follow_sym_link = (eval_flags & RTEMS_FS_FOLLOW_SYM_LINK) != 0; 117 IMFS_jnode_types_t type = IMFS_type( entry );119 mode_t mode = entry->st_mode; 118 120 119 121 rtems_filesystem_eval_path_clear_token( ctx ); 120 122 121 if ( type == IMFS_HARD_LINK && (follow_hard_link || !terminal)) { 122 entry = entry->info.hard_link.link_node; 123 if ( IMFS_is_hard_link( mode ) && ( follow_hard_link || !terminal ) ) { 124 const IMFS_link_t *hard_link = (const IMFS_link_t *) entry; 125 126 entry = hard_link->link_node; 123 127 } 124 128 125 if ( type == IMFS_SYM_LINK && (follow_sym_link || !terminal)) { 126 const char *target = entry->info.sym_link.name; 129 if ( S_ISLNK( mode ) && ( follow_sym_link || !terminal ) ) { 130 const IMFS_sym_link_t *sym_link = (const IMFS_sym_link_t *) entry; 131 const char *target = sym_link->name; 127 132 128 133 rtems_filesystem_eval_path_recursive( ctx, target, strlen( target ) ); 129 134 } else { 130 135 rtems_filesystem_global_location_t **fs_root_ptr = 131 IMFS_is_mount_point( entry, type );136 IMFS_is_mount_point( entry, mode ); 132 137 133 138 if ( fs_root_ptr == NULL ) { 134 --dir-> reference_count;139 --dir->Node.reference_count; 135 140 ++entry->reference_count; 136 141 currentloc->node_access = entry; -
cpukit/libfs/src/imfs/imfs_fifo.c
r369328f0 rcf36b70 20 20 #include "imfs.h" 21 21 22 #define JNODE2PIPE(_jnode) ( ( _jnode)->info.fifo.pipe )22 #define JNODE2PIPE(_jnode) ( ((IMFS_fifo_t *)(_jnode))->pipe ) 23 23 24 24 #define LIBIO2PIPE(_iop) ( JNODE2PIPE((IMFS_jnode_t *)(_iop)->pathinfo.node_access) ) … … 132 132 133 133 const IMFS_node_control IMFS_node_control_fifo = { 134 .imfs_type = IMFS_FIFO,135 134 .handlers = &IMFS_fifo_handlers, 135 .node_size = sizeof(IMFS_fifo_t), 136 136 .node_initialize = IMFS_node_initialize_default, 137 137 .node_remove = IMFS_node_remove_default, -
cpukit/libfs/src/imfs/imfs_fsunmount.c
r369328f0 rcf36b70 22 22 23 23 #define jnode_get_control( jnode ) \ 24 (& jnode->info.directory.Entries)24 (&((IMFS_directory_t *) jnode)->Entries) 25 25 26 26 #define jnode_has_no_children( jnode ) \ -
cpukit/libfs/src/imfs/imfs_handlers_device.c
r369328f0 rcf36b70 26 26 ) 27 27 { 28 const IMFS_jnode_t *node = loc->node_access; 29 const IMFS_device_t *io = &node->info.device; 28 const IMFS_device_t *device = loc->node_access; 30 29 31 buf->st_rdev = rtems_filesystem_make_dev_t( io->major, io->minor );30 buf->st_rdev = rtems_filesystem_make_dev_t( device->major, device->minor ); 32 31 33 32 return IMFS_stat( loc, buf ); … … 54 53 static IMFS_jnode_t *IMFS_node_initialize_device( 55 54 IMFS_jnode_t *node, 56 const IMFS_types_union *info55 void *arg 57 56 ) 58 57 { 59 node->info.device.major = info->device.major; 60 node->info.device.minor = info->device.minor; 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 ); 61 62 62 63 return node; … … 64 65 65 66 const IMFS_node_control IMFS_node_control_device = { 66 .imfs_type = IMFS_DEVICE,67 67 .handlers = &IMFS_device_handlers, 68 .node_size = sizeof(IMFS_device_t), 68 69 .node_initialize = IMFS_node_initialize_device, 69 70 .node_remove = IMFS_node_remove_default, -
cpukit/libfs/src/imfs/imfs_handlers_directory.c
r369328f0 rcf36b70 26 26 { 27 27 size_t size = 0; 28 const rtems_chain_control *chain = &node->info.directory.Entries; 28 const IMFS_directory_t *dir = (const IMFS_directory_t *) node; 29 const rtems_chain_control *chain = &dir->Entries; 29 30 const rtems_chain_node *current = rtems_chain_immutable_first( chain ); 30 31 const rtems_chain_node *tail = rtems_chain_immutable_tail( chain ); … … 70 71 static IMFS_jnode_t *IMFS_node_initialize_directory( 71 72 IMFS_jnode_t *node, 72 const IMFS_types_union *info73 void *arg 73 74 ) 74 75 { 75 rtems_chain_initialize_empty( &node->info.directory.Entries ); 76 IMFS_directory_t *dir = (IMFS_directory_t *) node; 77 78 rtems_chain_initialize_empty( &dir->Entries ); 76 79 77 80 return node; 78 81 } 79 82 80 static bool IMFS_is_mount_point( const IMFS_ jnode_t *node)83 static bool IMFS_is_mount_point( const IMFS_directory_t *dir ) 81 84 { 82 return node->info.directory.mt_fs != NULL;85 return dir->mt_fs != NULL; 83 86 } 84 87 … … 87 90 ) 88 91 { 89 if ( !rtems_chain_is_empty( &node->info.directory.Entries ) ) { 92 IMFS_directory_t *dir = (IMFS_directory_t *) node; 93 94 if ( !rtems_chain_is_empty( &dir->Entries ) ) { 90 95 errno = ENOTEMPTY; 91 node= NULL;92 } else if ( IMFS_is_mount_point( node) ) {96 dir = NULL; 97 } else if ( IMFS_is_mount_point( dir ) ) { 93 98 errno = EBUSY; 94 node= NULL;99 dir = NULL; 95 100 } 96 101 97 return node;102 return &dir->Node; 98 103 } 99 104 100 105 const IMFS_node_control IMFS_node_control_directory = { 101 .imfs_type = IMFS_DIRECTORY,102 106 .handlers = &IMFS_directory_handlers, 107 .node_size = sizeof(IMFS_directory_t), 103 108 .node_initialize = IMFS_node_initialize_directory, 104 109 .node_remove = IMFS_node_remove_directory, -
cpukit/libfs/src/imfs/imfs_handlers_link.c
r369328f0 rcf36b70 31 31 const IMFS_jnode_t *node = loc->node_access; 32 32 33 if ( IMFS_type( node ) != IMFS_HARD_LINK ) { 34 buf->st_size = strlen( node->info.sym_link.name ); 33 if ( !IMFS_is_hard_link( node->st_mode ) ) { 34 const IMFS_sym_link_t *sym_link = (const IMFS_sym_link_t *) node; 35 36 buf->st_size = strlen( sym_link->name ); 35 37 36 38 return IMFS_stat( loc, buf ); 37 39 } else { 40 const IMFS_link_t *hard_link = (const IMFS_link_t *) node; 38 41 rtems_filesystem_location_info_t targetloc = *loc; 39 42 40 targetloc.node_access = node->info.hard_link.link_node;43 targetloc.node_access = hard_link->link_node; 41 44 IMFS_Set_handlers( &targetloc ); 42 45 … … 65 68 static IMFS_jnode_t *IMFS_node_initialize_hard_link( 66 69 IMFS_jnode_t *node, 67 const IMFS_types_union *info70 void *arg 68 71 ) 69 72 { 70 node->info.hard_link.link_node = info->hard_link.link_node; 73 IMFS_link_t *hard_link = (IMFS_link_t *) node; 74 75 hard_link->link_node = arg; 71 76 72 77 return node; … … 77 82 ) 78 83 { 79 IMFS_jnode_t *target = node->info.hard_link.link_node; 84 IMFS_link_t *hard_link = (IMFS_link_t *) node; 85 IMFS_jnode_t *target = hard_link->link_node; 80 86 81 87 _Assert( target != NULL ); … … 95 101 96 102 const IMFS_node_control IMFS_node_control_hard_link = { 97 .imfs_type = IMFS_HARD_LINK,98 103 .handlers = &IMFS_link_handlers, 104 .node_size = sizeof(IMFS_link_t), 99 105 .node_initialize = IMFS_node_initialize_hard_link, 100 106 .node_remove = IMFS_node_remove_hard_link, … … 104 110 static IMFS_jnode_t *IMFS_node_initialize_sym_link( 105 111 IMFS_jnode_t *node, 106 const IMFS_types_union *info112 void *arg 107 113 ) 108 114 { 109 node->info.sym_link.name = info->sym_link.name; 115 IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node; 116 117 sym_link->name = arg; 110 118 111 119 return node; 112 120 } 113 121 114 static IMFS_jnode_t *IMFS_node_destroy_sym_link( IMFS_jnode_t *node )122 static void IMFS_node_destroy_sym_link( IMFS_jnode_t *node ) 115 123 { 116 free( node->info.sym_link.name );124 IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node; 117 125 118 return node; 126 free( sym_link->name ); 127 128 IMFS_node_destroy_default( node ); 119 129 } 120 130 121 131 const IMFS_node_control IMFS_node_control_sym_link = { 122 .imfs_type = IMFS_SYM_LINK,123 132 .handlers = &IMFS_link_handlers, 133 .node_size = sizeof(IMFS_sym_link_t), 124 134 .node_initialize = IMFS_node_initialize_sym_link, 125 135 .node_remove = IMFS_node_remove_default, -
cpukit/libfs/src/imfs/imfs_handlers_memfile.c
r369328f0 rcf36b70 26 26 ) 27 27 { 28 const IMFS_ jnode_t *node = loc->node_access;28 const IMFS_file_t *file = loc->node_access; 29 29 30 buf->st_size = node->info.file.size;30 buf->st_size = file->File.size; 31 31 buf->st_blksize = imfs_rq_memfile_bytes_per_block; 32 32 … … 35 35 36 36 static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = { 37 .open_h = memfile_open,37 .open_h = rtems_filesystem_default_open, 38 38 .close_h = rtems_filesystem_default_close, 39 39 .read_h = memfile_read, … … 52 52 }; 53 53 54 static const rtems_filesystem_file_handlers_r IMFS_linfile_handlers = { 55 .open_h = IMFS_linfile_open, 56 .close_h = rtems_filesystem_default_close, 57 .read_h = IMFS_linfile_read, 58 .write_h = rtems_filesystem_default_write, 59 .ioctl_h = rtems_filesystem_default_ioctl, 60 .lseek_h = rtems_filesystem_default_lseek_file, 61 .fstat_h = IMFS_stat_file, 62 .ftruncate_h = rtems_filesystem_default_ftruncate, 63 .fsync_h = rtems_filesystem_default_fsync_or_fdatasync_success, 64 .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync_success, 65 .fcntl_h = rtems_filesystem_default_fcntl, 66 .kqfilter_h = rtems_filesystem_default_kqfilter, 67 .poll_h = rtems_filesystem_default_poll, 68 .readv_h = rtems_filesystem_default_readv, 69 .writev_h = rtems_filesystem_default_writev 70 }; 71 54 72 const IMFS_node_control IMFS_node_control_memfile = { 55 .imfs_type = IMFS_MEMORY_FILE,56 73 .handlers = &IMFS_memfile_handlers, 74 .node_size = sizeof(IMFS_file_t), 57 75 .node_initialize = IMFS_node_initialize_default, 58 76 .node_remove = IMFS_node_remove_default, … … 61 79 62 80 const IMFS_node_control IMFS_node_control_linfile = { 63 . imfs_type = IMFS_LINEAR_FILE,64 . handlers = &IMFS_memfile_handlers,81 .handlers = &IMFS_linfile_handlers, 82 .node_size = sizeof(IMFS_file_t), 65 83 .node_initialize = IMFS_node_initialize_default, 66 84 .node_remove = IMFS_node_remove_default, -
cpukit/libfs/src/imfs/imfs_initsupp.c
r369328f0 rcf36b70 125 125 IMFS_assert( node->reference_count == 0 ); 126 126 127 node = (*node->control->node_destroy)( node ); 128 129 free( node ); 127 (*node->control->node_destroy)( node ); 130 128 } 131 129 … … 143 141 static IMFS_jnode_t *IMFS_node_initialize_enosys( 144 142 IMFS_jnode_t *node, 145 const IMFS_types_union *info143 void *arg 146 144 ) 147 145 { … … 153 151 IMFS_jnode_t *IMFS_node_initialize_default( 154 152 IMFS_jnode_t *node, 155 const IMFS_types_union *info153 void *arg 156 154 ) 157 155 { … … 166 164 } 167 165 168 IMFS_jnode_t *IMFS_node_destroy_default( IMFS_jnode_t *node )166 void IMFS_node_destroy_default( IMFS_jnode_t *node ) 169 167 { 170 return node;168 free( node ); 171 169 } 172 170 173 171 const IMFS_node_control IMFS_node_control_enosys = { 174 .imfs_type = IMFS_INVALID_NODE,175 172 .handlers = &rtems_filesystem_handlers_default, 173 .node_size = sizeof(IMFS_jnode_t), 176 174 .node_initialize = IMFS_node_initialize_enosys, 177 175 .node_remove = IMFS_node_remove_default, -
cpukit/libfs/src/imfs/imfs_link.c
r369328f0 rcf36b70 28 28 ) 29 29 { 30 IMFS_types_union info; 31 IMFS_jnode_t *new_node; 32 IMFS_jnode_t *target; 30 IMFS_jnode_t *new_node; 31 IMFS_jnode_t *target; 33 32 34 33 target = targetloc->node_access; 35 info.hard_link.link_node = target;36 34 37 35 /* … … 49 47 name, 50 48 namelen, 51 ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )),52 &info49 IMFS_STAT_FMT_HARD_LINK | ( S_IRWXU | S_IRWXG | S_IRWXO ), 50 target 53 51 ); 54 52 -
cpukit/libfs/src/imfs/imfs_load_tar.c
r369328f0 rcf36b70 46 46 int offset; 47 47 unsigned long nblocks; 48 IMFS_jnode_t *node;49 48 int rv = 0; 50 49 int eval_flags = RTEMS_FS_FOLLOW_LINK; … … 124 123 125 124 if ( !rtems_filesystem_location_is_null( currentloc ) ) { 126 node = IMFS_create_node( 127 currentloc, 128 IMFS_LINEAR_FILE, 129 rtems_filesystem_eval_path_get_token( &ctx ), 130 rtems_filesystem_eval_path_get_tokenlen( &ctx ), 131 (file_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG, 132 NULL 133 ); 134 node->info.linearfile.size = file_size; 135 node->info.linearfile.direct = &tar_image[offset]; 125 IMFS_linearfile_t *linfile = (IMFS_linearfile_t *) 126 IMFS_create_node( 127 currentloc, 128 IMFS_LINEAR_FILE, 129 rtems_filesystem_eval_path_get_token( &ctx ), 130 rtems_filesystem_eval_path_get_tokenlen( &ctx ), 131 (file_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG, 132 NULL 133 ); 134 135 if ( linfile != NULL ) { 136 linfile->File.size = file_size; 137 linfile->direct = &tar_image[offset]; 138 } 136 139 } 137 140 -
cpukit/libfs/src/imfs/imfs_make_generic_node.c
r369328f0 rcf36b70 30 30 IMFS_jnode_t *IMFS_node_initialize_generic( 31 31 IMFS_jnode_t *node, 32 const IMFS_types_union *info32 void *arg 33 33 ) 34 34 { 35 node->info.generic.context = info->generic.context; 35 IMFS_generic_t *generic = (IMFS_generic_t *) node; 36 37 generic->context = arg; 36 38 37 39 return node; … … 73 75 74 76 if ( rv == 0 ) { 75 if ( node_control->imfs_type == IMFS_GENERIC ) { 76 rtems_filesystem_eval_path_context_t ctx; 77 int eval_flags = RTEMS_FS_FOLLOW_LINK 78 | RTEMS_FS_MAKE 79 | RTEMS_FS_EXCLUSIVE; 80 const rtems_filesystem_location_info_t *currentloc = 81 rtems_filesystem_eval_path_start( &ctx, path, eval_flags ); 77 rtems_filesystem_eval_path_context_t ctx; 78 int eval_flags = RTEMS_FS_FOLLOW_LINK 79 | RTEMS_FS_MAKE 80 | RTEMS_FS_EXCLUSIVE; 81 const rtems_filesystem_location_info_t *currentloc = 82 rtems_filesystem_eval_path_start( &ctx, path, eval_flags ); 82 83 83 if ( IMFS_is_imfs_instance( currentloc ) ) { 84 IMFS_types_union info; 85 IMFS_jnode_t *new_node; 84 if ( IMFS_is_imfs_instance( currentloc ) ) { 85 IMFS_jnode_t *new_node = IMFS_create_node_with_control( 86 currentloc, 87 node_control, 88 rtems_filesystem_eval_path_get_token( &ctx ), 89 rtems_filesystem_eval_path_get_tokenlen( &ctx ), 90 mode, 91 context 92 ); 86 93 87 info.generic.context = context; 88 new_node = IMFS_create_node_with_control( 89 currentloc, 90 node_control, 91 rtems_filesystem_eval_path_get_token( &ctx ), 92 rtems_filesystem_eval_path_get_tokenlen( &ctx ), 93 mode, 94 &info 95 ); 94 if ( new_node != NULL ) { 95 IMFS_jnode_t *parent = currentloc->node_access; 96 96 97 if ( new_node != NULL ) { 98 IMFS_jnode_t *parent = currentloc->node_access; 99 100 IMFS_mtime_ctime_update( parent ); 101 } else { 102 rv = -1; 103 } 97 IMFS_mtime_ctime_update( parent ); 104 98 } else { 105 rtems_filesystem_eval_path_error( &ctx, ENOTSUP );106 99 rv = -1; 107 100 } 108 109 rtems_filesystem_eval_path_cleanup( &ctx );110 101 } else { 111 errno = EINVAL;102 rtems_filesystem_eval_path_error( &ctx, ENOTSUP ); 112 103 rv = -1; 113 104 } 105 106 rtems_filesystem_eval_path_cleanup( &ctx ); 114 107 } 115 108 -
cpukit/libfs/src/imfs/imfs_mknod.c
r369328f0 rcf36b70 24 24 #include "imfs.h" 25 25 26 static void get_type_and_info_by_mode_and_dev( 27 mode_t mode, 28 dev_t dev, 29 IMFS_jnode_types_t *type, 30 IMFS_types_union *info 31 ) 26 static IMFS_jnode_types_t get_type( mode_t mode ) 32 27 { 33 28 if ( S_ISDIR( mode ) ) { 34 *type =IMFS_DIRECTORY;29 return IMFS_DIRECTORY; 35 30 } else if ( S_ISBLK( mode ) || S_ISCHR( mode ) ) { 36 *type = IMFS_DEVICE; 37 rtems_filesystem_split_dev_t( 38 dev, 39 info->device.major, 40 info->device.minor 41 ); 31 return IMFS_DEVICE; 42 32 } else if (S_ISFIFO( mode )) { 43 *type =IMFS_FIFO;33 return IMFS_FIFO; 44 34 } else { 45 35 IMFS_assert( S_ISREG( mode ) ); 46 *type =IMFS_MEMORY_FILE;36 return IMFS_MEMORY_FILE; 47 37 } 48 38 } … … 58 48 int rv = 0; 59 49 IMFS_jnode_types_t type; 60 IMFS_types_union info;61 50 IMFS_jnode_t *new_node; 62 51 63 get_type_and_info_by_mode_and_dev( mode, dev, &type, &info);52 type = get_type( mode ); 64 53 65 new_node = IMFS_create_node( parentloc, type, name, namelen, mode, & info);54 new_node = IMFS_create_node( parentloc, type, name, namelen, mode, &dev ); 66 55 if ( new_node != NULL ) { 67 56 IMFS_jnode_t *parent = parentloc->node_access; -
cpukit/libfs/src/imfs/imfs_mount.c
r369328f0 rcf36b70 30 30 31 31 if ( IMFS_is_directory( node ) ) { 32 if ( node->info.directory.mt_fs == NULL ) { 33 node->info.directory.mt_fs = mt_entry; 32 IMFS_directory_t *dir = (IMFS_directory_t *) node; 33 34 if ( dir->mt_fs == NULL ) { 35 dir->mt_fs = mt_entry; 34 36 } else { 35 37 errno = EBUSY; -
cpukit/libfs/src/imfs/imfs_readlink.c
r369328f0 rcf36b70 27 27 ) 28 28 { 29 IMFS_ jnode_t *node;29 IMFS_sym_link_t *sym_link; 30 30 ssize_t i; 31 31 32 node= loc->node_access;32 sym_link = loc->node_access; 33 33 34 IMFS_assert( node->control->imfs_type == IMFS_SYM_LINK ); 35 36 for( i=0; ((i<bufsize) && (node->info.sym_link.name[i] != '\0')); i++ ) 37 buf[i] = node->info.sym_link.name[i]; 34 for( i=0; ((i<bufsize) && (sym_link->name[i] != '\0')); i++ ) 35 buf[i] = sym_link->name[i]; 38 36 39 37 return i; -
cpukit/libfs/src/imfs/imfs_symlink.c
r369328f0 rcf36b70 31 31 ) 32 32 { 33 IMFS_types_union info;34 IMFS_jnode_t 33 char *dup_target; 34 IMFS_jnode_t *new_node; 35 35 36 36 /* 37 37 * Duplicate link name 38 38 */ 39 info.sym_link.name= strdup(target);40 if ( info.sym_link.name== NULL) {39 dup_target = strdup(target); 40 if (dup_target == NULL) { 41 41 rtems_set_errno_and_return_minus_one(ENOMEM); 42 42 } … … 51 51 namelen, 52 52 ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )), 53 &info53 dup_target 54 54 ); 55 55 56 56 if (new_node == NULL) { 57 free( info.sym_link.name);57 free(dup_target); 58 58 rtems_set_errno_and_return_minus_one(ENOMEM); 59 59 } -
cpukit/libfs/src/imfs/imfs_unmount.c
r369328f0 rcf36b70 30 30 31 31 if ( IMFS_is_directory( node ) ) { 32 if ( node->info.directory.mt_fs == mt_entry ) { 33 node->info.directory.mt_fs = NULL; 32 IMFS_directory_t *dir = (IMFS_directory_t *) node; 33 34 if ( dir->mt_fs == mt_entry ) { 35 dir->mt_fs = NULL; 34 36 } else { 35 37 errno = EINVAL; -
cpukit/libfs/src/imfs/memfile.c
r369328f0 rcf36b70 30 30 */ 31 31 MEMFILE_STATIC int IMFS_memfile_extend( 32 IMFS_ jnode_t *the_jnode,33 bool zero_fill,34 off_t new_length32 IMFS_memfile_t *memfile, 33 bool zero_fill, 34 off_t new_length 35 35 ); 36 36 37 37 MEMFILE_STATIC int IMFS_memfile_addblock( 38 IMFS_ jnode_t *the_jnode,39 unsigned int block38 IMFS_memfile_t *memfile, 39 unsigned int block 40 40 ); 41 41 42 42 MEMFILE_STATIC void IMFS_memfile_remove_block( 43 IMFS_ jnode_t *the_jnode,44 unsigned int block43 IMFS_memfile_t *memfile, 44 unsigned int block 45 45 ); 46 46 47 47 MEMFILE_STATIC block_p *IMFS_memfile_get_block_pointer( 48 IMFS_ jnode_t *the_jnode,48 IMFS_memfile_t *memfile, 49 49 unsigned int block, 50 50 int malloc_it … … 52 52 53 53 MEMFILE_STATIC ssize_t IMFS_memfile_read( 54 IMFS_ jnode_t *the_jnode,54 IMFS_file_t *file, 55 55 off_t start, 56 56 unsigned char *destination, … … 59 59 60 60 ssize_t IMFS_memfile_write( /* cannot be static as used in imfs_fchmod.c */ 61 IMFS_ jnode_t *the_jnode,61 IMFS_memfile_t *memfile, 62 62 off_t start, 63 63 const unsigned char *source, … … 71 71 ); 72 72 73 int memfile_open(73 int IMFS_linfile_open( 74 74 rtems_libio_t *iop, 75 75 const char *pathname, … … 78 78 ) 79 79 { 80 IMFS_ jnode_t *the_jnode;81 82 the_jnode = iop->pathinfo.node_access;80 IMFS_file_t *file; 81 82 file = iop->pathinfo.node_access; 83 83 84 84 /* 85 85 * Perform 'copy on write' for linear files 86 86 */ 87 if ((iop->flags & LIBIO_FLAGS_WRITE) 88 && (IMFS_type( the_jnode ) == IMFS_LINEAR_FILE)) { 89 uint32_t count = the_jnode->info.linearfile.size; 90 const unsigned char *buffer = the_jnode->info.linearfile.direct; 91 92 the_jnode->control = &IMFS_node_control_memfile; 93 the_jnode->info.file.size = 0; 94 the_jnode->info.file.indirect = 0; 95 the_jnode->info.file.doubly_indirect = 0; 96 the_jnode->info.file.triply_indirect = 0; 87 if ((iop->flags & LIBIO_FLAGS_WRITE) != 0) { 88 uint32_t count = file->File.size; 89 const unsigned char *buffer = file->Linearfile.direct; 90 91 file->Node.control = &IMFS_node_control_memfile; 92 file->File.size = 0; 93 file->Memfile.indirect = 0; 94 file->Memfile.doubly_indirect = 0; 95 file->Memfile.triply_indirect = 0; 97 96 if ((count != 0) 98 && (IMFS_memfile_write( the_jnode, 0, buffer, count) == -1))97 && (IMFS_memfile_write(&file->Memfile, 0, buffer, count) == -1)) 99 98 return -1; 100 99 } 101 100 102 101 return 0; 102 } 103 104 ssize_t IMFS_linfile_read( 105 rtems_libio_t *iop, 106 void *buffer, 107 size_t count 108 ) 109 { 110 IMFS_file_t *file = IMFS_iop_to_file( iop ); 111 off_t start = iop->offset; 112 size_t size = file->File.size; 113 const unsigned char *data = file->Linearfile.direct; 114 115 if (count > size - start) 116 count = size - start; 117 118 IMFS_update_atime( &file->Node ); 119 iop->offset = start + count; 120 memcpy(buffer, &data[start], count); 121 122 return (ssize_t) count; 103 123 } 104 124 … … 109 129 ) 110 130 { 111 IMFS_jnode_t *the_jnode; 112 ssize_t status; 113 114 the_jnode = iop->pathinfo.node_access; 115 116 status = IMFS_memfile_read( the_jnode, iop->offset, buffer, count ); 131 IMFS_file_t *file = IMFS_iop_to_file( iop ); 132 ssize_t status; 133 134 status = IMFS_memfile_read( file, iop->offset, buffer, count ); 117 135 118 136 if ( status > 0 ) … … 128 146 ) 129 147 { 130 IMFS_ jnode_t *the_jnode;148 IMFS_memfile_t *memfile = IMFS_iop_to_memfile( iop ); 131 149 ssize_t status; 132 150 133 the_jnode = iop->pathinfo.node_access;134 135 151 if ((iop->flags & LIBIO_FLAGS_APPEND) != 0) 136 iop->offset = the_jnode->info.file.size;137 138 status = IMFS_memfile_write( the_jnode, iop->offset, buffer, count );152 iop->offset = memfile->File.size; 153 154 status = IMFS_memfile_write( memfile, iop->offset, buffer, count ); 139 155 140 156 if ( status > 0 ) … … 155 171 ) 156 172 { 157 IMFS_jnode_t *the_jnode; 158 159 the_jnode = iop->pathinfo.node_access; 173 IMFS_memfile_t *memfile = IMFS_iop_to_memfile( iop ); 160 174 161 175 /* … … 165 179 */ 166 180 167 if ( length > the_jnode->info.file.size )168 return IMFS_memfile_extend( the_jnode, true, length );181 if ( length > memfile->File.size ) 182 return IMFS_memfile_extend( memfile, true, length ); 169 183 170 184 /* … … 173 187 * future use and just set the length. 174 188 */ 175 the_jnode->info.file.size = length;176 177 IMFS_mtime_ctime_update( the_jnode);189 memfile->File.size = length; 190 191 IMFS_mtime_ctime_update( &memfile->File.Node ); 178 192 179 193 return 0; … … 188 202 */ 189 203 MEMFILE_STATIC int IMFS_memfile_extend( 190 IMFS_ jnode_t *the_jnode,191 bool zero_fill,192 off_t new_length204 IMFS_memfile_t *memfile, 205 bool zero_fill, 206 off_t new_length 193 207 ) 194 208 { … … 201 215 * Perform internal consistency checks 202 216 */ 203 IMFS_assert( the_jnode ); 204 IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE ); 217 IMFS_assert( memfile ); 205 218 206 219 /* … … 213 226 * Verify new file size is actually larger than current size 214 227 */ 215 if ( new_length <= the_jnode->info.file.size )228 if ( new_length <= memfile->File.size ) 216 229 return 0; 217 230 … … 220 233 */ 221 234 new_blocks = new_length / IMFS_MEMFILE_BYTES_PER_BLOCK; 222 old_blocks = the_jnode->info.file.size / IMFS_MEMFILE_BYTES_PER_BLOCK;223 offset = the_jnode->info.file.size - old_blocks * IMFS_MEMFILE_BYTES_PER_BLOCK;235 old_blocks = memfile->File.size / IMFS_MEMFILE_BYTES_PER_BLOCK; 236 offset = memfile->File.size - old_blocks * IMFS_MEMFILE_BYTES_PER_BLOCK; 224 237 225 238 /* … … 227 240 */ 228 241 for ( block=old_blocks ; block<=new_blocks ; block++ ) { 229 if ( !IMFS_memfile_addblock( the_jnode, block ) ) {242 if ( !IMFS_memfile_addblock( memfile, block ) ) { 230 243 if ( zero_fill ) { 231 244 size_t count = IMFS_MEMFILE_BYTES_PER_BLOCK - offset; 232 245 block_p *block_ptr = 233 IMFS_memfile_get_block_pointer( the_jnode, block, 0 );246 IMFS_memfile_get_block_pointer( memfile, block, 0 ); 234 247 235 248 memset( &(*block_ptr) [offset], 0, count); … … 238 251 } else { 239 252 for ( ; block>=old_blocks ; block-- ) { 240 IMFS_memfile_remove_block( the_jnode, block );253 IMFS_memfile_remove_block( memfile, block ); 241 254 } 242 255 rtems_set_errno_and_return_minus_one( ENOSPC ); … … 247 260 * Set the new length of the file. 248 261 */ 249 the_jnode->info.file.size = new_length; 250 251 IMFS_mtime_ctime_update(the_jnode); 262 memfile->File.size = new_length; 263 264 IMFS_mtime_ctime_update( &memfile->File.Node ); 265 252 266 return 0; 253 267 } … … 259 273 */ 260 274 MEMFILE_STATIC int IMFS_memfile_addblock( 261 IMFS_ jnode_t *the_jnode,262 unsigned int block275 IMFS_memfile_t *memfile, 276 unsigned int block 263 277 ) 264 278 { … … 266 280 block_p *block_entry_ptr; 267 281 268 IMFS_assert( the_jnode ); 269 IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE ); 282 IMFS_assert( memfile ); 270 283 271 284 /* 272 285 * Obtain the pointer for the specified block number 273 286 */ 274 block_entry_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 1 );287 block_entry_ptr = IMFS_memfile_get_block_pointer( memfile, block, 1 ); 275 288 if ( !block_entry_ptr ) 276 289 return 1; … … 301 314 */ 302 315 MEMFILE_STATIC void IMFS_memfile_remove_block( 303 IMFS_ jnode_t *the_jnode,304 unsigned int block316 IMFS_memfile_t *memfile, 317 unsigned int block 305 318 ) 306 319 { … … 308 321 block_p ptr; 309 322 310 block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );323 block_ptr = IMFS_memfile_get_block_pointer( memfile, block, 0 ); 311 324 if ( block_ptr ) { 312 325 ptr = *block_ptr; … … 373 386 * is better to stick to simple, easy to understand algorithms. 374 387 */ 375 IMFS_jnode_t *IMFS_memfile_remove(388 void IMFS_memfile_remove( 376 389 IMFS_jnode_t *the_jnode 377 390 ) 378 391 { 379 IMFS_memfile_t * info;392 IMFS_memfile_t *memfile; 380 393 int i; 381 394 int j; … … 383 396 block_p *p; 384 397 398 memfile = (IMFS_memfile_t *) the_jnode; 399 385 400 /* 386 401 * Perform internal consistency checks 387 402 */ 388 IMFS_assert( the_jnode ); 389 IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE ); 403 IMFS_assert( memfile ); 390 404 391 405 /* … … 401 415 * + triply indirect 402 416 */ 403 info = &the_jnode->info.file; 404 405 if ( info->indirect ) { 406 memfile_free_blocks_in_table( &info->indirect, to_free ); 407 } 408 409 if ( info->doubly_indirect ) { 417 418 if ( memfile->indirect ) { 419 memfile_free_blocks_in_table( &memfile->indirect, to_free ); 420 } 421 422 if ( memfile->doubly_indirect ) { 410 423 for ( i=0 ; i<IMFS_MEMFILE_BLOCK_SLOTS ; i++ ) { 411 if ( info->doubly_indirect[i] ) {424 if ( memfile->doubly_indirect[i] ) { 412 425 memfile_free_blocks_in_table( 413 (block_p **)& info->doubly_indirect[i], to_free );426 (block_p **)&memfile->doubly_indirect[i], to_free ); 414 427 } 415 428 } 416 memfile_free_blocks_in_table( & info->doubly_indirect, to_free );417 418 } 419 420 if ( info->triply_indirect ) {429 memfile_free_blocks_in_table( &memfile->doubly_indirect, to_free ); 430 431 } 432 433 if ( memfile->triply_indirect ) { 421 434 for ( i=0 ; i<IMFS_MEMFILE_BLOCK_SLOTS ; i++ ) { 422 p = (block_p *) info->triply_indirect[i];435 p = (block_p *) memfile->triply_indirect[i]; 423 436 if ( !p ) /* ensure we have a valid pointer */ 424 437 break; … … 429 442 } 430 443 memfile_free_blocks_in_table( 431 (block_p **)& info->triply_indirect[i], to_free );444 (block_p **)&memfile->triply_indirect[i], to_free ); 432 445 } 433 446 memfile_free_blocks_in_table( 434 (block_p **)& info->triply_indirect, to_free );435 } 436 437 return the_jnode;447 (block_p **)&memfile->triply_indirect, to_free ); 448 } 449 450 IMFS_node_destroy_default( the_jnode ); 438 451 } 439 452 … … 450 463 */ 451 464 MEMFILE_STATIC ssize_t IMFS_memfile_read( 452 IMFS_ jnode_t *the_jnode,465 IMFS_file_t *file, 453 466 off_t start, 454 467 unsigned char *destination, … … 470 483 * Perform internal consistency checks 471 484 */ 472 IMFS_assert( the_jnode ); 473 IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE || 474 IMFS_type( the_jnode ) == IMFS_LINEAR_FILE ); 485 IMFS_assert( file ); 475 486 IMFS_assert( dest ); 476 487 … … 481 492 my_length = length; 482 493 483 if ( IMFS_type( the_jnode ) == IMFS_LINEAR_FILE ) {484 unsigned char *file_ptr;485 486 file_ptr = (unsigned char *)the_jnode->info.linearfile.direct;487 488 if (my_length > (the_jnode->info.linearfile.size - start))489 my_length = the_jnode->info.linearfile.size - start;490 491 memcpy(dest, &file_ptr[start], my_length);492 493 IMFS_update_atime( the_jnode );494 495 return my_length;496 }497 498 494 /* 499 495 * If the last byte we are supposed to read is past the end of this … … 501 497 */ 502 498 last_byte = start + length; 503 if ( last_byte > the_jnode->info.file.size )504 my_length = the_jnode->info.file.size - start;499 if ( last_byte > file->Memfile.File.size ) 500 my_length = file->Memfile.File.size - start; 505 501 506 502 copied = 0; … … 522 518 if ( to_copy > my_length ) 523 519 to_copy = my_length; 524 block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );520 block_ptr = IMFS_memfile_get_block_pointer( &file->Memfile, block, 0 ); 525 521 if ( !block_ptr ) 526 522 return copied; … … 537 533 to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK; 538 534 while ( my_length >= IMFS_MEMFILE_BYTES_PER_BLOCK ) { 539 block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );535 block_ptr = IMFS_memfile_get_block_pointer( &file->Memfile, block, 0 ); 540 536 if ( !block_ptr ) 541 537 return copied; … … 553 549 554 550 if ( my_length ) { 555 block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );551 block_ptr = IMFS_memfile_get_block_pointer( &file->Memfile, block, 0 ); 556 552 if ( !block_ptr ) 557 553 return copied; … … 560 556 } 561 557 562 IMFS_update_atime( the_jnode );558 IMFS_update_atime( &file->Node ); 563 559 564 560 return copied; … … 569 565 * 570 566 * This routine writes the specified data buffer into the in memory 571 * file pointed to by the_jnode. The file is extended as needed.567 * file pointed to by memfile. The file is extended as needed. 572 568 */ 573 569 MEMFILE_STATIC ssize_t IMFS_memfile_write( 574 IMFS_ jnode_t *the_jnode,570 IMFS_memfile_t *memfile, 575 571 off_t start, 576 572 const unsigned char *source, … … 594 590 */ 595 591 IMFS_assert( source ); 596 IMFS_assert( the_jnode ); 597 IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE ); 592 IMFS_assert( memfile ); 598 593 599 594 my_length = length; … … 604 599 605 600 last_byte = start + my_length; 606 if ( last_byte > the_jnode->info.file.size ) {607 bool zero_fill = start > the_jnode->info.file.size;608 609 status = IMFS_memfile_extend( the_jnode, zero_fill, last_byte );601 if ( last_byte > memfile->File.size ) { 602 bool zero_fill = start > memfile->File.size; 603 604 status = IMFS_memfile_extend( memfile, zero_fill, last_byte ); 610 605 if ( status ) 611 606 return status; … … 630 625 if ( to_copy > my_length ) 631 626 to_copy = my_length; 632 block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );627 block_ptr = IMFS_memfile_get_block_pointer( memfile, block, 0 ); 633 628 if ( !block_ptr ) 634 629 return copied; … … 657 652 to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK; 658 653 while ( my_length >= IMFS_MEMFILE_BYTES_PER_BLOCK ) { 659 block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );654 block_ptr = IMFS_memfile_get_block_pointer( memfile, block, 0 ); 660 655 if ( !block_ptr ) 661 656 return copied; … … 677 672 to_copy = my_length; 678 673 if ( my_length ) { 679 block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );674 block_ptr = IMFS_memfile_get_block_pointer( memfile, block, 0 ); 680 675 if ( !block_ptr ) 681 676 return copied; … … 688 683 } 689 684 690 IMFS_mtime_ctime_update( the_jnode );685 IMFS_mtime_ctime_update( &memfile->File.Node ); 691 686 692 687 return copied; … … 724 719 block_p *IMFS_memfile_get_block_pointer( 725 720 #endif 726 IMFS_ jnode_t *the_jnode,721 IMFS_memfile_t *memfile, 727 722 unsigned int block, 728 723 int malloc_it … … 730 725 { 731 726 unsigned int my_block; 732 IMFS_memfile_t *info;733 727 unsigned int singly; 734 728 unsigned int doubly; … … 741 735 * Perform internal consistency checks 742 736 */ 743 IMFS_assert( the_jnode ); 744 IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE ); 745 746 info = &the_jnode->info.file; 737 IMFS_assert( memfile ); 738 747 739 my_block = block; 748 740 … … 751 743 */ 752 744 if ( my_block <= LAST_INDIRECT ) { 753 p = info->indirect;745 p = memfile->indirect; 754 746 755 747 if ( malloc_it ) { … … 759 751 if ( !p ) 760 752 return 0; 761 info->indirect = p;753 memfile->indirect = p; 762 754 } 763 return & info->indirect[ my_block ];755 return &memfile->indirect[ my_block ]; 764 756 } 765 757 … … 767 759 return 0; 768 760 769 return & info->indirect[ my_block ];761 return &memfile->indirect[ my_block ]; 770 762 } 771 763 … … 780 772 doubly = my_block / IMFS_MEMFILE_BLOCK_SLOTS; 781 773 782 p = info->doubly_indirect;774 p = memfile->doubly_indirect; 783 775 if ( malloc_it ) { 784 776 … … 787 779 if ( !p ) 788 780 return 0; 789 info->doubly_indirect = p;781 memfile->doubly_indirect = p; 790 782 } 791 783 … … 822 814 doubly %= IMFS_MEMFILE_BLOCK_SLOTS; 823 815 824 p = info->triply_indirect;816 p = memfile->triply_indirect; 825 817 826 818 if ( malloc_it ) { … … 829 821 if ( !p ) 830 822 return 0; 831 info->triply_indirect = p;823 memfile->triply_indirect = p; 832 824 } 833 825 -
testsuites/fstests/fsimfsgeneric01/init.c
r369328f0 rcf36b70 263 263 static IMFS_jnode_t *node_initialize( 264 264 IMFS_jnode_t *node, 265 const IMFS_types_union *info265 void *arg 266 266 ) 267 267 { 268 268 test_state *state = NULL; 269 269 270 node = IMFS_node_initialize_generic(node, info);270 node = IMFS_node_initialize_generic(node, arg); 271 271 state = IMFS_generic_get_context_by_node(node); 272 272 … … 287 287 } 288 288 289 static IMFS_jnode_t *node_destroy(IMFS_jnode_t *node)289 static void node_destroy(IMFS_jnode_t *node) 290 290 { 291 291 test_state *state = IMFS_generic_get_context_by_node(node); … … 294 294 *state = TEST_DESTROYED; 295 295 296 return node;296 IMFS_node_destroy_default(node); 297 297 } 298 298 299 299 static const IMFS_node_control node_control = { 300 .imfs_type = IMFS_GENERIC,301 300 .handlers = &node_handlers, 301 .node_size = sizeof(IMFS_generic_t), 302 302 .node_initialize = node_initialize, 303 303 .node_remove = node_remove, … … 371 371 static IMFS_jnode_t *node_initialize_error( 372 372 IMFS_jnode_t *node, 373 const IMFS_types_union *info373 void *arg 374 374 ) 375 375 { … … 386 386 } 387 387 388 static IMFS_jnode_t *node_destroy_inhibited(IMFS_jnode_t *node)388 static void node_destroy_inhibited(IMFS_jnode_t *node) 389 389 { 390 390 rtems_test_assert(false); 391 392 return node; 393 } 394 395 static const IMFS_node_control node_invalid_control = { 396 .imfs_type = IMFS_DIRECTORY, 391 } 392 393 static const IMFS_node_control node_initialization_error_control = { 397 394 .handlers = &node_handlers, 398 .node_initialize = node_initialize_error, 399 .node_remove = node_remove_inhibited, 400 .node_destroy = node_destroy_inhibited 401 }; 402 403 static const IMFS_node_control node_initialization_error_control = { 404 .imfs_type = IMFS_GENERIC, 405 .handlers = &node_handlers, 395 .node_size = sizeof(IMFS_generic_t), 406 396 .node_initialize = node_initialize_error, 407 397 .node_remove = node_remove_inhibited, … … 425 415 rv = IMFS_make_generic_node( 426 416 path, 427 S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,428 &node_invalid_control,429 NULL430 );431 rtems_test_assert(rv == -1);432 rtems_test_assert(errno == EINVAL);433 rtems_test_assert(rtems_resource_snapshot_check(&before));434 435 errno = 0;436 rv = IMFS_make_generic_node(437 path,438 417 S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO, 439 418 &node_control, -
testsuites/libtests/newlib01/init.c
r369328f0 rcf36b70 233 233 }; 234 234 235 static const IMFS_node_control node_control = { 236 .imfs_type = IMFS_GENERIC, 237 .handlers = &node_handlers, 238 .node_initialize = IMFS_node_initialize_default, 239 .node_remove = IMFS_node_remove_default, 240 .node_destroy = IMFS_node_destroy_default 241 }; 235 static const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER( 236 &node_handlers, 237 IMFS_node_initialize_default, 238 IMFS_node_destroy_default 239 ); 242 240 243 241 static void test(void) -
testsuites/libtests/tar02/init.c
r369328f0 rcf36b70 69 69 70 70 test_tarfs_load(); 71 IMFS_dump();72 71 73 72 TEST_END(); -
testsuites/libtests/tar02/tar02.scn
r369328f0 rcf36b70 1 *** TAR02 TEST***1 *** BEGIN OF TEST TAR 2 *** 2 2 Loading tarfs image ... successful 3 3 ========= /home/test_file ========= … … 9 9 initial tar image. 10 10 11 *************** Dump of Entire IMFS *************** 12 / 13 ....dev/ 14 ........ttyS0 (device 0, 0) 15 ........console (device 0, 0) 16 ........ttyS1 (device 0, 1) 17 ....home/ 18 ........test_file (file 73 0x390f8) 19 ....symlink links not printed 20 *************** End of Dump *************** 21 *** END OF TAR02 TEST *** 11 *** END OF TEST TAR 2 *** -
testsuites/psxtests/psxfile01/psxfile01.scn
r369328f0 rcf36b70 1 *** FILE TEST 1 *** 2 *************** Dump of Entire IMFS *************** 3 / 4 ....dev/ 5 ........console_a (device 0, 0) 6 ........console (device 0, 0) 7 ........console_b (device 0, 1) 8 *************** End of Dump *************** 1 *** BEGIN OF TEST PSXFILE 1 *** 9 2 stat of /dev/console 10 3 ....st_dev (0xfffe:0x0) … … 182 175 ....st_blksize 80 183 176 ....st_blocks 0 184 *************** Dump of Entire IMFS ***************185 /186 ....dev/187 ........console_a (device 0, 0)188 ........console (device 0, 0)189 ........console_b (device 0, 1)190 ........tty/191 ............S3 (device 255, 128)192 ........test_console (device 0, 0)193 ....etc/194 ........passwd (file 0)195 ....tmp/196 ........my_dir/197 ........tom (file 0)198 ........john (file 0)199 ........joel (file 533)200 ........j (file 130)201 ....imfs/202 ........hidden_on_mount/203 *************** End of Dump ***************204 177 truncate /tmp/j to length of 40 205 178 ....st_dev (0xfffe:0x0) … … 210 183 ....uid = 0 211 184 ....gid = 0 212 ....atime = Sat Dec 31 09:00:02 1988 213 ....mtime = Sat Dec 31 09:00:00 1988 214 ....ctime = Sat Dec 31 09:00:00 1988 215 ....st_blksize 80 216 ....st_blocks 0 217 *************** Dump of Entire IMFS *************** 218 / 219 ....dev/ 220 ........console_a (device 0, 0) 221 ........console (device 0, 0) 222 ........console_b (device 0, 1) 223 ........tty/ 224 ............S3 (device 255, 128) 225 ........test_console (device 0, 0) 226 ....etc/ 227 ........passwd (file 0) 228 ....tmp/ 229 ........my_dir/ 230 ........tom (file 0) 231 ........john (file 0) 232 ........j (file 40) 233 ....imfs/ 234 ........hidden_on_mount/ 235 *************** End of Dump *************** 185 ....atime = Sat Dec 31 09:00:01 1988 186 ....mtime = Sat Dec 31 09:00:02 1988 187 ....ctime = Sat Dec 31 09:00:02 1988 188 ....st_blksize 80 189 ....st_blocks 0 236 190 truncate /tmp/j to length of 0 237 191 truncate /tmp to length of 0 should fail with EISDIR 238 192 239 193 21: Is a directory 240 *************** Dump of Entire IMFS ***************241 /242 ....dev/243 ........console_a (device 0, 0)244 ........console (device 0, 0)245 ........console_b (device 0, 1)246 ........tty/247 ............S3 (device 255, 128)248 ........test_console (device 0, 0)249 ....etc/250 ........passwd (file 0)251 ....tmp/252 ........my_dir/253 ........tom (file 0)254 ........john (file 0)255 ........j (file 0)256 ....imfs/257 ........hidden_on_mount/258 *************** End of Dump ***************259 194 Writing First File 260 195 Writing Second File … … 265 200 this is a test line 266 201 267 *** END OF FILE TEST1 ***202 *** END OF TEST PSXFILE 1 *** -
testsuites/psxtests/psxfile01/test.c
r369328f0 rcf36b70 167 167 */ 168 168 169 max_size = IMFS_ memfile_maximum_size();169 max_size = IMFS_MEMFILE_MAXIMUM_SIZE; 170 170 171 171 build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); 172 172 rtems_status = rtems_clock_set( &time ); 173 173 directive_failed( rtems_status, "clock set" ); 174 175 /*176 * Dump an empty file system177 */178 179 IMFS_dump();180 174 181 175 /* … … 606 600 rtems_test_assert( ctime1 == ctime2); 607 601 608 IMFS_dump();609 610 602 unlink( "/tmp/joel" ); 611 603 … … 632 624 rtems_test_assert( ctime1 != ctime2); 633 625 634 IMFS_dump();635 636 626 /* try to truncate the console and see what happens */ 637 627 status = truncate( "/dev/console", 40 ); … … 647 637 printf( "%d: %s\n", errno, strerror( errno ) ); 648 638 rtems_test_assert( errno == EISDIR ); 649 650 IMFS_dump();651 639 652 640 status = truncate( "/tmp/fred", 10 ); -
testsuites/psxtests/psximfs02/init.c
r369328f0 rcf36b70 32 32 /* forward declarations to avoid warnings */ 33 33 rtems_task Init(rtems_task_argument argument); 34 void IMFS_dump(void);35 34 36 35 rtems_task Init( … … 184 183 status = mkfifo( "/fifo", S_IRWXU ); 185 184 rtems_test_assert( status == 0 ); 186 187 IMFS_dump();188 185 189 186 puts( "chown /fifo to 10 -- OK" ); -
testsuites/psxtests/psximfs02/psximfs02.scn
r369328f0 rcf36b70 1 *** TEST IMFS 02 ***1 *** BEGIN OF TEST PSXIMFS 2 *** 2 2 Creating directory /dir00 3 3 Creating directory /dir00/dir01 … … 25 25 Opening /node-slink in WRONLY mode -- expect EACCES 26 26 Allocate most of heap 27 Attempt to mount a fs at /dir01 -- expect ENOMEM28 Freeing allocated memory 27 Attempt to mount a fs at dir01 -- expect ENOMEMFreeing allocated memory 28 Changing directory to / 29 29 Allocate most of heap 30 Changing directory to /31 30 Attempt to create /node-link-2 for /node -- expect ENOMEM 32 31 Attempt to create /node-slink-2 for /node -- expect ENOMEM 33 32 Freeing allocated memory 34 33 Allocate most of heap 35 Attempt to create /node-slink-2 for /node -- expect ENOMEM 36 Freeing allocated memory 37 Attempt to stat a hardlink -- expect ENOTSUP 34 Attempt to create node-slink-2 for /node -- expect ENOMEMFreeing allocated memory 35 Attempt to stat a hardlink 38 36 Changing euid to 10 39 37 Attempt chmod on /node -- expect EPERM … … 41 39 Changing euid back to 0 [root] 42 40 Creating a fifo -- OK 43 *************** Dump of Entire IMFS ***************44 /45 ....dev/46 ........console (device 0, 0)47 ....dir00/48 ........dir01/49 ........dir01-link0 links not printed50 ........dir01-link1 links not printed51 ........dir01-link2 links not printed52 ........dir01-link3 links not printed53 ........dir01-link4 links not printed54 ........dir01-link5 links not printed55 ........dir01-link6 links not printed56 ....node (file 0)57 ....node-link links not printed58 ....node-slink links not printed59 ....fifo FIFO not printed60 *************** End of Dump ***************61 41 chown /fifo to 10 -- OK 62 42 Changing euid to 10 63 43 chmod /fifo -- OK 64 44 chown /fifo to 0 -- OK 65 *** END OF TEST IMFS 02 ***45 *** END OF TEST PSXIMFS 2 ***
Note: See TracChangeset
for help on using the changeset viewer.