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