Ignore:
Timestamp:
Feb 14, 2015, 7:07:19 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
a43a3466
Parents:
5640dd5
git-author:
Sebastian Huber <sebastian.huber@…> (02/14/15 19:07:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/14/15 20:34:42)
Message:

IMFS: Add CONFIGURE_IMFS_DISABLE_READDIR

File:
1 moved

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/imfs/imfs_dir_default.c

    r5640dd5 rf785492  
    22 * @file
    33 *
    4  * @brief IMFS Read Next Directory
    54 * @ingroup IMFS
    65 */
     
    2120#include "imfs.h"
    2221
     22#include <dirent.h>
    2323#include <string.h>
    24 #include <dirent.h>
    2524
    26 ssize_t imfs_dir_read(
     25static ssize_t IMFS_dir_read(
    2726  rtems_libio_t  *iop,
    2827  void           *buffer,
     
    8786   return bytes_transferred;
    8887}
     88
     89static size_t IMFS_directory_size( const IMFS_jnode_t *node )
     90{
     91  size_t size = 0;
     92  const IMFS_directory_t *dir = (const IMFS_directory_t *) node;
     93  const rtems_chain_control *chain = &dir->Entries;
     94  const rtems_chain_node *current = rtems_chain_immutable_first( chain );
     95  const rtems_chain_node *tail = rtems_chain_immutable_tail( chain );
     96
     97  while ( current != tail ) {
     98    size += sizeof( struct dirent );
     99    current = rtems_chain_immutable_next( current );
     100  }
     101
     102  return size;
     103}
     104
     105static int IMFS_stat_directory(
     106  const rtems_filesystem_location_info_t *loc,
     107  struct stat *buf
     108)
     109{
     110  const IMFS_jnode_t *node = loc->node_access;
     111
     112  buf->st_size = IMFS_directory_size( node );
     113
     114  return IMFS_stat( loc, buf );
     115}
     116
     117static const rtems_filesystem_file_handlers_r IMFS_dir_default_handlers = {
     118  .open_h = rtems_filesystem_default_open,
     119  .close_h = rtems_filesystem_default_close,
     120  .read_h = IMFS_dir_read,
     121  .write_h = rtems_filesystem_default_write,
     122  .ioctl_h = rtems_filesystem_default_ioctl,
     123  .lseek_h = rtems_filesystem_default_lseek_directory,
     124  .fstat_h = IMFS_stat_directory,
     125  .ftruncate_h = rtems_filesystem_default_ftruncate_directory,
     126  .fsync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
     127  .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
     128  .fcntl_h = rtems_filesystem_default_fcntl,
     129  .kqfilter_h = rtems_filesystem_default_kqfilter,
     130  .poll_h = rtems_filesystem_default_poll,
     131  .readv_h = rtems_filesystem_default_readv,
     132  .writev_h = rtems_filesystem_default_writev
     133};
     134
     135const IMFS_mknod_control IMFS_mknod_control_dir_default = {
     136  {
     137    .handlers = &IMFS_dir_default_handlers,
     138    .node_initialize = IMFS_node_initialize_directory,
     139    .node_remove = IMFS_node_remove_directory,
     140    .node_destroy = IMFS_node_destroy_default
     141  },
     142  .node_size = sizeof( IMFS_directory_t )
     143};
Note: See TracChangeset for help on using the changeset viewer.