[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.1 Filesystem-level functions 2.2 Inode Functions 2.3 Directory functions 2.4 Bitmap Functions 2.5 EXT2 data abstractions 2.6 Byte-swapping functions 2.7 Other functions
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following functions operate on a filesystem handle. Most EXT2FS
Library functions require a filesystem handle as their first argument.
There are two functions which create a filesystem handle,
ext2fs_open
and ext2fs_initialize
.
The filesystem can also be closed using ext2fs_close
, and any
changes to the superblock and group descripts can be written out to disk
using ext2fs_flush
.
2.1.1 Opening an ext2 filesystem 2.1.2 Closing and flushing out changes 2.1.3 Initializing a filesystem 2.1.4 Filesystem flag functions
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Most libext2fs functions take a filesystem handle of type
ext2_filsys
. A filesystem handle is created either by opening
an existing function using ext2fs_open
, or by initializing a new
filesystem using ext2fs_initialize
.
Opens a filesystem named name, using the the io_manager
manager to define the input/output routines needed to read and
write the filesystem. In the case of the unix_io
io_manager,
name is interpreted as the Unix filename of the filesystem image.
This is often a device file, such as `/dev/hda1'.
The superblock parameter specifies the block number of the
superblock which should be used when opening the filesystem.
If superblock is zero, ext2fs_open
will use the primary
superblock located at offset 1024 bytes from the start of the filesystem
image.
The block_size parameter specifies the block size used by the
filesystem. Normally this is determined automatically from the
filesystem uperblock. If block_size is non-zero, it must match
the block size found in the superblock, or the error
EXT2_ET_UNEXPECTED_BLOCK_SIZE
will be returned. The
block_size parameter is also used to help fund the superblock when
superblock is non-zero.
The flags argument contains a bitmask of flags which control how the filesystem open should be handled.
EXT2_FLAG_RW
EXT2_FLAG_FORCE
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Write any changes to the high-level filesystem data structures in the fs filesystem. The following data structures will be written out:
ext2fs_read_bitmaps
.
Close the io_manager abstraction for fs and release all memory associated with the filesystem handle.
Flush out any changes to the high-level filesystem data structures using
ext2fs_flush
if the filesystem is marked dirty; then close and
free the filesystem using ext2fs_free
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An ext2 filesystem is initializing by the mke2fs
program. The
two functions described here, ext2fs_initialize
and
ext2fs_allocate_tables
do much of the initial work for setting up
a filesystem. However, they don't do the whole job. mke2fs
calls ext2fs_initialize
to set up the filesystem superblock, and
calls ext2fs_allocate_tables
to allocate space for the inode
table, and the inode and block bitmaps. In addition, mke2fs
must
also initialize the inode tables by clearing them with zeros, create the
root and lost+found directories, and reserve the reserved inodes.
This function is used by the mke2fs
program to initialize a
filesystem. The ext2fs_initialize
function creates a filesystem
handle which is returned in ret_fs that has been properly setup
for a filesystem to be located in name, using the io_manager
manager. The prototype superblock in param is used to
supply parameters such as the number of blocks in the filesystem, the
block size, etc.
The ext2fs_initialize
function does not actually do any I/O; that
will be done when the application program calls ext2fs_close
or
ext2fs_flush
. Also, this function only initializes the
superblock and group descriptor structures. It does not create the
inode table or the root directory. This must be done by the calling
application, such as mke2fs
.
The following values may be set in the param prototype superblock;
if a value of 0 is found in a field, ext2fs_initialize
will use a
default value. The calling application should zero out the prototype
entire superblock, and then fill in any appropriate values.
s_blocks_count
s_inodes_count
s_r_blocks_count
s_log_block_size
s_log_frag_size
s_log_block_size
.
s_first_data_block
s_max_mnt_count
e2fsck
. When
e2fsck
is run without the `-f' option, e2fsck
will
skip the filesystem check if the number of times that the filesystem has
been mounted is less than s_max_mnt_count
and if the interval
between the last time a filesystem check was performed and the current
time is less than s_checkinterval
(see below). The default value
of s_max_mnt_count
is 20.
s_checkinterval
e2fsck
. The default value of this field is 180 days (six
months).
s_errors
The default behavior is `EXT2_ERRORS_CONTINUE'.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The filesystem handle has a number of flags which can be manipulated using the following function. Some of these flags affect how the libext2fs filesystem behaves; others are provided solely for the application's convenience.
ext2fs_close
is
called. ext2fs_mark_super_dirty
will also set the filesystem
changed flag. The dirty flag is automatically cleared by
ext2fs_flush
when the superblock is written to disk.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.2.1 Reading and writing inodes 2.2.2 Iterating over inodes in a filesystem 2.2.3 Iterating over blocks in an inode 2.2.4 Convenience functions for Inodes
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The inode_scan abstraction is useful for iterating over all the inodes in a filesystem.
ext2fs_get_next_inode
. The buffer_blocks parameter
controls how many blocks of the inode table are read in at a time. A
large number of blocks requires more memory, but reduces the overhead in
seeking and reading from the disk. If buffer_blocks is zero, a
suitable default value will be used.
This function returns the next inode from the filesystem; the inode number of the inode is stored in ino, and the inode is stored in inode.
If the inode is located in a block that has been marked as bad,
ext2fs_get_next_inode
will return the error
EXT2_ET_BAD_BLOCK_IN_INODE_TABLE
.
ext2_get_next_inode
when all of the inodes in a block group have
been processed.
Set the scan_flags set_flags and clear the scan_flags clear_flags. The following flags can be set using this interface:
ext2fs_get_next_inode
will return the error
EXT2_ET_MISSING_INODE_TABLE.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Returns an array of blocks corresponding to the direct, indirect, doubly indirect, and triply indirect blocks as stored in the inode structure.
ENOTDIR
if it is not.
Returns 1 if the inode's block entries actually valid block entries, and 0 if not. Inodes which represent devices and fast symbolic links do not contain valid block entries.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.4.1 Reading and Writing Bitmaps 2.4.2 Allocating Bitmaps 2.4.3 Freeing bitmaps 2.4.4 Bitmap Operations 2.4.5 Comparing bitmaps 2.4.6 Modifying Bitmaps 2.4.7 Resizing Bitmaps 2.4.8 Clearing Bitmaps
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions set, clear, and test bits in a block bitmap bitmap.
These functions set, clear, and test bits in an inode bitmap bitmap.
These "fast" functions are like their normal counterparts; however, they are implemented as inline functions and do not perform bounds checks on the inode number or block number; they are assumed to be correct. They should only be used in speed-critical applications, where the inode or block number has already been validated by other means.
Return the first inode or block which is stored in the bitmap.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The ext2 library has a number of abstractions which are useful for ext2 utility programs.
2.5.1 Badblocks list management 2.5.2 Directory-block list management 2.5.3 Inode count functions
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The dblist abstraction stores a list of blocks belonging to
directories. This list can be useful when a program needs to interate
over all directory entries in a filesystem; e2fsck
does this in
pass 2 of its operations, and debugfs
needs to do this when it is
trying to turn an inode number into a pathname.
Creates a dblist data structure and return it in ret_dblist.
Free a dblist data structure.
Add an entry to the dblist data structure. This call records the fact that block number blockcnt of directory inode ino is stored in block blk.
Change an entry in the dblist data structure; this changes the location of block number blockcnt of directory indoe ino to be block blk.
This iterator calls func for every entry in the dblist data structure.
This iterator takes reads in the directory block indicated in each dblist entry, and calls func for each directory entry in each directory block. If dblist contains all the directory blocks in a filesystem, this function provides a convenient way to iterate over all directory entries for that filesystem.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The icount abstraction is a specialized data type used by e2fsck
to store how many times a particular inode is referenced by the
filesystem. This is used twice; once to store the actual number of times
that the inode is reference; and once to store the claimed number of times
the inode is referenced according to the inode structure.
This abstraction is designed to be extremely efficient for storing this sort of information, by taking advantage of the following properties of inode counts, namely (1) inode counts are very often zero (because the inode is currrently not in use), and (2) many files have a inode count of 1 (because they are a file which has no additional hard links).
Creates an icount stucture for a filesystem fs, with initial space
for size inodes whose count is greater than 1. The flags
parameter is either 0 or EXT2_ICOUNT_OPT_INCREMENT
, which
indicates that icount structure should be able to increment inode counts
quickly. The icount structure is returned in ret. The returned
icount structure initially has a count of zero for all inodes.
The hint parameter allows the caller to optionally pass in another icount structure which is used to initialize the array of inodes whose count is greater than 1. It is used purely as a speed optimization so that the icount structure can determine in advance which inodes are likely to contain a count grater than 1.
Frees an icount structure.
Returns in ret fetches the count for a particular inode ino.
Increments the ref count for inode ino.
Decrements the ref count for inode ino.
Sets the reference count for inode ino to be count.
Returns the current number of inodes in icount which has a count greater than 1.
Validates the internal rep invariant of icount; if there are any problems, print out debugging information to f. This function is intended for debugging and testing use only.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
/* version.c */
This function returns the current version of the ext2 library. The return value contains an integer version code, which consists of the major version number of the library multiplied by 100, plus the minor version number of the library. Hence, if the library version is 1.08, the returned value will be 108.
If ver_string and/or date_string are non-NULL, they will be set to point at a constant string containing the library version and/or release date, respectively.
This function takes a version string which may included in an
application and returns a version code using the same algorithm used by
ext2fs_get_library_version
. It can be used by programs included
in the e2fsprogs
distribution to assure that they are using an
up-to-date ext2 shared library.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |