summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2010-10-11 04:40:08 +0000
committerChris Johns <chrisj@rtems.org>2010-10-11 04:40:08 +0000
commit5a24436e22a823a2fb929b6b0c9112a9011629bf (patch)
treecb8da493349021320a2b62934aebb09255f96bb3 /cpukit/libfs
parentRegenerate. (diff)
downloadrtems-5a24436e22a823a2fb929b6b0c9112a9011629bf.tar.bz2
2010-10-11 Chris Johns <chrisj@rtems.org>
* libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h: Add inode-delete. * libfs/src/rfs/rtems-rfs-shell.c: Fix formatting. * libfs/src/rfs/rtems-rfs-rtems-dir.c: Use ssize_t. Fix spelling. * libfs/src/rfs/rtems-rfs-block.c: Fix rtems_rfs_block_get_bpos to return the position correctly. A bpos does not have any special processing. Do no reset the buffer handle when shrinking indirectly. * libfs/src/rfs/rtems-rfs-inode.c: Add trace. * libfs/src/rfs/rtems-rfs-format.c: Fix comments. * libfs/src/rfs/rtems-rfs-group.c: Limit the inodes to the blocks in a group so the accounting works. * libfs/src/rfs/rtems-rfs-dir.c: PR 1705. Fix handling the offsets when deleting an entry. * libfs/src/rfs/rtems-rfs-buffer.h: Remove rtems_rfs_buffer_handle_reset. It is not needed and dangerous. * cpukit/libmisc/untar/untar.c: Merge 4.11 pax fix. This fix also supports MacOS's tar.
Diffstat (limited to 'cpukit/libfs')
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-block.c21
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-dir.c43
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-trace.h2
3 files changed, 43 insertions, 23 deletions
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-block.c b/cpukit/libfs/src/rfs/rtems-rfs-block.c
index 5ffadcc284..342d738f22 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-block.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-block.c
@@ -46,18 +46,19 @@
#include <rtems/rfs/rtems-rfs-inode.h>
void
-rtems_rfs_block_get_bpos (rtems_rfs_file_system* fs,
- rtems_rfs_pos pos,
- rtems_rfs_block_pos* bpos)
+rtems_rfs_block_get_bpos (rtems_rfs_file_system* fs,
+ rtems_rfs_pos pos,
+ rtems_rfs_block_pos* bpos)
{
bpos->bno = pos / rtems_rfs_fs_block_size (fs);
bpos->boff = pos % rtems_rfs_fs_block_size (fs);
}
rtems_rfs_pos
-rtems_rfs_block_get_pos (rtems_rfs_file_system* fs,
- rtems_rfs_block_pos* bpos)
+rtems_rfs_block_get_pos (rtems_rfs_file_system* fs,
+ rtems_rfs_block_pos* bpos)
{
+#if 0
rtems_rfs_pos pos = 0;
if (bpos->bno)
{
@@ -66,13 +67,17 @@ rtems_rfs_block_get_pos (rtems_rfs_file_system* fs,
pos = rtems_rfs_fs_block_size (fs);
pos += (bpos->bno - 1) * rtems_rfs_fs_block_size (fs);
}
+#else
+ rtems_rfs_pos pos;
+ pos = (bpos->bno * rtems_rfs_fs_block_size (fs)) + bpos->boff;
+#endif
return pos;
}
void
-rtems_rfs_block_get_block_size (rtems_rfs_file_system* fs,
- rtems_rfs_pos pos,
- rtems_rfs_block_size* size)
+rtems_rfs_block_get_block_size (rtems_rfs_file_system* fs,
+ rtems_rfs_pos pos,
+ rtems_rfs_block_size* size)
{
if (pos == 0)
rtems_rfs_block_set_size_zero (size);
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-dir.c b/cpukit/libfs/src/rfs/rtems-rfs-dir.c
index 3ed394609b..7b44824f90 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-dir.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-dir.c
@@ -127,6 +127,10 @@ rtems_rfs_dir_lookup_ino (rtems_rfs_file_system* fs,
{
uint8_t* entry;
+ if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_LOOKUP_INO))
+ printf ("rtems-rfs: dir-lookup-ino: block read, ino=%" PRIu32 " bno=%" PRId32 "\n",
+ rtems_rfs_inode_ino (inode), map.bpos.bno);
+
rc = rtems_rfs_buffer_handle_request (fs, &entries, block, true);
if (rc > 0)
{
@@ -171,8 +175,9 @@ rtems_rfs_dir_lookup_ino (rtems_rfs_file_system* fs,
{
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK))
printf ("rtems-rfs: dir-lookup-ino: "
- "checking entry for ino %" PRId32 ": off=%04" PRIx32 " length:%d ino:%" PRId32 "\n",
- rtems_rfs_inode_ino (inode), map.bpos.boff,
+ "checking entry for ino %" PRId32 ": bno=%04" PRIx32 "/off=%04" PRIx32
+ " length:%d ino:%" PRId32 "\n",
+ rtems_rfs_inode_ino (inode), map.bpos.bno, map.bpos.boff,
elength, rtems_rfs_dir_entry_ino (entry));
if (memcmp (entry + RTEMS_RFS_DIR_ENTRY_SIZE, name, length) == 0)
@@ -414,7 +419,7 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
while (rc == 0)
{
uint8_t* entry;
- int offset;
+ int eoffset;
rc = rtems_rfs_buffer_handle_request (fs, &buffer, block, true);
if (rc > 0)
@@ -425,11 +430,19 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
rtems_rfs_inode_ino (dir), rc, strerror (rc));
break;
}
+
+ /*
+ * If we are searching start at the beginning of the block. If not searching
+ * skip to the offset in the block.
+ */
+ if (search)
+ eoffset = 0;
+ else
+ eoffset = offset % rtems_rfs_fs_block_size (fs);
- entry = rtems_rfs_buffer_data (&buffer);
- offset = 0;
+ entry = rtems_rfs_buffer_data (&buffer) + eoffset;
- while (offset < (rtems_rfs_fs_block_size (fs) - RTEMS_RFS_DIR_ENTRY_SIZE))
+ while (eoffset < (rtems_rfs_fs_block_size (fs) - RTEMS_RFS_DIR_ENTRY_SIZE))
{
rtems_rfs_ino eino;
int elength;
@@ -444,8 +457,9 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
{
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_DEL_ENTRY))
printf ("rtems-rfs: dir-del-entry: "
- "bad length or ino for ino %" PRIu32 ": %u/%" PRId32 " @ %04x\n",
- rtems_rfs_inode_ino (dir), elength, eino, offset);
+ "bad length or ino for ino %" PRIu32 ": %u/%" PRId32
+ " @ %" PRIu32 ".%04x\n",
+ rtems_rfs_inode_ino (dir), elength, eino, block, eoffset);
rc = EIO;
break;
}
@@ -453,7 +467,7 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
if (ino == rtems_rfs_dir_entry_ino (entry))
{
uint32_t remaining;
- remaining = rtems_rfs_fs_block_size (fs) - (offset + elength);
+ remaining = rtems_rfs_fs_block_size (fs) - (eoffset + elength);
memmove (entry, entry + elength, remaining);
memset (entry + remaining, 0xff, elength);
@@ -468,12 +482,13 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_DEL_ENTRY))
printf ("rtems-rfs: dir-del-entry: "
- "last block free for ino %" PRIu32 ": elength=%i offset=%d last=%s\n",
- ino, elength, offset,
+ "last block free for ino %" PRIu32 ": elength=%i block=%" PRIu32
+ " offset=%d last=%s\n",
+ ino, elength, block, eoffset,
rtems_rfs_block_map_last (&map) ? "yes" : "no");
if ((elength == RTEMS_RFS_DIR_ENTRY_EMPTY) &&
- (offset == 0) && rtems_rfs_block_map_last (&map))
+ (eoffset == 0) && rtems_rfs_block_map_last (&map))
{
rc = rtems_rfs_block_map_shrink (fs, &map, 1);
if (rc > 0)
@@ -497,8 +512,8 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
break;
}
- entry += elength;
- offset += elength;
+ entry += elength;
+ eoffset += elength;
}
if (rc == 0)
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-trace.h b/cpukit/libfs/src/rfs/rtems-rfs-trace.h
index 516bfe8e8f..19f46828c4 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-trace.h
+++ b/cpukit/libfs/src/rfs/rtems-rfs-trace.h
@@ -28,7 +28,7 @@
/**
* Is tracing enabled ?
*/
-#define RTEMS_RFS_TRACE 0
+#define RTEMS_RFS_TRACE 1
/**
* The type of the mask.