Commit Graph

1013 Commits (0eeec8ac61bf1eaa31533b2be825cd75580829c9)

Author SHA1 Message Date
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
Theodore Ts'o 168b6b53be Remove bashism in test script for libblkid
Thanks to Christian Kujau for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-25 19:45:29 -04:00
Theodore Ts'o c7015e491f Add 64-bit support to the test_io manager
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-24 19:17:01 -04:00
Theodore Ts'o c0af709e52 Merge branch 'maint'
Conflicts:

	README
	version.h
2008-05-21 16:56:42 -04:00
Theodore Ts'o 492ea6556e blkid: If the device mtime is newer that the cache time, force a revalidation
This fixes problems turned up by a test case written by Erez Zadok's
group which constantly reformats filesystems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-20 17:28:54 -04:00
Theodore Ts'o bb767b2fc3 ext2fs.h: Add l_i_file_acl_high and l_version_hi to on-disk inode structure
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-15 22:14:52 -04:00
Eric Sandeen 9817a2ba2d fix extent_goto for non-0 leaf levels
The logic for stopping at the right level in extent_goto was wrong,
so if you asked it to go to any level other than 0 (the leaf
level) it would fail.

Also add this argument to the tst_extents goto command to test it.

(I thought this was a failure in my split code but it was this
helper that was causing problems...)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-05-14 13:28:49 -04:00
Eric Sandeen 22269b8b60 - fix swap sanity tests in blkid, and blkid tests
Swap is actually native-endian on disk, and with the latest
swapspace sanity checks I added we need to have native swapspace
examples in the blkid tests, so re-mkswap them during testing.

One one other required change, though; mkswap requires at least
10 pages of swap, so the image needs to be increased to 10x64k
if mkswap is to succeed...

Maybe it'd be better to just dd it out on the fly?

Addresses-redhat-bugzilla: 445786

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-05-12 16:17:11 -04:00
Matthias Koenig cc435cb11a libuuid: don't use unitialized variable
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-05-11 20:41:15 -04:00
Theodore Ts'o b93cb0664e Fix parallel build problem
Problem was introduced by commit a4b69b7f18

Thanks to Eric Sandeen from Red Hat for pointing out this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-05-11 20:34:12 -04:00
Theodore Ts'o faa08e4c92 Merge branch 'next' into tt/flex-bg 2008-04-27 22:24:36 -04:00
Theodore Ts'o c860850441 ext2fs_add_journal_inode: Optimize writing the journal data blocks
Add a new function ext2fs_zero_blocks(), and use it so that journal
data blocks is written in larger chunks to speed up the creation of
the journal.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-27 19:42:23 -04:00
Aneesh Kumar K.V 72a168b59c libext2fs: Add undo I/O manager
This I/O manager saves the contents of the location being overwritten
to a tdb database. This helps in undoing the changes done to the
file system.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-27 19:40:46 -04:00
Theodore Ts'o 9ba400027f mke2fs: New bitmap and inode table allocation for FLEX_BG
Change the way we allocate bitmaps and inode tables if the FLEX_BG
feature is used at mke2fs time.  It places calculates a new offset for
bitmaps and inode table base on the number of groups that the user
wishes to pack together using the new "-G" option.  Creating a
filesystem with 64 block groups in a flex group can be done by:

mke2fs -j -I 256 -O flex_bg -G 32 /dev/sdX

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-04-22 23:32:16 -04:00
Theodore Ts'o 494a1daad3 Basic flexible block group support
Add superblock definition, and dumpe2fs and debugfs support.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-04-22 23:32:15 -04:00
Theodore Ts'o d11736c6dd ext2fs_open_inode_scan: Handle an non-zero bg_itable_used in block group 0
Previously, the portion of the inode table for block group 0 was
always completely zero'ed out, so the ext2fs_open_inode_scan() didn't
handle a non-zero bg_itable_used value for the first block group.  Fix
this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-22 23:22:17 -04:00
Theodore Ts'o 0f2794c020 mke2fs/libext2fs: Fix lazy inode table initialization
This fixes some bugs which I introduced recently while revamping the
uninit_bg code.  Since mke2fs is no longer calling
ext2fs_set_gdt_csum(), it's important that ext2fs_initialize()
correctly initialize bg_itable_unused for all block group descriptors.
In addition, mke2fs needs to zero out the the reserved inodes based on
the values of bg_itable_unused set by ext2fs_initialize().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-22 23:18:37 -04:00
Theodore Ts'o 4476105bf3 Merge branch 'maint'
Conflicts:

	configure
2008-04-21 21:35:44 -04:00
Theodore Ts'o 8bcaaabb1a blkid: Keep cached filesystem information on EACCES and ENOENT errors
When a nonprivileged user uses the blkid command, we want to keep the
cached filesystem information, and opening a device file could result
in an EACCESS or ENOENT (if an intervening directory is mode 700).  We
were previously testing for EPERM, which was really the wrong error
code to be testing against.

