[rtems commit] Fill in the correct d_off in rtems_rfs_dir_read.

Chris Johns chrisj at rtems.org
Wed Apr 11 01:57:28 UTC 2018


Module:    rtems
Branch:    master
Commit:    d869c1824aa3239005a969c025a69c182d560e16
Changeset: http://git.rtems.org/rtems/commit/?id=d869c1824aa3239005a969c025a69c182d560e16

Author:    Fan Deng <enetor at gmail.com>
Date:      Tue Oct 10 16:32:41 2017 -0700

Fill in the correct d_off in rtems_rfs_dir_read.

rtems_rfs_dir_read searches the directory inode's entries list starting
at the specified offset until an empty entry (last entry) is encountered. It
fills in a struct dirent with the name of the entry, length of the name, ino of
the entry, and the absolute offset of the entry in the parent directory's
entries
list.

Unfortunately, the stock implementation of rtems_rfs_dir_read returns a
somewhat arbitrary offset (as dirent::d_off), while
rtems_rfs_dir_lookup_ino always returns the correct offset.

This change fixes that logic so the returned offset is accurate.

Tested by comparing the offset returned in dirent with the result of
rtems_rfs_dir_lookup_ino.

---

 cpukit/libfs/src/rfs/rtems-rfs-dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libfs/src/rfs/rtems-rfs-dir.c b/cpukit/libfs/src/rfs/rtems-rfs-dir.c
index 58bf305..ceaafc5 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-dir.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-dir.c
@@ -602,7 +602,7 @@ rtems_rfs_dir_read (rtems_rfs_file_system*  fs,
       }
 
       memset (dirent, 0, sizeof (struct dirent));
-      dirent->d_off = offset;
+      dirent->d_off = rtems_rfs_block_get_pos (fs, &map.bpos);
       dirent->d_reclen = sizeof (struct dirent);
 
       *length += elength;




More information about the vc mailing list