LLFIO  v2.00
llfio_v2_xxx::algorithm::traverse_visitor Struct Reference

A visitor for the filesystem traversal algorithm. More...

#include "traverse.hpp"

Inheritance diagram for llfio_v2_xxx::algorithm::traverse_visitor:
llfio_v2_xxx::algorithm::contents_visitor llfio_v2_xxx::algorithm::reduce_visitor llfio_v2_xxx::algorithm::summarize_visitor llfio_v2_xxx::algorithm::compare_visitor

Public Member Functions

virtual result< directory_handledirectory_open_failed (void *data, result< void >::error_type &&error, const directory_handle &dirh, path_view leaf, size_t depth) noexcept
 Called when we failed to open a directory for enumeration. The default fails the traversal with that error. Return a default constructed instance to ignore the failure. More...
 
virtual result< bool > pre_enumeration (void *data, const directory_handle &dirh, size_t depth) noexcept
 Called to decide whether to enumerate a directory. More...
 
virtual result< void > post_enumeration (void *data, const directory_handle &dirh, directory_handle::buffers_type &contents, size_t depth) noexcept
 Called just after each directory enumeration. You can modify the results to affect the traversal, typically you would set the stat to default constructed to cause it to be ignored. You are guaranteed that at least stat.st_type is valid for every entry in contents, and items whose type is a directory will be enqueued after this call for later traversal. More...
 
virtual result< void > stack_updated (void *data, size_t dirs_processed, size_t known_dirs_remaining, size_t depth_processed, size_t known_depth_remaining) noexcept
 Called whenever the traversed stack of directory hierarchy is updated. This can act as an estimated progress indicator, or to give an accurate progress indicator by matching it against a previous traversal. More...
 
virtual result< size_t > finished (void *data, result< size_t > result) noexcept
 Called when a traversal finishes, whether due to success or failure. Always called from the original thread.
 

Detailed Description

A visitor for the filesystem traversal algorithm.

Note that at any time, returning a failure causes traverse() to exit as soon as possible with the same failure. Depth is how deep into the directory hierarchy we are, with zero being the base path handle being traversed.

Member Function Documentation

◆ directory_open_failed()

virtual result<directory_handle> llfio_v2_xxx::algorithm::traverse_visitor::directory_open_failed ( void *  data,
result< void >::error_type &&  error,
const directory_handle dirh,
path_view  leaf,
size_t  depth 
)
inlinevirtualnoexcept

Called when we failed to open a directory for enumeration. The default fails the traversal with that error. Return a default constructed instance to ignore the failure.

Note
May be called from multiple kernel threads concurrently.

Reimplemented in llfio_v2_xxx::algorithm::summarize_visitor, and llfio_v2_xxx::algorithm::reduce_visitor.

54  {
55  (void) data;
56  (void) dirh;
57  (void) leaf;
58  (void) depth;
59  return failure(std::move(error));
60  }

◆ post_enumeration()

virtual result<void> llfio_v2_xxx::algorithm::traverse_visitor::post_enumeration ( void *  data,
const directory_handle dirh,
directory_handle::buffers_type contents,
size_t  depth 
)
inlinevirtualnoexcept

Called just after each directory enumeration. You can modify the results to affect the traversal, typically you would set the stat to default constructed to cause it to be ignored. You are guaranteed that at least stat.st_type is valid for every entry in contents, and items whose type is a directory will be enqueued after this call for later traversal.

Note
May be called from multiple kernel threads concurrently.

Reimplemented in llfio_v2_xxx::algorithm::summarize_visitor, llfio_v2_xxx::algorithm::reduce_visitor, llfio_v2_xxx::algorithm::compare_visitor, and llfio_v2_xxx::algorithm::contents_visitor.

92  {
93  (void) data;
94  (void) dirh;
95  (void) contents;
96  (void) depth;
97  return success();
98  }
result< contents_visitor::contents_type > contents(const path_handle &dirh, contents_visitor *visitor=nullptr, size_t threads=0, bool force_slow_path=false) noexcept
Calculate the contents of everything within and under dirh. What is returned is unordered.
Definition: contents.hpp:223

◆ pre_enumeration()

virtual result<bool> llfio_v2_xxx::algorithm::traverse_visitor::pre_enumeration ( void *  data,
const directory_handle dirh,
size_t  depth 
)
inlinevirtualnoexcept

Called to decide whether to enumerate a directory.

Note that it is more efficient to ignore the directory entry in post_enumeration() than to ignore it here, as a handle is opened for the directory before this callback. Equally, if you need that handle to inspect the directory e.g. to check if one is entering a different filesystem from the root, here is best.

The default returns true.

Note
May be called from multiple kernel threads concurrently.
75  {
76  (void) data;
77  (void) dirh;
78  (void) depth;
79  return true;
80  }

◆ stack_updated()

virtual result<void> llfio_v2_xxx::algorithm::traverse_visitor::stack_updated ( void *  data,
size_t  dirs_processed,
size_t  known_dirs_remaining,
size_t  depth_processed,
size_t  known_depth_remaining 
)
inlinevirtualnoexcept

Called whenever the traversed stack of directory hierarchy is updated. This can act as an estimated progress indicator, or to give an accurate progress indicator by matching it against a previous traversal.

Parameters
dataThe third party data pointer passed to traverse().
dirs_processedThe total number of directories traversed so far.
known_dirs_remainingThe currently known number of directories awaiting traversal.
depth_processedHow many levels deep we have already completely traversed.
known_depth_remainingThe currently known number of levels we shall traverse.
Note
May be called from multiple kernel threads concurrently.
116  {
117  (void) data;
118  (void) dirs_processed;
119  (void) known_dirs_remaining;
120  (void) depth_processed;
121  (void) known_depth_remaining;
122  return success();
123  }

The documentation for this struct was generated from the following file: