class VnodeIterator
Defined at line 103 of file ../../src/storage/minfs/vnode_mapper.h
Iterator that keeps track of block pointers for a given file block. Depending on the file
block, there can be up to three levels of block pointers.
Example use, reading a range of blocks:
VnodeMapper mapper(vnode);
VnodeIterator iterator;
zx_status_t status = iterator.Init(
&mapper
, /*transaction=*/nullptr, start_block);
if (status != ZX_OK)
return status;
while (block_count > 0) {
blk_t block = iterator.Blk();
uint64_t count = iterator.GetContiguousBlockCount(block_count);
if (block) {
status = ReadBlocks(buffer, iterator.file_block(), block, count);
if (status != ZX_OK)
return status;
} else {
ZeroBlocks(buffer, iterator.file_block(), count);
}
status = iterator.Advance(count);
if (status != ZX_OK)
return status;
block_count -= count;
}
Public Methods
void VnodeIterator ()
Users must call Init before the iterator is usable. Behaviour is undefined if any methods,
except the destructor, are called before Init has successfully returned.
Defined at line 107 of file ../../src/storage/minfs/vnode_mapper.h
void VnodeIterator (VnodeIterator && )
Movable but not copyable.
Defined at line 110 of file ../../src/storage/minfs/vnode_mapper.h
VnodeIterator & operator= (VnodeIterator && )
Defined at line 111 of file ../../src/storage/minfs/vnode_mapper.h
uint64_t file_block ()
Returns the file block that the iterator is currently located at.
Defined at line 120 of file ../../src/storage/minfs/vnode_mapper.h
blk_t Blk ()
Returns the target block as a blk_t. Zero is special and means the block is unmapped/sparse.
Defined at line 123 of file ../../src/storage/minfs/vnode_mapper.h
zx::result<> SetBlk (blk_t block)
Sets the target block. The iterator will need to be flushed after calling this (by calling the
Flush method).
Defined at line 129 of file ../../src/storage/minfs/vnode_mapper.h
zx::result<> Init (VnodeMapper * mapper, PendingWork * transaction, uint64_t file_block)
-- VnodeIterator --
Defined at line 271 of file ../../src/storage/minfs/vnode_mapper.cc
uint64_t GetContiguousBlockCount (uint64_t max_blocks)
Returns the length in blocks of a contiguous range at most |max_blocks|. For
efficiency/simplicity reasons, it might return fewer than there actually are.
Defined at line 371 of file ../../src/storage/minfs/vnode_mapper.cc
zx::result<> Flush ()
Flushes any changes that may have been made. This is a no-op if there are no changes or
this iterator is read-only.
Defined at line 459 of file ../../src/storage/minfs/vnode_mapper.cc
zx::result<> Advance (uint64_t advance)
Advances the iterator by |advance| blocks. This will also flush the iterator first if
necessary.
Defined at line 470 of file ../../src/storage/minfs/vnode_mapper.cc