aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-07-22 14:06:47 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-09-08 20:49:58 +0200
commitf5e46e0444197deee2eca93d36a8ebeb1ffd7a17 (patch)
treec445d43cd13d5c2b365755744d1c3770b037f98e /include
parentd5e2c6a3146c20354ab11f1dae48ab755996fa96 (diff)
Add a hard link detecting/filtering directory iterator
The reason this is implemented separately, instead of roling it into the recursive iterator, is so that we can do additional filtering in between. For instance, we can rewrite the path and the hard link path will match up, or if we remove nodes from the hierarchy, we won't end up with a hard link pointing outside. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/sqfs/io.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/sqfs/io.h b/include/sqfs/io.h
index bf104f9..91343d6 100644
--- a/include/sqfs/io.h
+++ b/include/sqfs/io.h
@@ -653,6 +653,26 @@ SQFS_API int sqfs_dir_iterator_create_native(sqfs_dir_iterator_t **out,
SQFS_API int sqfs_dir_iterator_create_recursive(sqfs_dir_iterator_t **out,
sqfs_dir_iterator_t *base);
+/**
+ * @brief Construct a directory iterator that detects hard links
+ *
+ * @memberof sqfs_dir_iterator_t
+ *
+ * This creates a directory iterator implementation that returns entries from
+ * a wrapped iterator, but detects and filters hard links using the device and
+ * inode numbers from the entries. If an entry is observed with the same values
+ * than a previous entry, the entry is changed into a link with
+ * the @ref SQFS_DIR_ENTRY_FLAG_HARD_LINK flags set and asking for the link
+ * target returns the previously seen entry name.
+ *
+ * @param out Returns a pointer to the hard link filter iterator
+ * @param base The directory iterator to wrap internally
+ *
+ * @return Zero on success, an @ref SQFS_ERROR code on failure.
+ */
+SQFS_API int sqfs_hard_link_filter_create(sqfs_dir_iterator_t **out,
+ sqfs_dir_iterator_t *base);
+
#ifdef __cplusplus
}
#endif