Changeset 53da07e in rtems


Ignore:
Timestamp:
May 14, 2012, 1:21:30 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
7666afc
Parents:
fed66f99
git-author:
Sebastian Huber <sebastian.huber@…> (05/14/12 13:21:30)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/15/12 08:01:42)
Message:

Filesystem: PR1255: Move offset update to handlers

It is now the responsibility of the read() and write() handler to update
the offset field of the IO descriptor (rtems_libio_t). This change
makes it possible to protect the IO descriptor from concurrent access by
per file locks.

Location:
cpukit
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/src/blkdev-imfs.c

    rfed66f99 r53da07e  
    7676
    7777  if (remaining >= 0) {
     78    iop->offset += count;
    7879    rv = (ssize_t) count;
    7980  } else {
     
    135136
    136137  if (remaining >= 0) {
     138    iop->offset += count;
    137139    rv = (ssize_t) count;
    138140  } else {
  • cpukit/libcsupport/include/rtems/libio.h

    rfed66f99 r53da07e  
    787787 * @brief Reads from a node.
    788788 *
     789 * This handler is responsible to update the offset field of the IO descriptor.
     790 *
    789791 * @param[in, out] iop The IO pointer.
    790792 * @param[out] buffer The buffer for read data.
     
    804806/**
    805807 * @brief Writes to a node.
     808 *
     809 * This handler is responsible to update the offset field of the IO descriptor.
    806810 *
    807811 * @param[in, out] iop The IO pointer.
  • cpukit/libcsupport/src/read.c

    rfed66f99 r53da07e  
    2323)
    2424{
    25   ssize_t      rc;
    2625  rtems_libio_t *iop;
    2726
     
    3635   *  Now process the read().
    3736   */
    38   rc = (*iop->pathinfo.handlers->read_h)( iop, buffer, count );
    39 
    40   if ( rc > 0 )
    41     iop->offset += rc;
    42 
    43   return rc;
     37  return (*iop->pathinfo.handlers->read_h)( iop, buffer, count );
    4438}
    4539
  • cpukit/libcsupport/src/readv.c

    rfed66f99 r53da07e  
    107107
    108108    if ( bytes > 0 ) {
    109       iop->offset += bytes;
    110109      total       += bytes;
    111110    }
  • cpukit/libcsupport/src/sup_fs_deviceio.c

    rfed66f99 r53da07e  
    7373  status = rtems_io_read( major, minor, &args );
    7474  if ( status == RTEMS_SUCCESSFUL ) {
     75    iop->offset += args.bytes_moved;
     76
    7577    return (ssize_t) args.bytes_moved;
    7678  } else {
     
    99101  status = rtems_io_write( major, minor, &args );
    100102  if ( status == RTEMS_SUCCESSFUL ) {
     103    iop->offset += args.bytes_moved;
     104
    101105    return (ssize_t) args.bytes_moved;
    102106  } else {
  • cpukit/libcsupport/src/write.c

    rfed66f99 r53da07e  
    3030)
    3131{
    32   ssize_t  rc;
    3332  rtems_libio_t     *iop;
    3433
     
    4342   *  Now process the write() request.
    4443   */
    45   rc = (*iop->pathinfo.handlers->write_h)( iop, buffer, count );
    46 
    47   if ( rc > 0 )
    48     iop->offset += rc;
    49 
    50   return rc;
     44  return (*iop->pathinfo.handlers->write_h)( iop, buffer, count );
    5145}
  • cpukit/libcsupport/src/writev.c

    rfed66f99 r53da07e  
    114114
    115115    if ( bytes > 0 ) {
    116       iop->offset += bytes;
    117116      total       += bytes;
    118117    }
  • cpukit/libfs/src/dosfs/msdos_file.c

    rfed66f99 r53da07e  
    118118    ret = fat_file_read(iop->pathinfo.mt_entry, fat_fd, iop->offset, count,
    119119                        buffer);
     120    if (ret > 0)
     121        iop->offset += ret;
    120122
    121123    rtems_semaphore_release(fs_info->vol_sema);
     
    164166     * file was extended
    165167     */
    166     if (iop->offset + ret > fat_fd->fat_file_size)
    167         fat_fd->fat_file_size = iop->offset + ret;
     168    iop->offset += ret;
     169    if (iop->offset > fat_fd->fat_file_size)
     170        fat_fd->fat_file_size = iop->offset;
    168171
    169172    rtems_semaphore_release(fs_info->vol_sema);
  • cpukit/libfs/src/imfs/memfile.c

    rfed66f99 r53da07e  
    122122{
    123123  IMFS_jnode_t   *the_jnode;
     124  ssize_t         status;
    124125
    125126  the_jnode = iop->pathinfo.node_access;
    126127
    127   return IMFS_memfile_read( the_jnode, iop->offset, buffer, count );
     128  status = IMFS_memfile_read( the_jnode, iop->offset, buffer, count );
     129
     130  if ( status > 0 )
     131    iop->offset += status;
     132
     133  return status;
    128134}
    129135
     
    148154
    149155  status = IMFS_memfile_write( the_jnode, iop->offset, buffer, count );
     156
     157  if ( status > 0 )
     158    iop->offset += status;
    150159
    151160  return status;
  • cpukit/libfs/src/nfsclient/src/nfs.c

    rfed66f99 r53da07e  
    23122312        } while (count > 0);
    23132313
     2314        if (rv > 0) {
     2315                iop->offset = offset;
     2316        }
     2317
    23142318        return rv;
    23152319}
     
    24192423
    24202424        node->age = nowSeconds();
     2425
     2426        iop->offset += count;
    24212427
    24222428        return count;
  • cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c

    rfed66f99 r53da07e  
    164164  }
    165165
     166  if (read >= 0)
     167    iop->offset = pos + read;
     168
    166169  rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
    167170
     
    221224      return rtems_rfs_rtems_error ("file-write: write append seek", rc);
    222225    }
    223     iop->offset = pos;
    224226  }
    225227
     
    251253    }
    252254  }
     255
     256  if (write >= 0)
     257    iop->offset = pos + write;
    253258
    254259  rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
Note: See TracChangeset for help on using the changeset viewer.