Changeset cf36b70 in rtems


Ignore:
Timestamp:
12/31/14 09:56:05 (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
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)
Message:

IMFS: Replace node union with individual struct

This reduces the average node size.

Add and use IMFS_GENERIC_INITIALIZER().

Files:
1 deleted
33 edited

Legend:

Unmodified
Added
Removed
  • cpukit/dev/i2c/i2c-bus.c

    r369328f0 rcf36b70  
    224224};
    225225
    226 static IMFS_jnode_t *i2c_bus_node_destroy(IMFS_jnode_t *node)
     226static void i2c_bus_node_destroy(IMFS_jnode_t *node)
    227227{
    228228  i2c_bus *bus;
     
    231231  (*bus->destroy)(bus);
    232232
    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
     236static 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);
    243241
    244242int i2c_bus_register(
  • cpukit/dev/i2c/i2c-dev.c

    r369328f0 rcf36b70  
    117117};
    118118
    119 static IMFS_jnode_t *i2c_dev_node_destroy(IMFS_jnode_t *node)
     119static void i2c_dev_node_destroy(IMFS_jnode_t *node)
    120120{
    121121  i2c_dev *dev;
     
    124124  (*dev->destroy)(dev);
    125125
    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
     129static 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);
    136134
    137135int i2c_dev_register(
  • cpukit/libblock/src/blkdev-imfs.c

    r369328f0 rcf36b70  
    230230static IMFS_jnode_t *rtems_blkdev_imfs_initialize(
    231231  IMFS_jnode_t *node,
    232   const IMFS_types_union *info
     232  void *arg
    233233)
    234234{
     
    236236  rtems_disk_device *dd;
    237237
    238   node = IMFS_node_initialize_generic(node, info);
     238  node = IMFS_node_initialize_generic(node, arg);
    239239
    240240  ctx = IMFS_generic_get_context_by_node(node);
     
    245245}
    246246
    247 static IMFS_jnode_t *rtems_blkdev_imfs_destroy(IMFS_jnode_t *node)
     247static void rtems_blkdev_imfs_destroy(IMFS_jnode_t *node)
    248248{
    249249  rtems_blkdev_imfs_context *ctx = IMFS_generic_get_context_by_node(node);
     
    261261  free(ctx);
    262262
    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
     266static 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  );
    273272
    274273rtems_status_code rtems_blkdev_create(
  • cpukit/libfs/Makefile.am

    r369328f0 rcf36b70  
    4343libimfs_a_SOURCES += src/imfs/deviceio.c \
    4444    src/imfs/fifoimfs_init.c src/imfs/imfs_chown.c src/imfs/imfs_config.c \
    45     src/imfs/imfs_creat.c src/imfs/imfs_debug.c src/imfs/imfs_directory.c \
     45    src/imfs/imfs_creat.c src/imfs/imfs_directory.c \
    4646    src/imfs/imfs_eval.c src/imfs/imfs_fchmod.c \
    4747    src/imfs/imfs_fifo.c \
  • cpukit/libfs/src/imfs/deviceio.c

    r369328f0 rcf36b70  
    3030)
    3131{
    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 );
    3533
    3634  return rtems_deviceio_open(
     
    3937    oflag,
    4038    mode,
    41     the_jnode->info.device.major,
    42     the_jnode->info.device.minor
     39    device->major,
     40    device->minor
    4341  );
    4442}
     
    4846)
    4947{
    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 );
    5349
    5450  return rtems_deviceio_close(
    5551    iop,
    56     the_jnode->info.device.major,
    57     the_jnode->info.device.minor
     52    device->major,
     53    device->minor
    5854  );
    5955}
     
    6561)
    6662{
    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 );
    7064
    7165  return rtems_deviceio_read(
     
    7367    buffer,
    7468    count,
    75     the_jnode->info.device.major,
    76     the_jnode->info.device.minor
     69    device->major,
     70    device->minor
    7771  );
    7872}
     
    8478)
    8579{
    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 );
    8981
    9082  return rtems_deviceio_write(
     
    9284    buffer,
    9385    count,
    94     the_jnode->info.device.major,
    95     the_jnode->info.device.minor
     86    device->major,
     87    device->minor
    9688  );
    9789}
     
    10395)
    10496{
    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 );
    10898
    10999  return rtems_deviceio_control(
     
    111101    command,
    112102    buffer,
    113     the_jnode->info.device.major,
    114     the_jnode->info.device.minor
     103    device->major,
     104    device->minor
    115105  );
    116106}
  • cpukit/libfs/src/imfs/imfs.h

    r369328f0 rcf36b70  
    4141struct IMFS_jnode_tt;
    4242typedef 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;
    6943
    7044/**
     
    10175typedef block_p *block_ptr;
    10276
    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 
    11577/*
    11678 *  Important block numbers for "memfiles"
     
    143105  IMFS_MEMORY_FILE,
    144106  IMFS_LINEAR_FILE,
    145   IMFS_FIFO,
    146   IMFS_GENERIC,
    147   IMFS_INVALID_NODE
     107  IMFS_FIFO
    148108} IMFS_jnode_types_t;
    149109
    150 /* The IMFS_GENERIC does not count */
    151110#define IMFS_TYPE_COUNT (IMFS_FIFO + 1)
    152111
    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 
    164112/** @} */
    165113
     
    172120 * @brief Initializes an IMFS node.
    173121 *
    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.
    176125 *
    177126 * @retval node Successful operation.
     
    184133typedef IMFS_jnode_t *(*IMFS_node_control_initialize)(
    185134  IMFS_jnode_t *node,
    186   const IMFS_types_union *info
     135  void *arg
    187136);
    188137
     
    190139 * @brief Returns the node and does nothing else.
    191140 *
    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.
    194143 *
    195144 * @retval node Returns always the node passed as parameter.
     
    199148IMFS_jnode_t *IMFS_node_initialize_default(
    200149  IMFS_jnode_t *node,
    201   const IMFS_types_union *info
     150  void *arg
    202151);
    203152
     
    205154 * @brief Returns the node and sets the generic node context.
    206155 *
    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.
    209159 *
    210160 * @retval node Returns always the node passed as parameter.
     
    214164IMFS_jnode_t *IMFS_node_initialize_generic(
    215165  IMFS_jnode_t *node,
    216   const IMFS_types_union *info
     166  void *arg
    217167);
    218168
     
    220170 * @brief Prepares the removal of an IMFS node from its parent directory.
    221171 *
    222  * @param[in,out] node The IMFS node.
     172 * @param[in] node The IMFS node.
    223173 *
    224174 * @retval node Successful operation.
     
    235185 * @brief Returns the node and does nothing else.
    236186 *
    237  * @param[in,out] node The IMFS node.
     187 * @param[in] node The IMFS node.
    238188 *
    239189 * @retval node Returns always the node passed as parameter.
     
    248198 * @brief Destroys an IMFS node.
    249199 *
    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.
    253201 *
    254202 * @see IMFS_node_control and IMFS_node_destroy_default().
    255203 */
    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.
     204typedef void (*IMFS_node_control_destroy)( IMFS_jnode_t *node );
     205
     206/**
     207 * @brief Frees the node.
     208 *
     209 * @param[in] node The IMFS node.
    264210 *
    265211 * @see IMFS_node_control.
    266212 */
    267 IMFS_jnode_t *IMFS_node_destroy_default( IMFS_jnode_t *node );
     213void IMFS_node_destroy_default( IMFS_jnode_t *node );
    268214
    269215/**
     
    271217 */
    272218typedef struct {
    273   IMFS_jnode_types_t imfs_type;
    274219  const rtems_filesystem_file_handlers_r *handlers;
     220  size_t node_size;
    275221  IMFS_node_control_initialize node_initialize;
    276222  IMFS_node_control_remove node_remove;
     
    324270  time_t              stat_ctime;            /* Time of last status change */
    325271  const IMFS_node_control *control;
    326   IMFS_types_union    info;
    327272};
     273
     274typedef 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
     280typedef struct {
     281  IMFS_jnode_t              Node;
     282  rtems_device_major_number major;
     283  rtems_device_minor_number minor;
     284} IMFS_device_t;
     285
     286typedef struct {
     287  IMFS_jnode_t  Node;
     288  IMFS_jnode_t *link_node;
     289} IMFS_link_t;
     290
     291typedef struct {
     292  IMFS_jnode_t  Node;
     293  char         *name;
     294} IMFS_sym_link_t;
     295
     296typedef struct {
     297  IMFS_jnode_t Node;
     298  size_t       size;             /* size of file in bytes */
     299} IMFS_filebase_t;
     300
     301typedef 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
     308typedef 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 */
     314typedef 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
     321typedef struct {
     322  IMFS_jnode_t    Node;
     323  pipe_control_t *pipe;
     324} IMFS_fifo_t;
     325
     326typedef struct {
     327  IMFS_jnode_t  Node;
     328  void         *context;
     329} IMFS_generic_t;
     330
     331static 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
     338static 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
     343static 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
     348static inline IMFS_memfile_t *IMFS_iop_to_memfile( const rtems_libio_t *iop )
     349{
     350  return (IMFS_memfile_t *) iop->pathinfo.node_access;
     351}
    328352
    329353static inline void IMFS_update_atime( IMFS_jnode_t *jnode )
     
    481505
    482506/**
    483  * @brief Dump the entire IMFS.
    484  *
    485  * This routine dumps the entire IMFS that is mounted at the root
    486  * 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 created
    495  * using the IMFS memory file type.
    496  *
    497  * Return the size of the largest file which can be created
    498  * using the IMFS memory file type.
    499  */
    500 extern int IMFS_memfile_maximum_size( void );
    501 
    502 /**
    503507 * @brief Destroy an IMFS node.
    504508 */
     
    582586  size_t namelen,
    583587  mode_t mode,
    584   const IMFS_types_union *info
     588  void *arg
    585589);
    586590
     
    597601  size_t namelen,
    598602  mode_t mode,
    599   const IMFS_types_union *info
     603  void *arg
    600604);
    601605
     
    618622 * use the reference counting of the IMFS.  This provides automatic node
    619623 * 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  }
    622643
    623644/**
     
    639660 * #include <rtems/imfs.h>
    640661 *
    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 *   ...
    647664 * };
     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 * );
    648688 *
    649689 * void example(void *some_node_context)
     
    689729);
    690730
    691 extern IMFS_jnode_t *IMFS_memfile_remove(
     731extern void IMFS_memfile_remove(
    692732 IMFS_jnode_t  *the_jnode         /* IN/OUT */
    693733);
     
    735775
    736776/**
    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 */
     781extern int IMFS_linfile_open(
    743782  rtems_libio_t *iop,             /* IN  */
    744783  const char    *pathname,        /* IN  */
    745784  int            oflag,           /* IN  */
    746785  mode_t         mode             /* IN  */
     786);
     787
     788extern ssize_t IMFS_linfile_read(
     789  rtems_libio_t *iop,
     790  void          *buffer,
     791  size_t         count
    747792);
    748793
     
    906951
    907952static inline void IMFS_add_to_directory(
    908   IMFS_jnode_t *dir,
    909   IMFS_jnode_t *node
     953  IMFS_jnode_t *dir_node,
     954  IMFS_jnode_t *entry_node
    910955)
    911956{
    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 );
    914961}
    915962
     
    921968}
    922969
    923 static inline IMFS_jnode_types_t IMFS_type( const IMFS_jnode_t *node )
    924 {
    925   return node->control->imfs_type;
    926 }
    927 
    928970static inline bool IMFS_is_directory( const IMFS_jnode_t *node )
    929971{
    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
     977static inline bool IMFS_is_hard_link( mode_t mode )
     978{
     979  return ( mode & S_IFMT ) == IMFS_STAT_FMT_HARD_LINK;
    931980}
    932981
     
    937986  size_t namelen,
    938987  mode_t mode,
    939   const IMFS_types_union *info
     988  void *arg
    940989)
    941990{
     
    949998    namelen,
    950999    mode,
    951     info
     1000    arg
    9521001  );
    9531002}
     
    9641013)
    9651014{
    966   return node->info.generic.context;
     1015  const IMFS_generic_t *generic = (const IMFS_generic_t *) node;
     1016
     1017  return generic->context;
    9671018}
    9681019
  • cpukit/libfs/src/imfs/imfs_creat.c

    r369328f0 rcf36b70  
    2929  size_t namelen,
    3030  mode_t mode,
    31   const IMFS_types_union *info
     31  void *arg
    3232)
    3333{
     
    4747   *  Allocate an IMFS jnode
    4848   */
    49   node = calloc( 1, sizeof( IMFS_jnode_t ) );
     49  node = calloc( 1, node_control->node_size );
    5050  if ( !node ) {
    5151    errno = ENOMEM;
     
    7979  node->st_ino = ++fs_info->ino_count;
    8080
    81   initialized_node = (*node->control->node_initialize)( node, info );
     81  initialized_node = (*node->control->node_initialize)( node, arg );
    8282  if ( initialized_node == NULL ) {
    8383    free( node );
     
    9393  size_t namelen,
    9494  mode_t mode,
    95   const IMFS_types_union *info
     95  void *arg
    9696)
    9797{
     
    103103    namelen,
    104104    mode,
    105     info
     105    arg
    106106  );
    107107
  • cpukit/libfs/src/imfs/imfs_directory.c

    r369328f0 rcf36b70  
    3434   *  imfs_jnode_t struct for this file descriptor.
    3535   */
    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;
    4444
    4545   rtems_filesystem_instance_lock( &iop->pathinfo );
    4646
    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;
    4949
    5050   /* Move to the first of the desired directory entries */
     
    5555   /* -dirent- size. These could result in unexpected results          */
    5656   last_entry = first_entry
    57      + (count / sizeof( struct dirent )) * sizeof( struct dirent );
     57     + (count / sizeof( *dir_ent )) * sizeof( *dir_ent );
    5858
    5959   /* The directory was not empty so try to move to the desired entry in chain*/
    6060   for (
    6161      current_entry = 0,
    62         the_node = rtems_chain_first( the_chain );
     62        node = rtems_chain_immutable_first( entries );
    6363      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 )
    6767   ) {
    6868      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
    6973         /* 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 );
    8382      }
    8483   }
  • cpukit/libfs/src/imfs/imfs_eval.c

    r369328f0 rcf36b70  
    3939
    4040static IMFS_jnode_t *IMFS_search_in_directory(
    41   IMFS_jnode_t *dir,
     41  IMFS_directory_t *dir,
    4242  const char *token,
    4343  size_t tokenlen
     
    4545{
    4646  if ( rtems_filesystem_is_current_directory( token, tokenlen ) ) {
    47     return dir;
     47    return &dir->Node;
    4848  } else {
    4949    if ( rtems_filesystem_is_parent_directory( token, tokenlen ) ) {
    50       return dir->Parent;
     50      return dir->Node.Parent;
    5151    } else {
    52       rtems_chain_control *entries = &dir->info.directory.Entries;
     52      rtems_chain_control *entries = &dir->Entries;
    5353      rtems_chain_node *current = rtems_chain_first( entries );
    5454      rtems_chain_node *tail = rtems_chain_tail( entries );
     
    7373static rtems_filesystem_global_location_t **IMFS_is_mount_point(
    7474  IMFS_jnode_t *node,
    75   IMFS_jnode_types_t type
     75  mode_t mode
    7676)
    7777{
    7878  rtems_filesystem_global_location_t **fs_root_ptr = NULL;
    7979
    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;
    8385    }
    8486  }
     
    98100  rtems_filesystem_location_info_t *currentloc =
    99101    rtems_filesystem_eval_path_get_currentloc( ctx );
    100   IMFS_jnode_t *dir = currentloc->node_access;
     102  IMFS_directory_t *dir = currentloc->node_access;
    101103  bool access_ok = rtems_filesystem_eval_path_check_access(
    102104    ctx,
    103105    RTEMS_FS_PERMS_EXEC,
    104     dir->st_mode,
    105     dir->st_uid,
    106     dir->st_gid
     106    dir->Node.st_mode,
     107    dir->Node.st_uid,
     108    dir->Node.st_gid
    107109  );
    108110
     
    115117      bool follow_hard_link = (eval_flags & RTEMS_FS_FOLLOW_HARD_LINK) != 0;
    116118      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;
    118120
    119121      rtems_filesystem_eval_path_clear_token( ctx );
    120122
    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;
    123127      }
    124128
    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;
    127132
    128133        rtems_filesystem_eval_path_recursive( ctx, target, strlen( target ) );
    129134      } else {
    130135        rtems_filesystem_global_location_t **fs_root_ptr =
    131           IMFS_is_mount_point( entry, type );
     136          IMFS_is_mount_point( entry, mode );
    132137
    133138        if ( fs_root_ptr == NULL ) {
    134           --dir->reference_count;
     139          --dir->Node.reference_count;
    135140          ++entry->reference_count;
    136141          currentloc->node_access = entry;
  • cpukit/libfs/src/imfs/imfs_fifo.c

    r369328f0 rcf36b70  
    2020#include "imfs.h"
    2121
    22 #define JNODE2PIPE(_jnode)  ( (_jnode)->info.fifo.pipe )
     22#define JNODE2PIPE(_jnode)  ( ((IMFS_fifo_t *)(_jnode))->pipe )
    2323
    2424#define LIBIO2PIPE(_iop)  ( JNODE2PIPE((IMFS_jnode_t *)(_iop)->pathinfo.node_access) )
     
    132132
    133133const IMFS_node_control IMFS_node_control_fifo = {
    134   .imfs_type = IMFS_FIFO,
    135134  .handlers = &IMFS_fifo_handlers,
     135  .node_size = sizeof(IMFS_fifo_t),
    136136  .node_initialize = IMFS_node_initialize_default,
    137137  .node_remove = IMFS_node_remove_default,
  • cpukit/libfs/src/imfs/imfs_fsunmount.c

    r369328f0 rcf36b70  
    2222
    2323#define jnode_get_control( jnode ) \
    24   (&jnode->info.directory.Entries)
     24  (&((IMFS_directory_t *) jnode)->Entries)
    2525
    2626#define jnode_has_no_children( jnode )  \
  • cpukit/libfs/src/imfs/imfs_handlers_device.c

    r369328f0 rcf36b70  
    2626)
    2727{
    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;
    3029
    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 );
    3231
    3332  return IMFS_stat( loc, buf );
     
    5453static IMFS_jnode_t *IMFS_node_initialize_device(
    5554  IMFS_jnode_t *node,
    56   const IMFS_types_union *info
     55  void *arg
    5756)
    5857{
    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 );
    6162
    6263  return node;
     
    6465
    6566const IMFS_node_control IMFS_node_control_device = {
    66   .imfs_type = IMFS_DEVICE,
    6767  .handlers = &IMFS_device_handlers,
     68  .node_size = sizeof(IMFS_device_t),
    6869  .node_initialize = IMFS_node_initialize_device,
    6970  .node_remove = IMFS_node_remove_default,
  • cpukit/libfs/src/imfs/imfs_handlers_directory.c

    r369328f0 rcf36b70  
    2626{
    2727  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;
    2930  const rtems_chain_node *current = rtems_chain_immutable_first( chain );
    3031  const rtems_chain_node *tail = rtems_chain_immutable_tail( chain );
     
    7071static IMFS_jnode_t *IMFS_node_initialize_directory(
    7172  IMFS_jnode_t *node,
    72   const IMFS_types_union *info
     73  void *arg
    7374)
    7475{
    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 );
    7679
    7780  return node;
    7881}
    7982
    80 static bool IMFS_is_mount_point( const IMFS_jnode_t *node )
     83static bool IMFS_is_mount_point( const IMFS_directory_t *dir )
    8184{
    82   return node->info.directory.mt_fs != NULL;
     85  return dir->mt_fs != NULL;
    8386}
    8487
     
    8790)
    8891{
    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 ) ) {
    9095    errno = ENOTEMPTY;
    91     node = NULL;
    92   } else if ( IMFS_is_mount_point( node ) ) {
     96    dir = NULL;
     97  } else if ( IMFS_is_mount_point( dir ) ) {
    9398    errno = EBUSY;
    94     node = NULL;
     99    dir = NULL;
    95100  }
    96101
    97   return node;
     102  return &dir->Node;
    98103}
    99104
    100105const IMFS_node_control IMFS_node_control_directory = {
    101   .imfs_type = IMFS_DIRECTORY,
    102106  .handlers = &IMFS_directory_handlers,
     107  .node_size = sizeof(IMFS_directory_t),
    103108  .node_initialize = IMFS_node_initialize_directory,
    104109  .node_remove = IMFS_node_remove_directory,
  • cpukit/libfs/src/imfs/imfs_handlers_link.c

    r369328f0 rcf36b70  
    3131  const IMFS_jnode_t *node = loc->node_access;
    3232
    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 );
    3537
    3638    return IMFS_stat( loc, buf );
    3739  } else {
     40    const IMFS_link_t *hard_link = (const IMFS_link_t *) node;
    3841    rtems_filesystem_location_info_t targetloc = *loc;
    3942
    40     targetloc.node_access = node->info.hard_link.link_node;
     43    targetloc.node_access = hard_link->link_node;
    4144    IMFS_Set_handlers( &targetloc );
    4245
     
    6568static IMFS_jnode_t *IMFS_node_initialize_hard_link(
    6669  IMFS_jnode_t *node,
    67   const IMFS_types_union *info
     70  void *arg
    6871)
    6972{
    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;
    7176
    7277  return node;
     
    7782)
    7883{
    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;
    8086
    8187  _Assert( target != NULL );
     
    95101
    96102const IMFS_node_control IMFS_node_control_hard_link = {
    97   .imfs_type = IMFS_HARD_LINK,
    98103  .handlers = &IMFS_link_handlers,
     104  .node_size = sizeof(IMFS_link_t),
    99105  .node_initialize = IMFS_node_initialize_hard_link,
    100106  .node_remove = IMFS_node_remove_hard_link,
     
    104110static IMFS_jnode_t *IMFS_node_initialize_sym_link(
    105111  IMFS_jnode_t *node,
    106   const IMFS_types_union *info
     112  void *arg
    107113)
    108114{
    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;
    110118
    111119  return node;
    112120}
    113121
    114 static IMFS_jnode_t *IMFS_node_destroy_sym_link( IMFS_jnode_t *node )
     122static void IMFS_node_destroy_sym_link( IMFS_jnode_t *node )
    115123{
    116   free( node->info.sym_link.name );
     124  IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node;
    117125
    118   return node;
     126  free( sym_link->name );
     127
     128  IMFS_node_destroy_default( node );
    119129}
    120130
    121131const IMFS_node_control IMFS_node_control_sym_link = {
    122   .imfs_type = IMFS_SYM_LINK,
    123132  .handlers = &IMFS_link_handlers,
     133  .node_size = sizeof(IMFS_sym_link_t),
    124134  .node_initialize = IMFS_node_initialize_sym_link,
    125135  .node_remove = IMFS_node_remove_default,
  • cpukit/libfs/src/imfs/imfs_handlers_memfile.c

    r369328f0 rcf36b70  
    2626)
    2727{
    28   const IMFS_jnode_t *node = loc->node_access;
     28  const IMFS_file_t *file = loc->node_access;
    2929
    30   buf->st_size = node->info.file.size;
     30  buf->st_size = file->File.size;
    3131  buf->st_blksize = imfs_rq_memfile_bytes_per_block;
    3232
     
    3535
    3636static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
    37   .open_h = memfile_open,
     37  .open_h = rtems_filesystem_default_open,
    3838  .close_h = rtems_filesystem_default_close,
    3939  .read_h = memfile_read,
     
    5252};
    5353
     54static 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
    5472const IMFS_node_control IMFS_node_control_memfile = {
    55   .imfs_type = IMFS_MEMORY_FILE,
    5673  .handlers = &IMFS_memfile_handlers,
     74  .node_size = sizeof(IMFS_file_t),
    5775  .node_initialize = IMFS_node_initialize_default,
    5876  .node_remove = IMFS_node_remove_default,
     
    6179
    6280const 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),
    6583  .node_initialize = IMFS_node_initialize_default,
    6684  .node_remove = IMFS_node_remove_default,
  • cpukit/libfs/src/imfs/imfs_initsupp.c

    r369328f0 rcf36b70  
    125125  IMFS_assert( node->reference_count == 0 );
    126126
    127   node = (*node->control->node_destroy)( node );
    128 
    129   free( node );
     127  (*node->control->node_destroy)( node );
    130128}
    131129
     
    143141static IMFS_jnode_t *IMFS_node_initialize_enosys(
    144142  IMFS_jnode_t *node,
    145   const IMFS_types_union *info
     143  void *arg
    146144)
    147145{
     
    153151IMFS_jnode_t *IMFS_node_initialize_default(
    154152  IMFS_jnode_t *node,
    155   const IMFS_types_union *info
     153  void *arg
    156154)
    157155{
     
    166164}
    167165
    168 IMFS_jnode_t *IMFS_node_destroy_default( IMFS_jnode_t *node )
     166void IMFS_node_destroy_default( IMFS_jnode_t *node )
    169167{
    170   return node;
     168  free( node );
    171169}
    172170
    173171const IMFS_node_control IMFS_node_control_enosys = {
    174   .imfs_type = IMFS_INVALID_NODE,
    175172  .handlers = &rtems_filesystem_handlers_default,
     173  .node_size = sizeof(IMFS_jnode_t),
    176174  .node_initialize = IMFS_node_initialize_enosys,
    177175  .node_remove = IMFS_node_remove_default,
  • cpukit/libfs/src/imfs/imfs_link.c

    r369328f0 rcf36b70  
    2828)
    2929{
    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;
    3332
    3433  target = targetloc->node_access;
    35   info.hard_link.link_node = target;
    3634
    3735  /*
     
    4947    name,
    5048    namelen,
    51     ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )),
    52     &info
     49    IMFS_STAT_FMT_HARD_LINK | ( S_IRWXU | S_IRWXG | S_IRWXO ),
     50    target
    5351  );
    5452
  • cpukit/libfs/src/imfs/imfs_load_tar.c

    r369328f0 rcf36b70  
    4646   int                              offset;
    4747   unsigned long                    nblocks;
    48    IMFS_jnode_t                    *node;
    4948   int rv = 0;
    5049   int eval_flags = RTEMS_FS_FOLLOW_LINK;
     
    124123
    125124      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        }
    136139      }
    137140
  • cpukit/libfs/src/imfs/imfs_make_generic_node.c

    r369328f0 rcf36b70  
    3030IMFS_jnode_t *IMFS_node_initialize_generic(
    3131  IMFS_jnode_t *node,
    32   const IMFS_types_union *info
     32  void *arg
    3333)
    3434{
    35   node->info.generic.context = info->generic.context;
     35  IMFS_generic_t *generic = (IMFS_generic_t *) node;
     36
     37  generic->context = arg;
    3638
    3739  return node;
     
    7375
    7476  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 );
    8283
    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      );
    8693
    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;
    9696
    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 );
    10498      } else {
    105         rtems_filesystem_eval_path_error( &ctx, ENOTSUP );
    10699        rv = -1;
    107100      }
    108 
    109       rtems_filesystem_eval_path_cleanup( &ctx );
    110101    } else {
    111       errno = EINVAL;
     102      rtems_filesystem_eval_path_error( &ctx, ENOTSUP );
    112103      rv = -1;
    113104    }
     105
     106    rtems_filesystem_eval_path_cleanup( &ctx );
    114107  }
    115108
  • cpukit/libfs/src/imfs/imfs_mknod.c

    r369328f0 rcf36b70  
    2424#include "imfs.h"
    2525
    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 )
     26static IMFS_jnode_types_t get_type( mode_t mode )
    3227{
    3328  if ( S_ISDIR( mode ) ) {
    34     *type = IMFS_DIRECTORY;
     29    return IMFS_DIRECTORY;
    3530  } 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;
    4232  } else if (S_ISFIFO( mode )) {
    43     *type = IMFS_FIFO;
     33    return IMFS_FIFO;
    4434  } else {
    4535    IMFS_assert( S_ISREG( mode ) );
    46     *type = IMFS_MEMORY_FILE;
     36    return IMFS_MEMORY_FILE;
    4737  }
    4838}
     
    5848  int rv = 0;
    5949  IMFS_jnode_types_t type;
    60   IMFS_types_union info;
    6150  IMFS_jnode_t *new_node;
    6251
    63   get_type_and_info_by_mode_and_dev( mode, dev, &type, &info );
     52  type = get_type( mode );
    6453
    65   new_node = IMFS_create_node( parentloc, type, name, namelen, mode, &info );
     54  new_node = IMFS_create_node( parentloc, type, name, namelen, mode, &dev );
    6655  if ( new_node != NULL ) {
    6756    IMFS_jnode_t *parent = parentloc->node_access;
  • cpukit/libfs/src/imfs/imfs_mount.c

    r369328f0 rcf36b70  
    3030
    3131  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;
    3436    } else {
    3537      errno = EBUSY;
  • cpukit/libfs/src/imfs/imfs_readlink.c

    r369328f0 rcf36b70  
    2727)
    2828{
    29   IMFS_jnode_t      *node;
     29  IMFS_sym_link_t   *sym_link;
    3030  ssize_t            i;
    3131
    32   node = loc->node_access;
     32  sym_link = loc->node_access;
    3333
    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];
    3836
    3937  return i;
  • cpukit/libfs/src/imfs/imfs_symlink.c

    r369328f0 rcf36b70  
    3131)
    3232{
    33   IMFS_types_union   info;
    34   IMFS_jnode_t      *new_node;
     33  char         *dup_target;
     34  IMFS_jnode_t *new_node;
    3535
    3636  /*
    3737   * Duplicate link name
    3838   */
    39   info.sym_link.name = strdup(target);
    40   if (info.sym_link.name == NULL) {
     39  dup_target = strdup(target);
     40  if (dup_target == NULL) {
    4141    rtems_set_errno_and_return_minus_one(ENOMEM);
    4242  }
     
    5151    namelen,
    5252    ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )),
    53     &info
     53    dup_target
    5454  );
    5555
    5656  if (new_node == NULL) {
    57     free(info.sym_link.name);
     57    free(dup_target);
    5858    rtems_set_errno_and_return_minus_one(ENOMEM);
    5959  }
  • cpukit/libfs/src/imfs/imfs_unmount.c

    r369328f0 rcf36b70  
    3030
    3131  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;
    3436    } else {
    3537      errno = EINVAL;
  • cpukit/libfs/src/imfs/memfile.c

    r369328f0 rcf36b70  
    3030 */
    3131MEMFILE_STATIC int IMFS_memfile_extend(
    32    IMFS_jnode_t  *the_jnode,
    33    bool           zero_fill,
    34    off_t          new_length
     32   IMFS_memfile_t *memfile,
     33   bool            zero_fill,
     34   off_t           new_length
    3535);
    3636
    3737MEMFILE_STATIC int IMFS_memfile_addblock(
    38    IMFS_jnode_t  *the_jnode,
    39    unsigned int   block
     38   IMFS_memfile_t *memfile,
     39   unsigned int    block
    4040);
    4141
    4242MEMFILE_STATIC void IMFS_memfile_remove_block(
    43    IMFS_jnode_t  *the_jnode,
    44    unsigned int   block
     43   IMFS_memfile_t *memfile,
     44   unsigned int    block
    4545);
    4646
    4747MEMFILE_STATIC block_p *IMFS_memfile_get_block_pointer(
    48    IMFS_jnode_t   *the_jnode,
     48   IMFS_memfile_t *memfile,
    4949   unsigned int    block,
    5050   int             malloc_it
     
    5252
    5353MEMFILE_STATIC ssize_t IMFS_memfile_read(
    54    IMFS_jnode_t    *the_jnode,
     54   IMFS_file_t     *file,
    5555   off_t            start,
    5656   unsigned char   *destination,
     
    5959
    6060ssize_t IMFS_memfile_write(  /* cannot be static as used in imfs_fchmod.c */
    61    IMFS_jnode_t          *the_jnode,
     61   IMFS_memfile_t        *memfile,
    6262   off_t                  start,
    6363   const unsigned char   *source,
     
    7171);
    7272
    73 int memfile_open(
     73int IMFS_linfile_open(
    7474  rtems_libio_t *iop,
    7575  const char    *pathname,
     
    7878)
    7979{
    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;
    8383
    8484  /*
    8585   * Perform 'copy on write' for linear files
    8686   */
    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;
    9796    if ((count != 0)
    98      && (IMFS_memfile_write(the_jnode, 0, buffer, count) == -1))
     97     && (IMFS_memfile_write(&file->Memfile, 0, buffer, count) == -1))
    9998        return -1;
    10099  }
    101100
    102101  return 0;
     102}
     103
     104ssize_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;
    103123}
    104124
     
    109129)
    110130{
    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 );
    117135
    118136  if ( status > 0 )
     
    128146)
    129147{
    130   IMFS_jnode_t   *the_jnode;
     148  IMFS_memfile_t *memfile = IMFS_iop_to_memfile( iop );
    131149  ssize_t         status;
    132150
    133   the_jnode = iop->pathinfo.node_access;
    134 
    135151  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 );
    139155
    140156  if ( status > 0 )
     
    155171)
    156172{
    157   IMFS_jnode_t   *the_jnode;
    158 
    159   the_jnode = iop->pathinfo.node_access;
     173  IMFS_memfile_t *memfile = IMFS_iop_to_memfile( iop );
    160174
    161175  /*
     
    165179   */
    166180
    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 );
    169183
    170184  /*
     
    173187   *  future use and just set the length.
    174188   */
    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 );
    178192
    179193  return 0;
     
    188202 */
    189203MEMFILE_STATIC int IMFS_memfile_extend(
    190    IMFS_jnode_t  *the_jnode,
    191    bool           zero_fill,
    192    off_t          new_length
     204   IMFS_memfile_t *memfile,
     205   bool            zero_fill,
     206   off_t           new_length
    193207)
    194208{
     
    201215   *  Perform internal consistency checks
    202216   */
    203   IMFS_assert( the_jnode );
    204     IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE );
     217  IMFS_assert( memfile );
    205218
    206219  /*
     
    213226   *  Verify new file size is actually larger than current size
    214227   */
    215   if ( new_length <= the_jnode->info.file.size )
     228  if ( new_length <= memfile->File.size )
    216229    return 0;
    217230
     
    220233   */
    221234  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;
    224237
    225238  /*
     
    227240   */
    228241  for ( block=old_blocks ; block<=new_blocks ; block++ ) {
    229     if ( !IMFS_memfile_addblock( the_jnode, block ) ) {
     242    if ( !IMFS_memfile_addblock( memfile, block ) ) {
    230243       if ( zero_fill ) {
    231244          size_t count = IMFS_MEMFILE_BYTES_PER_BLOCK - offset;
    232245          block_p *block_ptr =
    233             IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
     246            IMFS_memfile_get_block_pointer( memfile, block, 0 );
    234247
    235248          memset( &(*block_ptr) [offset], 0, count);
     
    238251    } else {
    239252       for ( ; block>=old_blocks ; block-- ) {
    240          IMFS_memfile_remove_block( the_jnode, block );
     253         IMFS_memfile_remove_block( memfile, block );
    241254       }
    242255       rtems_set_errno_and_return_minus_one( ENOSPC );
     
    247260   *  Set the new length of the file.
    248261   */
    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
    252266  return 0;
    253267}
     
    259273 */
    260274MEMFILE_STATIC int IMFS_memfile_addblock(
    261    IMFS_jnode_t  *the_jnode,
    262    unsigned int   block
     275   IMFS_memfile_t *memfile,
     276   unsigned int    block
    263277)
    264278{
     
    266280  block_p *block_entry_ptr;
    267281
    268   IMFS_assert( the_jnode );
    269   IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE );
     282  IMFS_assert( memfile );
    270283
    271284  /*
    272285   * Obtain the pointer for the specified block number
    273286   */
    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 );
    275288  if ( !block_entry_ptr )
    276289    return 1;
     
    301314 */
    302315MEMFILE_STATIC void IMFS_memfile_remove_block(
    303    IMFS_jnode_t  *the_jnode,
    304    unsigned int   block
     316   IMFS_memfile_t *memfile,
     317   unsigned int    block
    305318)
    306319{
     
    308321  block_p  ptr;
    309322
    310   block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 );
     323  block_ptr = IMFS_memfile_get_block_pointer( memfile, block, 0 );
    311324  if ( block_ptr ) {
    312325    ptr = *block_ptr;
     
    373386 *         is better to stick to simple, easy to understand algorithms.
    374387 */
    375 IMFS_jnode_t *IMFS_memfile_remove(
     388void IMFS_memfile_remove(
    376389 IMFS_jnode_t  *the_jnode
    377390)
    378391{
    379   IMFS_memfile_t  *info;
     392  IMFS_memfile_t  *memfile;
    380393  int              i;
    381394  int              j;
     
    383396  block_p         *p;
    384397
     398  memfile = (IMFS_memfile_t *) the_jnode;
     399
    385400  /*
    386401   *  Perform internal consistency checks
    387402   */
    388   IMFS_assert( the_jnode );
    389   IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE );
     403  IMFS_assert( memfile );
    390404
    391405  /*
     
    401415   *    + triply indirect
    402416   */
    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 ) {
    410423    for ( i=0 ; i<IMFS_MEMFILE_BLOCK_SLOTS ; i++ ) {
    411       if ( info->doubly_indirect[i] ) {
     424      if ( memfile->doubly_indirect[i] ) {
    412425        memfile_free_blocks_in_table(
    413          (block_p **)&info->doubly_indirect[i], to_free );
     426         (block_p **)&memfile->doubly_indirect[i], to_free );
    414427      }
    415428    }
    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 ) {
    421434    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];
    423436      if ( !p )  /* ensure we have a valid pointer */
    424437         break;
     
    429442      }
    430443      memfile_free_blocks_in_table(
    431         (block_p **)&info->triply_indirect[i], to_free );
     444        (block_p **)&memfile->triply_indirect[i], to_free );
    432445    }
    433446    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 );
    438451}
    439452
     
    450463 */
    451464MEMFILE_STATIC ssize_t IMFS_memfile_read(
    452    IMFS_jnode_t    *the_jnode,
     465   IMFS_file_t     *file,
    453466   off_t            start,
    454467   unsigned char   *destination,
     
    470483   *  Perform internal consistency checks
    471484   */
    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 );
    475486  IMFS_assert( dest );
    476487
     
    481492  my_length = length;
    482493
    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 
    498494  /*
    499495   *  If the last byte we are supposed to read is past the end of this
     
    501497   */
    502498  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;
    505501
    506502  copied = 0;
     
    522518    if ( to_copy > my_length )
    523519      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 );
    525521    if ( !block_ptr )
    526522      return copied;
     
    537533  to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK;
    538534  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 );
    540536    if ( !block_ptr )
    541537      return copied;
     
    553549
    554550  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 );
    556552    if ( !block_ptr )
    557553      return copied;
     
    560556  }
    561557
    562   IMFS_update_atime( the_jnode );
     558  IMFS_update_atime( &file->Node );
    563559
    564560  return copied;
     
    569565 *
    570566 *  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.
    572568 */
    573569MEMFILE_STATIC ssize_t IMFS_memfile_write(
    574    IMFS_jnode_t          *the_jnode,
     570   IMFS_memfile_t        *memfile,
    575571   off_t                  start,
    576572   const unsigned char   *source,
     
    594590   */
    595591  IMFS_assert( source );
    596   IMFS_assert( the_jnode );
    597   IMFS_assert( IMFS_type( the_jnode ) == IMFS_MEMORY_FILE );
     592  IMFS_assert( memfile );
    598593
    599594  my_length = length;
     
    604599
    605600  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 );
    610605    if ( status )
    611606      return status;
     
    630625    if ( to_copy > my_length )
    631626      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 );
    633628    if ( !block_ptr )
    634629      return copied;
     
    657652  to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK;
    658653  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 );
    660655    if ( !block_ptr )
    661656      return copied;
     
    677672  to_copy = my_length;
    678673  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 );
    680675    if ( !block_ptr )
    681676      return copied;
     
    688683  }
    689684
    690   IMFS_mtime_ctime_update( the_jnode );
     685  IMFS_mtime_ctime_update( &memfile->File.Node );
    691686
    692687  return copied;
     
    724719block_p *IMFS_memfile_get_block_pointer(
    725720#endif
    726    IMFS_jnode_t   *the_jnode,
     721   IMFS_memfile_t *memfile,
    727722   unsigned int    block,
    728723   int             malloc_it
     
    730725{
    731726  unsigned int    my_block;
    732   IMFS_memfile_t *info;
    733727  unsigned int    singly;
    734728  unsigned int    doubly;
     
    741735   *  Perform internal consistency checks
    742736   */
    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
    747739  my_block = block;
    748740
     
    751743   */
    752744  if ( my_block <= LAST_INDIRECT ) {
    753     p = info->indirect;
     745    p = memfile->indirect;
    754746
    755747    if ( malloc_it ) {
     
    759751        if ( !p )
    760752           return 0;
    761         info->indirect = p;
     753        memfile->indirect = p;
    762754      }
    763       return &info->indirect[ my_block ];
     755      return &memfile->indirect[ my_block ];
    764756    }
    765757
     
    767759      return 0;
    768760
    769     return &info->indirect[ my_block ];
     761    return &memfile->indirect[ my_block ];
    770762  }
    771763
     
    780772    doubly = my_block / IMFS_MEMFILE_BLOCK_SLOTS;
    781773
    782     p = info->doubly_indirect;
     774    p = memfile->doubly_indirect;
    783775    if ( malloc_it ) {
    784776
     
    787779        if ( !p )
    788780           return 0;
    789         info->doubly_indirect = p;
     781        memfile->doubly_indirect = p;
    790782      }
    791783
     
    822814    doubly %= IMFS_MEMFILE_BLOCK_SLOTS;
    823815
    824     p = info->triply_indirect;
     816    p = memfile->triply_indirect;
    825817
    826818    if ( malloc_it ) {
     
    829821        if ( !p )
    830822           return 0;
    831         info->triply_indirect = p;
     823        memfile->triply_indirect = p;
    832824      }
    833825
  • testsuites/fstests/fsimfsgeneric01/init.c

    r369328f0 rcf36b70  
    263263static IMFS_jnode_t *node_initialize(
    264264  IMFS_jnode_t *node,
    265   const IMFS_types_union *info
     265  void *arg
    266266)
    267267{
    268268  test_state *state = NULL;
    269269
    270   node = IMFS_node_initialize_generic(node, info);
     270  node = IMFS_node_initialize_generic(node, arg);
    271271  state = IMFS_generic_get_context_by_node(node);
    272272
     
    287287}
    288288
    289 static IMFS_jnode_t *node_destroy(IMFS_jnode_t *node)
     289static void node_destroy(IMFS_jnode_t *node)
    290290{
    291291  test_state *state = IMFS_generic_get_context_by_node(node);
     
    294294  *state = TEST_DESTROYED;
    295295
    296   return node;
     296  IMFS_node_destroy_default(node);
    297297}
    298298
    299299static const IMFS_node_control node_control = {
    300   .imfs_type = IMFS_GENERIC,
    301300  .handlers = &node_handlers,
     301  .node_size = sizeof(IMFS_generic_t),
    302302  .node_initialize = node_initialize,
    303303  .node_remove = node_remove,
     
    371371static IMFS_jnode_t *node_initialize_error(
    372372  IMFS_jnode_t *node,
    373   const IMFS_types_union *info
     373  void *arg
    374374)
    375375{
     
    386386}
    387387
    388 static IMFS_jnode_t *node_destroy_inhibited(IMFS_jnode_t *node)
     388static void node_destroy_inhibited(IMFS_jnode_t *node)
    389389{
    390390  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
     393static const IMFS_node_control node_initialization_error_control = {
    397394  .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),
    406396  .node_initialize = node_initialize_error,
    407397  .node_remove = node_remove_inhibited,
     
    425415  rv = IMFS_make_generic_node(
    426416    path,
    427     S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
    428     &node_invalid_control,
    429     NULL
    430   );
    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,
    438417    S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO,
    439418    &node_control,
  • testsuites/libtests/newlib01/init.c

    r369328f0 rcf36b70  
    233233};
    234234
    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 };
     235static const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER(
     236  &node_handlers,
     237  IMFS_node_initialize_default,
     238  IMFS_node_destroy_default
     239);
    242240
    243241static void test(void)
  • testsuites/libtests/tar02/init.c

    r369328f0 rcf36b70  
    6969
    7070  test_tarfs_load();
    71   IMFS_dump();
    7271
    7372  TEST_END();
  • testsuites/libtests/tar02/tar02.scn

    r369328f0 rcf36b70  
    1 *** TAR02 TEST ***
     1*** BEGIN OF TEST TAR 2 ***
    22Loading tarfs image ... successful
    33========= /home/test_file =========
     
    99initial tar image.
    1010
    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 ***
    92stat of /dev/console
    103....st_dev     (0xfffe:0x0)
     
    182175....st_blksize 80
    183176....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       ***************
    204177truncate /tmp/j to length of 40
    205178....st_dev     (0xfffe:0x0)
     
    210183....uid = 0
    211184....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
    236190truncate /tmp/j to length of 0
    237191truncate /tmp to length of 0 should fail with EISDIR
    238192
    23919321: 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       ***************
    259194Writing First File
    260195Writing Second File
     
    265200this is a test line
    266201
    267 *** END OF FILE TEST 1 ***
     202*** END OF TEST PSXFILE 1 ***
  • testsuites/psxtests/psxfile01/test.c

    r369328f0 rcf36b70  
    167167   */
    168168
    169   max_size = IMFS_memfile_maximum_size();
     169  max_size = IMFS_MEMFILE_MAXIMUM_SIZE;
    170170
    171171  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
    172172  rtems_status = rtems_clock_set( &time );
    173173  directive_failed( rtems_status, "clock set" );
    174 
    175   /*
    176    *  Dump an empty file system
    177    */
    178 
    179   IMFS_dump();
    180174
    181175  /*
     
    606600  rtems_test_assert( ctime1 == ctime2);
    607601
    608   IMFS_dump();
    609 
    610602  unlink( "/tmp/joel" );
    611603
     
    632624  rtems_test_assert( ctime1 != ctime2);
    633625
    634   IMFS_dump();
    635 
    636626  /* try to truncate the console and see what happens */
    637627  status = truncate( "/dev/console", 40 );
     
    647637  printf( "%d: %s\n", errno, strerror( errno ) );
    648638  rtems_test_assert( errno == EISDIR );
    649 
    650   IMFS_dump();
    651639
    652640  status = truncate( "/tmp/fred", 10 );
  • testsuites/psxtests/psximfs02/init.c

    r369328f0 rcf36b70  
    3232/* forward declarations to avoid warnings */
    3333rtems_task Init(rtems_task_argument argument);
    34 void IMFS_dump(void);
    3534
    3635rtems_task Init(
     
    184183  status = mkfifo( "/fifo", S_IRWXU );
    185184  rtems_test_assert( status == 0 );
    186 
    187   IMFS_dump();
    188185 
    189186  puts( "chown /fifo to 10 -- OK" );
  • testsuites/psxtests/psximfs02/psximfs02.scn

    r369328f0 rcf36b70  
    1 *** TEST IMFS 02 ***
     1*** BEGIN OF TEST PSXIMFS 2 ***
    22Creating directory /dir00
    33Creating directory /dir00/dir01
     
    2525Opening /node-slink in WRONLY mode -- expect EACCES
    2626Allocate most of heap
    27 Attempt to mount a fs at /dir01 -- expect ENOMEM
    28 Freeing allocated memory
     27Attempt to mount a fs at dir01 -- expect ENOMEMFreeing allocated memory
     28Changing directory to /
    2929Allocate most of heap
    30 Changing directory to /
    3130Attempt to create /node-link-2 for /node -- expect ENOMEM
    3231Attempt to create /node-slink-2 for /node -- expect ENOMEM
    3332Freeing allocated memory
    3433Allocate 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
     34Attempt to create node-slink-2 for /node -- expect ENOMEMFreeing allocated memory
     35Attempt to stat a hardlink
    3836Changing euid to 10
    3937Attempt chmod on /node -- expect EPERM
     
    4139Changing euid back to 0 [root]
    4240Creating 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 printed
    50 ........dir01-link1 links not printed
    51 ........dir01-link2 links not printed
    52 ........dir01-link3 links not printed
    53 ........dir01-link4 links not printed
    54 ........dir01-link5 links not printed
    55 ........dir01-link6 links not printed
    56 ....node (file 0)
    57 ....node-link links not printed
    58 ....node-slink links not printed
    59 ....fifo FIFO not printed
    60 ***************      End of Dump       ***************
    6141chown /fifo to 10 -- OK
    6242Changing euid to 10
    6343chmod /fifo -- OK
    6444chown /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.