change log for rtems (2010-10-11)

rtems-vc at rtems.org rtems-vc at rtems.org
Mon Oct 11 05:10:37 UTC 2010


 *ccj*:
2010-10-11      Chris Johns <chrisj at 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.

M 1.2634  cpukit/ChangeLog
M    1.7  cpukit/libfs/src/rfs/rtems-rfs-block.c
M    1.4  cpukit/libfs/src/rfs/rtems-rfs-buffer.h
M    1.8  cpukit/libfs/src/rfs/rtems-rfs-dir.c
M    1.8  cpukit/libfs/src/rfs/rtems-rfs-format.c
M    1.6  cpukit/libfs/src/rfs/rtems-rfs-group.c
M    1.5  cpukit/libfs/src/rfs/rtems-rfs-inode.c
M    1.7  cpukit/libfs/src/rfs/rtems-rfs-rtems-dir.c
M   1.11  cpukit/libfs/src/rfs/rtems-rfs-shell.c
M    1.2  cpukit/libfs/src/rfs/rtems-rfs-trace.h
M    1.3  cpukit/libfs/src/rfs/rtems-rfs-trace.c

diff -u rtems/cpukit/ChangeLog:1.2633 rtems/cpukit/ChangeLog:1.2634
--- rtems/cpukit/ChangeLog:1.2633	Fri Oct  8 04:44:44 2010
+++ rtems/cpukit/ChangeLog	Sun Oct 10 23:34:48 2010
@@ -1,3 +1,22 @@
+2010-10-11	Chris Johns <chrisj at 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.
+
 2010-10-08	Ralf Corsépius <ralf.corsepius at rtems.org>
 
 	* configure.ac: pthread_attr* functions are in <pthread.h>, not in

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-block.c:1.6 rtems/cpukit/libfs/src/rfs/rtems-rfs-block.c:1.7
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-block.c:1.6	Thu Jun 17 17:04:51 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-block.c	Sun Oct 10 23:34:48 2010
@@ -46,33 +46,25 @@
 #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)
 {
-  rtems_rfs_pos pos = 0;
-  if (bpos->bno)
-  {
-    pos = bpos->boff;
-    if (pos == 0)
-      pos = rtems_rfs_fs_block_size (fs);
-    pos += (bpos->bno - 1) * rtems_rfs_fs_block_size (fs);
-  }
-  return pos;
+  return (bpos->bno * rtems_rfs_fs_block_size (fs)) + bpos->boff;
 }
 
 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);
@@ -634,8 +626,6 @@
       int b;
       for (b = 0; b < RTEMS_RFS_INODE_BLOCKS; b++)
         map->blocks[b] = rtems_rfs_block_get_number (buffer, b);
-
-      rtems_rfs_buffer_handle_reset (buffer);
     }
     else
     {

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-buffer.h:1.3 rtems/cpukit/libfs/src/rfs/rtems-rfs-buffer.h:1.4
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-buffer.h:1.3	Wed Jun 16 09:39:14 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-buffer.h	Sun Oct 10 23:34:48 2010
@@ -186,22 +186,6 @@
                                      rtems_rfs_buffer_handle* handle);
 
 /**
- * Reset a handle.
- *
- * @param fs The file system data.
- * @param handle The buffer handle to reset.
- * @return int The error number (errno). No error if 0.
- */
-static inline int
-rtems_rfs_buffer_handle_reset (rtems_rfs_buffer_handle* handle)
-{
-  handle->dirty = false;
-  handle->bnum  = 0; 
-  handle->buffer = NULL;
-  return 0;
-}
-
-/**
  * Open a handle.
  *
  * @param fs The file system data.
@@ -212,7 +196,9 @@
 rtems_rfs_buffer_handle_open (rtems_rfs_file_system*   fs,
                               rtems_rfs_buffer_handle* handle)
 {
-  rtems_rfs_buffer_handle_reset (handle);
+  handle->dirty = false;
+  handle->bnum  = 0; 
+  handle->buffer = NULL;
   return 0;
 }
 
@@ -228,6 +214,9 @@
                                rtems_rfs_buffer_handle* handle)
 {
   rtems_rfs_buffer_handle_release (fs, handle);
+  handle->dirty = false;
+  handle->bnum  = 0; 
+  handle->buffer = NULL;
   return 0;
 }
 

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.c:1.7 rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.c:1.8
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.c:1.7	Tue Jun 15 18:34:56 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.c	Sun Oct 10 23:34:48 2010
@@ -127,6 +127,10 @@
     {
       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 @@
         {
           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 @@
   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_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 @@
       {
         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 @@
       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 @@
 
         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 @@
         break;
       }
       
-      entry  += elength;
-      offset += elength;
+      entry   += elength;
+      eoffset += elength;
     }
 
     if (rc == 0)
@@ -605,10 +620,7 @@
       if (remaining <= RTEMS_RFS_DIR_ENTRY_SIZE)
         *length += remaining;
       
-      if (elength < RTEMS_RFS_DIR_ENTRY_SIZE)
-        elength = 0;
-      else
-        elength -= RTEMS_RFS_DIR_ENTRY_SIZE;
+      elength -= RTEMS_RFS_DIR_ENTRY_SIZE;
       if (elength > NAME_MAX)
         elength = NAME_MAX;
       

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-format.c:1.7 rtems/cpukit/libfs/src/rfs/rtems-rfs-format.c:1.8
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-format.c:1.7	Thu Aug 26 01:31:15 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-format.c	Sun Oct 10 23:34:48 2010
@@ -84,8 +84,7 @@
                                   rtems_rfs_fs_block_size (fs));
   bits_per_block = rtems_rfs_bits_per_block (fs);
   /*
-   * There could be more bits that there are blocks, eg 512K disk with 512
-   * blocks.
+   * There could be more bits than blocks, eg 512K disk with 512 blocks.
    */
   if (bits_per_block > (rtems_rfs_fs_blocks (fs) - RTEMS_RFS_SUPERBLOCK_SIZE))
     bits_per_block = rtems_rfs_fs_blocks (fs) - RTEMS_RFS_SUPERBLOCK_SIZE;
