aboutsummaryrefslogtreecommitdiff
path: root/include/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-09-15 16:29:10 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-09-15 21:48:47 +0200
commitf0479f3acd90a46f8354277360c96763fa74ef65 (patch)
treeecd6e52e0a7482e6ad7e3f9153deff9ce3da2c46 /include/sqfs
parent2f172b69bda25d26790538cea7a15044f8207a7b (diff)
libsqfs: dir reader: encapsulate internal state in a separate object
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs')
-rw-r--r--include/sqfs/dir_reader.h52
-rw-r--r--include/sqfs/predef.h1
2 files changed, 53 insertions, 0 deletions
diff --git a/include/sqfs/dir_reader.h b/include/sqfs/dir_reader.h
index abd49bd..eb90b7a 100644
--- a/include/sqfs/dir_reader.h
+++ b/include/sqfs/dir_reader.h
@@ -21,6 +21,7 @@
#define SQFS_DIR_READER_H
#include "sqfs/predef.h"
+#include "sqfs/meta_reader.h"
/**
* @file dir_reader.h
@@ -97,6 +98,57 @@ typedef enum {
SQFS_DIR_OPEN_ALL_FLAGS = 0x00000001,
} SQFS_DIR_OPEN_FLAGS;
+/**
+ * @brief sqfs_dir_reader_state_t
+ *
+ * @extends sqfs_readdir_state_t
+ *
+ * A meta data cursor for reading a directory, but with additional data
+ * for the @ref sqfs_dir_reader_t, e.g. for resolving inodes.
+ */
+struct sqfs_dir_reader_state_t {
+ /**
+ * @brief Base cursor structure for the directory meta data
+ */
+ sqfs_readdir_state_t cursor;
+
+ /**
+ * @brief An inode reference to the parent inode of the directory
+ *
+ * This is only available if the reader was created with
+ * the @ref SQFS_DIR_READER_DOT_ENTRIES flag and the behavior was
+ * not disabled when opening the directory.
+ */
+ sqfs_u64 parent_ref;
+
+ /**
+ * @brief A reference to the inode of the directory itself
+ *
+ * This is only available if the reader was created with
+ * the @ref SQFS_DIR_READER_DOT_ENTRIES flag and the behavior was
+ * not disabled when opening the directory.
+ */
+ sqfs_u64 cur_ref;
+
+ /**
+ * @brief A reference to the current entries inode
+ *
+ * After a successfull call to @ref sqfs_dir_reader_read, this contains
+ * a reference to the inode coresponding to the returned entry.
+ */
+ sqfs_u64 ent_ref;
+
+ /**
+ * @brief An opaque, internal state value
+ */
+ sqfs_u8 state;
+
+ /**
+ * @brief A backup of `state` to reset the state if requested
+ */
+ sqfs_u8 start_state;
+};
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
index fbc6519..8e7c1b8 100644
--- a/include/sqfs/predef.h
+++ b/include/sqfs/predef.h
@@ -80,6 +80,7 @@ typedef struct sqfs_compressor_config_t sqfs_compressor_config_t;
typedef struct sqfs_compressor_t sqfs_compressor_t;
typedef struct sqfs_dir_writer_t sqfs_dir_writer_t;
typedef struct sqfs_dir_reader_t sqfs_dir_reader_t;
+typedef struct sqfs_dir_reader_state_t sqfs_dir_reader_state_t;
typedef struct sqfs_id_table_t sqfs_id_table_t;
typedef struct sqfs_meta_reader_t sqfs_meta_reader_t;
typedef struct sqfs_meta_writer_t sqfs_meta_writer_t;