Ticket #1968: pr1968-rfs-seek-bug.diff

File pr1968-rfs-seek-bug.diff, 4.7 KB (added by Chris Johns, on 11/22/11 at 02:13:47)

RFS seek bug fix

  • cpukit/libfs/src/rfs/rtems-rfs-file.c

    RCS file: /usr1/CVS/rtems/cpukit/libfs/src/rfs/rtems-rfs-file.c,v
    retrieving revision 1.4.2.3
    diff -p -u -u -r1.4.2.3 rtems-rfs-file.c
    rtems_rfs_file_seek (rtems_rfs_file_hand 
    424424   */
    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;
    430467  return 0;
  • cpukit/libfs/src/rfs/rtems-rfs-rtems.h

    RCS file: /usr1/CVS/rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems.h,v
    retrieving revision 1.2
    diff -p -u -u -r1.2 rtems-rfs-rtems.h
     
    2525#include <errno.h>
    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
    3636
    int rtems_rfs_rtems_error (const char* m 
    7272#define RTEMS_RFS_RTEMS_DEBUG_READLINK      (1 << 9)
    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/**
    8485 * Call to check if this part is bring traced. If RTEMS_RFS_RTEMS_TRACE is
  • cpukit/libfs/src/rfs/rtems-rfs-trace.c

    RCS file: /usr1/CVS/rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.c,v
    retrieving revision 1.2.2.1
    diff -p -u -u -r1.2.2.1 rtems-rfs-trace.c
    rtems_rfs_trace_shell_command (int argc, 
    9292    "symlink-read",
    9393    "file-open",
    9494    "file-close",
    95     "file-io"
     95    "file-io",
     96    "file-set"
    9697  };
    9798
    9899  rtems_rfs_trace_mask set_value = 0;
    rtems_rfs_trace_shell_command (int argc, 
    140141          if (strcmp (argv[arg], table[t]) == 0)
    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          }
    148149        }