@@ -353,7 +352,7 @@
   rtems_rfs_buffer_mark_dirty (&handle);
 
   /*
-   * Initialise the inode tables if rerquired to do so.
+   * Initialise the inode tables if required to do so.
    */
   if (initialise_inodes)
   {

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-group.c:1.5 rtems/cpukit/libfs/src/rfs/rtems-rfs-group.c:1.6
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-group.c:1.5	Wed Jun 16 21:44:49 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-group.c	Sun Oct 10 23:34:48 2010
@@ -46,6 +46,15 @@
 
   if ((base + size) >= rtems_rfs_fs_blocks (fs))
     size = rtems_rfs_fs_blocks (fs) - base;
+
+  /*
+   * Limit the inodes to the same size as the blocks. This is what the
+   * format does and if this is not done the accounting of inodes does
+   * not work. If we are so pushed for inodes that this makes a difference
+   * the format configuration needs reviewing.
+   */
+  if (inodes > size)
+    inodes = size;
   
   if (rtems_rfs_trace (RTEMS_RFS_TRACE_GROUP_OPEN))
     printf ("rtems-rfs: group-open: base=%" PRId32 ", blocks=%zd inodes=%zd\n",

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-inode.c:1.4 rtems/cpukit/libfs/src/rfs/rtems-rfs-inode.c:1.5
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-inode.c:1.4	Wed Jun 16 12:30:35 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-inode.c	Sun Oct 10 23:34:48 2010
@@ -296,6 +296,12 @@
                         rtems_rfs_inode_handle* handle)
 {
   int rc = 0;
+  
+  if (rtems_rfs_trace (RTEMS_RFS_TRACE_INODE_DELETE))
+    printf("rtems-rfs: inode-delete: ino:%" PRIu32 " loaded:%s\n",
+           rtems_rfs_inode_ino (handle),
+           rtems_rfs_inode_is_loaded (handle) ? "yes" : "no");
+
   if (rtems_rfs_inode_is_loaded (handle))
   {
     rtems_rfs_block_map map;

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems-dir.c:1.6 rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems-dir.c:1.7
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems-dir.c:1.6	Wed Aug 25 04:37:49 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-rtems-dir.c	Sun Oct 10 23:34:48 2010
@@ -26,6 +26,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <unistd.h>
 
 #include <rtems/rfs/rtems-rfs-dir.h>
 #include <rtems/rfs/rtems-rfs-link.h>
@@ -113,7 +114,7 @@
   rtems_rfs_ino          ino = rtems_rfs_rtems_get_iop_ino (iop);
   rtems_rfs_inode_handle inode;
   struct dirent*         dirent;
-  size_t                 bytes_transfered;
+  ssize_t                bytes_transferred;
   int                    d;
   int                    rc;
 
@@ -129,7 +130,7 @@
     return rtems_rfs_rtems_error ("dir_read: read inode", rc);
   }
 
-  bytes_transfered = 0;
+  bytes_transferred = 0;
   
   for (d = 0; d < count; d++, dirent++)
   {
@@ -142,17 +143,17 @@
     }
     if (rc > 0)
     {
-      bytes_transfered = rtems_rfs_rtems_error ("dir_read: dir read", rc);
+      bytes_transferred = rtems_rfs_rtems_error ("dir_read: dir read", rc);
       break;
     }
     iop->offset += size;
-    bytes_transfered += sizeof (struct dirent);
+    bytes_transferred += sizeof (struct dirent);
   }
 
   rtems_rfs_inode_close (fs, &inode);
   rtems_rfs_rtems_unlock (fs);
   
-  return (ssize_t) bytes_transfered;
+  return bytes_transferred;
 }
 
 /**

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-shell.c:1.10 rtems/cpukit/libfs/src/rfs/rtems-rfs-shell.c:1.11
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-shell.c:1.10	Thu Jun 24 08:28:39 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-shell.c	Sun Oct 10 23:34:48 2010
@@ -123,24 +123,24 @@
   printf ("RFS Filesystem Data\n");
   printf ("             flags: %08" PRIx32 "\n", fs->flags);
 #if 0
-  printf ("            device: %08lx\n", rtems_rfs_fs_device (fs));
+  printf ("            device: %08lx\n",         rtems_rfs_fs_device (fs));
 #endif
-  printf ("            blocks: %zu\n",  rtems_rfs_fs_blocks (fs));
-  printf ("        block size: %zu\n",  rtems_rfs_fs_block_size (fs));
-  printf ("              size: %" PRIu64 "\n",  rtems_rfs_fs_size (fs));
-  printf ("  media block size: %" PRIu32 "\n",  rtems_rfs_fs_media_block_size (fs));
-  printf ("        media size: %" PRIu64 "\n", rtems_rfs_fs_media_size (fs));
-  printf ("            inodes: %" PRIu32 "\n",  rtems_rfs_fs_inodes (fs));
-  printf ("        bad blocks: %" PRIu32 "\n",  fs->bad_blocks);
-  printf ("  max. name length: %" PRIu32 "\n",  rtems_rfs_fs_max_name (fs));
-  printf ("            groups: %d\n",   fs->group_count);
-  printf ("      group blocks: %zd\n",  fs->group_blocks);
-  printf ("      group inodes: %zd\n",  fs->group_inodes);
-  printf ("  inodes per block: %zd\n",  fs->inodes_per_block);
-  printf ("  blocks per block: %zd\n",  fs->blocks_per_block);
-  printf ("     singly blocks: %zd\n",  fs->block_map_singly_blocks);
-  printf ("    doublly blocks: %zd\n",  fs->block_map_doubly_blocks);
-  printf (" max. held buffers: %" PRId32 "\n",  fs->max_held_buffers);
+  printf ("            blocks: %zu\n",           rtems_rfs_fs_blocks (fs));
+  printf ("        block size: %zu\n",           rtems_rfs_fs_block_size (fs));
+  printf ("              size: %" PRIu64 "\n",   rtems_rfs_fs_size (fs));
+  printf ("  media block size: %" PRIu32 "\n",   rtems_rfs_fs_media_block_size (fs));
+  printf ("        media size: %" PRIu64 "\n",   rtems_rfs_fs_media_size (fs));
+  printf ("            inodes: %" PRIu32 "\n",   rtems_rfs_fs_inodes (fs));
+  printf ("        bad blocks: %" PRIu32 "\n",   fs->bad_blocks);
+  printf ("  max. name length: %" PRIu32 "\n",   rtems_rfs_fs_max_name (fs));
+  printf ("            groups: %d\n",            fs->group_count);
+  printf ("      group blocks: %zd\n",           fs->group_blocks);
+  printf ("      group inodes: %zd\n",           fs->group_inodes);
+  printf ("  inodes per block: %zd\n",           fs->inodes_per_block);
+  printf ("  blocks per block: %zd\n",           fs->blocks_per_block);
+  printf ("     singly blocks: %zd\n",           fs->block_map_singly_blocks);
+  printf ("    doublly blocks: %zd\n",           fs->block_map_doubly_blocks);
+  printf (" max. held buffers: %" PRId32 "\n",   fs->max_held_buffers);
 
   rtems_rfs_shell_lock_rfs (fs);
 
@@ -302,8 +302,7 @@
     }
   }
 
-  if ((start < 0) || (end < 0) ||
-      (start >= total) || (end >= total))
+  if ((start >= total) || (end >= total))
   {
     printf ("error: inode out of range (0->%" PRId32 ").\n", total - 1);
     return 1;

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.h:1.1 rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.h:1.2
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.h:1.1	Wed Feb 17 18:24:25 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.h	Sun Oct 10 23:34:48 2010
@@ -28,7 +28,9 @@
 /**
  * Is tracing enabled ?
  */
