GNU Info

Info Node: (libext2fs.info)Iterating over blocks in an inode

(libext2fs.info)Iterating over blocks in an inode


Next: Inode Convenience Functions Prev: Iterating over inodes in a filesystem Up: Inode Functions
Enter node , (file) or (file)node

Iterating over blocks in an inode
---------------------------------

 - Function: errcode_t ext2fs_block_iterate (ext2_filsys FS,
     ext2_ino_t INO, int FLAGS, char *block_buf, int
     (*func)(ext2_filsys FS, blk_t *BLOCKNR, int BLOCKCNT, void
     *PRIVATE), void *PRIVATE)

     Iterate over all of the blocks in inode number INO in filesystem
     FS, by calling the function FUNC for each block in the inode.  The
     BLOCK_BUF parameter should either be NULL, or if the
     `ext2fs_block_iterate' function is called repeatedly, the overhead
     of allocating and freeing scratch memory can be avoided by passing
     a pointer to a scratch buffer which must be at least as big as
     three times the filesystem's blocksize.

     The FLAGS parameter controls how the iterator will function:

    `BLOCK_FLAG_HOLE'
          This flag indiciates that the interator function should be
          called on blocks where the block number is zero (also known
          as "holes".)  It is also known as BLOCK_FLAG_APPEND, since it
          is also used by functions such as ext2fs_expand_dir() to add
          a new block to an inode.

    `BLOCK_FLAG_TRAVERSE'
          This flag indicates that the iterator function for the
          indirect, doubly indirect, etc. blocks should be called after
          all of the blocks containined in the indirect blocks are
          processed.  This is useful if you are going to be
          deallocating blocks from an inode.

    `BLOCK_FLAG_DATA_ONLY'
          This flag indicates that the iterator function should be
          called for data blocks only.

     The callback function FUNC is called with a number of parameters;
     the FS and PRIVATE parameters are self-explanatory, and their
     values are taken from the parameters to `ext2fs_block_iterate'.
     (The PRIVATE data structure is generally used by callers to
     `ext2fs_block_iterate' so that some private data structure can be
     passed to the callback function.  The BLOCKCNT parameter, if
     non-negative, indicates the logical block number of a data block
     in the inode.  If BLOCKCNT is less than zero, then FUNC was called
     on a metadata block, and BLOCKCNT will be one of the following
     values:  BLOCK_COUNT_IND, BLOCK_COUNT_DIND, BLOCK_COUNT_TIND, or
     BLOCK_COUNT_TRANSLATOR.  The BLOCKNR is a pointer to the inode or
     indirect block entry listing physical block number.  The callback
     function may modify the physical block number, if it returns the
     BLOCK_CHANGED flag.

     The callback function FUNC returns a result code which is composed
     of the logical OR of the following flags:

    `BLOCK_CHANGED'
          This flag indicates that callback function has modified the
          physical block number pointed to by BLOCKNR.

    `BLOCK_ABORT'
          This flag requests that `ext2fs_block_iterate' to stop
          immediately and return to the caller.


 - Function: errcode_t ext2fs_block_iterate2 (ext2_filsys FS,
          ext2_ino_t INO, int FLAGS, char *BLOCK_buf, int
          (*func)(ext2_filsys FS, blk_t *BLOCKNR, e2_blkcnt_t BLOCKCNT,
          blk_t REF_BLK, int REF_OFFSET, void *PRIVATE), void *PRIVATE)
     This function is much like `ext2fs_block_iterate2', except that the
     BLOCKCNT type is a 64-bit signed quantity, to support larger
     files, and the addition of the REF_BLK and REF_OFFSET arguments
     passed to the callback function, which identify the location of
     the physical block pointed to by pointer BLOCKNR.  If REF_BLK is
     zero, then REF_OFFSET contains the offset into the `i_blocks'
     array.  If REF_BLK is non-zero, then the physical block location
     is contained inside an indirect block group, and REF_OFFSET
     contains the offset into the indirect block.



automatically generated by info2www version 1.2.2.9