summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2011-12-09 07:21:02 +0000
committerChris Johns <chrisj@rtems.org>2011-12-09 07:21:02 +0000
commit8504f12471ba9d514056edca902eeae26354e739 (patch)
tree7be735a95b79ecafb1c4688fa98472ab57d5a0a1 /cpukit
parent2011-12-09 Ralf Corsépius <ralf.corsepius@rtems.org> (diff)
downloadrtems-8504f12471ba9d514056edca902eeae26354e739.tar.bz2
2011-12-09 Chris Johns <chrisj@rtems.org>
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.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/ChangeLog11
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-file.c77
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-rtems.h19
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-trace.c7
4 files changed, 83 insertions, 31 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index ace035f837..5935621a86 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,14 @@
+2011-12-09 Chris Johns <chrisj@rtems.org>
+
+ 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.
+
+
2011-12-08 Ralf Corsépius <ralf.corsepius@rtems.org>
* rtems/src/rtemsobjectgetname.c:
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file.c b/cpukit/libfs/src/rfs/rtems-rfs-file.c
index 6087f764d6..d8a7335ea4 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-file.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-file.c
@@ -424,8 +424,45 @@ rtems_rfs_file_seek (rtems_rfs_file_handle* handle,
*/
if (pos < rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (handle),
handle->shared))
+ {
rtems_rfs_file_set_bpos (handle, pos);
-
+
+ /*
+ * If the file has a block check if it maps to the current position and it
+ * does not release it. That will force us to get the block at the new
+ * position when the I/O starts.
+ */
+ if (rtems_rfs_buffer_handle_has_block (&handle->buffer))
+ {
+ rtems_rfs_buffer_block block;
+ int rc;
+
+ rc = rtems_rfs_block_map_find (rtems_rfs_file_fs (handle),
+ rtems_rfs_file_map (handle),
+ rtems_rfs_file_bpos (handle),
+ &block);
+ if (rc > 0)
+ return rc;
+ if (rtems_rfs_buffer_bnum (&handle->buffer) != block)
+ {
+ rc = rtems_rfs_buffer_handle_release (rtems_rfs_file_fs (handle),
+ rtems_rfs_file_buffer (handle));
+ if (rc > 0)
+ return rc;
+ }
+ }
+ }
+ else
+ {
+ /*
+ * The seek is outside the current file so release any buffer. A write will
+ * extend the file.
+ */
+ int rc = rtems_rfs_file_io_release (handle);
+ if (rc > 0)
+ return rc;
+ }
+
*new_pos = pos;
return 0;
}
@@ -441,23 +478,25 @@ rtems_rfs_file_set_size (rtems_rfs_file_handle* handle,
if (rtems_rfs_trace (RTEMS_RFS_TRACE_FILE_IO))
printf ("rtems-rfs: file-set-size: size=%" PRIu64 "\n", new_size);
+ size = rtems_rfs_file_size (handle);
+
/*
- * Short cut for the common truncate on open call.
+ * If the file is same size do nothing else grow or shrink it ?
+ *
+ * If the file does not change size do not update the times.
*/
- if (new_size == 0)
- {
- rc = rtems_rfs_block_map_free_all (rtems_rfs_file_fs (handle), map);
- if (rc > 0)
- return rc;
- }
- else
+ if (size != new_size)
{
- size = rtems_rfs_file_size (handle);
-
/*
- * If the file is same size do nothing else grow or shrink it ?
+ * Short cut for the common truncate on open call.
*/
- if (size != new_size)
+ if (new_size == 0)
+ {
+ rc = rtems_rfs_block_map_free_all (rtems_rfs_file_fs (handle), map);
+ if (rc > 0)
+ return rc;
+ }
+ else
{
if (size < new_size)
{
@@ -567,14 +606,14 @@ rtems_rfs_file_set_size (rtems_rfs_file_handle* handle,
rtems_rfs_file_bpos (handle));
}
}
- }
- handle->shared->size.count = rtems_rfs_block_map_count (map);
- handle->shared->size.offset = rtems_rfs_block_map_size_offset (map);
-
- if (rtems_rfs_file_update_mtime (handle))
- handle->shared->mtime = time (NULL);
+ handle->shared->size.count = rtems_rfs_block_map_count (map);
+ handle->shared->size.offset = rtems_rfs_block_map_size_offset (map);
+ if (rtems_rfs_file_update_mtime (handle))
+ handle->shared->mtime = time (NULL);
+ }
+
return 0;
}
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems.h b/cpukit/libfs/src/rfs/rtems-rfs-rtems.h
index 19f51da31c..a1b0e8556e 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-rtems.h
+++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems.h
@@ -25,12 +25,12 @@
#include <errno.h>
/**
- * RTEMS RFS RTEMS Error Enable. Set to 1 to printing of errors. Default is off.
+ * RTEMS RFS RTEMS Error Enable. Set to 1 for printing of errors. Default is off.
*/
#define RTEMS_RFS_RTEMS_ERROR 0
/**
- * RTEMS RFS RTEMS Trace Enable. Set to 1 to printing of errors. Default is off.
+ * RTEMS RFS RTEMS Trace Enable. Set to 1 for printing of errors. Default is off.
*/
#define RTEMS_RFS_RTEMS_TRACE 0
@@ -72,13 +72,14 @@ int rtems_rfs_rtems_error (const char* mesg, int error);
#define RTEMS_RFS_RTEMS_DEBUG_READLINK (1 << 9)
#define RTEMS_RFS_RTEMS_DEBUG_FCHMOD (1 << 10)
#define RTEMS_RFS_RTEMS_DEBUG_STAT (1 << 11)
-#define RTEMS_RFS_RTEMS_DEBUG_DIR_RMNOD (1 << 12)
-#define RTEMS_RFS_RTEMS_DEBUG_FILE_OPEN (1 << 13)
-#define RTEMS_RFS_RTEMS_DEBUG_FILE_CLOSE (1 << 14)
-#define RTEMS_RFS_RTEMS_DEBUG_FILE_READ (1 << 15)
-#define RTEMS_RFS_RTEMS_DEBUG_FILE_WRITE (1 << 16)
-#define RTEMS_RFS_RTEMS_DEBUG_FILE_LSEEK (1 << 17)
-#define RTEMS_RFS_RTEMS_DEBUG_FILE_FTRUNC (1 << 18)
+#define RTEMS_RFS_RTEMS_DEBUG_RENAME (1 << 12)
+#define RTEMS_RFS_RTEMS_DEBUG_DIR_RMNOD (1 << 13)
+#define RTEMS_RFS_RTEMS_DEBUG_FILE_OPEN (1 << 14)
+#define RTEMS_RFS_RTEMS_DEBUG_FILE_CLOSE (1 << 15)
+#define RTEMS_RFS_RTEMS_DEBUG_FILE_READ (1 << 16)
+#define RTEMS_RFS_RTEMS_DEBUG_FILE_WRITE (1 << 17)
+#define RTEMS_RFS_RTEMS_DEBUG_FILE_LSEEK (1 << 18)
+#define RTEMS_RFS_RTEMS_DEBUG_FILE_FTRUNC (1 << 19)
/**
* Call to check if this part is bring traced. If RTEMS_RFS_RTEMS_TRACE is
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-trace.c b/cpukit/libfs/src/rfs/rtems-rfs-trace.c
index 5484c68d79..6d8873979b 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-trace.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-trace.c
@@ -92,7 +92,8 @@ rtems_rfs_trace_shell_command (int argc, char *argv[])
"symlink-read",
"file-open",
"file-close",
- "file-io"
+ "file-io",
+ "file-set"
};
rtems_rfs_trace_mask set_value = 0;
@@ -140,9 +141,9 @@ rtems_rfs_trace_shell_command (int argc, char *argv[])
if (strcmp (argv[arg], table[t]) == 0)
{
if (set)
- set_value = 1 << t;
+ set_value = 1ULL << t;
else
- clear_value = 1 << t;
+ clear_value = 1ULL << t;
break;
}
}