Commit Graph

544 Commits (master)

Author SHA1 Message Date
Bernhard M. Wiedemann e68476935b debugfs: fix typo in message
Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-02 15:23:55 -05:00
Eric Sandeen 77b493e35b debugfs: don't swap htree nodes in-place
htree_dump_int_node() was swapping htree nodes in-place,
something not done elsewhere, so it made the sparse checker
unhappy.  Just use dedicated variables to hold the 2 needed
(endian-swapped) values.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-04 11:26:21 -05:00
Theodore Ts'o 9ed2c124f3 debugfs: add allocate and set functionality to the bmap command
This also makes it easier test the ext2fs_bmap2() function.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-13 11:59:30 -04:00
Darrick J. Wong b291c11f08 misc: use libmagic when libblkid can't identify something
If we're using check_plausibility() to try to identify something that
obviously isn't an ext* filesystem and libblkid doesn't know what it
is, try libmagic instead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-20 23:42:19 -04:00
Darrick J. Wong c8b20b40eb misc: add plausibility checks to debugfs/tune2fs/dumpe2fs/e2fsck
If any of these utilities detect a bad superblock magic, call
check_plausibility to see if blkid can identify the passed-in argument
as something else (xfs, partition, etc.) in the hopes of catching a
user error.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 23:44:31 -04:00
Darrick J. Wong 53c5d6062e debugfs: manage needs_recover feature when messing with the journal
Set the needs_recover incompat feature when debugfs writes journal
transactions so that we actually replay the journal contents at the
next mount.

Likewise, clear it if we successfully recover the journal.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-19 02:01:43 -04:00
Darrick J. Wong d4daf0d89b misc: fix Coverity complaints
Fix a few problems that Coverity picked up with error handling.

Fixes-Coverity-Bug: 1239278
Fixes-Coverity-Bug: 1239279
Fixes-Coverity-Bug: 1239280
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-18 21:47:38 -04:00
Darrick J. Wong 463eb92131 debugfs: add the ability to write transactions to the journal
Extend debugfs with the ability to create transactions and replay the
journal.  This will eventually be used to test kernel recovery and
metadata_csum recovery.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:37 -04:00
Darrick J. Wong 759c46cf45 debugfs: create journal handling routines
Create a journal.c with routines adapted from e2fsck/journal.c to
handle opening and closing the journal, and setting up the
descriptors, and all that.  Unlike e2fsck's versions which try to
identify and fix problems, the routines here have no way to repair
anything.

