Changeset f785492 in rtems


Ignore:
Timestamp:
Feb 14, 2015, 7:07:19 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 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

Files:
2 added
1 deleted
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/Makefile.am

    r5640dd5 rf785492  
    4343libimfs_a_SOURCES += src/imfs/deviceio.c \
    4444    src/imfs/imfs_chown.c src/imfs/imfs_config.c \
    45     src/imfs/imfs_creat.c src/imfs/imfs_directory.c \
     45    src/imfs/imfs_creat.c \
    4646    src/imfs/imfs_eval.c src/imfs/imfs_fchmod.c \
     47    src/imfs/imfs_dir.c \
     48    src/imfs/imfs_dir_default.c \
     49    src/imfs/imfs_dir_minimal.c \
    4750    src/imfs/imfs_fifo.c \
    4851    src/imfs/imfs_make_generic_node.c \
    4952    src/imfs/imfs_fsunmount.c \
    5053    src/imfs/imfs_handlers_device.c \
    51     src/imfs/imfs_handlers_directory.c \
    5254    src/imfs/imfs_init.c \
    5355    src/imfs/imfs_initsupp.c src/imfs/imfs_link.c src/imfs/imfs_load_tar.c \
  • cpukit/libfs/src/imfs/imfs.h

    r5640dd5 rf785492  
    136136);
    137137
     138IMFS_jnode_t *IMFS_node_initialize_directory(
     139  IMFS_jnode_t *node,
     140  void *arg
     141);
     142
    138143/**
    139144 * @brief Returns the node and sets the generic node context.
     
    179184  IMFS_jnode_t *node
    180185);
     186
     187IMFS_jnode_t *IMFS_node_remove_directory( IMFS_jnode_t *node );
    181188
    182189/**
     
    385392 */
    386393
    387 extern const IMFS_mknod_control IMFS_mknod_control_directory;
     394extern const IMFS_mknod_control IMFS_mknod_control_dir_default;
     395extern const IMFS_mknod_control IMFS_mknod_control_dir_minimal;
    388396extern const IMFS_mknod_control IMFS_mknod_control_device;
    389397extern const IMFS_mknod_control IMFS_mknod_control_memfile;
     
    701709
    702710/**
    703  * @brief Read the next directory of the IMFS.
    704  *
    705  * This routine will read the next directory entry based on the directory
    706  * offset. The offset should be equal to -n- time the size of an individual
    707  * dirent structure. If n is not an integer multiple of the sizeof a
    708  * dirent structure, an integer division will be performed to determine
    709  * directory entry that will be returned in the buffer. Count should reflect
    710  * -m- times the sizeof dirent bytes to be placed in the buffer.
    711  * If there are not -m- dirent elements from the current directory position
    712  * to the end of the exisiting file, the remaining entries will be placed in
    713  * the buffer and the returned value will be equal to -m actual- times the
    714  * size of a directory entry.
    715  */
    716 extern ssize_t imfs_dir_read(
    717   rtems_libio_t *iop,              /* IN  */
    718   void          *buffer,           /* IN  */
    719   size_t         count             /* IN  */
    720 );
    721 
    722 /**
    723711 * @name IMFS Memory File Handlers
    724712 *
  • 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};
  • cpukit/libfs/src/imfs/imfs_init.c

    r5640dd5 rf785492  
    4949
    5050static const IMFS_mknod_controls IMFS_default_mknod_controls = {
    51   .directory = &IMFS_mknod_control_directory,
     51  .directory = &IMFS_mknod_control_dir_default,
    5252  .device = &IMFS_mknod_control_device,
    5353  .file = &IMFS_mknod_control_memfile,
  • cpukit/sapi/include/confdefs.h

    r5640dd5 rf785492  
    620620
    621621      static const IMFS_mknod_controls _Configure_IMFS_mknod_controls = {
    622         &IMFS_mknod_control_directory,
     622        #ifdef CONFIGURE_IMFS_DISABLE_READDIR
     623          &IMFS_mknod_control_dir_minimal,
     624        #else
     625          &IMFS_mknod_control_dir_default,
     626        #endif
    623627        &IMFS_mknod_control_device,
    624628        #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_FILE
  • doc/user/conf.t

    r5640dd5 rf785492  
    28942894In case this configuration option is defined, then the support to rename nodes
    28952895is disabled in the root IMFS.
     2896
     2897@c
     2898@c === CONFIGURE_IMFS_DISABLE_READDIR ===
     2899@c
     2900@subsection Disable Directory Read Support of Root IMFS
     2901
     2902@findex CONFIGURE_IMFS_DISABLE_READDIR
     2903
     2904@table @b
     2905@item CONSTANT:
     2906@code{CONFIGURE_IMFS_DISABLE_READDIR}
     2907
     2908@item DATA TYPE:
     2909Boolean feature macro.
     2910
     2911@item RANGE:
     2912Defined or undefined.
     2913
     2914@item DEFAULT VALUE:
     2915This is not defined by default.
     2916
     2917@end table
     2918
     2919@subheading DESCRIPTION:
     2920In case this configuration option is defined, then the support to read a
     2921directory is disabled in the root IMFS.  It is still possible to open nodes in
     2922a directory.
    28962923
    28972924@c
  • testsuites/fstests/fsimfsconfig01/init.c

    r5640dd5 rf785492  
    2020
    2121#include <sys/stat.h>
     22#include <dirent.h>
    2223#include <errno.h>
    2324#include <fcntl.h>
     
    4748  int rv;
    4849  int fd;
     50  DIR *dirp;
     51  struct dirent *dire;
     52  struct stat st;
    4953
    5054  TEST_BEGIN();
     
    8892  rtems_test_assert(rv == -1);
    8993  rtems_test_assert(errno == ENOSYS);
     94
     95  dirp = opendir(mnt);
     96  rtems_test_assert(dirp != NULL);
     97
     98  errno = 0;
     99  dire = readdir(dirp);
     100  rtems_test_assert(dire == NULL);
     101  rtems_test_assert(errno == ENOTSUP);
     102
     103  rv = closedir(dirp);
     104  rtems_test_assert(rv == 0);
     105
     106  rv = stat(mnt, &st);
     107  rtems_test_assert(rv == 0);
     108  rtems_test_assert(st.st_size == 0);
    90109
    91110  errno = 0;
     
    146165#define CONFIGURE_IMFS_DISABLE_MOUNT
    147166#define CONFIGURE_IMFS_DISABLE_RENAME
     167#define CONFIGURE_IMFS_DISABLE_READDIR
    148168#define CONFIGURE_IMFS_DISABLE_RMNOD
    149169#define CONFIGURE_IMFS_DISABLE_SYMLINK
Note: See TracChangeset for help on using the changeset viewer.