It looks like the right place to check for ino=0 in
ext2fs_read_inode_full() is before creating the inode cache, otherwise
since we set icache[i].ino = 0 in create_icache(), it will match the
loop below and thus we return a wrong value.
Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
There were a few places where we don't check to make sure
dev->bid_type is non-NULL before dereferencing the pointer, mostly in
debug code.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
ext2fs_group_desc_csum_verify() is always checking the bg_checksum (to
make sure it is zero) even when the GDT_CSUM feature is not present.
This is normally OK, but apparently there are filesystems in the wild
where this field has not be initialized to zero.
Addresses-Debian-Bug: #490637
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
On Solaris setbuf() will discard any pending output to the stream, so
make we call fflush() before calling setbuf().
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Solaris's header files are very picky about which C compiler can be
used for SUSv3 conformance. Use of C99 is not compatible with SUSv2
(_XOPEN_SOURCE=500), and C89 is not compatible with SUSv3
(_XOPEN_SOURCE=600). Since we need some SUSv3 functions, consistently
use SUSv3 so that e2fsprogs will build on Solaris using c99.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If we fail doing ext2fs_allocate_block_bitmap() or
ext2fs_allocate_inode_bitmap() we directly goto cleanup and don't free
the memory allocated to buf.
Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
E2fsck could to do more damage to a filesystem by trying to relocate
inode tables due to corrupted block group descriptors, and the
relocation could seriously damage the filesystem.
This patch enhances ext2fs_check_desk() so it detects more
self-inconsistent block group descriptors, including the cases where
e2sck might be tempted to relocate the inode table, and reports the
block group descriptors as invalid; this will cause e2fsck to attempt
to use the backup superblocks, which hopefully have not been trashed.
Addresses-Sourceforge-Bug: #1840291
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Also change mke2fs.conf to enable huge_file,dir_nlink,extra_isize, and
uninit_bg by default for ext4 filesystems, and enable extra_isize in
the library as well.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The blkid/tests contains new tests for swap, but the type-1 swapfile
test depends on mkswap supporting the "-U" option to specify the UUID.
This is not available even on relatively recent versions of mkswap
(2.13.1 16-Jan-2008) so the test needs to be changed to handle this.
If the "-U" option is not supported, don't verify the UUID in the blkid
output during testing.
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The offset for both inode bitmaps and inode tables is overshot by one
block causing a hole between the group of bitmaps and inode tables
when initializing a filesystem using mke2fs.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
There could be stale entries in blkid file, so if the device does not
exist, skip it.
Addresses-Debian-Bug: #487758, #487783
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
We need to use list_for_each_safe in case a device gets removed from
the list during garbage collection.
Also make the manpage slightly more informative about
what the -g garbage collection option does.
Addresses-Debian-Bug: #487758, #487783
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
extent.c should only try to include ss/ssh.h when it is compiled with
-DDEBUG. Otherwise it's not necessary and it breaks the Debian MIPS
build (and the Debian MIPS build only) because it tries to build
libext2fs without building libss as part of a MIPS-specific build
rule.
Addresses-Debian-Bug: #487675
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Some architectures (ppc ...) need a bigger swapfile than is shipped,
in the test image so the current re-make of swap was failing.
We could either ship a bigger image or just dd a bigger file...
There is one more minor problem with the tests; older mkswap does not
support the -U uuid specification. I'm not sure offhand what to do
about that problem, or if it really needs fixing.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Modern gcc accepted what was there previously, but it's clearly not
correct C code, and this may have been the explanation for why a user
trying to compile a recent version of e2fsprogs failed to do so on Red
Hat 7.3.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This could cause certain mke2fs feature combinations to result in the
initial blocks of the inode table getting wiped out when the journal
is created.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The public header files depend on the the autoconf defines
WORDS_BIGENDIAN and HAVE_SYS_TYPES_H, so we add them to ext2_types.h
so that external programs which try to use ext2fs_swap*() will work
correctly on big-endian systems. Fortunately, few if any programs
need to use this libext2's byte-swap functions directly.
Addresses-Debian-Bug: #484879
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This patch adds ZFS filesystem detection to libblkid.
It probes for VDEV_BOOT_MAGIC in the first 2 ZFS labels in big-endian
and little-endian formats.
Unfortunately the probe table doesn't support probing from the end of
the device, otherwise we could also probe in the 3rd and 4th labels (in
case the first 2 labels were accidentally overwritten)..
Eventually we would set the UUID from the ZFS pool GUID and the LABEL tag
from the pool name, but that requires parsing an XDR encoding of the pool
configuration which is not trivial.
Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Add callback functions for ext2fs_alloc_block() and
ext2fs_block_alloc_stats(). This is needed so e2fsck can be informed
when the extent_set_bmap() function needs to allocate or deallocate
blocks.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit enables read/write access via the block iterator for
extent-based inodes.
Also fixed some bugs regarding the handling on non-leaf extent nodes
when iterating over extents in a file.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
ext2fs_extent_delete() will also update the parent node and decrement
the inode block count.
Passing in the EXT2_EXTENT_DELETE_KEEP_EMPTY flag will allow the empty
node to remain.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Allows unmapping or remapping single mapped logical blocks,
and mapping currently unmapped blocks.
Also implements ext2fs_extent_fix_parents() to fix parent
index logical starts, if the first index of a node changes
its logical start block.
Currently this can result in unnecessary new single-block extents; I
think perhaps ext2fs_extent_insert should grow a flag to request
merging with a nearby extent?
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If ext2fs_extent_insert finds that the requested node
for insertion is full, it will currently fail.
With this patch it will split as necessary to make room, unless an
EXT2_EXTENT_INSERT_NOSPLIT flag is passed to it.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When called for a given handle, the new function extent_node_split()
will split the current node such that half of the node's entries will
be moved to a new tree block. The parent will then be updated to
point to the (now smaller) original node as well as the new node.
If the root node is requested to be split, it will move all
entries out to a new node, and leave a single entry in the
root pointing to that new node.
If the reqested split node's parent is full it will recursively
split up to the root to make room for the new node's insertion.
If you ask to split a non-root node with only one entry,
it will refuse (we'd have an empty node otherwise).
It also updates the i_blocks count when a new block has
successfully been connected to the tree.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the inode's i_block[] array is completely empty, create an empty
extent tree in the in-core inode and set the EXT4_EXTENT_FL inode
flag. This makes it easy to create a new inode using extents.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>