Changeset d991d2f in rtems


Ignore:
Timestamp:
Mar 14, 2011, 5:07:19 AM (9 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10
Children:
f96d31c9
Parents:
56c56501
Message:

2011-03-14 Chris Johns <chrisj@…>

PR 1757/filesystem

  • libfs/src/rfs/rtems-rfs-block-pos.h, libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-rtems-file.c: Set the file size in iop-size when a file is open. Fix lseek to end of file then write for sizes less than half the file system block size.
Location:
cpukit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r56c56501 rd991d2f  
     12011-03-14      Chris Johns <chrisj@rtems.org>
     2
     3        PR 1757/filesystem
     4        * libfs/src/rfs/rtems-rfs-block-pos.h,
     5        libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-file.c,
     6        libfs/src/rfs/rtems-rfs-rtems-file.c: Set the file size in
     7        iop-size when a file is open. Fix lseek to end of file then write
     8        for sizes less than half the file system block size.
     9       
    1102011-03-08      Joel Sherrill <joel.sherrilL@OARcorp.com>
    211
  • cpukit/libfs/src/rfs/rtems-rfs-block-pos.h

    r56c56501 rd991d2f  
    194194
    195195/**
     196 * Do the sizes match ?
     197 */
     198#define rtems_rfs_block_size_equal(_lhs, _rhs) \
     199  (((_lhs)->count == (_rhs)->count) && ((_lhs)->offset == (_rhs)->count))
     200
     201/**
    196202 * Zero a block size.
    197203 *
  • cpukit/libfs/src/rfs/rtems-rfs-block.h

    r56c56501 rd991d2f  
    164164
    165165/**
    166  * Set the size offset for the map.
    167  */
    168 #define rtems_rfs_block_map_set_size_offset(_m, _o) ((_m)->size.offset = (_o))
    169 
    170 /**
    171166 * Are we at the last block in the map ?
    172167 */
     
    196191#define rtems_rfs_block_map_block_offset(_m) ((_m)->bpos.boff)
    197192
     193/**
     194 * Set the size offset for the map. The map is tagged as dirty.
     195 *
     196 * @param map Pointer to the open map to set the offset in.
     197 * @param offset The offset to set in the map's size.
     198 */
     199static inline void
     200rtems_rfs_block_map_set_size_offset (rtems_rfs_block_map* map,
     201                                     rtems_rfs_block_off  offset)
     202{
     203  map->size.offset = offset;
     204  map->dirty = true;
     205}
     206
     207/**
     208 * Set the map's size. The map is tagged as dirty.
     209 *
     210 * @param map Pointer to the open map to set the offset in.
     211 * @param size The size to set in the map's size.
     212 */
     213static inline void
     214rtems_rfs_block_map_set_size (rtems_rfs_block_map*  map,
     215                              rtems_rfs_block_size* size)
     216{
     217  rtems_rfs_block_copy_size (&map->size, size);
     218  map->dirty = true;
     219}
    198220/**
    199221 * Open a block map. The block map data in the inode is copied into the
  • cpukit/libfs/src/rfs/rtems-rfs-file.c

    r56c56501 rd991d2f  
    173173      rtems_rfs_inode_set_ctime (&handle->shared->inode,
    174174                                 handle->shared->ctime);
    175       handle->shared->map.size.count = handle->shared->size.count;
    176       handle->shared->map.size.offset = handle->shared->size.offset;
     175      if (!rtems_rfs_block_size_equal (&handle->shared->size,
     176                                       &handle->shared->map.size))
     177        rtems_rfs_block_map_set_size (&handle->shared->map,
     178                                      &handle->shared->size);
    177179    }
    178180   
     
    421423   * write occurs.
    422424   */
    423   if (pos <= rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (handle),
    424                                              handle->shared))
     425  if (pos < rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (handle),
     426                                            handle->shared))
    425427    rtems_rfs_file_set_bpos (handle, pos);
    426428 
  • cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c

    r56c56501 rd991d2f  
    7171    printf("rtems-rfs: file-open: handle:%p\n", file);
    7272 
     73  iop->size = rtems_rfs_file_size (file);
    7374  iop->file_info = file;
    7475 
     
    196197 
    197198  /*
    198    * If the iop position is past the physical end of the file we need to set the
    199    * file size to the new length before writing.
     199   * If the iop position is past the physical end of the file we need to set
     200   * the file size to the new length before writing. If the position equals the
     201   * size of file we are still past the end of the file as positions number
     202   * from 0. For a specific position we need a file that has a length of one
     203   * more.
    200204   */
    201205 
    202   if (pos > rtems_rfs_file_size (file))
    203   {
    204     rc = rtems_rfs_file_set_size (file, pos);
     206  if (pos >= rtems_rfs_file_size (file))
     207  {
     208    rc = rtems_rfs_file_set_size (file, pos + 1);
    205209    if (rc)
    206210    {
     
    208212      return rtems_rfs_rtems_error ("file-write: write extend", rc);
    209213    }
    210     rtems_rfs_file_set_bpos (file, pos);
    211   }
     214  }
     215 
     216  rtems_rfs_file_set_bpos (file, pos);
    212217 
    213218  while (count)
Note: See TracChangeset for help on using the changeset viewer.