Changeset e4d35d8 in rtems


Ignore:
Timestamp:
Feb 5, 2015, 3:43:58 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
9247d3f
Parents:
24ec25d
git-author:
Sebastian Huber <sebastian.huber@…> (02/05/15 15:43:58)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/12/15 19:53:34)
Message:

IMFS: Split linfile and memfile modules

Make several functions static.

Location:
cpukit/libfs
Files:
1 added
2 edited
2 moved

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/Makefile.am

    r24ec25d re4d35d8  
    5050    src/imfs/imfs_handlers_device.c \
    5151    src/imfs/imfs_handlers_directory.c \
    52     src/imfs/imfs_handlers_memfile.c src/imfs/imfs_init.c \
     52    src/imfs/imfs_init.c \
    5353    src/imfs/imfs_initsupp.c src/imfs/imfs_link.c src/imfs/imfs_load_tar.c \
     54    src/imfs/imfs_linfile.c \
    5455    src/imfs/imfs_mknod.c src/imfs/imfs_mount.c \
    5556    src/imfs/imfs_rename.c src/imfs/imfs_rmnod.c \
    56     src/imfs/imfs_stat.c src/imfs/imfs_symlink.c \
     57    src/imfs/imfs_stat.c src/imfs/imfs_stat_file.c src/imfs/imfs_symlink.c \
    5758    src/imfs/imfs_unmount.c src/imfs/imfs_utime.c src/imfs/ioman.c \
    58     src/imfs/memfile.c src/imfs/miniimfs_init.c src/imfs/imfs.h
     59    src/imfs/imfs_memfile.c src/imfs/miniimfs_init.c src/imfs/imfs.h
    5960
    6061# POSIX FIFO/pipe
  • cpukit/libfs/src/imfs/imfs.h

    r24ec25d re4d35d8  
    512512);
    513513
     514extern int IMFS_stat_file(
     515  const rtems_filesystem_location_info_t *loc,
     516  struct stat *buf
     517);
     518
    514519/**
    515520 * @brief IMFS evaluation node support.
     
    710715extern int IMFS_unmount(
    711716  rtems_filesystem_mount_table_entry_t *mt_entry  /* IN */
    712 );
    713 
    714 extern void IMFS_memfile_remove(
    715  IMFS_jnode_t  *the_jnode         /* IN/OUT */
    716 );
    717 
    718 /**
    719  * @brief Truncate a memory file.
    720  *
    721  * This routine processes the ftruncate() system call.
    722  */
    723 extern int memfile_ftruncate(
    724   rtems_libio_t *iop,               /* IN  */
    725   off_t          length             /* IN  */
    726717);
    727718
     
    757748/**@{*/
    758749
    759 /**
    760  * @brief Open a linear file.
    761  *
    762  * Transforms the file into a memfile if opened for writing.
    763  */
    764 extern int IMFS_linfile_open(
    765   rtems_libio_t *iop,             /* IN  */
    766   const char    *pathname,        /* IN  */
    767   int            oflag,           /* IN  */
    768   mode_t         mode             /* IN  */
    769 );
    770 
    771 extern ssize_t IMFS_linfile_read(
    772   rtems_libio_t *iop,
    773   void          *buffer,
    774   size_t         count
    775 );
    776 
    777 /**
    778  * @brief Read a memory file.
    779  *
    780  * This routine processes the read() system call.
    781  */
    782 extern ssize_t memfile_read(
    783   rtems_libio_t *iop,             /* IN  */
    784   void          *buffer,          /* IN  */
    785   size_t         count            /* IN  */
    786 );
    787 
    788 /**
    789  * @brief Write a memory file.
    790  *
    791  * This routine processes the write() system call.
    792  */
    793 extern ssize_t memfile_write(
    794   rtems_libio_t *iop,             /* IN  */
    795   const void    *buffer,          /* IN  */
    796   size_t         count            /* IN  */
     750extern ssize_t IMFS_memfile_write(
     751  IMFS_memfile_t      *memfile,
     752  off_t                start,
     753  const unsigned char *source,
     754  unsigned int         length
    797755);
    798756
  • cpukit/libfs/src/imfs/imfs_linfile.c

    r24ec25d re4d35d8  
    22 * @file
    33 *
    4  * @brief Memfile Operations Tables
    54 * @ingroup IMFS
    65 */
     
    2120#include "imfs.h"
    2221
    23 static int IMFS_stat_file(
    24   const rtems_filesystem_location_info_t *loc,
    25   struct stat *buf
     22static ssize_t IMFS_linfile_read(
     23  rtems_libio_t *iop,
     24  void          *buffer,
     25  size_t         count
    2626)
    2727{
    28   const IMFS_file_t *file = loc->node_access;
     28  IMFS_file_t *file = IMFS_iop_to_file( iop );
     29  off_t start = iop->offset;
     30  size_t size = file->File.size;
     31  const unsigned char *data = file->Linearfile.direct;
    2932
    30   buf->st_size = file->File.size;
    31   buf->st_blksize = imfs_rq_memfile_bytes_per_block;
     33  if (count > size - start)
     34    count = size - start;
    3235
    33   return IMFS_stat( loc, buf );
     36  IMFS_update_atime( &file->Node );
     37  iop->offset = start + count;
     38  memcpy(buffer, &data[start], count);
     39
     40  return (ssize_t) count;
    3441}
    3542
    36 static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
    37   .open_h = rtems_filesystem_default_open,
    38   .close_h = rtems_filesystem_default_close,
    39   .read_h = memfile_read,
    40   .write_h = memfile_write,
    41   .ioctl_h = rtems_filesystem_default_ioctl,
    42   .lseek_h = rtems_filesystem_default_lseek_file,
    43   .fstat_h = IMFS_stat_file,
    44   .ftruncate_h = memfile_ftruncate,
    45   .fsync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
    46   .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
    47   .fcntl_h = rtems_filesystem_default_fcntl,
    48   .kqfilter_h = rtems_filesystem_default_kqfilter,
    49   .poll_h = rtems_filesystem_default_poll,
    50   .readv_h = rtems_filesystem_default_readv,
    51   .writev_h = rtems_filesystem_default_writev
    52 };
     43static int IMFS_linfile_open(
     44  rtems_libio_t *iop,
     45  const char    *pathname,
     46  int            oflag,
     47  mode_t         mode
     48)
     49{
     50  IMFS_file_t *file;
     51
     52  file = iop->pathinfo.node_access;
     53
     54  /*
     55   * Perform 'copy on write' for linear files
     56   */
     57  if ((iop->flags & LIBIO_FLAGS_WRITE) != 0) {
     58    uint32_t count = file->File.size;
     59    const unsigned char *buffer = file->Linearfile.direct;
     60
     61    file->Node.control            = &IMFS_mknod_control_memfile.node_control;
     62    file->File.size               = 0;
     63    file->Memfile.indirect        = 0;
     64    file->Memfile.doubly_indirect = 0;
     65    file->Memfile.triply_indirect = 0;
     66    if ((count != 0)
     67     && (IMFS_memfile_write(&file->Memfile, 0, buffer, count) == -1))
     68        return -1;
     69  }
     70
     71  return 0;
     72}
    5373
    5474static const rtems_filesystem_file_handlers_r IMFS_linfile_handlers = {
     
    7090};
    7191
    72 const IMFS_mknod_control IMFS_mknod_control_memfile = {
    73   {
    74     .handlers = &IMFS_memfile_handlers,
    75     .node_initialize = IMFS_node_initialize_default,
    76     .node_remove = IMFS_node_remove_default,
    77     .node_destroy = IMFS_memfile_remove
    78   },
    79   .node_size = sizeof( IMFS_file_t )
    80 };
    81 
    8292const IMFS_node_control IMFS_node_control_linfile = {
    8393  .handlers = &IMFS_linfile_handlers,
  • cpukit/libfs/src/imfs/imfs_memfile.c

    r24ec25d re4d35d8  
    2424#include <string.h>
    2525
    26 #define MEMFILE_STATIC
    27 
    2826/*
    2927 *  Prototypes of private routines
    3028 */
    31 MEMFILE_STATIC int IMFS_memfile_extend(
     29static int IMFS_memfile_extend(
    3230   IMFS_memfile_t *memfile,
    3331   bool            zero_fill,
     
    3533);
    3634
    37 MEMFILE_STATIC int IMFS_memfile_addblock(
     35static int IMFS_memfile_addblock(
    3836   IMFS_memfile_t *memfile,
    3937   unsigned int    block
    4038);
    4139
    42 MEMFILE_STATIC void IMFS_memfile_remove_block(
     40static void IMFS_memfile_remove_block(
    4341   IMFS_memfile_t *memfile,
    4442   unsigned int    block
    4543);
    4644
    47 MEMFILE_STATIC block_p *IMFS_memfile_get_block_pointer(
     45static block_p *IMFS_memfile_get_block_pointer(
    4846   IMFS_memfile_t *memfile,
    4947   unsigned int    block,
     
    5149);
    5250
    53 MEMFILE_STATIC ssize_t IMFS_memfile_read(
     51static ssize_t IMFS_memfile_read(
    5452   IMFS_file_t     *file,
    5553   off_t            start,
     
    5856);
    5957
    60 ssize_t IMFS_memfile_write(  /* cannot be static as used in imfs_fchmod.c */
    61    IMFS_memfile_t        *memfile,
    62    off_t                  start,
    63    const unsigned char   *source,
    64    unsigned int           length
    65 );
    66 
    67 void *memfile_alloc_block(void);
    68 
    69 void memfile_free_block(
     58static void *memfile_alloc_block(void);
     59
     60static void memfile_free_block(
    7061  void *memory
    7162);
    7263
    73 int IMFS_linfile_open(
    74   rtems_libio_t *iop,
    75   const char    *pathname,
    76   int            oflag,
    77   mode_t         mode
    78 )
    79 {
    80   IMFS_file_t *file;
    81 
    82   file = iop->pathinfo.node_access;
    83 
    84   /*
    85    * Perform 'copy on write' for linear files
    86    */
    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_mknod_control_memfile.node_control;
    92     file->File.size               = 0;
    93     file->Memfile.indirect        = 0;
    94     file->Memfile.doubly_indirect = 0;
    95     file->Memfile.triply_indirect = 0;
    96     if ((count != 0)
    97      && (IMFS_memfile_write(&file->Memfile, 0, buffer, count) == -1))
    98         return -1;
    99   }
    100 
    101   return 0;
    102 }
    103 
    104 ssize_t IMFS_linfile_read(
     64static ssize_t memfile_read(
    10565  rtems_libio_t *iop,
    10666  void          *buffer,
     
    10969{
    11070  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;
    123 }
    124 
    125 ssize_t memfile_read(
    126   rtems_libio_t *iop,
    127   void          *buffer,
    128   size_t         count
    129 )
    130 {
    131   IMFS_file_t *file = IMFS_iop_to_file( iop );
    13271  ssize_t      status;
    13372
     
    14079}
    14180
    142 ssize_t memfile_write(
     81static ssize_t memfile_write(
    14382  rtems_libio_t *iop,
    14483  const void    *buffer,
     
    166105 */
    167106
    168 int memfile_ftruncate(
     107static int memfile_ftruncate(
    169108  rtems_libio_t        *iop,
    170109  off_t                 length
     
    201140 *  extend the file.
    202141 */
    203 MEMFILE_STATIC int IMFS_memfile_extend(
     142static int IMFS_memfile_extend(
    204143   IMFS_memfile_t *memfile,
    205144   bool            zero_fill,
     
    272211 *  This routine adds a single block to the specified in-memory file.
    273212 */
    274 MEMFILE_STATIC int IMFS_memfile_addblock(
     213static int IMFS_memfile_addblock(
    275214   IMFS_memfile_t *memfile,
    276215   unsigned int    block
     
    313252 *         dangerous and the results unpredictable.
    314253 */
    315 MEMFILE_STATIC void IMFS_memfile_remove_block(
     254static void IMFS_memfile_remove_block(
    316255   IMFS_memfile_t *memfile,
    317256   unsigned int    block
     
    369308
    370309/*
    371  *  IMFS_memfile_remove
     310 *  IMFS_memfile_destroy
    372311 *
    373312 *  This routine frees all memory associated with an in memory file.
     
    386325 *         is better to stick to simple, easy to understand algorithms.
    387326 */
    388 void IMFS_memfile_remove(
     327static void IMFS_memfile_destroy(
    389328 IMFS_jnode_t  *the_jnode
    390329)
     
    462401 *  read).
    463402 */
    464 MEMFILE_STATIC ssize_t IMFS_memfile_read(
     403static ssize_t IMFS_memfile_read(
    465404   IMFS_file_t     *file,
    466405   off_t            start,
     
    567506 *  file pointed to by memfile.  The file is extended as needed.
    568507 */
    569 MEMFILE_STATIC ssize_t IMFS_memfile_write(
     508ssize_t IMFS_memfile_write(
    570509   IMFS_memfile_t        *memfile,
    571510   off_t                  start,
     
    892831  memfile_blocks_allocated--;
    893832}
     833
     834static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
     835  .open_h = rtems_filesystem_default_open,
     836  .close_h = rtems_filesystem_default_close,
     837  .read_h = memfile_read,
     838  .write_h = memfile_write,
     839  .ioctl_h = rtems_filesystem_default_ioctl,
     840  .lseek_h = rtems_filesystem_default_lseek_file,
     841  .fstat_h = IMFS_stat_file,
     842  .ftruncate_h = memfile_ftruncate,
     843  .fsync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
     844  .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
     845  .fcntl_h = rtems_filesystem_default_fcntl,
     846  .kqfilter_h = rtems_filesystem_default_kqfilter,
     847  .poll_h = rtems_filesystem_default_poll,
     848  .readv_h = rtems_filesystem_default_readv,
     849  .writev_h = rtems_filesystem_default_writev
     850};
     851
     852const IMFS_mknod_control IMFS_mknod_control_memfile = {
     853  {
     854    .handlers = &IMFS_memfile_handlers,
     855    .node_initialize = IMFS_node_initialize_default,
     856    .node_remove = IMFS_node_remove_default,
     857    .node_destroy = IMFS_memfile_destroy
     858  },
     859  .node_size = sizeof( IMFS_file_t )
     860};
Note: See TracChangeset for help on using the changeset viewer.