summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2010-02-26 05:54:59 +0000
committerChris Johns <chrisj@rtems.org>2010-02-26 05:54:59 +0000
commit3cfa6368c3211eed83df08850f0af26481f161f6 (patch)
tree822cfa7d031cb1d644172cff41ab8f952c038a34 /cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
parent combine all checks for missing MAC address (diff)
downloadrtems-3cfa6368c3211eed83df08850f0af26481f161f6.tar.bz2
010-02-26 Chris Johns <chrisj@rtems.org>
* libfs/src/rfs/rtems-rfs-block.c: Reset a buffer handle after moving down an indirection level. * libfs/src/rfs/rtems-rfs-dir.c: Move directory entry validation into a macro and use the macro. Fix the range check on the ino so all inodes can be used. * libfs/src/rfs/rtems-rfs-file-system.c, libfs/src/rfs/rtems-rfs-file-system.h:: Add a version number to the superblock. Use RTEMS_RFS_INODE_SIZE. * libfs/src/rfs/rtems-rfs-file.c: Fix the size offset on partial block lengths. Set the size in the file handle on a truncate to 0. * libfs/src/rfs/rtems-rfs-format.c: Add a version number to the superblock. Use RTEMS_RFS_INODE_SIZE. A better set of defaults for small disks. * libfs/src/rfs/rtems-rfs-inode.c: Use RTEMS_RFS_INODE_SIZE. Free the allocated inode if it cannot be opened. * libfs/src/rfs/rtems-rfs-inode.h: Add RTEMS_RFS_INODE_SIZE. * libfs/src/rfs/rtems-rfs-rtems-file.c: Move some of the iop acceses inside the fs lock. * libfs/src/rfs/rtems-rfs-shell.c: Use RTEMS_RFS_INODE_SIZE.
Diffstat (limited to 'cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c')
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
index 18ef2d2d77..e13e2330c5 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
@@ -39,7 +39,7 @@ rtems_rfs_rtems_file_open (rtems_libio_t* iop,
uint32_t mode)
{
rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (&iop->pathinfo);
- rtems_rfs_ino ino = rtems_rfs_rtems_get_iop_ino (iop);
+ rtems_rfs_ino ino;
rtems_rfs_file_handle* file;
uint32_t flags;
int rc;
@@ -52,6 +52,8 @@ rtems_rfs_rtems_file_open (rtems_libio_t* iop,
rtems_rfs_rtems_lock (fs);
+ ino = rtems_rfs_rtems_get_iop_ino (iop);
+
rc = rtems_rfs_file_open (fs, ino, flags, &file);
if (rc > 0)
{
@@ -109,7 +111,7 @@ rtems_rfs_rtems_file_read (rtems_libio_t* iop,
size_t count)
{
rtems_rfs_file_handle* file = iop->file_info;
- rtems_rfs_pos pos = iop->offset;
+ rtems_rfs_pos pos;
uint8_t* data = buffer;
ssize_t read = 0;
int rc;
@@ -119,6 +121,8 @@ rtems_rfs_rtems_file_read (rtems_libio_t* iop,
rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
+ pos = iop->offset;
+
if (pos < rtems_rfs_file_size (file))
{
while (count)
@@ -172,7 +176,7 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop,
size_t count)
{
rtems_rfs_file_handle* file = iop->file_info;
- rtems_rfs_pos pos = iop->offset;
+ rtems_rfs_pos pos;
const uint8_t* data = buffer;
ssize_t write = 0;
int rc;
@@ -182,6 +186,8 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop,
rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
+ pos = iop->offset;
+
/*
* If the iop position is past the physical end of the file we need to set the
* file size to the new length before writing.
@@ -266,10 +272,10 @@ rtems_rfs_rtems_file_lseek (rtems_libio_t* iop,
if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FILE_LSEEK))
printf("rtems-rfs: file-lseek: handle:%p offset:%Ld\n", file, offset);
- pos = iop->offset;
-
rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
+ pos = iop->offset;
+
rc = rtems_rfs_file_seek (file, pos, &pos);
if (rc)
{
@@ -300,7 +306,7 @@ rtems_rfs_rtems_file_ftruncate (rtems_libio_t* iop,
printf("rtems-rfs: file-ftrunc: handle:%p length:%Ld\n", file, length);
rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
-
+
rc = rtems_rfs_file_set_size (file, length);
if (rc)
rc = rtems_rfs_rtems_error ("file_ftruncate: set size", rc);