summaryrefslogtreecommitdiff
path: root/lib/ext2fs
AgeCommit message (Collapse)AuthorFilesLines
2009-08-05Convert libext2fs to 64-bit bitmap interfaceValerie Aurora Henson16-116/+241
(Includes fixes from Nick Dokos) Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22Add support for 64-bit bitmapsTheodore Ts'o9-10/+1195
Initial design was done by Theodore Ts'o; implementation was fleshed out by Valerie Aurora Henson. Also includes some fixes from Nick Dokos. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
2009-08-22Merge branch 'maint' into nextTheodore Ts'o1-2/+2
2009-08-22Move declaration of FS_IOC_FIEMAP ioctl to fiemap.hTheodore Ts'o1-0/+4
This helps e4defrag compile on systems where the system header files don't yet define FS_IOC_FIEMAP. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-01Merge branch 'maint' into nextTheodore Ts'o1-1/+1
Conflicts: misc/Makefile.in
2009-07-22libext2fs: Use blk_t instead of int in ext2fs_allocate_group_tableTheodore Ts'o1-1/+1
We are using a signed int to store a block number in ext2fs_allocate_group_table. We don't actually do any computation or comparisons using it, so it shouldn't cause any bugs, but it's technically incorrect, and it's possible an overly clever compiler might do something wrong with it. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-19libext2fs: Avoid creating unneeded new extents in ext2fs_extent_set_bmap()Theodore Ts'o1-25/+93
Avoiding inserting a new extent if it is possible to merge the new block to the beginning or the end of the previous or next extent. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-19libext2fs: Improve debugging printf's in extent.cTheodore Ts'o1-8/+51
Comment out less common debugging printf's, and fix some type warnings. Add high-level debugging printf's for ext2fs_extent_goto(), ext2fs_extent_insert(), ext2fs_extent_delete(), ext2fs_extent_replace() Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-19libext2fs: Fix regression in ext2fs_extent_set_bmap()Theodore Ts'o1-4/+5
Commit 0dc291611 introduced a regression when unmapping the first block in an extent. This caused e2fsck -fD to corrupt large directories if the directory has to shrink by more than one block. The problem was set_bmap should only go to a next leaf when setting a first block in an extent, and not when it is unmapping the first block in an extent. Addresses-Debian-Bug: #537510 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-18libext2fs: fix memory leak in error path in ext2fs_block_iterate2()Theodore Ts'o1-2/+4
Reported-by: Nic Case <number9652@yahoo.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-12libext2fs: Fix minor gcc -Wall warningsTheodore Ts'o3-10/+5
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11Remove tst_csum.c from lib/ext2fs/Makefile.in's SRCS listTheodore Ts'o1-1/+0
The tst_csum test is now part of csum.c, so there isn't a separate tst_csum.c file that should be listed as one of the source files in lib/ext2fs. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-10libext2fs: Make ext2fs_extent_set_bmap() more robust against ENOSPCTheodore Ts'o1-13/+33
In the case where we ext2fs_extent_set_bmap() is replacing the block mapping at the beginning of an already-existing extent, insert a new extent if necessary before shrinking an existing extent, to avoid data loss if the disk is full. This mostly addresses the problem described in Red Hat Bugzilla's statistics are still wrong, but at least the files on the filesystem are not corrupted. If there is a failure during the inode_scan_and_fix pass, the simplest thing to do may be to tell the user to run e2fsck -fy. Addresses-Red-Hat-Bug: #510379 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-09libext2fs: Add new function ext2fs_test_inode_bitmap_range()Theodore Ts'o2-4/+114
Optimize ext2fs_test_block_bitmap_range() and add a new function, ext2fs_test_inode_bitmap_range(), which works the same way as ext2fs_block_bitmap_range() but for inode bitmaps. It's needed for some code in the development branch, so let's drop it into the maint branch to make life easier in the future. Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-07libext2fs: reset handle after inserting new extentEric Sandeen1-0/+4
Commit 53422e moved the new extent insertion in ext2fs_extent_set_bmap() prior to the modification of the original extent, but the insert function left the handle pointing to the new extent. This left us modifying the -new- extent, instead of the original one, and winding up with a corrupt extent tree something like: BLOCKS: (0-1):588791-588792, (0):588791 We need to move back to the previous extent prior to modification, if we inserted a new one. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-02Add support for configure --enable-verbose-makecmdsTheodore Ts'o1-76/+76
Some people don't want to see the concise "kernel-style" make output. This configure option allows build engines that want to see the full set of commands executed by the makefile to get what they want. Most people will find this more distracting than useful, unless they need to debug the Makefiles. (It is not necessary to rerun configure to enable this verbose make output temprarily; if a developer wants to do a quick debug of a directory's makefile, he or she can simply edit the definition of the $(E) and $(Q) variables in the Makefile; instructions can be found in the MCONFIG file which is included in at the beginning of every Makefile.) Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-01Fix Makefile dependencies for libcom_errTheodore Ts'o1-12/+14
The e2fsprogs makefiles were using the same Makefile variable LIBCOM_ERR for the link-line arguments as well as the dependencies. Since LIBCOM_ERR can now include non-file arguments such as "-lpthread", we need to use a separate DEPLIBCOM_ERR variable that only has build file dependencies. Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR. Addresses-Sourceforge-Patches: #2813809 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29libext2fs: ensure validate_entry doesn't read beyond blocksizeNic Case1-3/+6
ext2fs_validate_entry would read beyond the end of the block to get dirent->rec_len for certain arguments (like if blocksize == final_offset). This patch adds a check so that doesn't happen, and changes the types of the arguments to avoid a compiler warning. Signed-off-by: Nic Case <number9652@yahoo.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-21Fix encoding for rec_len in directories for >= 64k blocksize file systemsTheodore Ts'o5-22/+82
Previously e2fsprogs interpreted 0 for a rec_len of 65536 (which could occur if the directory block is completely empty in 64k blocksize filesystems), while the kernel interpreted 65535 to mean 65536. The kernel will accept both to mean 65536, and encodes 65535 to be 65536. This commit changes e2fsprogs to match. We add the encoding agreed upon for 128k and 256k filesystems, but we don't enable support for these larger block sizes, since they haven't been fully tested. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-17libext2fs: initialize large inodes for journal & resizeEric Sandeen2-2/+2
I noticed that neither the journal nor resize inodes have i_extra_isize set post-mkfs; while this isn't likely to be a big problem, I think the below patch tidies it up. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-06-17libext2fs: write only core inode in update_path()Eric Sandeen1-7/+6
The ext2_extent_handle only has a struct ext2_inode allocated on it, and the same amount copied into it in that same function, but in update_path() we're possibly writing out more than that - for example 256 bytes, from that address. This causes uninitialized memory to get written to disk, overwriting the parts of the inode past the osd2 member (the end of the smaller structure). Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-15libext2fs: Fix memory leak in the extents handling functionTheodore Ts'o1-1/+1
Each time an extent handle is opened and closed, if the inode has an extent tree which does not fit in the inode's i_block structure, a filesystem block buffer was not getting released. Since e2fsck opens an extent handle for every inode using extents, this can translate to a very large amount of memory getting lost. Thanks to Henrik 'Mauritz' Johnson for discovering and pointing out this leak, which he ran into while running the "rdump" command in debugfs. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01libext2fs: Add ext2fs_block_iterate3()Theodore Ts'o2-27/+112
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01libext2fs: Add 64-bit bitopsValerie Aurora Henson3-0/+181
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-21Merge branch 'maint' into nextTheodore Ts'o2-38/+152
2009-07-12Merge branch 'maint' into nextTheodore Ts'o3-10/+5
2009-06-01Add 64-bit mkjournal.c interfaceJose R. Santos2-3/+17
Added 64-bit mkjournal.c interface. Needed to zero inode tables. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01Add ext2fs_div64_ceil()Jose R. Santos1-0/+9
Add a new div_cell routine able to handle 64bit values Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01Add 64-bit openfs interfaceJose R. Santos2-3/+11
Add new ext2fs_descriptor_block_loc2() routine that takes blk64_t as an input. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11Use new ext2fs_super_and_bgd_loc2 call in libext2fsJose R. Santos3-11/+27
The new ext2fs_super_and_bgd_loc2() function has some changes aside from just blk64_t support. Lets make sure that the interfaces are sane by adding libext2fs support early to get the new API tested here. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01Add 64-bit closefs interfaceJose R. Santos2-36/+90
Add new ext2fs_super_and_bgd_loc2() that returns blk64_t pointers. The function now returns the number of blocks used by super block and group descriptors since with flex_bg, it can no longer be assumed that bitmaps and inode tables still resided within the block group. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01Add 64-bit ext_attr interfaceJose R. Santos2-7/+31
Add ext2fs_read_ext_attr2(), ext2fs_write_ext_attr2() and ext2fs_adjust_ea_refcount2() that take blk64_t as an input. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01Add 64-bit alloc interfaceJose R. Santos2-18/+60
Add new ext2fs_new_block2(), ext2fs_get_free_blocks2() and ext2fs_alloc_block2() that take and return blk64_t. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01Add 64-bit alloc_stats interfaceJose R. Santos2-3/+11
Add new ext2fs_block_alloc_stats2() routine that takes blk64_t as an input. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01Add 64-bit dirblock interfaceJose R. Santos2-6/+21
Add new ext2fs_(read|write)_dir_block3() routines that take blk64_t as an input. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01Use blk64_t for blocks in struct ext2_fileJose R. Santos1-6/+6
The ext2_file structure is never exposed through the libext2fs API so it is safe to use 64-bit blocks for blockno and physclock without breaking the ABI. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-06Add new blk64_t handling functionsJose R. Santos3-11/+616
Add new blknum.c file which contains funtions to handle blk64_t and low/high values in super blocks and inodes. (Includes fixes from Nick Dokos, and additions from Valerie Aurora Henson) Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-01libext2fs: Add ext2_off64_t typeJose R. Santos1-0/+1
The ext2_off_t type is u32. Create a new 64-bit ext2_off64_t for 64bit offsets. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-12libext2fs: Add 64-bit support to the undo managerTheodore Ts'o1-10/+45
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-06libext2fs: Define bg_itable_unused_hi in the ext4_group_desc structureValerie Aurora Henson1-4/+7
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-30Update lib/xt2fs/Makefile.in using "make depend"Theodore Ts'o1-5/+0
2009-05-29libext2fs: Move test code for csum.c inline instead of in a separate fileTheodore Ts'o3-135/+116
Move the test code which is used to build the tst_csum progam from tst_csum into csum.c under an #ifdef DEBUG to simplify things and to avoid compile problems caused by not having a prototype for ext2fs_group_desc_csum(). Addresses-Sourceforge-Bug: #2484331 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-29libext2fs: Add an explicit error code for missing mtab fileTheodore Ts'o2-1/+4
To reduce user confusion, if the /etc/mtab file is missing ext2fs_check_mount_point and ext2fs_check_if_mounted will return a new, explicit error code to indicate this case. Addresses-Debian-Bug: #527859 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-28libext2fs: add ext2fs_extent_open2number96524-9/+24
The patch below adds a function, ext2fs_extent_open2(), that behaves as ext2fs_extent_open(), but will use the user-supplied inode structure when opening an extent instead of reading the inode from disk. It also changes several of the calls to extent_open() to use this enhancement. Signed-off-by: Nic Case <number9652@yahoo.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-25resize2fs: fix ENOSPC corruption caseEric Sandeen1-5/+6
http://people.redhat.com/esandeen/livecd-creator-imagefile.bz2 contains an image (for now) which, when resized to 578639, corrupts the filesystem. This is a bit crazy, I guess, because the fs currently has only 1 free block, but still, we should be graceful about the failure. Perhaps it would make sense to check the requested valuea against the minimum value resize2fs would compute for "-P" and fail (at least without a force). But in any case, this exposed 2 bugs when moving that one block required an extent split, which is what hit the ENOSPC. For starters, ext2fs_extent_set_bmap() in the "(re/un)mapping last block in extent" case was replacing the old extent before the new one was created; when the new extent creation failed, it left us in an inconsistent state. Simply changing the order of the two should fix this problem. Next, ext2fs_extent_insert was calling ext2fs_extent_delete() on *any* error, including one caused by failure to allocate a new block to split the node to hold that extent ... the handle was left unchanged, and we deleted the -original- extent. As a quick fix for this, just don't do the delete if we fail the split, though this may need to be smarter. I don't think we have terribly consistent behavior about where a handle is left on various errors. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-04Add missing file: lib/ext2fs/fiemap.hTheodore Ts'o1-0/+66
This file is needed so the updated filefrag program will compile. I missed a "git add"; oops. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-02Avoid unneeded updates of block group descriptors in ext2fs_closefs()Theodore Ts'o1-1/+2
If the superblock is clean, and we only need to update s_kbytes_written, then we only need to update the superblock. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23Update lib/ext2fs/Makefile.in using "make depend"Theodore Ts'o1-3/+3
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23libext2fs: read the block group descriptors more efficientlyTheodore Ts'o1-2/+18
When opening a filesystem, make ext2fs_open2() much more efficient by reading the normal block group descriptors all at once, instead of one block at a time. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22libext2fs: Skip relative pathnames in /etc/mtab in ismounted.cTheodore Ts'o1-0/+2
The functions which test to see if a device is mounted can get confused by entries in /etc/mtab for virtual filesystems: rootfs / rootfs rw 0 0 none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 If the device name doesn't start with a slash, ignore the /etc/mtab entry, so that relative pathnames passed into functions such as ext2fs_check_mount_point() or ext2fs_check_if_mounted() don't return false positives. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>