From 020698f3a92195eb371e806a0b3ed0649565046f Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 9 Apr 2022 23:20:09 +0200 Subject: Add support for '.' and '..' entries in sqfs_dir_reader_t Two flags are added to the dir reader API, one for the create function that the dir reader should report those entries and one to the open function to suppress that if it was enabled. To implement the feature, a mapping of visited directory inodes is maintained internally, that mapps inode numbers to inode references. When opening a directory, state is maintained to generate the fake entries for '.' and '..'. Since all the other functions are based on the open/read/rewind API, no alterations need to be made. The tree scan function is modified, to use the suppress flag, so it does not accidentally catch those entries. Signed-off-by: David Oberhollenzer --- extras/browse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'extras') diff --git a/extras/browse.c b/extras/browse.c index 2899ba5..cc31105 100644 --- a/extras/browse.c +++ b/extras/browse.c @@ -543,7 +543,8 @@ int main(int argc, char **argv) } /* create a directory reader and get the root inode */ - dr = sqfs_dir_reader_create(&super, cmp, file, 0); + dr = sqfs_dir_reader_create(&super, cmp, file, + SQFS_DIR_READER_DOT_ENTRIES); if (dr == NULL) { fprintf(stderr, "%s: error creating directory reader.\n", argv[1]); -- cgit v1.2.3