Changeset afaa753b in rtems


Ignore:
Timestamp:
Dec 9, 2011, 7:12:27 AM (7 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10
Children:
a906933
Parents:
10fa27d
Message:

2011-12-09 Chris Johns <chrisj@…>

PR 1968/filesystem

  • libfs/src/rfs/rtems-rfs-file.c: Fix to the seek bug where a seek to 0 after reading the end of the file did not point to the correct block.
  • libfs/src/rfs/rtems-rfs-rtems.h, libfs/src/rfs/rtems-rfs-trace.c: Fix the trace flags. Used to fix the bug.
Location:
cpukit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r10fa27d rafaa753b  
     12011-12-09      Chris Johns <chrisj@rtems.org>
     2
     3        PR 1968/filesystem
     4        * libfs/src/rfs/rtems-rfs-file.c: Fix to the seek bug where a seek
     5        to 0 after reading the end of the file did not point to the
     6        correct block.
     7        * libfs/src/rfs/rtems-rfs-rtems.h,
     8        libfs/src/rfs/rtems-rfs-trace.c: Fix the trace flags. Used to fix
     9        the bug.
     10       
    1112011-12-07      Ralf Corsépius <ralf.corsepius@rtems.org>
    212
  • cpukit/libfs/src/rfs/rtems-rfs-file.c

    r10fa27d rafaa753b  
    425425  if (pos < rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (handle),
    426426                                            handle->shared))
     427  {
    427428    rtems_rfs_file_set_bpos (handle, pos);
     429   
     430    /*
     431     * If the file has a block check if it maps to the current position and it
     432     * does not release it. That will force us to get the block at the new
     433     * position when the I/O starts.
     434     */
     435    if (rtems_rfs_buffer_handle_has_block (&handle->buffer))
     436    {
     437      rtems_rfs_buffer_block block;
     438      int                    rc;
     439     
     440      rc = rtems_rfs_block_map_find (rtems_rfs_file_fs (handle),
     441                                     rtems_rfs_file_map (handle),
     442                                     rtems_rfs_file_bpos (handle),
     443                                     &block);
     444      if (rc > 0)
     445        return rc;
     446      if (rtems_rfs_buffer_bnum (&handle->buffer) != block)
     447      {       
     448        rc = rtems_rfs_buffer_handle_release (rtems_rfs_file_fs (handle),
     449                                              rtems_rfs_file_buffer (handle));
     450        if (rc > 0)
     451          return rc;
     452      }
     453    }
     454  }
     455  else
     456  {
     457    /*
     458     * The seek is outside the current file so release any buffer. A write will
     459     * extend the file.
     460     */
     461    int rc = rtems_rfs_file_io_release (handle);
     462    if (rc > 0)
     463      return rc;
     464  }
    428465 
    429466  *new_pos = pos;
     
    442479    printf ("rtems-rfs: file-set-size: size=%" PRIu64 "\n", new_size);
    443480
     481  size = rtems_rfs_file_size (handle);
     482 
    444483  /*
    445    * Short cut for the common truncate on open call.
     484   * If the file is same size do nothing else grow or shrink it ?
     485   *
     486   * If the file does not change size do not update the times.
    446487   */
    447   if (new_size == 0)
    448   {
    449     rc = rtems_rfs_block_map_free_all (rtems_rfs_file_fs (handle), map);
    450     if (rc > 0)
    451       return rc;
    452   }
    453   else
    454   {
    455     size = rtems_rfs_file_size (handle);
    456  
     488  if (size != new_size)
     489  {
    457490    /*
    458      * If the file is same size do nothing else grow or shrink it ?
     491     * Short cut for the common truncate on open call.
    459492     */
    460     if (size != new_size)
     493    if (new_size == 0)
     494    {
     495      rc = rtems_rfs_block_map_free_all (rtems_rfs_file_fs (handle), map);
     496      if (rc > 0)
     497        return rc;
     498    }
     499    else
    461500    {
    462501      if (size < new_size)
     
    568607      }
    569608    }
    570   }
    571 
    572   handle->shared->size.count  = rtems_rfs_block_map_count (map);
    573   handle->shared->size.offset = rtems_rfs_block_map_size_offset (map);
    574 
    575   if (rtems_rfs_file_update_mtime (handle))
    576     handle->shared->mtime = time (NULL);
     609
     610    handle->shared->size.count  = rtems_rfs_block_map_count (map);
     611    handle->shared->size.offset = rtems_rfs_block_map_size_offset (map);
     612
     613    if (rtems_rfs_file_update_mtime (handle))
     614      handle->shared->mtime = time (NULL);
     615  }
    577616 
    578617  return 0;
  • cpukit/libfs/src/rfs/rtems-rfs-rtems.h

    r10fa27d rafaa753b  
    2626
    2727/**
    28  * RTEMS RFS RTEMS Error Enable. Set to 1 to printing of errors. Default is off.
     28 * RTEMS RFS RTEMS Error Enable. Set to 1 for printing of errors. Default is off.
    2929 */
    3030#define RTEMS_RFS_RTEMS_ERROR 0
    3131
    3232/**
    33  * RTEMS RFS RTEMS Trace Enable. Set to 1 to printing of errors. Default is off.
     33 * RTEMS RFS RTEMS Trace Enable. Set to 1 for printing of errors. Default is off.
    3434 */
    3535#define RTEMS_RFS_RTEMS_TRACE 0
     
    7373#define RTEMS_RFS_RTEMS_DEBUG_FCHMOD        (1 << 10)
    7474#define RTEMS_RFS_RTEMS_DEBUG_STAT          (1 << 11)
    75 #define RTEMS_RFS_RTEMS_DEBUG_DIR_RMNOD     (1 << 12)
    76 #define RTEMS_RFS_RTEMS_DEBUG_FILE_OPEN     (1 << 13)
    77 #define RTEMS_RFS_RTEMS_DEBUG_FILE_CLOSE    (1 << 14)
    78 #define RTEMS_RFS_RTEMS_DEBUG_FILE_READ     (1 << 15)
    79 #define RTEMS_RFS_RTEMS_DEBUG_FILE_WRITE    (1 << 16)
    80 #define RTEMS_RFS_RTEMS_DEBUG_FILE_LSEEK    (1 << 17)
    81 #define RTEMS_RFS_RTEMS_DEBUG_FILE_FTRUNC   (1 << 18)
     75#define RTEMS_RFS_RTEMS_DEBUG_RENAME        (1 << 12)
     76#define RTEMS_RFS_RTEMS_DEBUG_DIR_RMNOD     (1 << 13)
     77#define RTEMS_RFS_RTEMS_DEBUG_FILE_OPEN     (1 << 14)
     78#define RTEMS_RFS_RTEMS_DEBUG_FILE_CLOSE    (1 << 15)
     79#define RTEMS_RFS_RTEMS_DEBUG_FILE_READ     (1 << 16)
     80#define RTEMS_RFS_RTEMS_DEBUG_FILE_WRITE    (1 << 17)
     81#define RTEMS_RFS_RTEMS_DEBUG_FILE_LSEEK    (1 << 18)
     82#define RTEMS_RFS_RTEMS_DEBUG_FILE_FTRUNC   (1 << 19)
    8283
    8384/**
  • cpukit/libfs/src/rfs/rtems-rfs-trace.c

    r10fa27d rafaa753b  
    9393    "file-open",
    9494    "file-close",
    95     "file-io"
     95    "file-io",
     96    "file-set"
    9697  };
    9798
     
    141142          {
    142143            if (set)
    143               set_value = 1 << t;
     144              set_value = 1ULL << t;
    144145            else
    145               clear_value = 1 << t;
     146              clear_value = 1ULL << t;
    146147            break;
    147148          }
Note: See TracChangeset for help on using the changeset viewer.