-#define RTEMS_RFS_TRACE 0
+#if !defined (RTEMS_RFS_TRACE)
+#define RTEMS_RFS_TRACE 1
+#endif
 
 /**
  * The type of the mask.
@@ -62,21 +64,22 @@
 #define RTEMS_RFS_TRACE_INODE_LOAD             (1ULL << 20)
 #define RTEMS_RFS_TRACE_INODE_UNLOAD           (1ULL << 21)
 #define RTEMS_RFS_TRACE_INODE_CREATE           (1ULL << 22)
-#define RTEMS_RFS_TRACE_LINK                   (1ULL << 23)
-#define RTEMS_RFS_TRACE_UNLINK                 (1ULL << 24)
-#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO         (1ULL << 25)
-#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK   (1ULL << 26)
-#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_FOUND   (1ULL << 27)
-#define RTEMS_RFS_TRACE_DIR_ADD_ENTRY          (1ULL << 28)
-#define RTEMS_RFS_TRACE_DIR_DEL_ENTRY          (1ULL << 29)
-#define RTEMS_RFS_TRACE_DIR_READ               (1ULL << 30)
-#define RTEMS_RFS_TRACE_DIR_EMPTY              (1ULL << 31)
-#define RTEMS_RFS_TRACE_SYMLINK                (1ULL << 32)
-#define RTEMS_RFS_TRACE_SYMLINK_READ           (1ULL << 33)
-#define RTEMS_RFS_TRACE_FILE_OPEN              (1ULL << 34)
-#define RTEMS_RFS_TRACE_FILE_CLOSE             (1ULL << 35)
-#define RTEMS_RFS_TRACE_FILE_IO                (1ULL << 36)
-#define RTEMS_RFS_TRACE_FILE_SET               (1ULL << 37)
+#define RTEMS_RFS_TRACE_INODE_DELETE           (1ULL << 23)
+#define RTEMS_RFS_TRACE_LINK                   (1ULL << 24)
+#define RTEMS_RFS_TRACE_UNLINK                 (1ULL << 25)
+#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO         (1ULL << 26)
+#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK   (1ULL << 27)
+#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_FOUND   (1ULL << 28)
+#define RTEMS_RFS_TRACE_DIR_ADD_ENTRY          (1ULL << 29)
+#define RTEMS_RFS_TRACE_DIR_DEL_ENTRY          (1ULL << 30)
+#define RTEMS_RFS_TRACE_DIR_READ               (1ULL << 31)
+#define RTEMS_RFS_TRACE_DIR_EMPTY              (1ULL << 32)
+#define RTEMS_RFS_TRACE_SYMLINK                (1ULL << 33)
+#define RTEMS_RFS_TRACE_SYMLINK_READ           (1ULL << 34)
+#define RTEMS_RFS_TRACE_FILE_OPEN              (1ULL << 35)
+#define RTEMS_RFS_TRACE_FILE_CLOSE             (1ULL << 36)
+#define RTEMS_RFS_TRACE_FILE_IO                (1ULL << 37)
+#define RTEMS_RFS_TRACE_FILE_SET               (1ULL << 38)
 
 /**
  * Call to check if this part is bring traced. If RTEMS_RFS_TRACE is defined to

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.c:1.2 rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.c:1.3
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.c:1.2	Fri Mar 26 23:04:40 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.c	Sun Oct 10 23:34:48 2010
@@ -78,6 +78,7 @@
     "inode-load",
     "inode-unload",
     "inode-create",
+    "inode-delete",
     "link",
     "unlink",
     "dir-lookup-ino",


 *ccj* (on branch rtems-4-10-branch):
2010-10-11      Chris Johns <chrisj at 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.

M 1.2346.2.70  cpukit/ChangeLog
M 1.4.2.3  cpukit/libfs/src/rfs/rtems-rfs-block.c
M 1.6.2.2  cpukit/libfs/src/rfs/rtems-rfs-dir.c
M 1.1.2.1  cpukit/libfs/src/rfs/rtems-rfs-trace.h
M 1.12.6.1  cpukit/libmisc/untar/untar.c

diff -u rtems/cpukit/ChangeLog:1.2346.2.69 rtems/cpukit/ChangeLog:1.2346.2.70
--- rtems/cpukit/ChangeLog:1.2346.2.69	Wed Sep 29 09:21:33 2010
+++ rtems/cpukit/ChangeLog	Sun Oct 10 23:40:07 2010
@@ -1,3 +1,29 @@
+2010-10-11      Chris Johns <chrisj at 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.
+	
 2010-09-29	Ralf Corsépius <ralf.corsepius at rtems.org>
 
 	* automake/compile.am: Remove non release-suitable warning flags.

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-block.c:1.4.2.2 rtems/cpukit/libfs/src/rfs/rtems-rfs-block.c:1.4.2.3
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-block.c:1.4.2.2	Thu Jun 17 17:10:20 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-block.c	Sun Oct 10 23:40:08 2010
@@ -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 @@
       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 -u rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.c:1.6.2.1 rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.c:1.6.2.2
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.c:1.6.2.1	Tue Jun 15 18:35:05 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-dir.c	Sun Oct 10 23:40:08 2010
@@ -127,6 +127,10 @@
     {
       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 @@
         {
           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 @@
   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_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 @@
       {
         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 @@
       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 @@
 
         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 @@
         break;
       }
       
-      entry  += elength;
-      offset += elength;
+      entry   += elength;
+      eoffset += elength;
     }
 
     if (rc == 0)

diff -u rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.h:1.1 rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.h:1.1.2.1
--- rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.h:1.1	Wed Feb 17 18:24:25 2010
+++ rtems/cpukit/libfs/src/rfs/rtems-rfs-trace.h	Sun Oct 10 23:40:08 2010
@@ -28,7 +28,7 @@
 /**
  * Is tracing enabled ?
  */