[ Modified by tytso to fold debugfs/jfs_user.h into e2fsck/jfs_user.h,
  so we don't have to copy recovery.c and revoke.c into debugfs. --tytso ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:44:10 -04:00
Darrick J. Wong 38d5adf339 e2fsck/debugfs: fix descriptor block size handling errors with journal_csum
It turns out that there are some serious problems with the on-disk
format of journal checksum v2.  The foremost is that the function to
calculate descriptor tag size returns sizes that are too big.  This
causes alignment issues on some architectures and is compounded by the
fact that some parts of jbd2 use the structure size (incorrectly) to
determine the presence of a 64bit journal instead of checking the
feature flags.  These errors regrettably lead to the journal
corruption reported by Mr. Reardon.

Therefore, introduce journal checksum v3, which enlarges the
descriptor block tag format to allow for full 32-bit checksums of
journal blocks, fix the journal tag function to return the correct
sizes, and fix the jbd2 recovery code to use feature flags to
determine 64bitness.

Add a few function helpers so we don't have to open-code quite so
many pieces.

Switching to a 16-byte block size was found to increase journal size
overhead by a maximum of 0.1%, to convert a 32-bit journal with no
checksumming to a 32-bit journal with checksum v3 enabled.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 12:40:54 -04:00
Theodore Ts'o 8a54677711 debugfs: add better error checking when printing extended attributes
Check to make sure the length of the name and value fields in the
extended attribute don't result in overrun the bounds of the inode.

Addresses-Coverity-Bug: #709517

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-29 14:20:21 -04:00
Theodore Ts'o c1c8800b71 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	version.h
2014-08-25 18:37:37 -04:00
Darrick J. Wong c4c9bc590c misc: fix gcc warnings
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-24 12:22:11 -04:00
Theodore Ts'o 59a591f6b5 debugfs: fix set_inode_field block[IND|DIND|TIND]
After we determine that we can't parse the array value as an integer,
we need to restore the square brackets to the field name, so that we
can find a match with block[IND], block[DIND], and block[TIND] in the
inode field table.

Reported-by: Jun He <jhe@cs.wisc.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-19 08:27:59 -04:00
Theodore Ts'o 489ff4a2c7 Merge branch 'maint' into next
Conflicts:
	configure
2014-08-08 17:02:34 -04:00
Aaron Crane b6edbf6b90 debugfs: teach rdump to take multiple source arguments
[ modified to update man page by tytso ]

Signed-off-by: Aaron Crane <arc@aaroncrane.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-04 18:58:23 -04:00
Aaron Crane 850fe1aca7 debugfs: refactor do_rdump()
No behaviour changes.  This will simplify the next commit.

Signed-off-by: Aaron Crane <arc@aaroncrane.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-04 18:58:23 -04:00
Aaron Crane 3b0662fc95 debugfs: fix double-close bug in "rdump" and "dump -p"
Previously, both of these usages called dump_file() with a true value as
the "preserve" argument, which caused it to in turn call fix_perms() to
make the permissions on the locally-dumped file match those found on the
ext2 filesystem. fix_perms() then attempted to close(2) the file descriptor
(if any) before returning (though it didn't attempt to report on any errors
found while doing so).

However, in both of these situations, the local file being dumped had been
opened by the caller of dump_file(), which also closes it (and reports on
any errors detected when closing). This meant that both "rdump" and "dump
-p" would then emit a spurious EBADF message when trying to re-close the
local file descriptor.

Deleting the spurious close(2) call in fix_perms() fixes the problem in both
commands.

Signed-off-by: Aaron Crane <arc@aaroncrane.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-04 18:58:23 -04:00
Aaron Crane 09727a0705 debugfs: be more specific in error messages
Signed-off-by: Aaron Crane <arc@aaroncrane.co.uk>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-04 18:58:23 -04:00
Theodore Ts'o 14207cf60e Merge branch 'maint' into next
Conflicts:
	configure
	misc/Makefile.in
2014-08-02 22:05:03 -04:00
Andreas Dilger 0befec4e24 misc: quiet signed/unsigned charactr compiler warnings
Quiet warnings about signed vs. unsigned character mismatch.
Use __u8 for storing UUIDs instead of char to match the superblock
s_uuid field.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-01 21:39:27 -04:00
Darrick J. Wong 97c607b1a2 libext2fs: provide a function to set inode size
Provide an API to set i_size in an inode and take care of all required
feature flag modifications.  Refactor the code to use this new
function.

[ Moved the function to lib/ext2fs/blk_num.c, which is the rest of
  these sorts of functions live, and renamed it to be
  ext2fs_inode_size_set() instead of ext2fs_inode_set_size() to be
  consistent with the other functions in in blk_num.c -- tytso ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 14:34:56 -04:00
Theodore Ts'o 50972e1f7d Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
	e2fsck/pass5.c
2014-07-26 09:46:50 -04:00
Andreas Dilger 8b90ab2b1c build: fix unused/uninitialized variable warnings
Fix a few warnings about unused and uninitialized variables.

Also fix util/subst.c to include <sys/time.h> to avoid using
undeclared functions gettimeofday() and futimes().

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 22:48:01 -04:00
Darrick J. Wong 7ba5cc744b debugfs: fix printing of inline data during symlink inode dump
When we're dumping a fast symlink inode, we print some odd things to
stdout.  To clean this up, first don't print inline data EA, since the
inode dump doesn't display file and directory contents.  Then, teach
the inode dump function how to print out either an inline data fast
symlink or a non-inline data fast symlink.

(This is a follow-up to the earlier patch "debugfs: Only print the
first 60 bytes from i_block on a fast symlink")

[ Modified by tytso so that the d_inline_dump test works when build
  directory is different from the source directory --- i.e., when
  doing a VPATH build. ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-22 18:44:33 -04:00
Theodore Ts'o f9f3050a0a Merge branch 'maint' into next
Conflicts:
	debian/changelog
	e2fsck/pass1.c
	lib/ext2fs/Makefile.in
2014-07-22 14:57:40 -04:00
Darrick J. Wong fa633bf9f6 debugfs: allow bmap to allocate blocks
Allow set_inode_field's bmap command in debugfs to allocate blocks,
which enables us to allocate blocks for indirect blocks and internal
extent tree blocks.  True, we could do this manually, but seems like
unnecessary bookkeeping activity for humans.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-22 13:52:25 -04:00
Darrick J. Wong e13ebfdd5f debugfs: create inode_dump command to dump an inode in hex
Create a command that will dump an entire inode's space in hex.

[ Modified by tytso to add a description to the man page, and to add
  the more formal command name, inode_dump, in addition to short
  command name of "idump". ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-22 13:48:54 -04:00
Theodore Ts'o 7f7d1cb462 Merge branch 'maint' into next
Conflicts:
	debugfs/set_fields.c
	tests/f_mmp/script
	tests/f_mmp_garbage/script
	tests/m_mmp/script
	tests/t_mmp_1on/script
	tests/t_mmp_2off/script
2014-07-06 00:09:27 -04:00
Lukas Czerner 47fee2ef6a e2fsprogs: introduce ext2fs_close_free() helper
Currently there are many uses of ext2fs_close() which might be wrong.
First of all ext2fs_close() does not set the ext2_filsys pointer to NULL
so the caller is responsible for clearing it, however there are some
cases there we do not do it.

Second of all very small number of users of ext2fs_close() actually
check the return value. If there is a problem in ext2fs_close() it will
not even free the ext2_filsys structure, but majority of users expect it
to do so.

To fix both problems this commit introduces a new helper
ext2fs_close_free() which will not only check for the return value and
free the ext2_filsys structure if the call to ext2fs_close2() failed,
but it will also set the ext2_filsys pointer to NULL.

Replace every use of ext2fs_close() in e2fsprogs tools with
ext2fs_close_free() - there is no real reason to keep using
ext2fs_close().

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2014-07-05 21:06:48 -04:00
Theodore Ts'o a511695931 debugfs: add support setting the error_count and associated sb fields
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-04 16:39:49 -04:00
Zheng Liu 328731738d debugfs: do not display fast symlink with inline data
After enabling symlink with inline data, stat command in debugfs will
think an inode is a fast symlink.  This patch fixes this issue.

Cc: Ian Nartowicz <claws@nartowicz.co.uk>
Cc: Tao Ma <tm@tao.ma>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-06-02 10:57:20 -04:00
Zheng Liu ab74c09071 debugfs: fix two warning messages when compiling with LLVM
This commit fixes two warning messages when compiling with LLVM.

Reported-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2014-05-27 13:20:06 -04:00
Darrick J. Wong ec3a42b192 Misc coverity fixes
Fix various small resource leaks and error code handling issues that
Coverity pointed out.

Fixes-Coverity-Bugs: 1215250, 1193379, 119194[2-4], 1049160
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-27 13:02:19 -04:00
Theodore Ts'o 6bb8845953 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
2014-05-27 12:38:23 -04:00
Andreas Dilger 999d38d9b9 debugfs: fix debugfs/quota.c compile warnings
Fix type mismatch and unused variable warnings.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-22 17:57:21 -04:00
Andreas Dilger 9d8cd8c461 debugfs: fix filehandle leak in copy_file()
Fix a file handle leak for the target file in copy_file() when error
handlers return without closing the file.  Instead, clean up at the
end of the function to handle cleanup in normal and error cases.

Minor other code style cleanups.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-22 17:54:36 -04:00
Andreas Dilger 90c5b4c9de debugfs: fix string_to_time for MacOS strptime()
The strptime() function does not update fields in struct tm that are
not specified in the input format.  The glibc implementation sets the
tm_yday field (%j) when any of the year (%Y), month (%m), or day (%d)
fields are changed, but the MacOS strptime() does not set tm_yday in
this case.  This caused string_to_time() to calculate the wrong Unix
epoch on MacOS. If tm_yday is unset, compute it in string_to_time().

This also fixes test regression failures for FreeBSD.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-22 17:52:23 -04:00
Theodore Ts'o ba08cb996a Merge branch 'maint' into next
Conflicts:
	debugfs/Makefile.in
	debugfs/debug_cmds.ct
	debugfs/debugfs.c
	debugfs/debugfs.h
	e2fsck/Makefile.in
	misc/Makefile.in
	misc/mke2fs.c
2014-05-13 11:01:07 -04:00
Theodore Ts'o 75fc42f1a1 debugfs: add commands to query the quota information
This allows us to verify quota information in an ext4 file systems
with the quota feature.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
2014-05-13 10:13:19 -04:00
Darrick J. Wong 46272d5aa2 debugfs: force logdump to display (old) journal contents
If the user passes the -O option to logdump, try to dump old log
contents.  This can be used to try to track down journal problems even
after the journal has been replayed.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 23:28:57 -04:00
Darrick J. Wong a1ff15f83b debugfs: teach logdump to deal with 64bit revoke tables
The logdump command doesn't know how to deal with revoke tables in
64bit journals, so teach it to do this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 21:04:17 -04:00
Darrick J. Wong 1bad6f4624 misc: coverity fixes
Fix various small resource leaks and error code handling issues that
Coverity pointed out.

Fixes-Coverity-Bugs: 11919{39-45}, 1174118, 1049160, 1049144
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 18:40:20 -04:00
Darrick J. Wong a46300fe70 misc: create better-packaged static analysis reports
Fix some minor bugs relating to passing CFLAGS to cppcheck, and
package the cppcheck output into nicer looking reports.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 18:32:07 -04:00
Darrick J. Wong 8a6cc1aebd misc: fix header complaints and resource leaks in e2fsprogs
Fix a few minor bugs that cppcheck complained about.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-14 09:53:19 -04:00
Darrick J. Wong 24997f1cd2 misc: cppcheck cleanups
Fix a number of things that cppcheck complains about.  Most of these
are minor resource leaks and forgotten declarations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-14 09:34:11 -04:00
Darrick J. Wong f1605243a4 all: Introduce cppcheck static checking for make C=1
Introduce more static checking via cppcheck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-14 09:32:50 -04:00
Darrick J. Wong 227239b10b debugfs: create commands to edit extended attributes
Enhance debugfs to be able to display and modify extended attributes, and
create some simple tests for the extended attribute editing functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-11 23:50:08 -04:00
Darrick J. Wong 2ddcee1771 debugfs, libext2fs: minor fixups to xattr support
Add magic number checking to the extended attribute editing handle;
move inline data to the head of the attribute list when writing so
that inline data ends up in the inode area; and always zero the
attribute space before writing to ensure that we can delete the last
xattr.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-11 23:49:16 -04:00
Darrick J. Wong a3111e80b8 create_inode: move debugfs internal state back to debugfs
Since create_inode.c is shared between debugfs and mke2fs, don't
spread debugfs internal state into mke2fs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-11 23:30:17 -04:00
Theodore Ts'o cecc79ac3f Update Makefile dependencies
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-06 11:26:41 -05:00
Theodore Ts'o d23b1965f3 Merge branch 'ry/mke2fs-populate' into next
Conflicts:
	debugfs/debugfs.c
2014-03-06 11:22:42 -05:00
Robert Yang 9aa3aa8dae debugfs: use the functions in misc/create_inode.c
* Use the functions in misc/create_inode.c, and remove the duplicated
  code.

* The CREATE_INODE_DEPS in the debugfs/Makefile.in is used for recording
  create_inode.o's depends which is from misc/Makefile.in, we have to
  recompile create_inode.o because we need it to print more messages when
  it is used by debugfs, just like we recompile e2freefrag.o, but it seems
  that the e2freefrag.o's depends in debugfs/Makefile.in is incorrect, it
  would not rebuild when its depends (e.g.: lib/config.h) is changed,
  which would cause unexpected errors. Make duplicated code in
  debugfs/Makefile.in and misc/Makefile.in is not a good idea, maybe we'd
  better define CREATE_INODE_DEPS in the top Makefile, I'd like to send
  another patch and fix the e2freefrag if you are fine with it.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:25 -05:00
Zheng Liu 54e880b870 libext2fs: handle inline data in read/write function
Currently ext2fs_file_read/write are used to copy data from/to a file.
But they manipulate data by blocksize.  For supporting inline data, we
handle it in two new fucntions called ext2fs_file_read/write_inline_data.

In read path the implementation is straightforward.  But in write path
things get more complicated because if the size of data is greater than
the maximum size of inline data we will expand this file.  So now we
will check this in ext2fs_inline_data_set.  If this inode doesn't have
enough space, it will return EXT2_ET_INLINE_DATA_NO_SPACE error.  Then
the caller will check this error and tries to expand the file.

The following commands in debugfs can handle inline_data feature after
applying this patch:
	- dump
	- cat
	- rdump
	- write

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-04 08:46:14 -05:00
Zheng Liu 8f3428d899 debugfs: make lsdel command support inline data
After checking inline data in ext2fs_inode_have_valid_blocks2() we won't
traverse the block in do_lsdel() function.  But if an inode has inline
data we also need to report it.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:14 -05:00
Zheng Liu 133e94627b debugfs: make stat command support inline data
If there is an inode with inline data, we just print the size of inline
data in stat command.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:13 -05:00
Zheng Liu 716a3c3536 libext2fs: handle inline_data in block iterator function
After applied this commit (a7f4c635), we have banned to traverse blocks
for an inode which has inline data because no block belongs to it.  But
before calling this function, we need to check inline data flag.  This
commit add a sanity check ext2fs_inode_has_valid_blocks2() to fix them
except that ext2fs_expand_dir because it will be fixed by another patch.

Meanwhile in this commit it fixes a bug that when we kill a file we
could leak an inode.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:13 -05:00
Darrick J. Wong 5beff1c0cf debugfs: dump all extended attributes
Use the new extended attribute APIs to display all extended attributes
(current code does not look in the EA block) and display full names
(current code ignores name index too).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-23 23:08:48 -05:00
Theodore Ts'o 3ba59bf649 Merge branch 'maint' into next 2014-02-23 23:07:38 -05:00
Theodore Ts'o fedfb27fe5 Add coverage testing using gcov
To check the coverage of e2fsprogs's regression test, do the
following:

	configure --enable-gcov
	make -j8 ; make -j8 check ; make coverage.txt

The coverage information will be the coverage.txt and *.gcov files in
the build directories.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-23 00:17:09 -05:00
Theodore Ts'o f0996c12d5 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/alloc.c
	misc/mke2fs.c
2014-01-30 19:05:16 -05:00
Theodore Ts'o 65c6c3e06f Add support for new compat feature "sparse_super2"
In practice, it is **extremely** rare for users to try to use more
than the first backup superblock located at the beginning of block
group #1.  (i.e., at block number 32768 for file systems with a 4k
block size).  This new compat feature restricts the backup superblock
to block group #1 and the last block group in the file system.

Aside from reducing the overhead of the file system by a small number
of blocks, by eliminating the rest of the backup superblocks, it
allows us to have a much more flexible metadata layout.  For example,
we can force all of the allocation bitmaps and inode table blocks to
the beginning of the disk, which allows most of the disk to be
exclusively used for contiguous data blocks.

This simplifies taking advantage of certain HDD specific features,
such as Shingled Magnetic Recording (aka Shingled Drives), and the
TCG's OPAL Storage Specification where having a simple mapping between
LBA block ranges and the data blocks used by the file system can make
life much simpler.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-30 13:58:18 -05:00
Theodore Ts'o 81eca9afc0 Merge branch 'maint' into next 2014-01-10 17:44:17 -05:00
Theodore Ts'o 40ca5c4768 debugfs: fix typo in commit 5a1d25a7b
The typo causes a compiler warning, but it's otherwise harmless.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-09 14:30:43 -05:00
Theodore Ts'o bc82f39437 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
	lib/ext2fs/csum.c
2014-01-09 12:25:37 -05:00
Theodore Ts'o 5a1d25a7b2 Fix up workarounds for dietlibc breakage
The dietlibc doesn't support the TZ environment variable, which is
required by the standard.  Work around this so that we can run the
regression test suite when building with dietlibc.  (This is useful
for finding problems.)

With this change, the only thing which doesn't work as far as dietlibc
is concerned is the posix_memalign test, and the MMP support tests
(because posix_memalign isn't provided by dietlibc, sigh.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-09 12:22:03 -05:00
Theodore Ts'o b220a336d5 debugfs: remove dead code
Addresses-Coverity-Id: #1138573

Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-08 19:45:55 -05:00
Theodore Ts'o d2dce124dd Merge branch 'maint' into next
Conflicts:
	debian/changelog
	e2fsck/Makefile.in
2014-01-06 06:58:58 -05:00
Theodore Ts'o 6c59a665da configure: fix --with-diet-libc
Newer versions of autoconf pull in AC_PROG_GCC as part of
AC_CANONICAL_HOST.  So we need check for WITH_DIET_LIBC earlier in
configure.in.

Also, e2fsprogs now needs functions which are found in diet libc's
compat library.  So add support for autoconf's LIBS function, and
automatically set libs to include -lcompat.

Finally, disable compiling e4defrag by deault if --with-diet-libc is
specified because the program has too many glibc dependencies.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-05 22:58:16 -05:00
Theodore Ts'o b34b94d5cd debugfs: clean up read_journal_block() to avoid Coverity complaint
The read_journal_block() function was needlessly complicated, which
made it harder to read/maintain, and it also tripped up Coverity.
Cleaning it up also avoided some signed/unsigned casts, and allows us
to avoid passing got back to the caller, since it wasn't needed.

Addresses-Coverity-Bug: #709539

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-04 19:11:37 -05:00
Eric Whitney a25fffae5c debugfs: restore and tweak original error messaging
In response to reviewer comments, commit fe56188b07 included changes
that modified some of the code used to output error messages when
checking user-supplied block numbers.  These changes converted calls
to parse_ulonglong() to calls to strtoblk().  Because strtoblk() calls
parse_ulonglong(), and both output error messages, two redundant and
relatively generic messages were output on each error.

Fix this by removing the error message output from strtoblk(), and
extending it to accept an optional error message argument that it
supplies in lieu of a default to parse_ulonglong().  Also, revert to
the more descriptive original error messages with mods per reviewer
comments, and fix an error message in do_replace_node().

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-30 16:56:19 -05:00
Theodore Ts'o 9c846766fd Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	version.h
2013-12-28 23:27:39 -05:00
Theodore Ts'o 2d8637b150 debugfs: document the lsdel command in the man page
Addresses-Debian-Bug: #731329

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-28 22:15:59 -05:00
Theodore Ts'o 2ffccc82c4 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/csum.c
2013-12-26 00:30:56 -05:00
Theodore Ts'o 45f143c20c debugfs: fix extent header in do_write for big-endian machines
Commit a17e9f30 set up the extent header for a new file.
Unfortunately it didn't correctly handle byte swapping; fix this so
the regression tests pass on PowerPC systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Eric Sandeen <sandeen@redhat.com>
2013-12-24 22:50:23 -05:00
Theodore Ts'o 3c22bf7e70 Add ext4 man page and update and clean up the other man pages
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 22:50:23 -05:00
Eric Whitney 32541fe4f9 debugfs: silence build warning and remove incorrect error message
Commit fe56188b07 modified the code used to check the block number
argument to the command line -s switch, adding a call to com_err().
This causes a compile time warning because the third argument to
com_err() isn't a string.  Also, when the block number argument is
bad it outputs an incorrect error message - "Operation not permitted".

Fix these minor problems by removing the call to com_err().  Other
code provides enough error reporting information in this case.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 22:50:23 -05:00
Andreas Dilger 2bc3041754 debugfs, e2fsck: fix s_desc_size handling
The s_desc_size in the superblock specifies the group descriptor
size in bytes, but in various places the EXT4_FEATURE_INCOMPAT_64BIT
flag implies that the descriptor size is EXT2_MIN_DESC_SIZE_64BIT
(64 bytes) instead of checking the actual size.  In other places,
the s_desc_size field is used without checking for INCOMPAT_64BIT.

In the case of ext2fs_group_desc() the s_desc_size was being ignored,
and assumed to be sizeof(struct ext4_group_desc), which would result
in garbage for any but the first group descriptor.  Similarly, in
ext2fs_group_desc_csum() and print_csum() they assumed that the
maximum group descriptor size was sizeof(struct ext4_group_desc).
Fix these functions to use the actual superblock s_desc_size if
INCOMPAT_64BIT.

Conversely, in ext2fs_swap_group_desc2() s_desc_size was used
without checking for INCOMPAT_64BIT being set.

The e2fsprogs behaviour is different than that of the kernel,
which always checks INCOMPAT_64BIT, and only uses s_desc_size to
determine the offset of group descriptors and what range of bytes
to checksum.

Allow specifying the s_desc_size field at mke2fs time with the
"-E desc_size=NNN" option.  Allow a power-of-two s_desc_size
value up to s_blocksize if INCOMPAT_64BIT is specified.  This
is not expected to be used by regular users at this time, so it
is not currently documented in the mke2fs usage or man page.

Add m_desc_size_128, f_desc_size_128, and f_desc_bad test cases to
verify mke2fs and e2fsck handling of larger group descriptor sizes.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 22:50:19 -05:00
Theodore Ts'o f404167dda Clean up sparse warnings
Mostly by adding static and removing excess extern qualifiers.  Also
convert a few remaining non-ANSI function declarations to ANSI.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-16 18:56:36 -05:00
Theodore Ts'o e4681bca17 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.8.in
2013-12-16 01:35:56 -05:00
Andreas Dilger dba2bbdfea debugfs: clean up debugfs man page and help text
Clean up the formatting of the debugfs(8) man page:
- add command aliases to the main descriptions
- use bold for sub-commands and italics for their arguments
- remove trailing spaces
- add "dirty" sub-command
- clarify "block_dump" and "zap_block" sub-commands

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-15 22:13:15 -05:00
Theodore Ts'o 2d3df8dc7f Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/newdir.c
2013-12-12 15:39:14 -05:00
Darrick J. Wong 85b8f7affa debugfs: don't leak mmp_s memory (on error path)
ext2fs_free_mem() takes a pointer to a pointer, similar to
ext2fs_get_mem().  Improve the documentation, and fix debugfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 12:57:27 -05:00
Darrick J. Wong ddbe78528f debugfs: don't leak fd when calling dump_file
The caller of dump_file provides a fd to write to, so the caller
should also dispose of the fd.  Also, the fd never gets closed if
preserve=1.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 12:51:01 -05:00
Darrick J. Wong fe56188b07 debugfs: handle 64bit block numbers
debugfs should use strtoull wrappers for reading block numbers from
the command line.  "unsigned long" isn't wide enough to handle block
numbers on 32bit platforms.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 12:49:17 -05:00
Darrick J. Wong 50295a3f9e debugfs: fix various minor bogosity
We should really use the ext2fs memory allocator functions in
copy_file(), and we really should return a value if there's allocation
problems.

Also fix up a minor bogosity in an error message.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Cc: Robert Yang <liezhi.yang@windriver.com>
Cc: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 12:43:39 -05:00
Darrick J. Wong 57d4fb66d2 debugfs: fix init_filesys help text
The help text for debugfs' init_filesys command is incorrect; the
second parameter is the size of the filesystem in blocks, not the size
of an individual filesystem block.  There is in fact no way to set
that parameter.

Reported-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 12:39:54 -05:00
Theodore Ts'o 1b977a0fad Merge branch 'maint' into next 2013-12-09 14:15:04 -05:00
Zheng Liu 5093775ab4 debugfs: update usage message for open and filefrag
The ussage message for the open and filefrag commands were missing
options; this commit fixes this.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-08 21:06:40 -05:00
Lev Solomonov a9b23fc99d debugfs: fix range mode of freei
commit 2ae5d1fdb8 was supposed to teach
'seti' and 'freei' to act on a range of consecutive inodes. apparently
only 'seti' has learned: 'freei' doesn't advance the ino, repeatedly
acting on the same one instead.

Signed-off-by: Lev Solomonov <solo@primarydata.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-04 21:55:27 -05:00
Theodore Ts'o ef429f5968 Merge branch 'maint' into next 2013-12-04 00:23:19 -05:00
Andreas Dilger 2fe2d408a4 mmp: fix 64-bit handling of s_mmp_block
Fix the checking of s_mmp_block in e2fsck_pass1() and
ext2fs_mmp_read() to handle the high 32 bits of s_blocks_count.
Remove redundant check of s_mmp_block in do_dump_mmp() right before
ext2fs_mmp_read() is called.

Also fix s_blocks_count_hi in check_backup_super_block(), since it
cannot use the ext2fs_blocks_count() helper easily.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-03 20:22:16 -05:00
Theodore Ts'o 1586850bcd Merge branch 'maint' into next 2013-10-14 09:57:23 -04:00
Robert Yang c756ec4217 debugfs.c: do sparse copy when src is a sparse file
Let debugfs do sparse copy when src is a sparse file, just like
"cp --sparse=auto"

* For the:
  #define IO_BUFSIZE 64*1024
  this is a suggested value from gnu coreutils:
  http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/ioblksize.h;h=1ae93255e7d0ccf0855208c7ae5888209997bf16;hb=HEAD

* Use malloc() to allocate memory for the buffer since put 64K (or
  more) on the stack seems not a good idea.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-10-13 22:08:40 -04:00
Robert Yang 355ffb2ff5 debugfs.c: the max length of debugfs argument is too short
The max length of debugfs argument is 256 which is too short, the
arguments are two paths, the PATH_MAX is 4096 according to
/usr/include/linux/limits.h, so use BUFSIZ (which is 8192 on Linux
systems), that's also what the ss library uses.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-10-13 22:07:57 -04:00
Theodore Ts'o e337e7fad8 Merge branch 'maint' into next
Conflicts:
	e2fsck/problem.c
	e2fsck/rehash.c
	e2fsck/super.c
2013-10-12 22:26:28 -04:00
Darrick J. Wong 832cb612f8 e2fsprogs: add (optional) sparse checking to the build
Run sparse against source files when building e2fsprogs with 'make C=1'.  If
instead C=2, it configures basic ext2 types for bitwise checking with sparse,
which can help find the (many many) spots where conversion errors are
(possibly) happening.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-11 23:12:40 -04:00
Darrick J. Wong 4dbfd79d14 e2fsprogs: fix blk_t <- blk64_t assignment mismatches
Fix all the places where we should be using a blk64_t instead of a
blk_t.  These fixes are more severe because 64bit values could be
truncated silently.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-07 09:51:48 -04:00
Theodore Ts'o fc9f162eea Merge branch 'maint' into next 2013-09-09 20:49:49 -04:00
Eric Sandeen a17e9f304b debugfs: properly set up extent header in do_write
do_write doesn't fully set up the first extent header on a new
inode, so if we write a 0-length file, and don't write any data
to the new file, we end up creating something that looks corrupt
to kernelspace:

EXT4-fs error (device loop0): ext4_ext_check_inode:464: inode #12: comm ls: bad header/extent: invalid magic - magic 0, entries 0, max 0(0), depth 0(0)

Do something similar to ext4_ext_tree_init() here, and
fill out the first extent header upon creation to avoid this.

Reported-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Tested-by: Robert Yang <liezhi.yang@windriver.com>
2013-07-28 22:32:15 -04:00