summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2011-09-16e4defrag: Check error return of sysconf()Eric Sandeen1-1/+4
In theory sysconf() can fail, so check for an error return. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsprogs: Don't try to close an fd which is negativeEric Sandeen3-6/+12
These reflect either file descriptors which aren't tested for failure, or closures of fd's which may have failed. In setup_tdb(), test for failure of mkstemp and return without trying to open the file (again). In reserve_stdio_fds, rather than closing the "extra" fd == 3 due to the way the loop is written, just don't go that far by using while (fd <= 2). In logsave, it forks and retries forever if open fails, but at least make coverity happy by explicitly not trying to close a negative file descriptor. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16tune2fs: handle inode and/or block bitmap read failures in resize_inode()Eric Sandeen1-2/+13
Handle these failures in resize_inode, and handle the propagated error in the caller. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: Fix leaks in error pathsEric Sandeen1-2/+5
fn and/or array was not freed in some error paths. [ Also make sure the array is NULL terminated before we free it in get_dirlist(). --tytso] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16test_icount: fclose() before exitEric Sandeen1-0/+2
Just to be tidy. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libext2: Fix leaks in write_bitmaps on error returnsEric Sandeen1-9/+19
block_buf and/or inode_buf may not be properly freed on an error return. Create a new errout: target to free them as needed in error conditions. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2initrd_helper: Fix memory leak on errorEric Sandeen1-4/+7
Some error paths did not properly free "buf" And the normal exit seemed to close e2_file twice (?) Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16mke2fs: Do not let -t or -T be specified more than onceEric Sandeen1-0/+10
In addition to not making sense, it causes a memory leak when fs_type gets overwritten. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: remove extraneous memsetEric Sandeen1-1/+0
e2fsck_allocate_memory() already sets allocated memory to 0, so remove the explicit memset. Especially since it was setting the wrong size (iter not *iter) Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16filefrag: Fix uninitialized "expected" valueEric Sandeen1-2/+3
The "count" variable is only ever set if FIBMAP is used, due to the -B switch, or a fiemap failure. However, we use it unconditionally to calculate "expected" for extN files, so we can end up printing garbage. Initialize count to 0, and unless we go through the FIBMAP path, expected will be 0 as well, and in that case do not print the message. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16subst: Fix free of uninit pointersEric Sandeen1-4/+1
in add_subst(), if the malloc of ent->name fails, we goto fail; which will free ent->name (which is null, so OK) but also free ent->value (which is uninitialized). There is no case where we must free ent->value on an error (it is allocated last, and if it fails it of course doesn't need to be freed) so just remove it. Also "retval" is only assigned once to the constant ENOMEM, so we can just return that explicitly in the failure case. Signed-off-by: Eric Saneeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsprogs: Fix some error cleanup path bugsEric Sandeen6-11/+11
In inode_open(), if the allocation of &io fails, we go to cleanup and dereference io to test io->name, which is a bug. Similarly in undo_open() if allocation of &data fails, we go to cleanup and dereference data to test data->real. In the test_open() case we explicitly set retval to the only possible error return from ext2fs_get_mem(), so remove that for tidiness. The other changes just make make earlier returns go through the error goto for consistency. In many cases we returned directly from the first error, but "goto cleanup" etc for every subsequent error. In some cases this leads to "impossible" tests such as: if (ptr) ext2fs_free_mem(&ptr) on paths where ptr cannot be null because we would have returned directly earlier, and Coverity flags this. This isn't really indicative of an error in most cases, but I think it can be clearer to always exit through the error goto if it's used later in the function. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: Don't store old_op from ehandler_operation if we don't restore it.Eric Sandeen2-4/+2
old_op is set but never used, because we restore "0" not old_op. So don't bother with it. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libe2p: reach unreachable codeEric Sandeen1-3/+4
The EOPNOTSUPP case is unreachable, being outside a set of: #if ... return; #else ... return; #endif Fix this up so that if neither HAVE_CHFLAGS nor HAVE_EXT2_IOCTLS applies, we set EOPNOTSUPP. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16freefrag: fix up getopt case statementEric Sandeen1-3/+1
There is no need to print out a "bad option" message; getopt does that for us, and in fact will change "c" to "?" so it's not even useful. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16uuidd: Add missing break to option case statementEric Sandeen1-0/+1
Specifying the "-n" option to uuidd would incorrectly fall through to the "-p" case, and assign that number to the pidfile_path. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsprogs: annotate intentional fallthroughs in case statementsEric Sandeen5-0/+10
Using the /* fallthrough */ comment lets Coverity (and humans) know that we really do want to fall through in these case statements. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: handle null fs in print_pathname()Eric Sandeen1-2/+3
testing fs for NULL in expand_percent_expression(): e2fsck_ctx = fs ? (e2fsck_t) fs->priv_data : NULL; implies that fs could be NULL, but it's passed to print_pathname() which defererences it without further testing. So make this safe by returning "???" for a nul fs. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libext2fs: Potential null ptr deref in undo_err_handler_initEric Sandeen1-1/+2
In the !undo_io_backing_manager case, undo_err_handler_init will be passed a null data->real, which will be dereferenced. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libext2: move buf variable completely under ifdefEric Sandeen1-3/+4
If !WORDS_BIGENDIAN, it is pointless to test whether buf is NULL, because it is initialized to NULL and never changed. This makes Coverity complain, so we can just move all handling of "buf" under the #ifdef. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16mke2fs: remove impossible tests for null usage_typesEric Sandeen1-5/+2
parse_fs_type explicitly sets usage_types if it is null, so there is no need to test for null later. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16fsck: fix -C option parsingEric Sandeen1-1/+1
The i++; statement is unreachable; fix same as commit f1c2eaac535bd9172a35ce39b6d8f392321f274d in util-linux Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsprogs: Remove impossible name_len tests.Eric Sandeen5-14/+3
The name_len field in ext2_dir_entry is actually comprised of the name length in the lower 8 bytes, and the filetype in the high 8 bytes. So in places, we mask name_len with 0xFF to get the actual length. But once we have masked name_len with 0xFF, there is no point in testing whether it is greater than EXT2_NAME_LEN, which is 255 - or 0xFF. So all of these tests are extraneous. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libext2: Fix EXT2_LIB_SOFTSUPP maskingEric Sandeen1-2/+2
EXT2_LIB_SOFTSUPP_INCOMPAT_* are supposed to be bitmasks of features which can be opened even though they are under development. The intent is that these are masked out of the features list, so that they will be ignored on open. However, the code does a logical not vs. a bitwise not: features &= !EXT2_LIB_SOFTSUPP_INCOMPAT; which will not have the desired effect... Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libext2s: fix swapfs.c so it builds on big endian systemsTheodore Ts'o2-11/+27
Also cleaned up ext2_fs.h, and improved the byte swapping code so the extra fields in the large inode are properly byte swapped. Addresses-Debian-Bug: #641838 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16debian: use 1.41.99 hack so that lintain doesn't complainTheodore Ts'o1-130/+183
We'll have to fix this up before 1.42 ships. And the quota library badly needs to be cleaned up... Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16Update for e2fsprogs 1.42-WIP-0916 releaseTheodore Ts'o5-8/+105
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16libquota: indicate in the ELF library image that it requires libext2fsTheodore Ts'o1-1/+1
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16debugfs: add 64-bit support to the set_field commandsTheodore Ts'o6-164/+313
The set_fields commands (set_super_value, set_inode_field, set_block_group) now handle fields which store in split fields on ext4's on-disk format. For example, the superblock fields s_blocks_count and s_blocks_count_hi. The user can either set the low or high part of the field via "blocks_count_lo" or "blocks_count_hi", or both parts can be set via "blocks_count". Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16libext2fs: add metadata checksum and snapshot feature flagsTheodore Ts'o8-15/+51
Reserve EXT4_FEATURE_RO_COMPAT_METADATA_CSUM and EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP. Also reserve fields in the superblock and the inode for the checksums. In the block group descriptor, reserve the exclude bitmap field for the snapshot feature, and checksums for the inode and block allocation bitmaps. With this commit, the metadata checksum and exclude bitmap features should have reserved all of the fields they need in ext4's on-disk format. This commit also fixes an a missing byte swap for s_overhead_blocks. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: Darrick J. Wong <djwong@us.ibm.com> Cc: Amir Goldstein <amir73il@gmail.com>
2011-09-16dumpe2fs: display "free blocks" as "free clusters" for bigalloc file systemsTheodore Ts'o2-5/+15
Change this for the equivalent function in debugfs as well. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16libext2fs: remove redundant last-group check in ext2fs_check_desc()Eric Sandeen1-2/+0
ext2fs_group_last_block2() already properly calculates the last block in the last group, so there is no need to special-case this after the call. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsck: fix error in computing blocks of the ending groupYongqiang Yang1-3/+2
If the blocks of a filesystem is a multiple of blocks_per_group, blocks of the ending group is computed wrongly. Use the new ext2fs_group_blocks_count() helper instead. Eric Sandeen: Converted to use new blocks per group helper Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16e2fsprogs: add ext2fs_group_blocks_count helperEric Sandeen6-35/+27
Code to count the number of blocks in the last partial group is cut and pasted around the e2fsprogs codebase a few times. Making this a helper function should improve matters. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16libext2fs: fix size check in tst_inode_sizeTheodore Ts'o2-1/+2
Also add run tst_inode_size automaically from "make check" Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16Merge branch 'maint' into nextTheodore Ts'o7-8/+23
2011-09-15e2fsck: do not attempt to discard if -n was specifiedLukas Czerner1-4/+3
If '-n' option is specified there should be no changes made to the file system hence we should not attempt to discard the file system. This commit adds a check into the e2fsck_discard_blocks() condition so it skip discard if E2F_OPT_NO flag is set. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15tests: Print out list of failed testsLukas Czerner1-1/+9
Currently we need to grep, list or just search for failed tests when running 'make check' which is annoying. This commit simply prints out the list of failed test names at the end of the output. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15e2fsprogs: Use punch hole as "discard" on regular filesLukas Czerner8-14/+59
If e2fsprogs tools (mke2fs, e2fsck) is run on regular file instead of on block device, we can use punch hole instead of regular discard command which would not work on regular file anyway. This gives us several advantages. First of all when e2fsck is run with '-E discard' parameter it will punch out all ununsed space from the image, hence trimming down the file system image. And secondly, when creating an file system on regular file (with '-E discard' which is default), we can use punch hole to clear the file content, hence we can skip inode table initialization, because reads from sparse area returns zeros. This will result in faster file system creation (without the need to specify lazy_itable_init) and smaller images. This commit also fixes some tests that would fail due to mke2fs showing discard progress, hence the output would differ. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15e2fsprogs: create open() and stat() helpersLukas Czerner7-50/+50
In many places we are using #ifdef HAVE_OPEN64 to determine if we can use open64() but that's ugly. This commit creates two new helpers ext2fs_open_file() for open() and ext2fs_stat() for stat(). Also we need new typedef ext2fs_struct_stat for struct stat. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15libext2fs: Add crc32c implementation for metadata checksummingDarrick J. Wong5-2/+1345
Add a slicing-by-8 CRC32c implementation for metadata checksumming. Adapted from Bob Pearson's kernel patch. Also added a self-test mechanism so we can verify that the crc32c implementation is working correctly. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15mke2fs: check that auto-detected blocksize <= sys_page_sizeYury V. Zaytsev1-11/+13
Block size can be specified manually via the -b option or deduced automatically. Unfortunately, the check that it is still smaller than the system page size is only performed right after the command line options are parsed. Therefore, if buggy or inappropriately installed/configured hardware hints that larger block sizes have to be used, mkfs will silently create a file system which can not be mounted on the system in question. By moving the check beyond the last assignment to blocksize it is now ensured, that mkfs will issue a warning even if inappropriate blocksize was auto-detected. The new behavior can be easily tested, by exporting the following variables before running mkfs: export MKE2FS_DEVICE_SECTSIZE=8192 export MKE2FS_DEVICE_PHYS_SECTSIZE=8192 Signed-off-by: Yury V. Zaytsev <yury@shurup.com> Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15mke2fs.8: Fix the documentation of maximum journal sizeSurbhi Palande1-1/+2
Fix the max journal size in mke2fs man page. Signed-off-by: Surbhi Palande <csurbhi@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15libext2fs: fix the range validation in bitmap_range2 funcsAmir Goldstein1-5/+5
The condition ((start+num) & ~0xffffffffULL) in bitmap_range2 and generic_bmap_range funcs in get_bitmap64.c was wrong and inconsistent with the condition (start+num-1 > bmap->real_end) in generic_bitmap_range funcs in get_bitmap.c. I got the following error from tune2fs on a 16TB fs: Illegal block number passed to ext2fs_unmark_block_bitmap #4294967295 for block bitmap for 16TB.img tune2fs: Invalid argument while reading bitmaps Fix to condition to ((start+num-1) & ~0xffffffffULL), because the bit (start+num) is not going to be changed by the funcs. Signed-off-by: Amir Goldstein <amir73il@users.sf.net> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15badblocks: update man page's description of the -v optionTheodore Ts'o1-1/+2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-15debian: update the e2fslibs and e2fslibs-dev files for the quota libraryTheodore Ts'o2-1/+3
We will include the quota library in e2fslibs for now. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-15libext2fs: fix binary and source compatibility with the dump programTheodore Ts'o4-4/+17
The dump program relies on fs->frag_size and the EXT2_FRAGS_PER_BLOCK() macro. Kind of silly for it to do so, but it's part of the kludgy way the dump program (which was originally written for the BSD FFS was ported over to support ext2/3.) Given how it makes assumptions about the ext2/3/4 file system being similar to the BSD FFS, it's a bit of a miracle it works for ext4 --- or at least appears to work... Addresses-Debian-Bug: #636418 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-15mke2fs: use "extent" consistently as a feature name in the man pageTheodore Ts'o1-1/+1
Addresses-Debian-Bug: #639411 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-15libe2p: fix bug so that MNTOPT_ options can be successfully parsedTheodore Ts'o1-1/+1
Thanks to Israel G. Lugo for pointing this out. Addresses-Debian-Bug: #641667 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-14e2image: fix invalid lseek error detectionLukas Czerner1-1/+2
In flush_l2_cache() we are using ext2fs_llseek() however we do not properly detect the error code returned from the function, because we are assigning it into ULL variable, hence we will not see negative values. Fix this by changing the type of the variable to ext2_loff_t which is signed and hence will store negative values. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>