OSDN Git Service

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