Addresses-Launchpad-Bug: #220275

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-21 19:22:49 -04:00
Theodore Ts'o 5711ed297b Transfer responsibility of setting the *_UNINIT flags to libext2fs
Mke2fs used to have special case, ugly code in
setup_lazy_bg/setup_uninit_bg flag which set the flags based on all
sorts of special cases.  Change it so that it is done in libext2fs,
and fix mke2fs to use alloc_stats functions which will take care of
clearing the *_UNINIT flags automatically as needed.

This is preparatory work to make the flex_bg allocation patch much
cleaner.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-21 01:39:23 -04:00
Theodore Ts'o 16b851cdae Remove LAZY_BG feature
This simplifies the code, and using the uninit_bg with the inode table
lazily initialized is just as good.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 23:33:34 -04:00
Theodore Ts'o 4a568505ab Add comments documenting ext2fs_[reserve_]super_and_bgd_loc()
Add an explanation of exactly what ext2fs_super_and_bgd_loc() and
ext2fs_reserve_super_and_bgd_loc() do, and more importantly, exactly
what they return.  Note that most callers should *not* rely on the
return value since it's rarely useful, especially once the flex_bg
feature is enabled and inode table and allocation bitmap blocks may
not be in the block group.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 19:22:49 -04:00
Theodore Ts'o 456e989270 ext2fs_set_gdt_csum: Remove setting of BLOCK_UNINIT
This function tried to set BLOCK_UNINIT based on the return value of
ext2fs_super_and_bgd_loc.  That's not something that works once we
start allowing flex_bg since the block group metadata might not be
located in the blockgroup itself.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 18:31:53 -04:00
Theodore Ts'o 3c5556ed4a ext2fs_set_gdt_csum: Remove bogus setting of ITABLE_ZEROED
It used to be the case that ext2fs_set_gdt_csum set the ITABLE_ZEROED
flag if the INODE_UNINIT is not set.  This assumed that the only
caller of ext2fs_set_gdt_csum was e2fsck (which was not true), and
that e2fsck would take care of zeroing the inode table (whic was also
not true).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 18:31:53 -04:00
Theodore Ts'o 41a5afa87b libe2p: Print the s_min_extra_isize and s_wanted_extra_isize fields
Make dumpe2fs and debugfs print out the s_min_extra_isize and
s_wanted_extra_isize fields from the superblock.

Update tests expect files as appropriate.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 16:10:07 -04:00
Theodore Ts'o 00a92841c2 libext2fs: Initialize s_min_extra_isize and s_wanted_extra_isize
Set the s_min_extra_isize and s_wanted_extra_isize superblock fields
to reasonable defaults in ext2fs_initialize().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 16:02:13 -04:00
Eric Sandeen 6360d129d0 blkid: more sanity checks for swap v1
mkswap followed by pvcreate on a block device
will still turn up as "swap" in blkid, because
pvcreate isn't particularly careful about zeroing
old signatures.  (neither is mkswap, for that matter).

Testing for appropriate version and page counts
gives us a bit more confidence that we have a
real swap (v1) partition.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-04-18 14:31:27 -04:00
Theodore Ts'o ba1e1254b0 Change the primary name of the extents feature to be 'extent'
This was the original name used by Lustre's patches; keep the plural
when converting feature names to a feature mask for compatibility's
sake.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 23:33:05 -04:00
Theodore Ts'o 2930dad2b2 Rename the feature uninit_groups to uninit_bg
Allow the old name of uninit_groups when converting feature names for
backwards compatibility for scripts running mke2fs and tune2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 23:31:44 -04:00
Eric Sandeen c21ed7705b Make extent_goto() deterministic when logical block not found
Make sure that extent_goto() leaves us at the last extent
prior to the requested logical block, if the logical block
requested lands in a hole.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-04-17 17:16:39 -04:00
Eric Sandeen 5e057d5cad Fix ext2fs_extent_insert when at last extent in node
ext2fs_extent_insert() only did a memmove if path->left
was > 0, but if we are at the last extent in the node,
path->left == 0, and this node must be moved before the
current extent is replaced with the newly inserted node.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-04-17 17:16:29 -04:00
Eric Sandeen 108e62e316 print a bit more info for the tst_extents info command
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 17:05:12 -04:00
Theodore Ts'o daf7a6e5d1 Fix tst_extents build when building w/o dynamic libraries
$(LIBSS) should automatically include @DLOPEN_LIB@ so the right thing
happens for programs that need to use the ss library.

Reorder the library link order for tst_extents since the blkid library
uses libuuid functions.

