Commit Graph

965 Commits (65f14120126880ac4395e744d30ee07a0d99cfe2)

Author SHA1 Message Date
Manish Katiyar 8eb3b8a0a0 ext2fs_read_inode: Check the validity of the inode number earlier
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>
2008-07-15 11:10:19 -04:00
Theodore Ts'o f56aa6e6ee Don't assume that /bin/true is always in /bin
... because it isn't on MacOS X

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-14 17:47:52 -04:00
Theodore Ts'o bb47c2a4af libblkid: Make sure we never reference a null dev->bid_type
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>
2008-07-13 19:10:10 -04:00
Theodore Ts'o 4729455f0a libext2fs: Don't check the group checksum when !GDT_CSUM
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>
2008-07-13 19:03:59 -04:00
Theodore Ts'o 2a7bfe8353 Flush stdio buffers before calling setbuf()
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>
2008-07-13 16:06:57 -04:00
Theodore Ts'o ebabf2ad6d Define _XOPEN_SOURCE to 600 consistently for Solaris C99 support
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>
2008-07-13 16:06:57 -04:00
Theodore Ts'o 5a299b5685 Remove gcc-specific varargs macro in extent.c
Use "#ifdef DEBUG // printf... // #endif" instead of dbg_printf().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:57 -04:00
Theodore Ts'o f926a7006d Remove vararg macro which causes portability problems from ext3_extent.h
Also remove other unneeded kernel-only cruft for ext3_extent.h.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:57 -04:00
Theodore Ts'o 5c3e1b917c Use K&R style comments instead of C99 comments for portability
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:56 -04:00
Theodore Ts'o 318824c1bb Fix Solaris shell script portability issues
Solaris ships with a pathetically ancient shell in /bin/sh,
so fix various shell scripts to accomodate.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-13 16:06:56 -04:00
Manish Katiyar 49b4670e5c libext2fs: Add stricter/earlier tests for blocksize in ext2fs_open()
Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-11 17:45:07 -04:00
Manish Katiyar adc4e77d89 libext2fs: fix potential memory leak in ext2fs_initialize()
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>
2008-07-11 14:45:58 -04:00
Theodore Ts'o 3da77aab97 Update dependencies in the Makefile for lib/ext2fs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-10 17:25:33 -04:00
Theodore Ts'o 009c02baf9 Make ext2fs_check_desc() more stringent to force use of backup superbocks
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>
2008-07-10 17:25:33 -04:00
Theodore Ts'o 2be8fe4397 mke2fs,tune2fs: Enable huge_file, dir_nlink, and extra_isize features
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>
2008-07-10 12:06:31 -04:00
Andreas Dilger 3fc1db6218 blkid: Make regression test tolerate older versions of mkswap
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>
2008-07-10 08:52:50 -04:00
Theodore Ts'o ba4a021009 libext2fs: Fix FLEX_BG offset used by ext2fs_allocate_group_table
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>
2008-07-07 16:12:28 -04:00
Ricardo M. Correia c03d992429 Add ZFS test image to blkid test suite
Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-07 15:13:09 -04:00
Eric Sandeen 79e62409b3 Clean up some trivial build warnings
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-06 18:36:56 -04:00
Theodore Ts'o bf58e3d1c6 blkid: Eliminate stale entries that duplicate a verified device
Addresses-Debian-Bug: #487758, #487783

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-28 22:17:54 -04:00
Theodore Ts'o b697f9d01c blkid: Make sure a device returned by blkid_find_dev_with_tag exists
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>
2008-06-28 22:17:43 -04:00
Eric Sandeen 772b89d342 blkid: use list_for_each_safe in garbage collection
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>
2008-06-28 22:17:20 -04:00
Theodore Ts'o 92e94afe4c libext2fs: Don't include ss/ss.h except when debugging
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>
2008-06-23 14:10:43 -04:00
Theodore Ts'o 8d45e2104c blkid: Fix cc portability problem in probe_lvm2()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-21 14:04:36 -04:00
Eric Sandeen 7f6a74b6d6 blkid: fix swap tests (again)
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>
2008-06-19 14:30:23 -04:00
Theodore Ts'o 71ff129e9f Merge branch 'maint'
Conflicts:

	README
	resize/online.c
	version.h