-#define RTEMS_RFS_TRACE 0
+#define RTEMS_RFS_TRACE 1
 
 /**
  * The type of the mask.

diff -u rtems/cpukit/libmisc/untar/untar.c:1.12 rtems/cpukit/libmisc/untar/untar.c:1.12.6.1
--- rtems/cpukit/libmisc/untar/untar.c:1.12	Wed Sep  5 18:46:36 2007
+++ rtems/cpukit/libmisc/untar/untar.c	Sun Oct 10 23:40:08 2010
@@ -39,7 +39,8 @@
  *   148      8 bytes  Header checksum (in octal ascii)
  *   156      1 bytes  Link flag
  *   157    100 bytes  Linkname ('\0' terminated, 99 maxmum length)
- *   257      8 bytes  Magic ("ustar  \0")
+ *   257      8 bytes  Magic PAX ("ustar\0" + 2 bytes padding)
+ *   257      8 bytes  Magic GNU tar ("ustar  \0")
  *   265     32 bytes  User name ('\0' terminated, 31 maxmum length)
  *   297     32 bytes  Group name ('\0' terminated, 31 maxmum length)
  *   329      8 bytes  Major device ID (in octal ascii)
@@ -143,7 +144,7 @@
       /* Read the header */
       bufr = &tar_ptr[ptr];
       ptr += 512;
-      if (strncmp(&bufr[257], "ustar  ", 7))
+      if (strncmp(&bufr[257], "ustar", 5))
       {
          retval = UNTAR_SUCCESSFUL;
          break;
@@ -253,7 +254,7 @@
 {
    int            fd;
    char           *bufr;
-   size_t         n;
+   ssize_t        n;
    char           fname[100];
    char           linkname[100];
    int            sum;
@@ -264,15 +265,17 @@
    unsigned long  size;
    unsigned char  linkflag;
 
-
    retval = UNTAR_SUCCESSFUL;
+
+   if ((fd = open(tar_name, O_RDONLY)) < 0) {
+       return UNTAR_FAIL;
+   }
+
    bufr = (char *)malloc(512);
-   if (bufr == NULL)
-   {
+   if (bufr == NULL) {
       return(UNTAR_FAIL);
    }
-
-   fd = open(tar_name, O_RDONLY);
+   
    while (1)
    {
       /* Read the header */
@@ -283,7 +286,7 @@
          break;
       }
 
-      if (strncmp(&bufr[257], "ustar  ", 7))
+      if (strncmp(&bufr[257], "ustar", 5))
       {
          break;
       }



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20101011/0849d40d/attachment.html>


More information about the vc mailing list