Thanks to Eric Sandeen for pointing this problem out!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 16:56:09 -04:00
Theodore Ts'o 1ca1059fd0 Add support for the HUGE_FILE feature
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-17 16:38:13 -04:00
Theodore Ts'o a91b3f36dd Merge branch 'maint' 2008-04-17 16:32:28 -04:00
Theodore Ts'o 6a141f218e Fix non-POSIX ">&" in the Makefile for lib/ss's "make check" rule
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-09 15:40:43 -04:00
Eric Sandeen 01c196b4f1 Fix a couple of implicit function declarations
Fedora seems to be gearing up to add
-Werror-implicit-function-declaration
to the standard build flags, so I thought I'd get out ahead
of this one...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-06 17:20:12 -04:00
Theodore Ts'o ae389208e9 Merge branch 'maint' into next 2008-04-06 17:10:49 -04:00
Theodore Ts'o 52bb0b050a libext2fs: Fix resize inode creation with non-standard s_first_data_block
Thanks to Max Lindner (lokimuh) for pointing this out.

   I'm playing around a bit with ext2 and multi-user encryption and I
   need space for my key management. So I set s_first_data_block to 4000
   or something like that.

   This way mke2fs segfaults when executing
   ext2fs_create_resize_inode() because

   blk_t goal = 3 + sb->s_reserved_gdt_blocks + fs->desc_blocks +
   fs->inode_blocks_per_group;

   will produce a integer underrun later and segfault then in the
   ext2fs_test_bit assembler inline function.

   when exchanging 3 with 2 + sb->s_first_data_block, mke2fs does not
   segfault.

   I'm not 100% sure if thats the correct way dealing with this issue
   but I think its a proper solution.

Addresses-Sourceforge-Bug: #1935847

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-06 17:00:23 -04:00
Theodore Ts'o 3541698f03 libext2fs: Fix big-endian bug in tst_csum.c
It's not necessary to byte-swap the checksum.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-01 17:03:00 -04:00
Theodore Ts'o a4b69b7f18 Add dependency rule so that static library when necessary for "make check"
Some library makefiles use $(LIB)/$(LIBRARY).a as a dependency for the
static library built by the makefile fragment.  Add it as a target
created when building $(LIBRARY).a so that it is rebuilt when necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-01 16:45:37 -04:00
Theodore Ts'o 4b57781f50 libext2fs: Make all test programs link only against the static library
This is needed so that all of the test programs compile correctly on
big-endian systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-01 16:43:24 -04:00
Andreas Dilger 6f19f44a4c libext2fs: Micro-optimization in inode scan code
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:37 -04:00
Andreas Dilger f628acea26 ext2fs_set_gdt_csum(): Return an error code on errors instead of void
Change the function signature so that ext2fs_set_gdt_csum() returns an
error code.

If the inode bitmap hasn't been loaded return EXT2_ET_NO_INODE_BITMAP.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:37 -04:00
Andreas Dilger d78ea441a2 ext2fs_set_gdt_csum(): Force the last block group to have a valid block bitmap
Never set the UNINIT_BLOCKS flag for the last group since the kernel
doesn't handle the case graefully if there is a full set of blocks in
each blockgroup marked UNINIT_BLOCKS.  The kernel should be fixed up,
but in the meantime this avoids hitting the problem, and is more
consistent with lazy_bg not marking the last group UNINIT.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:37 -04:00
Andreas Dilger 80fc4e698a ext2fs_set_gdt_csum(): Clean up superblock dirty flag handling
Only mark the superblock as dirty if the function actually managed to
change part of the block group descriptor.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:37 -04:00
Andreas Dilger 02a73f12df Fix the copyright notice in lib/ext2fs/tst_csum.c to be GPLv2 only
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-30 14:14:31 -04:00
Eric Sandeen d89ad0aefd Fix parallel builds for lib/ext2fs/extent.o
Updated the Makefile dependencies using "make depend".

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-25 09:59:45 -04:00
Eric Sandeen fb6627a3fb libext2fs: Fix byte-swap logic for i_block[] in inodes with extents
ext2fs_swap_inode_full() was incorrectly swapping the i_block array
for extents.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-24 08:25:40 -04:00
Eric Sandeen 85b59c40f4 Fix ext2fs_extent_get for uninit leaf extents
The ext2fs_extent_get() function was not OR-ing together UNINIT
and LEAF flags in the case where an extent was both; so if we
had an extent which was both uniint and leaf, pass1 would bail
out where depth == max_depth but was not marked as leaf, and
e2fsck (from the next branch) would abort with:

e2fsck 1.40.8 (13-Mar-2008)
Pass 1: Checking inodes, blocks, and sizes
Error1: No 'down' extent
Aborted

Also, if the error is encountered again, print the inode number
to aid debugging until it's properly handled, at least.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:45:27 -04:00
Jose R. Santos 3542ba0d37 Rename feature name from gdt_checksum to uninit_groups
This name is a more intuitive option when running mke2fs.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:33:12 -04:00
Jose R. Santos d4f34d41be Add uninit block group support to various libext2fs functions
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:33:12 -04:00
Jose R. Santos ca2634a46a Add initial checksum support for the gdt_checksum/uninit_group feature
- Add support for computing CRC-16 value.
- Add call to check/verify/set csum on block_groups.
- Add a test program to verify csum operations.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:32:11 -04:00