Changeset 657e1bf6 in rtems


Ignore:
Timestamp:
Oct 26, 1999, 8:17:13 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
7ee88c16
Parents:
e54a7d33
Message:

Added initial cut at miniIMFS which leaves out memfile and directory
readdir support. The next step is to add a mount table and configure
either the miniIMFS or the full IMFS at the application level.

Files:
8 added
1 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libcsupport/include/rtems/libio.h

    re54a7d33 r657e1bf6  
    307307 */
    308308
    309 struct rtems_filesystem_mount_table_entry_tt{
     309struct rtems_filesystem_mount_table_entry_tt {
    310310  Chain_Node                             Node;
    311311  rtems_filesystem_location_info_t       mt_point_node;
  • c/src/exec/libcsupport/src/base_fs.c

    re54a7d33 r657e1bf6  
    5353  init_fs_mount_table();
    5454
     55  /*
     56   *  mount the first filesystem.
     57   *
     58   *  NOTE: XXX This really needs to be read from a table of filesystems
     59   *        to mount initially and the miniIMFS needs to be shaken out.
     60   */
     61
    5562  status = mount(
    5663     &first_entry,
  • c/src/exec/libfs/src/imfs/imfs.h

    re54a7d33 r657e1bf6  
    184184
    185185typedef struct {
    186   ino_t    ino_count;
     186  ino_t                             ino_count;
     187  rtems_filesystem_file_handlers_r *memfile_handlers;
     188  rtems_filesystem_file_handlers_r *directory_handlers;
    187189} IMFS_fs_info_t;
    188190
     
    215217extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    216218extern rtems_filesystem_operations_table      IMFS_ops;
     219extern rtems_filesystem_operations_table      miniIMFS_ops;
    217220extern rtems_filesystem_limits_and_options_t  IMFS_LIMITS_AND_OPTIONS;
    218221
     
    223226int IMFS_initialize(
    224227   rtems_filesystem_mount_table_entry_t *mt_entry
     228);
     229
     230int miniIMFS_initialize(
     231   rtems_filesystem_mount_table_entry_t *mt_entry
     232);
     233
     234int IMFS_initialize_support(
     235   rtems_filesystem_mount_table_entry_t *mt_entry,
     236   rtems_filesystem_operations_table    *op_table,
     237   rtems_filesystem_file_handlers_r     *memfile_handlers,
     238   rtems_filesystem_file_handlers_r     *directory_handlers
    225239);
    226240
  • c/src/exec/libfs/src/imfs/imfs_eval.c

    re54a7d33 r657e1bf6  
    3333)
    3434{
    35   IMFS_jnode_t  *node = loc->node_access;
    36 
     35  IMFS_jnode_t    *node = loc->node_access;
     36  IMFS_fs_info_t  *fs_info;
     37
     38  fs_info = loc->mt_entry->fs_info;
    3739  switch( node->type ) {
    3840    case IMFS_DIRECTORY:
    39       loc->handlers = &IMFS_directory_handlers;
     41      loc->handlers = fs_info->directory_handlers;
    4042      break;
    4143    case IMFS_DEVICE:
     
    4749      break;
    4850    case IMFS_MEMORY_FILE:
    49       loc->handlers = &IMFS_memfile_handlers;
     51      loc->handlers = fs_info->memfile_handlers;
    5052      break;
    5153  }
  • c/src/exec/libfs/src/imfs/imfs_free.c

    re54a7d33 r657e1bf6  
    3636}
    3737
    38 
    39 /*
    40  *  IMFS_freenod
    41  *
    42  *  The following routine frees a node if possible.
    43  *
    44  *  The routine returns 0 if the node was not freed and 1 if it was.
    45  *
    46  *  NOTE:  This routine is for INTERNAL IMFS use only.
    47  */
    48 
    49 int IMFS_freenod(
    50   rtems_filesystem_location_info_t  *pathloc
    51 )
    52 {
    53   IMFS_jnode_t       *the_jnode;
    54 
    55   the_jnode = pathloc->node_access;
    56 
    57   if ( the_jnode->type == IMFS_DIRECTORY ) {
    58 
    59     /*
    60      * You cannot remove a node that still has children
    61      */
    62 
    63     if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
    64        return ENOTEMPTY;
    65 
    66     /*
    67      * You cannot remove the file system root node.
    68      */
    69     if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
    70        return EBUSY;
    71 
    72     /*
    73      * You cannot remove a mountpoint.
    74      */
    75      if ( the_jnode->info.directory.mt_fs != NULL )
    76        return EBUSY;       
    77   }
    78 
    79   if ( !rtems_libio_is_file_open( the_jnode ) &&
    80        (the_jnode->st_nlink < 1) ) {
    81 
    82     /*
    83      * Is the rtems_filesystem_current is this node?
    84      */
    85     if ( rtems_filesystem_current.node_access == pathloc->node_access ) {
    86       rtems_filesystem_current.node_access = NULL;
    87     }
    88 
    89     /*
    90      * Free memory associated with a memory file.
    91      */
    92     if ( the_jnode->type == IMFS_MEMORY_FILE )
    93       IMFS_memfile_remove( the_jnode );
    94 
    95     free( the_jnode );
    96   }
    97 
    98   return 0;
    99 }
  • c/src/exec/libfs/src/imfs/imfs_init.c

    re54a7d33 r657e1bf6  
    2727#endif
    2828
    29 /*
     29/* 
    3030 *  IMFS file system operations table
    3131 */
     
    4545  IMFS_unmount,
    4646  IMFS_fsunmount,
    47   IMFS_utime, 
     47  IMFS_utime,
    4848  IMFS_evaluate_link,
    4949  IMFS_symlink,
     
    5959)
    6060{
    61   IMFS_fs_info_t                        *fs_info;
    62   IMFS_jnode_t                          *jnode;
    63 
    64   /*
    65    *  Create the root node
    66    */
    67 
    68   temp_mt_entry->mt_fs_root.node_access = IMFS_create_node(
    69     NULL,
    70     IMFS_DIRECTORY,
    71     "",
    72     ( S_IRWXO | S_IRWXG| S_IRWXU ),
    73     NULL
    74   );
    75 
    76   temp_mt_entry->mt_fs_root.handlers    = &IMFS_directory_handlers;
    77   temp_mt_entry->mt_fs_root.ops         = &IMFS_ops;
    78   temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
    79 
    80   /*
    81    * Create custom file system data.
    82    */
    83   fs_info = calloc( 1, sizeof( IMFS_fs_info_t ) );
    84   if ( !fs_info ){
    85     free(temp_mt_entry->mt_fs_root.node_access);
    86     return 1;
    87   }
    88   temp_mt_entry->fs_info = fs_info;
    89 
    90   /*
    91    * Set st_ino for the root to 1.
    92    */
    93 
    94   fs_info->ino_count   = 1;
    95 
    96   jnode = temp_mt_entry->mt_fs_root.node_access;
    97   jnode->st_ino = fs_info->ino_count;
    98 
    99   return 0;
    100 }
    101 
    102 #define jnode_get_control( jnode ) \
    103   (&jnode->info.directory.Entries)
    104 
    105 #define jnode_has_no_children( jnode )  \
    106   Chain_Is_empty( jnode_get_control( jnode ) )
    107 
    108 #define jnode_has_children( jnode ) \
    109   ( ! jnode_has_no_children( jnode ) )
    110 
    111 #define jnode_get_first_child( jnode ) \
    112     ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    113 
    114 
    115 int IMFS_fsunmount(
    116   rtems_filesystem_mount_table_entry_t *temp_mt_entry
    117 )
    118 {
    119    IMFS_jnode_t                     *jnode;
    120    IMFS_jnode_t                     *next;
    121    rtems_filesystem_location_info_t loc;       
    122    int                              result = 0;
    123 
    124    /*
    125     * Traverse tree that starts at the mt_fs_root and deallocate memory
    126     * associated memory space
    127     */
    128    
    129    jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    130 
    131    do {
    132      next = jnode->Parent;
    133      loc.node_access = (void *)jnode;
    134 
    135      if ( jnode->type != IMFS_DIRECTORY ) {
    136         result = IMFS_unlink( &loc );
    137         if (result != 0)
    138           return -1;
    139         jnode = next;
    140      } else if ( jnode_has_no_children( jnode ) ) {
    141         result = IMFS_unlink( &loc );
    142         if (result != 0)
    143           return -1;
    144         jnode = next;
    145      }
    146      if ( jnode != NULL ) {
    147        if ( jnode->type == IMFS_DIRECTORY ) {
    148          if ( jnode_has_children( jnode ) )
    149            jnode = jnode_get_first_child( jnode );
    150        }
    151      }
    152    } while (jnode != NULL);
    153 
     61   IMFS_initialize_support(
     62     temp_mt_entry,
     63     &IMFS_ops,
     64     &IMFS_memfile_handlers,
     65     &IMFS_directory_handlers
     66   );
    15467   return 0;
    15568}
    156 
    157 
    158 
  • c/src/exec/libfs/src/imfs/imfs_initsupp.c

    re54a7d33 r657e1bf6  
    2828
    2929/*
    30  *  IMFS file system operations table
    31  */
    32 
    33 rtems_filesystem_operations_table  IMFS_ops = {
    34   IMFS_eval_path,
    35   IMFS_evaluate_for_make,
    36   IMFS_link,
    37   IMFS_unlink,
    38   IMFS_node_type,
    39   IMFS_mknod,
    40   IMFS_rmnod,
    41   IMFS_chown,
    42   IMFS_freenodinfo,
    43   IMFS_mount,
    44   IMFS_initialize,
    45   IMFS_unmount,
    46   IMFS_fsunmount,
    47   IMFS_utime,
    48   IMFS_evaluate_link,
    49   IMFS_symlink,
    50   IMFS_readlink
    51 };
    52 
    53 /*
    5430 *  IMFS_initialize
    5531 */
    5632
    57 int IMFS_initialize(
    58   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     33int IMFS_initialize_support(
     34  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     35   rtems_filesystem_operations_table    *op_table,
     36   rtems_filesystem_file_handlers_r     *memfile_handlers,
     37   rtems_filesystem_file_handlers_r     *directory_handlers
    5938)
    6039{
     
    7453  );
    7554
    76   temp_mt_entry->mt_fs_root.handlers    = &IMFS_directory_handlers;
    77   temp_mt_entry->mt_fs_root.ops         = &IMFS_ops;
     55  temp_mt_entry->mt_fs_root.handlers         = directory_handlers;
     56  temp_mt_entry->mt_fs_root.ops              = op_table;
    7857  temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
    7958
     
    9271   */
    9372
    94   fs_info->ino_count   = 1;
     73  fs_info->ino_count        = 1;
     74  fs_info->memfile_handlers = memfile_handlers;
     75  fs_info->memfile_handlers = directory_handlers;
    9576
    9677  jnode = temp_mt_entry->mt_fs_root.node_access;
     
    9980  return 0;
    10081}
    101 
    102 #define jnode_get_control( jnode ) \
    103   (&jnode->info.directory.Entries)
    104 
    105 #define jnode_has_no_children( jnode )  \
    106   Chain_Is_empty( jnode_get_control( jnode ) )
    107 
    108 #define jnode_has_children( jnode ) \
    109   ( ! jnode_has_no_children( jnode ) )
    110 
    111 #define jnode_get_first_child( jnode ) \
    112     ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    113 
    114 
    115 int IMFS_fsunmount(
    116   rtems_filesystem_mount_table_entry_t *temp_mt_entry
    117 )
    118 {
    119    IMFS_jnode_t                     *jnode;
    120    IMFS_jnode_t                     *next;
    121    rtems_filesystem_location_info_t loc;       
    122    int                              result = 0;
    123 
    124    /*
    125     * Traverse tree that starts at the mt_fs_root and deallocate memory
    126     * associated memory space
    127     */
    128    
    129    jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    130 
    131    do {
    132      next = jnode->Parent;
    133      loc.node_access = (void *)jnode;
    134 
    135      if ( jnode->type != IMFS_DIRECTORY ) {
    136         result = IMFS_unlink( &loc );
    137         if (result != 0)
    138           return -1;
    139         jnode = next;
    140      } else if ( jnode_has_no_children( jnode ) ) {
    141         result = IMFS_unlink( &loc );
    142         if (result != 0)
    143           return -1;
    144         jnode = next;
    145      }
    146      if ( jnode != NULL ) {
    147        if ( jnode->type == IMFS_DIRECTORY ) {
    148          if ( jnode_has_children( jnode ) )
    149            jnode = jnode_get_first_child( jnode );
    150        }
    151      }
    152    } while (jnode != NULL);
    153 
    154    return 0;
    155 }
    156 
    157 
    158 
  • c/src/exec/libfs/src/imfs/memfile.c

    re54a7d33 r657e1bf6  
    2929
    3030#define MEMFILE_STATIC
     31
     32/*
     33 *  Set of operations handlers for operations on memfile entities.
     34 */
     35
     36rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
     37  memfile_open,
     38  memfile_close,
     39  memfile_read,
     40  memfile_write,
     41  memfile_ioctl,
     42  memfile_lseek,
     43  IMFS_stat,
     44  IMFS_fchmod,
     45  memfile_ftruncate,
     46  NULL,                /* fpathconf */
     47  NULL,                /* fsync */
     48  IMFS_fdatasync,
     49  IMFS_fcntl
     50};
    3151
    3252/*
  • c/src/lib/include/rtems/libio.h

    re54a7d33 r657e1bf6  
    307307 */
    308308
    309 struct rtems_filesystem_mount_table_entry_tt{
     309struct rtems_filesystem_mount_table_entry_tt {
    310310  Chain_Node                             Node;
    311311  rtems_filesystem_location_info_t       mt_point_node;
  • c/src/lib/libc/Makefile.in

    re54a7d33 r657e1bf6  
    2525
    2626IMFS_C_PIECES = imfs_chown imfs_creat imfs_directory imfs_eval imfs_free \
    27     imfs_gtkn imfs_init imfs_link imfs_mknod imfs_mount imfs_fchmod \
    28     imfs_rmnod imfs_unlink imfs_unmount imfs_utime imfs_ntype imfs_stat \
    29     imfs_getchild memfile deviceio imfs_handlers imfs_debug imfs_symlink \
    30     imfs_readlink imfs_fdatasync imfs_fcntl
     27    imfs_fsunmount imfs_gtkn imfs_init imfs_initsupp imfs_link imfs_mknod \
     28    imfs_mount imfs_fchmod imfs_rmnod imfs_unlink imfs_unmount imfs_utime \
     29    imfs_ntype imfs_stat imfs_getchild memfile deviceio imfs_handlers_device \
     30    imfs_handlers_directory imfs_handlers_memfile imfs_debug imfs_symlink \
     31    imfs_readlink imfs_fdatasync imfs_fcntl miniimfs_init
    3132
    3233TERMIOS_C_PIECES = cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcgetattr \
  • c/src/lib/libc/base_fs.c

    re54a7d33 r657e1bf6  
    5353  init_fs_mount_table();
    5454
     55  /*
     56   *  mount the first filesystem.
     57   *
     58   *  NOTE: XXX This really needs to be read from a table of filesystems
     59   *        to mount initially and the miniIMFS needs to be shaken out.
     60   */
     61
    5562  status = mount(
    5663     &first_entry,
  • c/src/lib/libc/imfs.h

    re54a7d33 r657e1bf6  
    184184
    185185typedef struct {
    186   ino_t    ino_count;
     186  ino_t                             ino_count;
     187  rtems_filesystem_file_handlers_r *memfile_handlers;
     188  rtems_filesystem_file_handlers_r *directory_handlers;
    187189} IMFS_fs_info_t;
    188190
     
    215217extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    216218extern rtems_filesystem_operations_table      IMFS_ops;
     219extern rtems_filesystem_operations_table      miniIMFS_ops;
    217220extern rtems_filesystem_limits_and_options_t  IMFS_LIMITS_AND_OPTIONS;
    218221
     
    223226int IMFS_initialize(
    224227   rtems_filesystem_mount_table_entry_t *mt_entry
     228);
     229
     230int miniIMFS_initialize(
     231   rtems_filesystem_mount_table_entry_t *mt_entry
     232);
     233
     234int IMFS_initialize_support(
     235   rtems_filesystem_mount_table_entry_t *mt_entry,
     236   rtems_filesystem_operations_table    *op_table,
     237   rtems_filesystem_file_handlers_r     *memfile_handlers,
     238   rtems_filesystem_file_handlers_r     *directory_handlers
    225239);
    226240
  • c/src/lib/libc/imfs_eval.c

    re54a7d33 r657e1bf6  
    3333)
    3434{
    35   IMFS_jnode_t  *node = loc->node_access;
    36 
     35  IMFS_jnode_t    *node = loc->node_access;
     36  IMFS_fs_info_t  *fs_info;
     37
     38  fs_info = loc->mt_entry->fs_info;
    3739  switch( node->type ) {
    3840    case IMFS_DIRECTORY:
    39       loc->handlers = &IMFS_directory_handlers;
     41      loc->handlers = fs_info->directory_handlers;
    4042      break;
    4143    case IMFS_DEVICE:
     
    4749      break;
    4850    case IMFS_MEMORY_FILE:
    49       loc->handlers = &IMFS_memfile_handlers;
     51      loc->handlers = fs_info->memfile_handlers;
    5052      break;
    5153  }
  • c/src/lib/libc/imfs_free.c

    re54a7d33 r657e1bf6  
    3636}
    3737
    38 
    39 /*
    40  *  IMFS_freenod
    41  *
    42  *  The following routine frees a node if possible.
    43  *
    44  *  The routine returns 0 if the node was not freed and 1 if it was.
    45  *
    46  *  NOTE:  This routine is for INTERNAL IMFS use only.
    47  */
    48 
    49 int IMFS_freenod(
    50   rtems_filesystem_location_info_t  *pathloc
    51 )
    52 {
    53   IMFS_jnode_t       *the_jnode;
    54 
    55   the_jnode = pathloc->node_access;
    56 
    57   if ( the_jnode->type == IMFS_DIRECTORY ) {
    58 
    59     /*
    60      * You cannot remove a node that still has children
    61      */
    62 
    63     if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
    64        return ENOTEMPTY;
    65 
    66     /*
    67      * You cannot remove the file system root node.
    68      */
    69     if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
    70        return EBUSY;
    71 
    72     /*
    73      * You cannot remove a mountpoint.
    74      */
    75      if ( the_jnode->info.directory.mt_fs != NULL )
    76        return EBUSY;       
    77   }
    78 
    79   if ( !rtems_libio_is_file_open( the_jnode ) &&
    80        (the_jnode->st_nlink < 1) ) {
    81 
    82     /*
    83      * Is the rtems_filesystem_current is this node?
    84      */
    85     if ( rtems_filesystem_current.node_access == pathloc->node_access ) {
    86       rtems_filesystem_current.node_access = NULL;
    87     }
    88 
    89     /*
    90      * Free memory associated with a memory file.
    91      */
    92     if ( the_jnode->type == IMFS_MEMORY_FILE )
    93       IMFS_memfile_remove( the_jnode );
    94 
    95     free( the_jnode );
    96   }
    97 
    98   return 0;
    99 }
  • c/src/lib/libc/imfs_init.c

    re54a7d33 r657e1bf6  
    2727#endif
    2828
    29 /*
     29/* 
    3030 *  IMFS file system operations table
    3131 */
     
    4545  IMFS_unmount,
    4646  IMFS_fsunmount,
    47   IMFS_utime, 
     47  IMFS_utime,
    4848  IMFS_evaluate_link,
    4949  IMFS_symlink,
     
    5959)
    6060{
    61   IMFS_fs_info_t                        *fs_info;
    62   IMFS_jnode_t                          *jnode;
    63 
    64   /*
    65    *  Create the root node
    66    */
    67 
    68   temp_mt_entry->mt_fs_root.node_access = IMFS_create_node(
    69     NULL,
    70     IMFS_DIRECTORY,
    71     "",
    72     ( S_IRWXO | S_IRWXG| S_IRWXU ),
    73     NULL
    74   );
    75 
    76   temp_mt_entry->mt_fs_root.handlers    = &IMFS_directory_handlers;
    77   temp_mt_entry->mt_fs_root.ops         = &IMFS_ops;
    78   temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
    79 
    80   /*
    81    * Create custom file system data.
    82    */
    83   fs_info = calloc( 1, sizeof( IMFS_fs_info_t ) );
    84   if ( !fs_info ){
    85     free(temp_mt_entry->mt_fs_root.node_access);
    86     return 1;
    87   }
    88   temp_mt_entry->fs_info = fs_info;
    89 
    90   /*
    91    * Set st_ino for the root to 1.
    92    */
    93 
    94   fs_info->ino_count   = 1;
    95 
    96   jnode = temp_mt_entry->mt_fs_root.node_access;
    97   jnode->st_ino = fs_info->ino_count;
    98 
    99   return 0;
    100 }
    101 
    102 #define jnode_get_control( jnode ) \
    103   (&jnode->info.directory.Entries)
    104 
    105 #define jnode_has_no_children( jnode )  \
    106   Chain_Is_empty( jnode_get_control( jnode ) )
    107 
    108 #define jnode_has_children( jnode ) \
    109   ( ! jnode_has_no_children( jnode ) )
    110 
    111 #define jnode_get_first_child( jnode ) \
    112     ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    113 
    114 
    115 int IMFS_fsunmount(
    116   rtems_filesystem_mount_table_entry_t *temp_mt_entry
    117 )
    118 {
    119    IMFS_jnode_t                     *jnode;
    120    IMFS_jnode_t                     *next;
    121    rtems_filesystem_location_info_t loc;       
    122    int                              result = 0;
    123 
    124    /*
    125     * Traverse tree that starts at the mt_fs_root and deallocate memory
    126     * associated memory space
    127     */
    128    
    129    jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    130 
    131    do {
    132      next = jnode->Parent;
    133      loc.node_access = (void *)jnode;
    134 
    135      if ( jnode->type != IMFS_DIRECTORY ) {
    136         result = IMFS_unlink( &loc );
    137         if (result != 0)
    138           return -1;
    139         jnode = next;
    140      } else if ( jnode_has_no_children( jnode ) ) {
    141         result = IMFS_unlink( &loc );
    142         if (result != 0)
    143           return -1;
    144         jnode = next;
    145      }
    146      if ( jnode != NULL ) {
    147        if ( jnode->type == IMFS_DIRECTORY ) {
    148          if ( jnode_has_children( jnode ) )
    149            jnode = jnode_get_first_child( jnode );
    150        }
    151      }
    152    } while (jnode != NULL);
    153 
     61   IMFS_initialize_support(
     62     temp_mt_entry,
     63     &IMFS_ops,
     64     &IMFS_memfile_handlers,
     65     &IMFS_directory_handlers
     66   );
    15467   return 0;
    15568}
    156 
    157 
    158 
  • c/src/lib/libc/imfs_initsupp.c

    re54a7d33 r657e1bf6  
    2828
    2929/*
    30  *  IMFS file system operations table
    31  */
    32 
    33 rtems_filesystem_operations_table  IMFS_ops = {
    34   IMFS_eval_path,
    35   IMFS_evaluate_for_make,
    36   IMFS_link,
    37   IMFS_unlink,
    38   IMFS_node_type,
    39   IMFS_mknod,
    40   IMFS_rmnod,
    41   IMFS_chown,
    42   IMFS_freenodinfo,
    43   IMFS_mount,
    44   IMFS_initialize,
    45   IMFS_unmount,
    46   IMFS_fsunmount,
    47   IMFS_utime,
    48   IMFS_evaluate_link,
    49   IMFS_symlink,
    50   IMFS_readlink
    51 };
    52 
    53 /*
    5430 *  IMFS_initialize
    5531 */
    5632
    57 int IMFS_initialize(
    58   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     33int IMFS_initialize_support(
     34  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     35   rtems_filesystem_operations_table    *op_table,
     36   rtems_filesystem_file_handlers_r     *memfile_handlers,
     37   rtems_filesystem_file_handlers_r     *directory_handlers
    5938)
    6039{
     
    7453  );
    7554
    76   temp_mt_entry->mt_fs_root.handlers    = &IMFS_directory_handlers;
    77   temp_mt_entry->mt_fs_root.ops         = &IMFS_ops;
     55  temp_mt_entry->mt_fs_root.handlers         = directory_handlers;
     56  temp_mt_entry->mt_fs_root.ops              = op_table;
    7857  temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
    7958
     
    9271   */
    9372
    94   fs_info->ino_count   = 1;
     73  fs_info->ino_count        = 1;
     74  fs_info->memfile_handlers = memfile_handlers;
     75  fs_info->memfile_handlers = directory_handlers;
    9576
    9677  jnode = temp_mt_entry->mt_fs_root.node_access;
     
    9980  return 0;
    10081}
    101 
    102 #define jnode_get_control( jnode ) \
    103   (&jnode->info.directory.Entries)
    104 
    105 #define jnode_has_no_children( jnode )  \
    106   Chain_Is_empty( jnode_get_control( jnode ) )
    107 
    108 #define jnode_has_children( jnode ) \
    109   ( ! jnode_has_no_children( jnode ) )
    110 
    111 #define jnode_get_first_child( jnode ) \
    112     ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    113 
    114 
    115 int IMFS_fsunmount(
    116   rtems_filesystem_mount_table_entry_t *temp_mt_entry
    117 )
    118 {
    119    IMFS_jnode_t                     *jnode;
    120    IMFS_jnode_t                     *next;
    121    rtems_filesystem_location_info_t loc;       
    122    int                              result = 0;
    123 
    124    /*
    125     * Traverse tree that starts at the mt_fs_root and deallocate memory
    126     * associated memory space
    127     */
    128    
    129    jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    130 
    131    do {
    132      next = jnode->Parent;
    133      loc.node_access = (void *)jnode;
    134 
    135      if ( jnode->type != IMFS_DIRECTORY ) {
    136         result = IMFS_unlink( &loc );
    137         if (result != 0)
    138           return -1;
    139         jnode = next;
    140      } else if ( jnode_has_no_children( jnode ) ) {
    141         result = IMFS_unlink( &loc );
    142         if (result != 0)
    143           return -1;
    144         jnode = next;
    145      }
    146      if ( jnode != NULL ) {
    147        if ( jnode->type == IMFS_DIRECTORY ) {
    148          if ( jnode_has_children( jnode ) )
    149            jnode = jnode_get_first_child( jnode );
    150        }
    151      }
    152    } while (jnode != NULL);
    153 
    154    return 0;
    155 }
    156 
    157 
    158 
  • c/src/lib/libc/libio.h

    re54a7d33 r657e1bf6  
    307307 */
    308308
    309 struct rtems_filesystem_mount_table_entry_tt{
     309struct rtems_filesystem_mount_table_entry_tt {
    310310  Chain_Node                             Node;
    311311  rtems_filesystem_location_info_t       mt_point_node;
  • c/src/lib/libc/memfile.c

    re54a7d33 r657e1bf6  
    2929
    3030#define MEMFILE_STATIC
     31
     32/*
     33 *  Set of operations handlers for operations on memfile entities.
     34 */
     35
     36rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
     37  memfile_open,
     38  memfile_close,
     39  memfile_read,
     40  memfile_write,
     41  memfile_ioctl,
     42  memfile_lseek,
     43  IMFS_stat,
     44  IMFS_fchmod,
     45  memfile_ftruncate,
     46  NULL,                /* fpathconf */
     47  NULL,                /* fsync */
     48  IMFS_fdatasync,
     49  IMFS_fcntl
     50};
    3151
    3252/*
  • c/src/libfs/src/imfs/imfs.h

    re54a7d33 r657e1bf6  
    184184
    185185typedef struct {
    186   ino_t    ino_count;
     186  ino_t                             ino_count;
     187  rtems_filesystem_file_handlers_r *memfile_handlers;
     188  rtems_filesystem_file_handlers_r *directory_handlers;
    187189} IMFS_fs_info_t;
    188190
     
    215217extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    216218extern rtems_filesystem_operations_table      IMFS_ops;
     219extern rtems_filesystem_operations_table      miniIMFS_ops;
    217220extern rtems_filesystem_limits_and_options_t  IMFS_LIMITS_AND_OPTIONS;
    218221
     
    223226int IMFS_initialize(
    224227   rtems_filesystem_mount_table_entry_t *mt_entry
     228);
     229
     230int miniIMFS_initialize(
     231   rtems_filesystem_mount_table_entry_t *mt_entry
     232);
     233
     234int IMFS_initialize_support(
     235   rtems_filesystem_mount_table_entry_t *mt_entry,
     236   rtems_filesystem_operations_table    *op_table,
     237   rtems_filesystem_file_handlers_r     *memfile_handlers,
     238   rtems_filesystem_file_handlers_r     *directory_handlers
    225239);
    226240
  • c/src/libfs/src/imfs/imfs_eval.c

    re54a7d33 r657e1bf6  
    3333)
    3434{
    35   IMFS_jnode_t  *node = loc->node_access;
    36 
     35  IMFS_jnode_t    *node = loc->node_access;
     36  IMFS_fs_info_t  *fs_info;
     37
     38  fs_info = loc->mt_entry->fs_info;
    3739  switch( node->type ) {
    3840    case IMFS_DIRECTORY:
    39       loc->handlers = &IMFS_directory_handlers;
     41      loc->handlers = fs_info->directory_handlers;
    4042      break;
    4143    case IMFS_DEVICE:
     
    4749      break;
    4850    case IMFS_MEMORY_FILE:
    49       loc->handlers = &IMFS_memfile_handlers;
     51      loc->handlers = fs_info->memfile_handlers;
    5052      break;
    5153  }
  • c/src/libfs/src/imfs/imfs_free.c

    re54a7d33 r657e1bf6  
    3636}
    3737
    38 
    39 /*
    40  *  IMFS_freenod
    41  *
    42  *  The following routine frees a node if possible.
    43  *
    44  *  The routine returns 0 if the node was not freed and 1 if it was.
    45  *
    46  *  NOTE:  This routine is for INTERNAL IMFS use only.
    47  */
    48 
    49 int IMFS_freenod(
    50   rtems_filesystem_location_info_t  *pathloc
    51 )
    52 {
    53   IMFS_jnode_t       *the_jnode;
    54 
    55   the_jnode = pathloc->node_access;
    56 
    57   if ( the_jnode->type == IMFS_DIRECTORY ) {
    58 
    59     /*
    60      * You cannot remove a node that still has children
    61      */
    62 
    63     if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
    64        return ENOTEMPTY;
    65 
    66     /*
    67      * You cannot remove the file system root node.
    68      */
    69     if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
    70        return EBUSY;
    71 
    72     /*
    73      * You cannot remove a mountpoint.
    74      */
    75      if ( the_jnode->info.directory.mt_fs != NULL )
    76        return EBUSY;       
    77   }
    78 
    79   if ( !rtems_libio_is_file_open( the_jnode ) &&
    80        (the_jnode->st_nlink < 1) ) {
    81 
    82     /*
    83      * Is the rtems_filesystem_current is this node?
    84      */
    85     if ( rtems_filesystem_current.node_access == pathloc->node_access ) {
    86       rtems_filesystem_current.node_access = NULL;
    87     }
    88 
    89     /*
    90      * Free memory associated with a memory file.
    91      */
    92     if ( the_jnode->type == IMFS_MEMORY_FILE )
    93       IMFS_memfile_remove( the_jnode );
    94 
    95     free( the_jnode );
    96   }
    97 
    98   return 0;
    99 }
  • c/src/libfs/src/imfs/imfs_init.c

    re54a7d33 r657e1bf6  
    2727#endif
    2828
    29 /*
     29/* 
    3030 *  IMFS file system operations table
    3131 */
     
    4545  IMFS_unmount,
    4646  IMFS_fsunmount,
    47   IMFS_utime, 
     47  IMFS_utime,
    4848  IMFS_evaluate_link,
    4949  IMFS_symlink,
     
    5959)
    6060{
    61   IMFS_fs_info_t                        *fs_info;
    62   IMFS_jnode_t                          *jnode;
    63 
    64   /*
    65    *  Create the root node
    66    */
    67 
    68   temp_mt_entry->mt_fs_root.node_access = IMFS_create_node(
    69     NULL,
    70     IMFS_DIRECTORY,
    71     "",
    72     ( S_IRWXO | S_IRWXG| S_IRWXU ),
    73     NULL
    74   );
    75 
    76   temp_mt_entry->mt_fs_root.handlers    = &IMFS_directory_handlers;
    77   temp_mt_entry->mt_fs_root.ops         = &IMFS_ops;
    78   temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
    79 
    80   /*
    81    * Create custom file system data.
    82    */
    83   fs_info = calloc( 1, sizeof( IMFS_fs_info_t ) );
    84   if ( !fs_info ){
    85     free(temp_mt_entry->mt_fs_root.node_access);
    86     return 1;
    87   }
    88   temp_mt_entry->fs_info = fs_info;
    89 
    90   /*
    91    * Set st_ino for the root to 1.
    92    */
    93 
    94   fs_info->ino_count   = 1;
    95 
    96   jnode = temp_mt_entry->mt_fs_root.node_access;
    97   jnode->st_ino = fs_info->ino_count;
    98 
    99   return 0;
    100 }
    101 
    102 #define jnode_get_control( jnode ) \
    103   (&jnode->info.directory.Entries)
    104 
    105 #define jnode_has_no_children( jnode )  \
    106   Chain_Is_empty( jnode_get_control( jnode ) )
    107 
    108 #define jnode_has_children( jnode ) \
    109   ( ! jnode_has_no_children( jnode ) )
    110 
    111 #define jnode_get_first_child( jnode ) \
    112     ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    113 
    114 
    115 int IMFS_fsunmount(
    116   rtems_filesystem_mount_table_entry_t *temp_mt_entry
    117 )
    118 {
    119    IMFS_jnode_t                     *jnode;
    120    IMFS_jnode_t                     *next;
    121    rtems_filesystem_location_info_t loc;       
    122    int                              result = 0;
    123 
    124    /*
    125     * Traverse tree that starts at the mt_fs_root and deallocate memory
    126     * associated memory space
    127     */
    128    
    129    jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    130 
    131    do {
    132      next = jnode->Parent;
    133      loc.node_access = (void *)jnode;
    134 
    135      if ( jnode->type != IMFS_DIRECTORY ) {
    136         result = IMFS_unlink( &loc );
    137         if (result != 0)
    138           return -1;
    139         jnode = next;
    140      } else if ( jnode_has_no_children( jnode ) ) {
    141         result = IMFS_unlink( &loc );
    142         if (result != 0)
    143           return -1;
    144         jnode = next;
    145      }
    146      if ( jnode != NULL ) {
    147        if ( jnode->type == IMFS_DIRECTORY ) {
    148          if ( jnode_has_children( jnode ) )
    149            jnode = jnode_get_first_child( jnode );
    150        }
    151      }
    152    } while (jnode != NULL);
    153 
     61   IMFS_initialize_support(
     62     temp_mt_entry,
     63     &IMFS_ops,
     64     &IMFS_memfile_handlers,
     65     &IMFS_directory_handlers
     66   );
    15467   return 0;
    15568}
    156 
    157 
    158 
  • c/src/libfs/src/imfs/imfs_initsupp.c

    re54a7d33 r657e1bf6  
    2828
    2929/*
    30  *  IMFS file system operations table
    31  */
    32 
    33 rtems_filesystem_operations_table  IMFS_ops = {
    34   IMFS_eval_path,
    35   IMFS_evaluate_for_make,
    36   IMFS_link,
    37   IMFS_unlink,
    38   IMFS_node_type,
    39   IMFS_mknod,
    40   IMFS_rmnod,
    41   IMFS_chown,
    42   IMFS_freenodinfo,
    43   IMFS_mount,
    44   IMFS_initialize,
    45   IMFS_unmount,
    46   IMFS_fsunmount,
    47   IMFS_utime,
    48   IMFS_evaluate_link,
    49   IMFS_symlink,
    50   IMFS_readlink
    51 };
    52 
    53 /*
    5430 *  IMFS_initialize
    5531 */
    5632
    57 int IMFS_initialize(
    58   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     33int IMFS_initialize_support(
     34  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     35   rtems_filesystem_operations_table    *op_table,
     36   rtems_filesystem_file_handlers_r     *memfile_handlers,
     37   rtems_filesystem_file_handlers_r     *directory_handlers
    5938)
    6039{
     
    7453  );
    7554
    76   temp_mt_entry->mt_fs_root.handlers    = &IMFS_directory_handlers;
    77   temp_mt_entry->mt_fs_root.ops         = &IMFS_ops;
     55  temp_mt_entry->mt_fs_root.handlers         = directory_handlers;
     56  temp_mt_entry->mt_fs_root.ops              = op_table;
    7857  temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
    7958
     
    9271   */
    9372
    94   fs_info->ino_count   = 1;
     73  fs_info->ino_count        = 1;
     74  fs_info->memfile_handlers = memfile_handlers;
     75  fs_info->memfile_handlers = directory_handlers;
    9576
    9677  jnode = temp_mt_entry->mt_fs_root.node_access;
     
    9980  return 0;
    10081}
    101 
    102 #define jnode_get_control( jnode ) \
    103   (&jnode->info.directory.Entries)
    104 
    105 #define jnode_has_no_children( jnode )  \
    106   Chain_Is_empty( jnode_get_control( jnode ) )
    107 
    108 #define jnode_has_children( jnode ) \
    109   ( ! jnode_has_no_children( jnode ) )
    110 
    111 #define jnode_get_first_child( jnode ) \
    112     ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    113 
    114 
    115 int IMFS_fsunmount(
    116   rtems_filesystem_mount_table_entry_t *temp_mt_entry
    117 )
    118 {
    119    IMFS_jnode_t                     *jnode;
    120    IMFS_jnode_t                     *next;
    121    rtems_filesystem_location_info_t loc;       
    122    int                              result = 0;
    123 
    124    /*
    125     * Traverse tree that starts at the mt_fs_root and deallocate memory
    126     * associated memory space
    127     */
    128    
    129    jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    130 
    131    do {
    132      next = jnode->Parent;
    133      loc.node_access = (void *)jnode;
    134 
    135      if ( jnode->type != IMFS_DIRECTORY ) {
    136         result = IMFS_unlink( &loc );
    137         if (result != 0)
    138           return -1;
    139         jnode = next;
    140      } else if ( jnode_has_no_children( jnode ) ) {
    141         result = IMFS_unlink( &loc );
    142         if (result != 0)
    143           return -1;
    144         jnode = next;
    145      }
    146      if ( jnode != NULL ) {
    147        if ( jnode->type == IMFS_DIRECTORY ) {
    148          if ( jnode_has_children( jnode ) )
    149            jnode = jnode_get_first_child( jnode );
    150        }
    151      }
    152    } while (jnode != NULL);
    153 
    154    return 0;
    155 }
    156 
    157 
    158 
  • c/src/libfs/src/imfs/memfile.c

    re54a7d33 r657e1bf6  
    2929
    3030#define MEMFILE_STATIC
     31
     32/*
     33 *  Set of operations handlers for operations on memfile entities.
     34 */
     35
     36rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
     37  memfile_open,
     38  memfile_close,
     39  memfile_read,
     40  memfile_write,
     41  memfile_ioctl,
     42  memfile_lseek,
     43  IMFS_stat,
     44  IMFS_fchmod,
     45  memfile_ftruncate,
     46  NULL,                /* fpathconf */
     47  NULL,                /* fsync */
     48  IMFS_fdatasync,
     49  IMFS_fcntl
     50};
    3151
    3252/*
  • cpukit/libcsupport/include/rtems/libio.h

    re54a7d33 r657e1bf6  
    307307 */
    308308
    309 struct rtems_filesystem_mount_table_entry_tt{
     309struct rtems_filesystem_mount_table_entry_tt {
    310310  Chain_Node                             Node;
    311311  rtems_filesystem_location_info_t       mt_point_node;
  • cpukit/libcsupport/src/base_fs.c

    re54a7d33 r657e1bf6  
    5353  init_fs_mount_table();
    5454
     55  /*
     56   *  mount the first filesystem.
     57   *
     58   *  NOTE: XXX This really needs to be read from a table of filesystems
     59   *        to mount initially and the miniIMFS needs to be shaken out.
     60   */
     61
    5562  status = mount(
    5663     &first_entry,
  • cpukit/libfs/src/imfs/imfs.h

    re54a7d33 r657e1bf6  
    184184
    185185typedef struct {
    186   ino_t    ino_count;
     186  ino_t                             ino_count;
     187  rtems_filesystem_file_handlers_r *memfile_handlers;
     188  rtems_filesystem_file_handlers_r *directory_handlers;
    187189} IMFS_fs_info_t;
    188190
     
    215217extern rtems_filesystem_file_handlers_r       IMFS_directory_handlers;
    216218extern rtems_filesystem_operations_table      IMFS_ops;
     219extern rtems_filesystem_operations_table      miniIMFS_ops;
    217220extern rtems_filesystem_limits_and_options_t  IMFS_LIMITS_AND_OPTIONS;
    218221
     
    223226int IMFS_initialize(
    224227   rtems_filesystem_mount_table_entry_t *mt_entry
     228);
     229
     230int miniIMFS_initialize(
     231   rtems_filesystem_mount_table_entry_t *mt_entry
     232);
     233
     234int IMFS_initialize_support(
     235   rtems_filesystem_mount_table_entry_t *mt_entry,
     236   rtems_filesystem_operations_table    *op_table,
     237   rtems_filesystem_file_handlers_r     *memfile_handlers,
     238   rtems_filesystem_file_handlers_r     *directory_handlers
    225239);
    226240
  • cpukit/libfs/src/imfs/imfs_eval.c

    re54a7d33 r657e1bf6  
    3333)
    3434{
    35   IMFS_jnode_t  *node = loc->node_access;
    36 
     35  IMFS_jnode_t    *node = loc->node_access;
     36  IMFS_fs_info_t  *fs_info;
     37
     38  fs_info = loc->mt_entry->fs_info;
    3739  switch( node->type ) {
    3840    case IMFS_DIRECTORY:
    39       loc->handlers = &IMFS_directory_handlers;
     41      loc->handlers = fs_info->directory_handlers;
    4042      break;
    4143    case IMFS_DEVICE:
     
    4749      break;
    4850    case IMFS_MEMORY_FILE:
    49       loc->handlers = &IMFS_memfile_handlers;
     51      loc->handlers = fs_info->memfile_handlers;
    5052      break;
    5153  }
  • cpukit/libfs/src/imfs/imfs_free.c

    re54a7d33 r657e1bf6  
    3636}
    3737
    38 
    39 /*
    40  *  IMFS_freenod
    41  *
    42  *  The following routine frees a node if possible.
    43  *
    44  *  The routine returns 0 if the node was not freed and 1 if it was.
    45  *
    46  *  NOTE:  This routine is for INTERNAL IMFS use only.
    47  */
    48 
    49 int IMFS_freenod(
    50   rtems_filesystem_location_info_t  *pathloc
    51 )
    52 {
    53   IMFS_jnode_t       *the_jnode;
    54 
    55   the_jnode = pathloc->node_access;
    56 
    57   if ( the_jnode->type == IMFS_DIRECTORY ) {
    58 
    59     /*
    60      * You cannot remove a node that still has children
    61      */
    62 
    63     if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) )
    64        return ENOTEMPTY;
    65 
    66     /*
    67      * You cannot remove the file system root node.
    68      */
    69     if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access )
    70        return EBUSY;
    71 
    72     /*
    73      * You cannot remove a mountpoint.
    74      */
    75      if ( the_jnode->info.directory.mt_fs != NULL )
    76        return EBUSY;       
    77   }
    78 
    79   if ( !rtems_libio_is_file_open( the_jnode ) &&
    80        (the_jnode->st_nlink < 1) ) {
    81 
    82     /*
    83      * Is the rtems_filesystem_current is this node?
    84      */
    85     if ( rtems_filesystem_current.node_access == pathloc->node_access ) {
    86       rtems_filesystem_current.node_access = NULL;
    87     }
    88 
    89     /*
    90      * Free memory associated with a memory file.
    91      */
    92     if ( the_jnode->type == IMFS_MEMORY_FILE )
    93       IMFS_memfile_remove( the_jnode );
    94 
    95     free( the_jnode );
    96   }
    97 
    98   return 0;
    99 }
  • cpukit/libfs/src/imfs/imfs_init.c

    re54a7d33 r657e1bf6  
    2727#endif
    2828
    29 /*
     29/* 
    3030 *  IMFS file system operations table
    3131 */
     
    4545  IMFS_unmount,
    4646  IMFS_fsunmount,
    47   IMFS_utime, 
     47  IMFS_utime,
    4848  IMFS_evaluate_link,
    4949  IMFS_symlink,
     
    5959)
    6060{
    61   IMFS_fs_info_t                        *fs_info;
    62   IMFS_jnode_t                          *jnode;
    63 
    64   /*
    65    *  Create the root node
    66    */
    67 
    68   temp_mt_entry->mt_fs_root.node_access = IMFS_create_node(
    69     NULL,
    70     IMFS_DIRECTORY,
    71     "",
    72     ( S_IRWXO | S_IRWXG| S_IRWXU ),
    73     NULL
    74   );
    75 
    76   temp_mt_entry->mt_fs_root.handlers    = &IMFS_directory_handlers;
    77   temp_mt_entry->mt_fs_root.ops         = &IMFS_ops;
    78   temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
    79 
    80   /*
    81    * Create custom file system data.
    82    */
    83   fs_info = calloc( 1, sizeof( IMFS_fs_info_t ) );
    84   if ( !fs_info ){
    85     free(temp_mt_entry->mt_fs_root.node_access);
    86     return 1;
    87   }
    88   temp_mt_entry->fs_info = fs_info;
    89 
    90   /*
    91    * Set st_ino for the root to 1.
    92    */
    93 
    94   fs_info->ino_count   = 1;
    95 
    96   jnode = temp_mt_entry->mt_fs_root.node_access;
    97   jnode->st_ino = fs_info->ino_count;
    98 
    99   return 0;
    100 }
    101 
    102 #define jnode_get_control( jnode ) \
    103   (&jnode->info.directory.Entries)
    104 
    105 #define jnode_has_no_children( jnode )  \
    106   Chain_Is_empty( jnode_get_control( jnode ) )
    107 
    108 #define jnode_has_children( jnode ) \
    109   ( ! jnode_has_no_children( jnode ) )
    110 
    111 #define jnode_get_first_child( jnode ) \
    112     ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    113 
    114 
    115 int IMFS_fsunmount(
    116   rtems_filesystem_mount_table_entry_t *temp_mt_entry
    117 )
    118 {
    119    IMFS_jnode_t                     *jnode;
    120    IMFS_jnode_t                     *next;
    121    rtems_filesystem_location_info_t loc;       
    122    int                              result = 0;
    123 
    124    /*
    125     * Traverse tree that starts at the mt_fs_root and deallocate memory
    126     * associated memory space
    127     */
    128    
    129    jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    130 
    131    do {
    132      next = jnode->Parent;
    133      loc.node_access = (void *)jnode;
    134 
    135      if ( jnode->type != IMFS_DIRECTORY ) {
    136         result = IMFS_unlink( &loc );
    137         if (result != 0)
    138           return -1;
    139         jnode = next;
    140      } else if ( jnode_has_no_children( jnode ) ) {
    141         result = IMFS_unlink( &loc );
    142         if (result != 0)
    143           return -1;
    144         jnode = next;
    145      }
    146      if ( jnode != NULL ) {
    147        if ( jnode->type == IMFS_DIRECTORY ) {
    148          if ( jnode_has_children( jnode ) )
    149            jnode = jnode_get_first_child( jnode );
    150        }
    151      }
    152    } while (jnode != NULL);
    153 
     61   IMFS_initialize_support(
     62     temp_mt_entry,
     63     &IMFS_ops,
     64     &IMFS_memfile_handlers,
     65     &IMFS_directory_handlers
     66   );
    15467   return 0;
    15568}
    156 
    157 
    158 
  • cpukit/libfs/src/imfs/imfs_initsupp.c

    re54a7d33 r657e1bf6  
    2828
    2929/*
    30  *  IMFS file system operations table
    31  */
    32 
    33 rtems_filesystem_operations_table  IMFS_ops = {
    34   IMFS_eval_path,
    35   IMFS_evaluate_for_make,
    36   IMFS_link,
    37   IMFS_unlink,
    38   IMFS_node_type,
    39   IMFS_mknod,
    40   IMFS_rmnod,
    41   IMFS_chown,
    42   IMFS_freenodinfo,
    43   IMFS_mount,
    44   IMFS_initialize,
    45   IMFS_unmount,
    46   IMFS_fsunmount,
    47   IMFS_utime,
    48   IMFS_evaluate_link,
    49   IMFS_symlink,
    50   IMFS_readlink
    51 };
    52 
    53 /*
    5430 *  IMFS_initialize
    5531 */
    5632
    57 int IMFS_initialize(
    58   rtems_filesystem_mount_table_entry_t *temp_mt_entry
     33int IMFS_initialize_support(
     34  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
     35   rtems_filesystem_operations_table    *op_table,
     36   rtems_filesystem_file_handlers_r     *memfile_handlers,
     37   rtems_filesystem_file_handlers_r     *directory_handlers
    5938)
    6039{
     
    7453  );
    7554
    76   temp_mt_entry->mt_fs_root.handlers    = &IMFS_directory_handlers;
    77   temp_mt_entry->mt_fs_root.ops         = &IMFS_ops;
     55  temp_mt_entry->mt_fs_root.handlers         = directory_handlers;
     56  temp_mt_entry->mt_fs_root.ops              = op_table;
    7857  temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
    7958
     
    9271   */
    9372
    94   fs_info->ino_count   = 1;
     73  fs_info->ino_count        = 1;
     74  fs_info->memfile_handlers = memfile_handlers;
     75  fs_info->memfile_handlers = directory_handlers;
    9576
    9677  jnode = temp_mt_entry->mt_fs_root.node_access;
     
    9980  return 0;
    10081}
    101 
    102 #define jnode_get_control( jnode ) \
    103   (&jnode->info.directory.Entries)
    104 
    105 #define jnode_has_no_children( jnode )  \
    106   Chain_Is_empty( jnode_get_control( jnode ) )
    107 
    108 #define jnode_has_children( jnode ) \
    109   ( ! jnode_has_no_children( jnode ) )
    110 
    111 #define jnode_get_first_child( jnode ) \
    112     ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next))
    113 
    114 
    115 int IMFS_fsunmount(
    116   rtems_filesystem_mount_table_entry_t *temp_mt_entry
    117 )
    118 {
    119    IMFS_jnode_t                     *jnode;
    120    IMFS_jnode_t                     *next;
    121    rtems_filesystem_location_info_t loc;       
    122    int                              result = 0;
    123 
    124    /*
    125     * Traverse tree that starts at the mt_fs_root and deallocate memory
    126     * associated memory space
    127     */
    128    
    129    jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access;
    130 
    131    do {
    132      next = jnode->Parent;
    133      loc.node_access = (void *)jnode;
    134 
    135      if ( jnode->type != IMFS_DIRECTORY ) {
    136         result = IMFS_unlink( &loc );
    137         if (result != 0)
    138           return -1;
    139         jnode = next;
    140      } else if ( jnode_has_no_children( jnode ) ) {
    141         result = IMFS_unlink( &loc );
    142         if (result != 0)
    143           return -1;
    144         jnode = next;
    145      }
    146      if ( jnode != NULL ) {
    147        if ( jnode->type == IMFS_DIRECTORY ) {
    148          if ( jnode_has_children( jnode ) )
    149            jnode = jnode_get_first_child( jnode );
    150        }
    151      }
    152    } while (jnode != NULL);
    153 
    154    return 0;
    155 }
    156 
    157 
    158 
  • cpukit/libfs/src/imfs/memfile.c

    re54a7d33 r657e1bf6  
    2929
    3030#define MEMFILE_STATIC
     31
     32/*
     33 *  Set of operations handlers for operations on memfile entities.
     34 */
     35
     36rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
     37  memfile_open,
     38  memfile_close,
     39  memfile_read,
     40  memfile_write,
     41  memfile_ioctl,
     42  memfile_lseek,
     43  IMFS_stat,
     44  IMFS_fchmod,
     45  memfile_ftruncate,
     46  NULL,                /* fpathconf */
     47  NULL,                /* fsync */
     48  IMFS_fdatasync,
     49  IMFS_fcntl
     50};
    3151
    3252/*
Note: See TracChangeset for help on using the changeset viewer.