Commit Graph

895 Commits (4a568505ab904d39d9553e9c1d1c565615a5c6ca)

Author SHA1 Message Date
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
Theodore Ts'o 2d328bb76d Fix miscellaneous gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-17 23:17:13 -04:00
Andreas Dilger a7c9cb7d0d Add support for the DIR_NLINK feature.
This patch includes the changes required to e2fsck to understand the
nlink count changes made in the kernel.

In e2fsck pass 4, when we fetch the actual link count, if it is
exceeds 65,000 we set the link count to 1.  We silently fix the
situation where the nlink count of the directory is 1, and there are
fewer than 65,000 subdirectories, since since that can happen
naturally.

Patch originally from CFS, significantly rewritten by Theodore Ts'o.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-15 01:39:19 -04:00
Theodore Ts'o 60bbd1af53 libext2fs: Make icount use a 32-bit counter
In order to more accurately count the number of directories, which
with the DIR_NLINKS feature can now be greater than 65,000, change
icount to use a 32-bit counter.  This doesn't cost us anything extra
when the icount data structures are stored in memory, since due to
padding for alignment reasons.

If the actual count is greater than 65,500, we return 65,500.  This is
because e2fsck doesn't actually need to know the exact count; it only
needs to know if the number of subdirectories is greater than 65,000.
In the future if someone really needs to know the exact number, we
could add a 32-bit interface.  One isn't needed now, though.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-15 01:39:19 -04:00
Theodore Ts'o 6567e5a684 Merge branch 'maint' 2008-03-15 01:27:08 -04:00
Theodore Ts'o a80f3694a7 ext2_fs.h: Rename EXT4_ORPHAN_FS to be EXT3_ORPHAN_FS
No application will ever use the ORPHAN_FS flag, since it only shows
up in kernel memory, but it's been pointed out it was first used in
ext3, and so it should be renamed for accuracy.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-15 01:25:51 -04:00
Eric Sandeen 82e541885e Fix ext2fs_swap_inode_full() for in-inode xattrs on big-endian machines
After the fix for resize2fs's inode mover losing in-inode
extended attributes, the regression test I wrote caught
that the attrs were still getting lost on powerpc.

Looks like the problem is that ext2fs_swap_inode_full()
isn't paying attention to whether or not the EA magic is
in hostorder, so it's not recognized (and not swapped)
on BE machines.  Patch below seems to fix it.

Yay for regression tests.  ;)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-03-14 14:32:53 -04:00
Theodore Ts'o 252b736369 libext2fs: Fix fencepost error in ext2fs_extent_insert()
ext2fs_extent_insert() was copying n-1 of the existing extents when
moving things down to make room for the new extent.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-14 10:42:50 -04:00
Theodore Ts'o 83d9be1d5d libext2fs: Fix ext2fs_extent_delete() to always point at a valid entry
When deleting the last entry in a node, back up the current pointer so
it is always pointing at a valid entry.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 23:55:40 -04:00
Jose R. Santos 51b263e369 Add {read,write}_blk64 to inode_io.c
Add 64-bit block capable routines to inode IO manager.  Since fileio.c
does not yet have 64bit support, these routines will not handle 64bit
block numbers correctly yet.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 13:47:05 -04:00
Jose R. Santos 59ecd32dcb Add {read,write}_blk64 to unix_io.c
Add 64-bit block capable routines to Unix IO manager.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 13:46:58 -04:00
Jose R. Santos 3154e1cceb Add 64-bit IO manager operations to struct_io_manager.
In order to provide 64-bit block support for IO managers an maintain
ABI compatibility with the old API, some new functions need to be
added to struct_io_manger.  Luckily, strcut_io_manager has some
reserved space that we can use to add these new functions.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 13:46:44 -04:00
Theodore Ts'o a040a99b6c Merge branch 'maint'
Conflicts:

	lib/ext2fs/ext2_err.et.in
2008-03-13 10:53:26 -04:00
Theodore Ts'o 52b1dd5e49 libext2fs: Add ext2fs_dblist_get_last() and ext2fs_dblist_drop_last()
Add two new functions which allows the caller to examine the last
directory block entry added to the list, and to drop if it necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 00:34:16 -04:00
Theodore Ts'o dd232049d1 blkid: Fix portability problem caused by using uint instead of unsigned int
This is needed to fix compilation with DJGPP; thanks to Cristophe
Grenier for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-08 20:01:05 -05:00
Theodore Ts'o a49670e64e Merge branch 'maint'
Conflicts:

	lib/blkid/devname.c
	lib/blkid/probe.c
	misc/mke2fs.c
	misc/tune2fs.c
2008-02-27 18:53:34 -05:00
Theodore Ts'o 3a538e4244 Fix gcc -Wall warnings for lib/blkid/probe.c
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-27 02:06:08 -05:00
Theodore Ts'o 1f1ee19485 libblkid: Add error checking to devicemapper code to avoid segfaults
If a device mapper volume disappears while libblkid code is running,
it is possible for the devicemapper code to return errors, and since
libblkid wasn't checking for error returns, it would dereference a
null pointer and crash.  Add error checking to prevent this.

Addresses-RedHat-Bugzilla: #433857

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-26 22:24:42 -05:00
Theodore Ts'o ab52e12a90 libext2fs: Add EXT2_FLAG_NONFREE_ON_ERROR to ext2fs_open2()
Add a flag which returns the partially completed filesystem object so
e2fsck can print more intelligent error messages.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-26 20:45:36 -05:00