2008-06-17 23:54:51 -04:00
Theodore Ts'o cc19b95860 libblkid: Fix marginal C code in probe_lvm2()
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>
2008-06-17 13:03:47 -04:00
Theodore Ts'o bc507e31ad ext2fs_zero_blocks: Avoid clearing more blocks than requested
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>
2008-06-17 01:14:30 -04:00
Theodore Ts'o 81f6857b15 Fix LIBSS dependency problem for tests/test_icount and lib/ss/test_ss
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 22:19:52 -04:00
Theodore Ts'o 9d99416ea3 Fix dependency for $(LIBSS) when an explicit dlopen() library is needed
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 21:53:35 -04:00
Theodore Ts'o 5c4f8d6748 resize2fs: Add support to use the ext4 online resize ioctl's
First try the ext3 ioctl, but if we get an error, try using the ext4
ioctl.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 13:13:16 -04:00
Theodore Ts'o dabfa68f81 Update Makefile dependencies for lib/ext2fs 2008-06-07 11:56:23 -04:00
Theodore Ts'o 8895f43a60 Fix gcc -Wall warnings in libext2fs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 11:53:56 -04:00
Theodore Ts'o 96f4bb1fbc Fix gcc -Wall warnings in libuuid
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 11:53:20 -04:00
Theodore Ts'o dc9345a0bd Merge branch 'maint'
Conflicts:

	configure
2008-06-07 10:08:48 -04:00
Theodore Ts'o 488c75a6a6 Fix ext2fs_swap{16,32,64} for external applications on big-endian machines
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>
2008-06-07 08:55:21 -04:00
Theodore Ts'o 185c4aeaf2 e2fsck: Add support to check journal checksums
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-06 23:38:38 -04:00
Theodore Ts'o 69fbde418b Re-enable byte-swapping functions for use by journal checksums
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-06 23:38:38 -04:00
Aneesh Kumar K.V 2ea504bd64 libext2fs: Fix build failure on powerpc in ext2fs_swap_inode_full()
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-06 23:33:28 -04:00
Theodore Ts'o 8aa53bfa69 Merge branch 'maint' into next 2008-06-02 21:40:02 -04:00
Ricardo M. Correia c9bad3ce1a Add ZFS detection to libblkid
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>
2008-06-02 21:09:08 -04:00
Theodore Ts'o f5c562e232 libext2fs: Add callback functions for _alloc_block() and _block_alloc_stats()
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>
2008-06-02 18:52:12 -04:00
Theodore Ts'o ec9d6dd320 Wire ext2fs_bmap2() to use ext2fs_extent_set_bmap()
This commit enables read/write access via the ext2fs_bmap2() interface
for extent-based inodes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-02 18:52:12 -04:00
Theodore Ts'o d7b92206ba Wire ext2fs_block_iterate2() to use ext2fs_extent_set_bmap()
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>
2008-06-02 18:52:12 -04:00
Eric Sandeen c802ad9ed6 Teach ext2fs_extent_delete() to remove an empty extent node from the tree
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>
2008-06-02 18:52:12 -04:00
Eric Sandeen f4e9963c09 libext2fs: add new function ext2fs_extent_set_bmap()
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>
2008-06-02 18:52:05 -04:00
Eric Sandeen 01229db57e Teach ext2fs_extent_insert() to split the current node if necessary
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>
2008-06-02 10:14:08 -04:00
Eric Sandeen 9fd6a96d9b libext2fs: Teach extent.c how to split nodes
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>
2008-06-02 10:13:59 -04:00
Theodore Ts'o aa8e2f1c31 ext2fs_extent_open: If the inode is empty, initialize the extent tree
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>
2008-06-02 00:14:23 -04:00
Theodore Ts'o 05a32de263 ext2fs_extent_replace: Support uninit extents and check validity of e_len
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-01 22:56:37 -04:00