Home | History | Annotate | Download | only in doc
      1 \input texinfo    @c -*-texinfo-*-
      2 @c %**start of header
      3 @setfilename libext2fs.info
      4 @settitle The EXT2FS Library (version 1.40.8)
      5 @synindex tp fn
      6 @comment %**end of header
      7 
      8 @ifinfo
      9 @dircategory Development
     10 @format
     11 START-INFO-DIR-ENTRY
     12 * libext2fs: (libext2fs.info).                  The EXT2FS library.
     13 END-INFO-DIR-ENTRY
     14 @end format
     15 @end ifinfo
     16 
     17 @c smallbook
     18 
     19 @iftex
     20 @finalout
     21 @end iftex
     22 
     23 @c Note: the edition number is listed in *three* places; please update
     24 @c all three.  Also, update the month and year where appropriate.
     25 
     26 @c ==> Update edition number for settitle and subtitle, and in the
     27 @c ==> following paragraph; update date, too.
     28 
     29 
     30 @ifinfo
     31 This file documents the ext2fs library, a library for manipulating the
     32 ext2 filesystem.
     33 
     34 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Theodore Ts'o
     35 
     36 Permission is granted to make and distribute verbatim copies of
     37 this manual provided the copyright notice and this permission notice
     38 are preserved on all copies.
     39 
     40 @ignore
     41 Permission is granted to process this file through TeX and print the
     42 results, provided the printed document carries copying permission
     43 notice identical to this one except for the removal of this paragraph
     44 (this paragraph not being relevant to the printed manual).
     45 
     46 @end ignore
     47 Permission is granted to copy and distribute modified versions of this
     48 manual under the conditions for verbatim copying, provided that the entire
     49 resulting derived work is distributed under the terms of a permission
     50 notice identical to this one.
     51 
     52 Permission is granted to copy and distribute translations of this manual
     53 into another language, under the above conditions for modified versions,
     54 except that this permission notice may be stated in a translation approved
     55 by the author.
     56 @end ifinfo
     57 
     58 @setchapternewpage on
     59 @titlepage
     60 @c  use the new format for titles
     61 
     62 @title The EXT2FS Library
     63 @subtitle The EXT2FS Library
     64 @subtitle Version 1.40.8
     65 @subtitle March 2008
     66 
     67 @author by Theodore Ts'o
     68 
     69 @c Include the Distribution inside the titlepage so
     70 @c that headings are turned off.
     71 
     72 @tex
     73 \global\parindent=0pt
     74 \global\parskip=8pt
     75 \global\baselineskip=13pt
     76 @end tex
     77 
     78 @page
     79 @vskip 0pt plus 1filll
     80 Copyright @copyright{} 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
     81 2005 Theodore Ts'o
     82 
     83 @sp 2
     84 
     85 Permission is granted to make and distribute verbatim copies of
     86 this manual provided the copyright notice and this permission notice
     87 are preserved on all copies.
     88 
     89 Permission is granted to copy and distribute modified versions of this
     90 manual under the conditions for verbatim copying, provided that the entire
     91 resulting derived work is distributed under the terms of a permission
     92 notice identical to this one.
     93 
     94 Permission is granted to copy and distribute translations of this manual
     95 into another language, under the above conditions for modified versions,
     96 except that this permission notice may be stated in a translation approved
     97 by the Foundation.
     98 @end titlepage
     99 @headings double
    100 
    101 @ifinfo
    102 @node Top, Introduction to the EXT2FS Library, (dir), (dir)
    103 
    104 @top The EXT2FS Library
    105 
    106 This manual documents the EXT2FS Library, version 1.40.8.
    107 
    108 @end ifinfo
    109 
    110 @menu
    111 * Introduction to the EXT2FS Library::  
    112 * EXT2FS Library Functions::    
    113 * Concept Index::               
    114 * Function Index::              
    115 @end menu
    116 
    117 @c ----------------------------------------------------------------------
    118 
    119 @node Introduction to the EXT2FS Library, EXT2FS Library Functions, Top, Top
    120 @comment  node-name,  next,  previous,  up
    121 @chapter Introduction to the EXT2FS Library
    122 
    123 The EXT2FS library is designed to allow user-level programs to
    124 manipulate an ext2 filesystem.
    125 
    126 @node EXT2FS Library Functions, Concept Index, Introduction to the EXT2FS Library, Top
    127 @comment  node-name,  next,  previous,  up
    128 @chapter EXT2FS Library Functions
    129 
    130 @menu
    131 * Filesystem-level functions::  
    132 * Inode Functions::             
    133 * Directory functions::         
    134 * Bitmap Functions::            
    135 * EXT2 data abstractions::      
    136 * Byte-swapping functions::     
    137 * Other functions::             
    138 @end menu
    139 
    140 @c ----------------------------------------------------------------------
    141 
    142 @node Filesystem-level functions, Inode Functions, EXT2FS Library Functions, EXT2FS Library Functions
    143 @comment  node-name,  next,  previous,  up
    144 @section Filesystem-level functions
    145 
    146 The following functions operate on a filesystem handle.  Most EXT2FS
    147 Library functions require a filesystem handle as their first argument.
    148 There are two functions which create a filesystem handle,
    149 @code{ext2fs_open} and @code{ext2fs_initialize}.  
    150 
    151 The filesystem can also be closed using @code{ext2fs_close}, and any
    152 changes to the superblock and group descripts can be written out to disk
    153 using @code{ext2fs_flush}.
    154 
    155 @menu
    156 * Opening an ext2 filesystem::  
    157 * Closing and flushing out changes::  
    158 * Initializing a filesystem::   
    159 * Filesystem flag functions::   
    160 @end menu
    161 
    162 @c ----------------------------------------------------------------------
    163 
    164 @node Opening an ext2 filesystem, Closing and flushing out changes, Filesystem-level functions, Filesystem-level functions
    165 @comment  node-name,  next,  previous,  up
    166 @subsection Opening an ext2 filesystem
    167 
    168 Most libext2fs functions take a filesystem handle of type
    169 @code{ext2_filsys}.  A filesystem handle is created either by opening
    170 an existing function using @code{ext2fs_open}, or by initializing a new
    171 filesystem using @code{ext2fs_initialize}.
    172 
    173 @deftypefun errcode_t ext2fs_open (const char *@var{name}, int @var{flags}, int @var{superblock}, int @var{block_size}, io_manager @var{manager}, ext2_filsys *@var{ret_fs})
    174 
    175 Opens a filesystem named @var{name}, using the the io_manager
    176 @var{manager} to define the input/output routines needed to read and
    177 write the filesystem.  In the case of the @code{unix_io} io_manager,
    178 @var{name} is interpreted as the Unix filename of the filesystem image.
    179 This is often a device file, such as @file{/dev/hda1}.
    180 
    181 The @var{superblock} parameter specifies the block number of the
    182 superblock which should be used when opening the filesystem.
    183 If @var{superblock} is zero, @code{ext2fs_open} will use the primary
    184 superblock located at offset 1024 bytes from the start of the filesystem
    185 image.
    186 
    187 The @var{block_size} parameter specifies the block size used by the
    188 filesystem.  Normally this is determined automatically from the
    189 filesystem uperblock.  If @var{block_size} is non-zero, it must match
    190 the block size found in the superblock, or the error
    191 @code{EXT2_ET_UNEXPECTED_BLOCK_SIZE} will be returned.  The
    192 @var{block_size} parameter is also used to help fund the superblock when
    193 @var{superblock} is non-zero.
    194 
    195 The @var{flags} argument contains a bitmask of flags which control how
    196 the filesystem open should be handled.
    197 
    198 @table @code
    199 @item EXT2_FLAG_RW
    200 Open the filesystem for reading and writing.  Without this flag, the
    201 filesystem is opened for reading only.
    202 
    203 @item EXT2_FLAG_FORCE
    204 Open the filesystem regardless of the feature sets listed in the
    205 superblock.
    206 
    207 @end table
    208 @end deftypefun
    209 
    210 @c ----------------------------------------------------------------------
    211 
    212 @node Closing and flushing out changes, Initializing a filesystem, Opening an ext2 filesystem, Filesystem-level functions
    213 @comment  node-name,  next,  previous,  up
    214 @subsection Closing and flushing out changes
    215 
    216 @deftypefun errcode_t ext2fs_flush (ext2_filsys @var{fs})
    217 
    218 Write any changes to the high-level filesystem data structures in the
    219 @var{fs} filesystem.  The following data structures will be written out:
    220 
    221 @itemize @bullet
    222 @item The filesystem superblock
    223 @item The filesystem group descriptors
    224 @item The filesystem bitmaps, if read in via @code{ext2fs_read_bitmaps}.
    225 @end itemize
    226 
    227 @end deftypefun
    228 
    229 @deftypefun void ext2fs_free (ext2_filsys @var{fs})
    230 
    231 Close the io_manager abstraction for @var{fs} and release all memory
    232 associated with the filesystem handle.
    233 @end deftypefun
    234 
    235 @deftypefun errcode_t ext2fs_close (ext2_filsys @var{fs})
    236 
    237 Flush out any changes to the high-level filesystem data structures using
    238 @code{ext2fs_flush} if the filesystem is marked dirty; then close and
    239 free the filesystem using @code{ext2fs_free}.
    240 
    241 @end deftypefun
    242 
    243 @c ----------------------------------------------------------------------
    244 
    245 @node Initializing a filesystem, Filesystem flag functions, Closing and flushing out changes, Filesystem-level functions
    246 @comment  node-name,  next,  previous,  up
    247 @subsection Initializing a filesystem
    248 
    249 An ext2 filesystem is initializing by the @code{mke2fs} program.  The
    250 two functions described here, @code{ext2fs_initialize} and
    251 @code{ext2fs_allocate_tables} do much of the initial work for setting up
    252 a filesystem.  However, they don't do the whole job.  @code{mke2fs}
    253 calls @code{ext2fs_initialize} to set up the filesystem superblock, and
    254 calls @code{ext2fs_allocate_tables} to allocate space for the inode
    255 table, and the inode and block bitmaps.  In addition, @code{mke2fs} must
    256 also initialize the inode tables by clearing them with zeros, create the
    257 root and lost+found directories, and reserve the reserved inodes.
    258 
    259 @deftypefun errcode_t ext2fs_initialize (const char *@var{name}, int @var{flags}, struct ext2_super_block *@var{param}, io_manager @var{manager}, ext2_filsys *@var{ret_fs})
    260 
    261 This function is used by the @code{mke2fs} program to initialize a
    262 filesystem.  The @code{ext2fs_initialize} function creates a filesystem
    263 handle which is returned in @var{ret_fs} that has been properly setup
    264 for a filesystem to be located in @var{name}, using the io_manager
    265 @var{manager}.  The prototype superblock in @var{param} is used to
    266 supply parameters such as the number of blocks in the filesystem, the
    267 block size, etc.  
    268 
    269 The @code{ext2fs_initialize} function does not actually do any I/O; that
    270 will be done when the application program calls @code{ext2fs_close} or
    271 @code{ext2fs_flush}.  Also, this function only initializes the
    272 superblock and group descriptor structures.  It does not create the
    273 inode table or the root directory.  This must be done by the calling
    274 application, such as @code{mke2fs}.
    275 
    276 The following values may be set in the @var{param} prototype superblock;
    277 if a value of 0 is found in a field, @code{ext2fs_initialize} will use a
    278 default value.  The calling application should zero out the prototype
    279 entire superblock, and then fill in any appropriate values.
    280 
    281 @table @code
    282 
    283 @item s_blocks_count
    284 The number of blocks in the filesystem.  This parameter is mandatory and
    285 must be set by the calling application.
    286 
    287 @item s_inodes_count
    288 The number of inodes in the filesystem.  The
    289 default value is determined by calculating the size of the filesystem,
    290 and creating one inode for every 4096 bytes.
    291 
    292 @item s_r_blocks_count
    293 The number of blocks which should be reserved for the superuser.  The
    294 default value is zero blocks.
    295 
    296 @item s_log_block_size
    297 The blocksize of the filesystem.  Valid values are 0 (1024 bytes), 1
    298 (2048 bytes), or 2 (4096 bytes).  The default blocksize is 1024 bytes.
    299 
    300 @item s_log_frag_size
    301 The size of fragments.  The ext2 filesystem does not support fragments
    302 (and may never support fragments).  Currently this field must be the
    303 same as @code{s_log_block_size}.
    304 
    305 @item s_first_data_block
    306 The first data block for the filesystem.  For filesystem with a
    307 blocksize of 1024 bytes, this value must be at least 1, since the
    308 superblock is located in block number 1.  For filesystems with larger
    309 blocksizes, the superblock is still located at an offset of 1024 bytes,
    310 so the superblock is located in block number 0.  By default, this value
    311 is set to 1 for filesystems with a block size of 1024 bytes, or 0 for
    312 filesystems with larger blocksizes.
    313 
    314 @item s_max_mnt_count
    315 This field defines the number of times that the filesystem can be
    316 mounted before it should be checked using @code{e2fsck}.  When
    317 @code{e2fsck} is run without the @samp{-f} option, @code{e2fsck} will
    318 skip the filesystem check if the number of times that the filesystem has
    319 been mounted is less than @code{s_max_mnt_count} and if the interval
    320 between the last time a filesystem check was performed and the current
    321 time is less than @code{s_checkinterval} (see below).  The default value
    322 of @code{s_max_mnt_count} is 20.
    323 
    324 @item s_checkinterval
    325 This field defines the minimal interval between filesystem checks.  See
    326 the previous entry for a discussion of how this field is used by
    327 @code{e2fsck}.  The default value of this field is 180 days (six
    328 months).
    329 
    330 @item s_errors
    331 This field defines the behavior which should be used by the kernel of
    332 errors are detected in the filesystem.  Possible values include:
    333 
    334 @table @samp
    335 @item EXT2_ERRORS_CONTINUE
    336 Continue execution when errors are detected.
    337 
    338 @item EXT2_ERRORS_RO
    339 Remount the filesystem read-only.
    340 
    341 @item EXT2_ERRORS_PANIC
    342 Panic.
    343 
    344 @end table
    345 
    346 The default behavior is @samp{EXT2_ERRORS_CONTINUE}.
    347 
    348 @end table
    349 
    350 @end deftypefun
    351 
    352 @deftypefun errcode_t ext2fs_allocate_tables (ext2_filsys @var{fs})
    353 Allocate space for the inode table and the block and inode bitmaps.  The
    354 inode tables and block and inode bitmaps aren't actually initialized;
    355 this function just allocates the space for them.
    356 @end deftypefun
    357 
    358 @c ----------------------------------------------------------------------
    359 
    360 @node Filesystem flag functions,  , Initializing a filesystem, Filesystem-level functions
    361 @comment  node-name,  next,  previous,  up
    362 @subsection Filesystem flag functions
    363 
    364 The filesystem handle has a number of flags which can be manipulated
    365 using the following function.  Some of these flags affect how the
    366 libext2fs filesystem behaves; others are provided solely for the
    367 application's convenience.
    368 
    369 @deftypefun void ext2fs_mark_changed (ext2_filsys @var{fs})
    370 @deftypefunx int ext2fs_test_changed (ext2_filsys @var{fs})
    371 This flag indicates whether or not the filesystem has been changed. 
    372 It is not used by the ext2fs library.
    373 @end deftypefun
    374 
    375 @deftypefun void ext2fs_mark_super_dirty (ext2_filsys @var{fs})
    376 Mark the filesystem @var{fs} as being dirty; this will cause
    377 the superblock information to be flushed out when @code{ext2fs_close} is
    378 called.  @code{ext2fs_mark_super_dirty} will also set the filesystem 
    379 changed flag.  The dirty flag is automatically cleared by
    380 @code{ext2fs_flush} when the superblock is written to disk.
    381 @end deftypefun
    382 
    383 @deftypefun void ext2fs_mark_valid (ext2_filsys @var{fs})
    384 @deftypefunx void ext2fs_unmark_valid (ext2_filsys @var{fs})
    385 @deftypefunx int ext2fs_test_valid (ext2_filsys @var{fs})
    386 This flag indicates whether or not the filesystem is free of errors.
    387 It is not used by libext2fs, and is solely for the application's 
    388 convenience.
    389 @end deftypefun
    390 
    391 @deftypefun void ext2fs_mark_ib_dirty (ext2_filsys @var{fs})
    392 @deftypefunx void ext2fs_mark_bb_dirty (ext2_filsys @var{fs})
    393 @deftypefunx int ext2fs_test_ib_dirty (ext2_filsys @var{fs})
    394 @deftypefunx int ext2fs_test_bb_dirty (ext2_filsys @var{fs})
    395 These flags indicate whether or not the inode or block bitmaps have been
    396 modified.   If the flag is set, it will cause the appropriate bitmap
    397 to be written when the filesystem is closed or flushed.
    398 @end deftypefun
    399 
    400 
    401 
    402 @c ----------------------------------------------------------------------
    403 
    404 @node Inode Functions, Directory functions, Filesystem-level functions, EXT2FS Library Functions
    405 @comment  node-name,  next,  previous,  up
    406 @section Inode Functions
    407 
    408 @menu
    409 * Reading and writing inodes::  
    410 * Iterating over inodes in a filesystem::  
    411 * Iterating over blocks in an inode::  
    412 * Inode Convenience Functions::  
    413 @end menu
    414 
    415 @c ----------------------------------------------------------------------
    416 
    417 @node Reading and writing inodes, Iterating over inodes in a filesystem, Inode Functions, Inode Functions
    418 @comment  node-name,  next,  previous,  up
    419 @subsection Reading and writing inodes
    420 
    421 @deftypefun errcode_t ext2fs_read_inode (ext2_filsys @var{fs}, ext2_ino_t @var{ino}, struct ext2_inode *@var{inode})
    422 Read the inode number @var{ino} into @var{inode}.
    423 @end deftypefun
    424 
    425 @deftypefun errcode_t ext2fs_write_inode (ext2_filsys @var{fs}, ext2_ino_t @var{ino}, struct ext2_inode *@var{inode})
    426 Write @var{inode} to inode @var{ino}.
    427 @end deftypefun
    428 
    429 
    430 @c ----------------------------------------------------------------------
    431 
    432 @node Iterating over inodes in a filesystem, Iterating over blocks in an inode, Reading and writing inodes, Inode Functions
    433 @comment  node-name,  next,  previous,  up
    434 @subsection Iterating over inodes in a filesystem
    435 
    436 The inode_scan abstraction is useful for iterating over all the inodes
    437 in a filesystem.  
    438 
    439 @deftypefun errcode_t ext2fs_open_inode_scan (ext2_filsys @var{fs}, int @var{buffer_blocks}, ext2_inode_scan *@var{scan})
    440 Initialize the iteration variable @var{scan}.  This variable is used by
    441 @code{ext2fs_get_next_inode}.  The @var{buffer_blocks} parameter
    442 controls how many blocks of the inode table are read in at a time.  A
    443 large number of blocks requires more memory, but reduces the overhead in
    444 seeking and reading from the disk.  If @var{buffer_blocks} is zero, a
    445 suitable default value will be used.
    446 @end deftypefun
    447 
    448 @deftypefun void ext2fs_close_inode_scan (ext2_inode_scan @var{scan})
    449 Release the memory associated with @var{scan} and invalidate it.
    450 @end deftypefun
    451 
    452 @deftypefun errcode_t ext2fs_get_next_inode (ext2_inode_scan @var{scan}, ext2_ino_t *@var{ino}, struct ext2_inode *@var{inode})
    453 
    454 This function returns the next inode from the filesystem; the inode
    455 number of the inode is stored in @var{ino}, and the inode is stored in
    456 @var{inode}.  
    457 
    458 If the inode is located in a block that has been marked as bad,
    459 @code{ext2fs_get_next_inode} will return the error
    460 @code{EXT2_ET_BAD_BLOCK_IN_INODE_TABLE}.
    461 @end deftypefun
    462 
    463 @deftypefun errcode_t ext2fs_inode_scan_goto_blockgroup (ext2_inode_scan @var{scan}, int @var{group})
    464 Start the inode scan at a particular ext2 blockgroup, @var{group}.  
    465 This function may be safely called at any time while @var{scan} is valid.
    466 @end deftypefun
    467 
    468 @deftypefun void ext2fs_set_inode_callback (ext2_inode_scan @var{scan}, errcode_t (*done_group)(ext2_filsys @var{fs}, ext2_inode_scan @var{scan}, dgrp_t @var{group}, void * @var{private}), void *@var{done_group_data})
    469 Register a callback function which will be called by
    470 @code{ext2_get_next_inode} when all of the inodes in a block group have
    471 been processed.
    472 @end deftypefun
    473 
    474 @deftypefun int ext2fs_inode_scan_flags (ext2_inode_scan @var{scan}, int @var{set_flags}, int @var{clear_flags})
    475 
    476 Set the scan_flags @var{set_flags} and clear the scan_flags @var{clear_flags}.
    477 The following flags can be set using this interface:
    478 
    479 @table @samp
    480 
    481 @item EXT2_SF_SKIP_MISSING_ITABLE 
    482 When a block group is missing an inode table, skip it.  If this flag is
    483 not set @code{ext2fs_get_next_inode} will return the error
    484 EXT2_ET_MISSING_INODE_TABLE.
    485 
    486 @end table
    487 
    488 @end deftypefun
    489 
    490 @c ----------------------------------------------------------------------
    491 
    492 @node Iterating over blocks in an inode, Inode Convenience Functions, Iterating over inodes in a filesystem, Inode Functions
    493 @comment  node-name,  next,  previous,  up
    494 @subsection Iterating over blocks in an inode
    495 
    496 @deftypefun errcode_t ext2fs_block_iterate (ext2_filsys @var{fs},
    497 ext2_ino_t @var{ino}, int @var{flags}, char *block_buf, int
    498 (*func)(ext2_filsys @var{fs}, blk_t *@var{blocknr}, int @var{blockcnt},
    499 void *@var{private}), void *@var{private})
    500 
    501 Iterate over all of the blocks in inode number @var{ino} in filesystem
    502 @var{fs}, by calling the function @var{func} for each block in the
    503 inode.  The @var{block_buf} parameter should either be NULL, or if the
    504 @code{ext2fs_block_iterate} function is called repeatedly, the overhead
    505 of allocating and freeing scratch memory can be avoided by passing a
    506 pointer to a scratch buffer which must be at least as big as three times the
    507 filesystem's blocksize.  
    508 
    509 The @var{flags} parameter controls how the iterator will function:
    510 
    511 @table @samp
    512 
    513 @item BLOCK_FLAG_HOLE
    514 This flag indiciates that the interator function should be called on
    515 blocks where the block number is zero (also known as ``holes''.)  It is
    516 also known as BLOCK_FLAG_APPEND, since it is also used by functions
    517 such as ext2fs_expand_dir() to add a new block to an inode.
    518 
    519 @item BLOCK_FLAG_DEPTH_TRAVERSE
    520 This flag indicates that the iterator function for the
    521 indirect, doubly indirect, etc. blocks should be called after all
    522 of the blocks containined in the indirect blocks are processed.
    523 This is useful if you are going to be deallocating blocks from an
    524 inode.
    525 
    526 @item BLOCK_FLAG_DATA_ONLY
    527 This flag indicates that the iterator function should be
    528 called for data blocks only.
    529 
    530 @end table
    531 
    532 The callback function @var{func} is called with a number of parameters;
    533 the @var{fs} and @var{private} parameters are self-explanatory, and
    534 their values are taken from the parameters to
    535 @code{ext2fs_block_iterate}.  (The @var{private} data structure is
    536 generally used by callers to @code{ext2fs_block_iterate} so that some
    537 private data structure can be passed to the callback function.  The 
    538 @var{blockcnt} parameter, if non-negative, indicates the logical block
    539 number of a data block in the inode.  If @var{blockcnt} is less than
    540 zero, then @var{func} was called on a metadata block, and @var{blockcnt}
    541 will be one of the following values:  BLOCK_COUNT_IND, BLOCK_COUNT_DIND,
    542 BLOCK_COUNT_TIND, or BLOCK_COUNT_TRANSLATOR.  The @var{blocknr} is a
    543 pointer to the inode or indirect block entry listing physical block
    544 number.  The callback function may modify the physical block number, if
    545 it returns the @var{BLOCK_CHANGED} flag.
    546 
    547 
    548 The callback function @var{func} returns a result code which is composed of
    549 the logical OR of the following flags:
    550 
    551 @table @samp
    552 
    553 @item BLOCK_CHANGED
    554 
    555 This flag indicates that callback function has modified the physical
    556 block number pointed to by @var{blocknr}.
    557 
    558 @item BLOCK_ABORT
    559 
    560 This flag requests that @code{ext2fs_block_iterate} to stop immediately
    561 and return to the caller.
    562 
    563 @end table
    564 
    565 @end deftypefun
    566 
    567 @deftypefun errcode_t ext2fs_block_iterate2 (ext2_filsys @var{fs}, ext2_ino_t @var{ino}, int @var{flags}, char *@var{block}_buf, int (*func)(ext2_filsys @var{fs}, blk_t *@var{blocknr}, e2_blkcnt_t @var{blockcnt}, blk_t @var{ref_blk}, int  @var{ref_offset}, void *@var{private}), void *@var{private})
    568 
    569 This function is much like @code{ext2fs_block_iterate2}, except that the
    570 @var{blockcnt} type is a 64-bit signed quantity, to support larger
    571 files, and the addition of the @var{ref_blk} and @var{ref_offset}
    572 arguments passed to the callback function, which identify the location
    573 of the physical block pointed to by pointer @var{blocknr}.  If
    574 @var{ref_blk} is zero, then @var{ref_offset} contains the offset into
    575 the @code{i_blocks} array.  If @var{ref_blk} is non-zero, then the physical
    576 block location is contained inside an indirect block group, and
    577 @var{ref_offset} contains the offset into the indirect block.
    578 
    579 @end deftypefun
    580 
    581 @c ----------------------------------------------------------------------
    582 
    583 @node Inode Convenience Functions,  , Iterating over blocks in an inode, Inode Functions
    584 @comment  node-name,  next,  previous,  up
    585 @subsection Convenience functions for Inodes
    586 
    587 @deftypefun errcode_t ext2fs_get_blocks (ext2_filsys @var{fs}, ext2_ino_t @var{ino}, blk_t *@var{blocks})
    588 
    589 Returns an array of blocks corresponding to the direct,
    590 indirect, doubly indirect, and triply indirect blocks as stored in the
    591 inode structure.
    592 @end deftypefun
    593 
    594 @deftypefun errcode_t ext2fs_check_directory (ext2_filsys @var{fs}, ext2_ino_t @var{ino})
    595 Returns 0 if @var{ino} is a directory, and @code{ENOTDIR} if it is not.
    596 @end deftypefun
    597 
    598 @deftypefun int ext2_inode_has_valid_blocks (struct ext2_inode *@var{inode})
    599 
    600 Returns 1 if the inode's block entries actually valid block entries, and
    601 0 if not.  Inodes which represent devices and fast symbolic links do not
    602 contain valid block entries.
    603 @end deftypefun
    604 
    605 @c ----------------------------------------------------------------------
    606 
    607 @node Directory functions, Bitmap Functions, Inode Functions, EXT2FS Library Functions
    608 @comment  node-name,  next,  previous,  up
    609 @section Directory functions
    610 
    611 @menu
    612 * Directory block functions::   
    613 * Iterating over a directory::  
    614 * Creating and expanding directories::  
    615 * Creating and removing directory entries::  
    616 * Looking up filenames::        
    617 * Translating inode numbers to filenames::  
    618 @end menu
    619 
    620 @c ----------------------------------------------------------------------
    621 
    622 @node Directory block functions, Iterating over a directory, Directory functions, Directory functions
    623 @comment  node-name,  next,  previous,  up
    624 @subsection Directory block functions
    625 
    626 @deftypefun errcode_t ext2fs_read_dir_block (ext2_filsys @var{fs}, blk_t @var{block}, void *@var{buf})
    627 
    628 This function reads a directory block, performing any necessary
    629 byte swapping if necessary.
    630 @end deftypefun
    631 
    632 @deftypefun errcode_t ext2fs_write_dir_block (ext2_filsys @var{fs}, blk_t @var{block}, void *@var{buf})
    633 
    634 This function writes a directory block, performing any necessary
    635 byte swapping if necessary.
    636 @end deftypefun
    637 
    638 @deftypefun errcode_t ext2fs_new_dir_block (ext2_filsys @var{fs},
    639 ext2_ino_t @var{dir_ino}, ext2_ino_t @var{parent_ino}, char
    640 **@var{block})
    641 
    642 This function creates a new directory block in @var{block}.  If
    643 @var{dir_ino} is non-zero, then @var{dir_info} and @var{parent_ino} is used
    644 to initialize directory entries for @file{.} and @file{..}, respectively.
    645 @end deftypefun
    646 
    647 @c ----------------------------------------------------------------------
    648 
    649 @node Iterating over a directory, Creating and expanding directories, Directory block functions, Directory functions
    650 @comment  node-name,  next,  previous,  up
    651 @subsection Iterating over a directory
    652 
    653 @deftypefun errcode_t ext2fs_dir_iterate (ext2_filsys @var{fs}, ext2_ino_t @var{dir}, int @var{flags}, char *@var{block_buf}, int (*@var{func})(struct ext2_dir_entry *@var{dirent}, int @var{offset}, int @var{blocksize}, char *@var{buf}, void *@var{private}), void *@var{private})
    654 
    655 This function interates over all of the directory entries in the
    656 directory @var{dir}, calling the callback function @var{func} for each
    657 directory entry in the directory.  The @var{block_buf} parameter should
    658 either be NULL, or if the @code{ext2fs_dir_iterate} function is 
    659 called repeatedly, the overhead of allocating and freeing 
    660 scratch memory can be avoided by passing a pointer to a scratch buffer
    661 which must be at least as big as the filesystem's blocksize.  
    662 
    663 The @var{flags} parameter controls how the iterator will function:
    664 
    665 @table @samp
    666 
    667 @item DIRENT_FLAG_INCLUDE_EMPTY
    668 
    669 This flag indicates that the callback function should be called even 
    670 for deleted or empty directory entries.
    671 
    672 @end table
    673 
    674 @end deftypefun
    675 
    676 @c ----------------------------------------------------------------------
    677 
    678 @node Creating and expanding directories, Creating and removing directory entries, Iterating over a directory, Directory functions
    679 @comment  node-name,  next,  previous,  up
    680 @subsection Creating and expanding directories
    681 
    682 @deftypefun errcode_t ext2fs_mkdir (ext2_filsys @var{fs}, ext2_ino_t @var{parent}, ext2_ino_t @var{inum}, const char *@var{name})
    683 
    684 This function creates a new directory.  If @var{inum} is zero, then a
    685 new inode will be allocated; otherwise, the directory will be created in
    686 the inode specified by @var{inum}.  If @var{name} specifies the name of
    687 the new directory; if it is non-NULL, then the new directory will be
    688 linked into the parent directory @var{parent}.
    689 @end deftypefun
    690 
    691 @deftypefun errcode_t ext2fs_expand_dir (ext2_filsys @var{fs}, ext2_ino_t @var{dir})
    692 
    693 This function adds a new empty directory block and appends it to 
    694 the directory @var{dir}.  This allows functions such as
    695 @code{ext2fs_link} to add new directory entries to a directory which is full.
    696 
    697 @end deftypefun
    698 
    699 @c ----------------------------------------------------------------------
    700 
    701 @node Creating and removing directory entries, Looking up filenames, Creating and expanding directories, Directory functions
    702 @comment  node-name,  next,  previous,  up
    703 @subsection Creating and removing directory entries
    704 
    705 @deftypefun errcode_t ext2fs_link (ext2_filsys @var{fs}, ext2_ino_t @var{dir}, const char *@var{name}, ext2_ino_t @var{ino}, int flags)
    706 
    707 This function adds a new directory entry to the directory @var{dir}, 
    708 with @var{name} and @var{ino} specifying the name and inode number in
    709 the directory entry, respectively.  
    710 
    711 The low 3 bits of the flags field is used to specify the file type of
    712 inode:   (No other flags are currently defined.)
    713 
    714 @table @samp
    715 
    716 @item EXT2_FT_UNKNOWN
    717 
    718 The file type is unknown.
    719 
    720 @item EXT2_FT_REG_FILE
    721 
    722 The file type is a normal file.
    723 
    724 @item EXT2_FT_DIR
    725 
    726 The file type is a directory.
    727 
    728 @item EXT2_FT_CHRDEV
    729 
    730 The file type is a character device.
    731 
    732 @item EXT2_FT_BLKDEV
    733 
    734 The file type is a block device.
    735 
    736 @item EXT2_FT_FIFO
    737 
    738 The file type is a named pipe.
    739 
    740 @item EXT2_FT_SOCK
    741 
    742 The file type is a unix domain socket.
    743 
    744 @item EXT2_FT_SYMLINK
    745 
    746 The file type is a symbolic link.
    747 @end table 
    748 
    749 @end deftypefun
    750 
    751 @deftypefun errcode_t ext2fs_unlink (ext2_filsys @var{fs}, ext2_ino_t @var{dir}, const char *@var{name}, ext2_ino_t @var{ino}, int @var{flags})
    752 
    753 This function removes a directory entry from @var{dir}.
    754 The directory entry to be removed is the first one which is
    755 matched by @var{name} and @var{ino}.  If @var{name} is non-NULL, 
    756 the directory entry's name must match @var{name}.  If @var{ino} is
    757 non-zero, the directory entry's inode number must match @var{ino}.
    758 No flags are currently defined for @code{ext2fs_unlink}; callers should
    759 pass in zero to this parameter.
    760 
    761 @end deftypefun
    762 
    763 @c ----------------------------------------------------------------------
    764 
    765 @node Looking up filenames, Translating inode numbers to filenames, Creating and removing directory entries, Directory functions
    766 @comment  node-name,  next,  previous,  up
    767 @subsection Looking up filenames
    768 
    769 @deftypefun errcode_t ext2fs_lookup (ext2_filsys @var{fs}, ext2_ino_t @var{dir}, const char *@var{name}, int @var{namelen}, char *@var{buf}, ext2_ino_t *@var{inode})
    770 @end deftypefun
    771 
    772 @deftypefun errcode_t ext2fs_namei (ext2_filsys @var{fs}, ext2_ino_t @var{root}, ext2_ino_t @var{cwd}, const char *@var{name}, ext2_ino_t *@var{inode})
    773 @end deftypefun
    774 
    775 @deftypefun errcode_t ext2fs_namei_follow (ext2_filsys @var{fs}, ext2_ino_t @var{root}, ext2_ino_t @var{cwd}, const char *@var{name}, ext2_ino_t *@var{inode})
    776 @end deftypefun
    777 
    778 @deftypefun errcode_t ext2fs_follow_link (ext2_filsys @var{fs}, ext2_ino_t @var{root}, ext2_ino_t @var{cwd}, ext2_ino_t @var{inode}, ext2_ino_t *@var{res}_inode)
    779 @end deftypefun
    780 
    781 @c ----------------------------------------------------------------------
    782 
    783 @node Translating inode numbers to filenames,  , Looking up filenames, Directory functions
    784 @comment  node-name,  next,  previous,  up
    785 @subsection Translating inode numbers to filenames
    786 
    787 @deftypefun errcode_t ext2fs_get_pathname (ext2_filsys @var{fs}, ext2_ino_t @var{dir}, ext2_ino_t @var{ino}, char **@var{name})
    788 @end deftypefun
    789 
    790 
    791 @c ----------------------------------------------------------------------
    792 
    793 @node Bitmap Functions, EXT2 data abstractions, Directory functions, EXT2FS Library Functions
    794 @comment  node-name,  next,  previous,  up
    795 @section Bitmap Functions
    796 
    797 @menu
    798 * Reading and Writing Bitmaps::  
    799 * Allocating Bitmaps::          
    800 * Free bitmaps::                
    801 * Bitmap Operations::           
    802 * Comparing bitmaps::           
    803 * Modifying Bitmaps::           
    804 * Resizing Bitmaps::            
    805 * Clearing Bitmaps::            
    806 @end menu
    807 
    808 @c ----------------------------------------------------------------------
    809 
    810 @node Reading and Writing Bitmaps, Allocating Bitmaps, Bitmap Functions, Bitmap Functions
    811 @comment  node-name,  next,  previous,  up
    812 @subsection Reading and Writing Bitmaps
    813 
    814 @deftypefun errcode_t ext2fs_write_inode_bitmap (ext2_filsys @var{fs})
    815 @end deftypefun
    816 
    817 @deftypefun errcode_t ext2fs_write_block_bitmap (ext2_filsys @var{fs})
    818 @end deftypefun
    819 
    820 @deftypefun errcode_t ext2fs_read_inode_bitmap (ext2_filsys @var{fs})
    821 @end deftypefun
    822 
    823 @deftypefun errcode_t ext2fs_read_block_bitmap (ext2_filsys @var{fs})
    824 @end deftypefun
    825 
    826 @deftypefun errcode_t ext2fs_read_bitmaps (ext2_filsys @var{fs})
    827 @end deftypefun
    828 
    829 @deftypefun errcode_t ext2fs_write_bitmaps (ext2_filsys @var{fs})
    830 @end deftypefun
    831 
    832 @c ----------------------------------------------------------------------
    833 
    834 @node Allocating Bitmaps, Free bitmaps, Reading and Writing Bitmaps, Bitmap Functions
    835 @comment  node-name,  next,  previous,  up
    836 @subsection Allocating Bitmaps
    837 
    838 @deftypefun errcode_t ext2fs_allocate_generic_bitmap (__u32 @var{start}, __u32 @var{end}, _u32 @var{real_end}, const char *@var{descr}, ext2fs_generic_bitmap *@var{ret})
    839 @end deftypefun
    840 
    841 @deftypefun errcode_t ext2fs_allocate_block_bitmap (ext2_filsys @var{fs}, const char *@var{descr}, ext2fs_block_bitmap *@var{ret})
    842 @end deftypefun
    843 
    844 @deftypefun errcode_t ext2fs_allocate_inode_bitmap (ext2_filsys @var{fs}, const char *@var{descr}, ext2fs_inode_bitmap *@var{ret})
    845 @end deftypefun
    846 
    847 @c ----------------------------------------------------------------------
    848 
    849 @node Free bitmaps, Bitmap Operations, Allocating Bitmaps, Bitmap Functions
    850 @comment  node-name,  next,  previous,  up
    851 @subsection Freeing bitmaps
    852 
    853 
    854 @deftypefun void ext2fs_free_generic_bitmap (ext2fs_inode_bitmap @var{bitmap})
    855 @end deftypefun
    856 
    857 @deftypefun void ext2fs_free_block_bitmap (ext2fs_block_bitmap @var{bitmap})
    858 @end deftypefun
    859 
    860 @deftypefun void ext2fs_free_inode_bitmap (ext2fs_inode_bitmap @var{bitmap})
    861 @end deftypefun
    862 
    863 
    864 @c ----------------------------------------------------------------------
    865 
    866 @node Bitmap Operations, Comparing bitmaps, Free bitmaps, Bitmap Functions
    867 @comment  node-name,  next,  previous,  up
    868 @subsection Bitmap Operations
    869 
    870 @deftypefun void ext2fs_mark_block_bitmap (ext2fs_block_bitmap @var{bitmap}, blk_t @var{block})
    871 
    872 @deftypefunx void ext2fs_unmark_block_bitmap (ext2fs_block_bitmap @var{bitmap}, blk_t @var{block})
    873 
    874 @deftypefunx int ext2fs_test_block_bitmap (ext2fs_block_bitmap @var{bitmap}, blk_t @var{block})
    875 
    876 These functions set, clear, and test bits in a block bitmap @var{bitmap}.
    877 @end deftypefun
    878 
    879 
    880 @deftypefun void ext2fs_mark_inode_bitmap (ext2fs_inode_bitmap @var{bitmap}, ext2_ino_t @var{inode})
    881 
    882 @deftypefunx void ext2fs_unmark_inode_bitmap (ext2fs_inode_bitmap @var{bitmap}, ext2_ino_t @var{inode})
    883 
    884 @deftypefunx int ext2fs_test_inode_bitmap (ext2fs_inode_bitmap @var{bitmap}, ext2_ino_t @var{inode})
    885 
    886 These functions set, clear, and test bits in an inode bitmap @var{bitmap}.
    887 @end deftypefun
    888 
    889 @deftypefun void ext2fs_fast_mark_block_bitmap (ext2fs_block_bitmap @var{bitmap}, blk_t @var{block})
    890 
    891 @deftypefunx void ext2fs_fast_unmark_block_bitmap (ext2fs_block_bitmap @var{bitmap}, blk_t @var{block})
    892 
    893 @deftypefunx int ext2fs_fast_test_block_bitmap (ext2fs_block_bitmap @var{bitmap}, blk_t @var{block})
    894 
    895 @deftypefunx void ext2fs_fast_mark_inode_bitmap (ext2fs_inode_bitmap @var{bitmap}, ext2_ino_t @var{inode})
    896 
    897 @deftypefunx void ext2fs_fast_unmark_inode_bitmap (ext2fs_inode_bitmap @var{bitmap}, ext2_ino_t @var{inode})
    898 
    899 @deftypefunx int ext2fs_fast_test_inode_bitmap (ext2fs_inode_bitmap @var{bitmap}, ext2_ino_t @var{inode})
    900 
    901 These ``fast'' functions are like their normal counterparts; however,
    902 they are implemented as inline functions and do not perform bounds
    903 checks on the inode number or block number; they are assumed to be
    904 correct.  They should only be used in speed-critical applications, where
    905 the inode or block number has already been validated by other means.
    906 @end deftypefun
    907 
    908 @deftypefun blk_t ext2fs_get_block_bitmap_start (ext2fs_block_bitmap @var{bitmap})
    909 @deftypefunx ext2_ino_t ext2fs_get_inode_bitmap_start (ext2fs_inode_bitmap @var{bitmap})
    910 Return the first inode or block which is stored in the bitmap.
    911 @end deftypefun
    912 
    913 @deftypefun blk_t ext2fs_get_block_bitmap_end (ext2fs_block_bitmap @var{bitmap})
    914 @deftypefunx ext2_ino_t ext2fs_get_inode_bitmap_end (ext2fs_inode_bitmap @var{bitmap})
    915 
    916 Return the last inode or block which is stored in the bitmap.
    917 @end deftypefun
    918 
    919 
    920 @c ----------------------------------------------------------------------
    921 
    922 @node Comparing bitmaps, Modifying Bitmaps, Bitmap Operations, Bitmap Functions
    923 @comment  node-name,  next,  previous,  up
    924 @subsection Comparing bitmaps
    925 
    926 @deftypefun errcode_t ext2fs_compare_block_bitmap (ext2fs_block_bitmap @var{bm1}, ext2fs_block_bitmap @var{bm2})
    927 @end deftypefun
    928 
    929 @deftypefun errcode_t ext2fs_compare_inode_bitmap (ext2fs_inode_bitmap @var{bm1}, ext2fs_inode_bitmap @var{bm2})
    930 @end deftypefun
    931 
    932 
    933 @c ----------------------------------------------------------------------
    934 
    935 @node Modifying Bitmaps, Resizing Bitmaps, Comparing bitmaps, Bitmap Functions
    936 @comment  node-name,  next,  previous,  up
    937 @subsection Modifying Bitmaps
    938 
    939 @deftypefun errcode_t ext2fs_fudge_inode_bitmap_end (ext2fs_inode_bitmap @var{bitmap}, ext2_ino_t @var{end}, ext2_ino_t *@var{oend})
    940 @end deftypefun
    941 
    942 @deftypefun errcode_t ext2fs_fudge_block_bitmap_end (ext2fs_block_bitmap @var{bitmap}, blk_t @var{end}, blk_t *@var{oend})
    943 @end deftypefun
    944 
    945 @c ----------------------------------------------------------------------
    946 
    947 @node Resizing Bitmaps, Clearing Bitmaps, Modifying Bitmaps, Bitmap Functions
    948 @comment  node-name,  next,  previous,  up
    949 @subsection Resizing Bitmaps
    950 
    951 @deftypefun errcode_t ext2fs_resize_generic_bitmap (__u32 @var{new_end}, __u32 @var{new_real_end}, ext2fs_generic_bitmap @var{bmap})
    952 @end deftypefun
    953 
    954 @deftypefun errcode_t ext2fs_resize_inode_bitmap (__u32 @var{new_end}, __u32 @var{new_real_end}, ext2fs_inode_bitmap @var{bmap})
    955 @end deftypefun
    956 
    957 @deftypefun errcode_t ext2fs_resize_block_bitmap (__u32 @var{new_end}, __u32 @var{new_real_end}, ext2fs_block_bitmap @var{bmap})
    958 @end deftypefun
    959 
    960 
    961 @c ----------------------------------------------------------------------
    962 
    963 @node Clearing Bitmaps,  , Resizing Bitmaps, Bitmap Functions
    964 @comment  node-name,  next,  previous,  up
    965 @subsection Clearing Bitmaps
    966 
    967 @deftypefun void ext2fs_clear_inode_bitmap (ext2fs_inode_bitmap @var{bitmap})
    968 
    969 This function sets all of the bits in the inode bitmap @var{bitmap} to 
    970 be zero.
    971 
    972 @end deftypefun
    973 
    974 @deftypefun void ext2fs_clear_block_bitmap (ext2fs_block_bitmap @var{bitmap})
    975 
    976 This function sets all of the bits in the block bitmap @var{bitmap} to 
    977 be zero.
    978 @end deftypefun
    979 
    980 
    981 @c ----------------------------------------------------------------------
    982 
    983 @node EXT2 data abstractions, Byte-swapping functions, Bitmap Functions, EXT2FS Library Functions
    984 @comment  node-name,  next,  previous,  up
    985 @section EXT2 data abstractions
    986 
    987 The ext2 library has a number of abstractions which are useful for ext2
    988 utility programs.  
    989 
    990 @menu
    991 * Badblocks list management::   
    992 * Directory-block list management::  
    993 * Inode count functions::       
    994 @end menu
    995 
    996 @c ----------------------------------------------------------------------
    997 
    998 @node Badblocks list management, Directory-block list management, EXT2 data abstractions, EXT2 data abstractions
    999 @comment  node-name,  next,  previous,  up
   1000 @subsection Badblocks list management
   1001 
   1002 
   1003 @deftypefun errcode_t ext2fs_badblocks_list_create (ext2_badblocks_list *@var{ret}, int @var{size})
   1004 @end deftypefun
   1005 
   1006 @deftypefun void ext2fs_badblocks_list_free (ext2_badblocks_list @var{bb})
   1007 @end deftypefun
   1008 
   1009 @deftypefun errcode_t ext2fs_badblocks_list_add (ext2_badblocks_list @var{bb}, blk_t @var{blk})
   1010 @end deftypefun
   1011 
   1012 @deftypefun int ext2fs_badblocks_list_test (ext2_badblocks_list @var{bb}, blk_t @var{blk})
   1013 @end deftypefun
   1014 
   1015 @deftypefun errcode_t ext2fs_badblocks_list_iterate_begin (ext2_badblocks_list @var{bb}, ext2_badblocks_iterate *@var{ret})
   1016 @end deftypefun
   1017 
   1018 @deftypefun int ext2fs_badblocks_list_iterate (ext2_badblocks_iterate iter, blk_t *@var{blk})
   1019 @end deftypefun
   1020 
   1021 @deftypefun void ext2fs_badblocks_list_iterate_end (ext2_badblocks_iterate @var{iter})
   1022 @end deftypefun
   1023 
   1024 @deftypefun errcode_t ext2fs_update_bb_inode (ext2_filsys @var{fs}, ext2_badblocks_list @var{bb_list})
   1025 @end deftypefun
   1026 
   1027 @deftypefun errcode_t ext2fs_read_bb_inode (ext2_filsys @var{fs}, ext2_badblocks_list *@var{bb_list})
   1028 @end deftypefun
   1029 
   1030 @deftypefun errcode_t ext2fs_read_bb_FILE (ext2_filsys @var{fs}, FILE *f, ext2_badblocks_list *@var{bb_list}, void (*invalid)(ext2_filsys @var{fs}, blk_t @var{blk}))
   1031 @end deftypefun
   1032 
   1033 
   1034 @c ----------------------------------------------------------------------
   1035 
   1036 @node Directory-block list management, Inode count functions, Badblocks list management, EXT2 data abstractions
   1037 @comment  node-name,  next,  previous,  up
   1038 @subsection Directory-block list management
   1039 
   1040 The dblist abstraction stores a list of blocks belonging to
   1041 directories.  This list can be useful when a program needs to interate
   1042 over all directory entries in a filesystem; @code{e2fsck} does this in
   1043 pass 2 of its operations, and @code{debugfs} needs to do this when it is
   1044 trying to turn an inode number into a pathname.
   1045 
   1046 @deftypefun errcode_t ext2fs_init_dblist (ext2_filsys @var{fs}, ext2_dblist *@var{ret_dblist})
   1047 
   1048 Creates a dblist data structure and return it in @var{ret_dblist}.
   1049 @end deftypefun
   1050 
   1051 @deftypefun void ext2fs_free_dblist (ext2_dblist @var{dblist})
   1052 
   1053 Free a dblist data structure.
   1054 @end deftypefun
   1055 
   1056 @deftypefun errcode_t ext2fs_add_dir_block (ext2_dblist @var{dblist}, ext2_ino_t @var{ino}, blk_t @var{blk}, int @var{blockcnt})
   1057 
   1058 Add an entry to the dblist data structure.  This call records the fact
   1059 that block number @var{blockcnt} of directory inode @var{ino} is stored
   1060 in block @var{blk}.
   1061 @end deftypefun
   1062 
   1063 @deftypefun errcode_t ext2fs_set_dir_block (ext2_dblist @var{dblist}, ext2_ino_t @var{ino}, blk_t @var{blk}, int @var{blockcnt})
   1064 
   1065 Change an entry in the dblist data structure; this changes the location
   1066 of block number @var{blockcnt} of directory indoe @var{ino} to be block
   1067 @var{blk}. 
   1068 @end deftypefun
   1069 
   1070 @deftypefun errcode_t ext2fs_dblist_iterate (ext2_dblist @var{dblist}, int (*func)(ext2_filsys @var{fs}, struct ext2_db_entry *@var{db_info}, void *@var{private}), void *@var{private})
   1071 
   1072 This iterator calls @var{func} for every entry in the dblist data structure.
   1073 @end deftypefun
   1074 
   1075 @deftypefun errcode_t ext2fs_dblist_dir_iterate (ext2_dblist @var{dblist}, int flags, char *@var{block_buf}, int (*func)(ext2_ino_t @var{dir}, int  @var{entry}, struct ext2_dir_entry *@var{dirent}, int @var{offset}, int @var{blocksize}, char *@var{buf}, void *@var{private}), void *@var{private})
   1076 
   1077 This iterator takes reads in the directory block indicated in each
   1078 dblist entry, and calls @var{func} for each directory entry in each
   1079 directory block.  If @var{dblist} contains all the directory blocks in a
   1080 filesystem, this function provides a convenient way to iterate over all
   1081 directory entries for that filesystem.
   1082 @end deftypefun
   1083 
   1084 @c ----------------------------------------------------------------------
   1085 
   1086 @node Inode count functions,  , Directory-block list management, EXT2 data abstractions
   1087 @comment  node-name,  next,  previous,  up
   1088 @subsection Inode count functions
   1089 
   1090 The icount abstraction is a specialized data type used by @code{e2fsck}
   1091 to store how many times a particular inode is referenced by the
   1092 filesystem.  This is used twice; once to store the actual number of times
   1093 that the inode is reference; and once to store the claimed number of times
   1094 the inode is referenced according to the inode structure.
   1095 
   1096 This abstraction is designed to be extremely efficient for storing this
   1097 sort of information, by taking advantage of the following properties of
   1098 inode counts, namely (1) inode counts are very often zero (because
   1099 the inode is currrently not in use), and (2) many files have a inode
   1100 count of 1 (because they are a file which has no additional hard links).
   1101 
   1102 @deftypefun errcode_t ext2fs_create_icount2 (ext2_filsys @var{fs}, int @var{flags}, int @var{size}, ext2_icount_t @var{hint}, ext2_icount_t *@var{ret})
   1103 
   1104 Creates an icount stucture for a filesystem @var{fs}, with initial space
   1105 for @var{size} inodes whose count is greater than 1.  The @var{flags}
   1106 parameter is either 0 or @code{EXT2_ICOUNT_OPT_INCREMENT}, which
   1107 indicates that icount structure should be able to increment inode counts
   1108 quickly.  The icount structure is returned in @var{ret}.  The returned
   1109 icount structure initially has a count of zero for all inodes.
   1110 
   1111 The @var{hint} parameter allows the caller to optionally pass in another
   1112 icount structure which is used to initialize the array of inodes whose
   1113 count is greater than 1.  It is used purely as a speed optimization so
   1114 that the icount structure can determine in advance which inodes are
   1115 likely to contain a count grater than 1.
   1116 @end deftypefun
   1117 
   1118 @deftypefun void ext2fs_free_icount (ext2_icount_t @var{icount})
   1119 
   1120 Frees an icount structure.
   1121 @end deftypefun
   1122 
   1123 @deftypefun errcode_t ext2fs_icount_fetch (ext2_icount_t @var{icount}, ext2_ino_t @var{ino}, __u16 *@var{ret})
   1124 
   1125 Returns in @var{ret} fetches the count for a particular inode @var{ino}.
   1126 @end deftypefun
   1127 
   1128 @deftypefun errcode_t ext2fs_icount_increment (ext2_icount_t @var{icount}, ext2_ino_t @var{ino}, __u16 *@var{ret})
   1129 
   1130 Increments the ref count for inode @var{ino}.
   1131 @end deftypefun
   1132 
   1133 @deftypefun errcode_t ext2fs_icount_decrement (ext2_icount_t @var{icount}, ext2_ino_t @var{ino}, __u16 *@var{ret})
   1134 
   1135 Decrements the ref count for inode @var{ino}.
   1136 @end deftypefun
   1137 
   1138 @deftypefun errcode_t ext2fs_icount_store (ext2_icount_t @var{icount}, ext2_ino_t @var{ino}, __u16 @var{count})
   1139 
   1140 Sets the reference count for inode @var{ino} to be @var{count}.
   1141 @end deftypefun
   1142 
   1143 @deftypefun ext2_ino_t ext2fs_get_icount_size (ext2_icount_t @var{icount})
   1144 
   1145 Returns the current number of inodes in @var{icount} which has a count
   1146 greater than 1.
   1147 @end deftypefun
   1148 
   1149 @deftypefun errcode_t ext2fs_icount_validate (ext2_icount_t @var{icount}, FILE *@var{f})
   1150 
   1151 Validates the internal rep invariant of @var{icount}; if there are any
   1152 problems, print out debugging information to @var{f}.  This function is
   1153 intended for debugging and testing use only.
   1154 @end deftypefun
   1155 
   1156 
   1157 @c ----------------------------------------------------------------------
   1158 
   1159 @node Byte-swapping functions, Other functions, EXT2 data abstractions, EXT2FS Library Functions
   1160 @comment  node-name,  next,  previous,  up
   1161 @section Byte-swapping functions
   1162 
   1163 @deftypefun void ext2fs_swap_super (struct ext2_super_block * @var{super})
   1164 @end deftypefun
   1165 
   1166 @deftypefun void ext2fs_swap_group_desc (struct ext2_group_desc *@var{gdp})
   1167 @end deftypefun
   1168 
   1169 @deftypefun void ext2fs_swap_inode (ext2_filsys @var{fs}, struct ext2_inode *@var{to}, struct ext2_inode *@var{from}, int @var{hostorder})
   1170 @end deftypefun
   1171 
   1172 @deftypefun int ext2fs_native_flag (void)
   1173 @end deftypefun
   1174 
   1175 
   1176 @c ----------------------------------------------------------------------
   1177 
   1178 @node Other functions,  , Byte-swapping functions, EXT2FS Library Functions
   1179 @comment  node-name,  next,  previous,  up
   1180 @section Other functions
   1181 
   1182 /* alloc.c */
   1183 @deftypefun errcode_t ext2fs_new_inode (ext2_filsys @var{fs}, ext2_ino_t @var{dir}, int @var{mode}, ext2fs_inode_bitmap @var{map}, ext2_ino_t *@var{ret})
   1184 @end deftypefun
   1185 
   1186 @deftypefun errcode_t ext2fs_new_block (ext2_filsys @var{fs}, blk_t @var{goal}, ext2fs_block_bitmap @var{map}, blk_t *@var{ret})
   1187 @end deftypefun
   1188 
   1189 @deftypefun errcode_t ext2fs_get_free_blocks (ext2_filsys @var{fs}, blk_t @var{start}, blk_t @var{finish}, int @var{num}, ext2fs_block_bitmap @var{map}, blk_t *@var{ret})
   1190 @end deftypefun
   1191 
   1192 /* check_desc.c */
   1193 @deftypefun errcode_t ext2fs_check_desc (ext2_filsys @var{fs})
   1194 @end deftypefun
   1195 
   1196 @deftypefun errcode_t ext2_get_num_dirs (ext2_filsys @var{fs}, ext2_ino_t *@var{ret_num_dirs})
   1197 @end deftypefun
   1198 
   1199 
   1200 /* getsize.c */
   1201 @deftypefun errcode_t ext2fs_get_device_size (const char *@var{file}, int @var{blocksize}, blk_t *@var{retblocks})
   1202 @end deftypefun
   1203 
   1204 
   1205 /* ismounted.c */
   1206 @deftypefun errcode_t ext2fs_check_if_mounted (const char *@var{file}, int *@var{mount_flags})
   1207 @end deftypefun
   1208 
   1209 /* version.c */
   1210 
   1211 @deftypefun int ext2fs_get_library_version (const char **@var{ver_string}, const char **@var{date_string})
   1212 
   1213 This function returns the current version of the ext2 library.  The
   1214 return value contains an integer version code, which consists of the
   1215 major version number of the library multiplied by 100, plus the minor
   1216 version number of the library.  Hence, if the library version is 1.08,
   1217 the returned value will be 108.
   1218 
   1219 If @var{ver_string} and/or @var{date_string} are non-NULL, they will be
   1220 set to point at a constant string containing the library version and/or
   1221 release date, respectively.
   1222 @end deftypefun
   1223 
   1224 @deftypefun int ext2fs_parse_version_string (const char *@var{ver_string})
   1225 
   1226 This function takes a version string which may included in an
   1227 application and returns a version code using the same algorithm used by
   1228 @code{ext2fs_get_library_version}.  It can be used by programs included
   1229 in the @code{e2fsprogs} distribution to assure that they are using an
   1230 up-to-date ext2 shared library.
   1231 @end deftypefun
   1232 
   1233 /* inline functions */
   1234 @deftypefun int ext2fs_group_of_blk (ext2_filsys @var{fs}, blk_t @var{blk})
   1235 
   1236 This function returns the block group which contains the block @var{blk}.
   1237 
   1238 @end deftypefun
   1239 
   1240 @deftypefun int ext2fs_group_of_ino (ext2_filsys @var{fs}, ext2_ino_t @var{ino})
   1241 
   1242 This function returns the block group which contains the inode @var{ino}.
   1243 @end deftypefun
   1244 
   1245 
   1246 @c ----------------------------------------------------------------------
   1247 
   1248 @node Concept Index, Function Index, EXT2FS Library Functions, Top
   1249 @comment  node-name,  next,  previous,  up
   1250 @unnumbered Concept Index
   1251 @printindex cp
   1252 
   1253 @c ----------------------------------------------------------------------
   1254 
   1255 @node Function Index,  , Concept Index, Top
   1256 @comment  node-name,  next,  previous,  up
   1257 @unnumbered Function and Type Index
   1258 @printindex fn
   1259 
   1260 
   1261 @contents
   1262 @bye
   1263