[Libguestfs] [PATCH] filesystem_walk: fixed root inode listing

Matteo Cafasso noxdafox at gmail.com
Wed Aug 24 20:42:05 UTC 2016


With the current implementation, the root inode of the given partition
is ignored.

The root inode is now reported. Its name will be a single dot '.'
reproducing the TSK API.

Signed-off-by: Matteo Cafasso <noxdafox at gmail.com>
---
 daemon/tsk.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/daemon/tsk.c b/daemon/tsk.c
index dd368d7..4a0517b 100644
--- a/daemon/tsk.c
+++ b/daemon/tsk.c
@@ -114,9 +114,12 @@ fswalk_callback (TSK_FS_FILE *fsfile, const char *path, void *data)
   struct guestfs_int_tsk_dirent dirent;
 
   /* Ignore ./ and ../ */
-  ret = TSK_FS_ISDOT (fsfile->name->name);
-  if (ret != 0)
-    return TSK_WALK_CONT;
+  if (TSK_FS_ISDOT (fsfile->name->name)) {
+    /* Root is represented as . */
+    if (fsfile->fs_info->root_inum != fsfile->name->meta_addr ||
+        strcmp (fsfile->name->name, "."))
+      return TSK_WALK_CONT;
+  }
 
   /* Build the full relative path of the entry */
   ret = asprintf (&fname, "%s%s", path, fsfile->name->name);
-- 
2.9.3




More information about the Libguestfs mailing list