Commit Graph

221 Commits (master)

Author SHA1 Message Date
Theodore Ts'o 22137497fa debugfs: fix typo when printing out the dtime label
If the inode has extended timestamps, the dtime was printed with a
label of "crtime".  Fix this.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-09-01 01:01:48 -04:00
Theodore Ts'o b199291909 debugfs: add the debugfs copy_inode subcommand
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-08-31 18:13:16 -04:00
Theodore Ts'o c0495d96fd Remove the last of behaviour-specific checks on EXT2_OS_LINUX
If there is a feature check, we can just depend on the feature check.
If it is something that can't be checked via a feature flag, then
instead of checking for EXT2_OS_LINUX, we should instead check for
*NOT* EXT2_OS_HURD. since HURD is the special case.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-06-07 13:36:47 -04:00
Theodore Ts'o 1fc23b5e77 Fix support for configure --enable-jbd-debug
We haven't used this in a while, so it's bitrotted a bit.  Fix it up
so that it works correctly.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-04-15 19:01:38 -04:00
Theodore Ts'o dcb8e1fa04 Merge branch 'maint' into next 2016-03-06 20:37:49 -05:00
Theodore Ts'o f3d9ac36a0 debugfs: add support for the project id field
Teach the stat and set_inode_field commands to support the project ID
field.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 20:08:52 -05:00
Andreas Dilger 2fe6136c48 debugfs: improve dump_mmp handling
If MMP is not enabled on a filesystem (s_mmp_block == 0), print this
clearly rather than "MMP: block number beyond filesystem range".

Add an option to "debugfs dump_mmp" to specify the MMP block number
instead of getting it from the superblock s_mmp_block field.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 18:11:48 -05:00
Theodore Ts'o 188960ea4b debugfs: add support to properly set and display extended timestamps
This code is partially derived from patches from David Turner to allow
debugfs to properly support extended timestamps.

Cc: David Turner <novalis@novalis.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2015-11-30 11:42:00 -05:00
Darrick J. Wong 4ee2669982 debugfs: clean up feature test macros with predicate functions
Create separate predicate functions to test/set/clear feature flags,
thereby replacing the wordy old macros.  Furthermore, clean out the
places where we open-coded feature tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-10-24 01:26:35 -04:00
Theodore Ts'o df0b907ec1 debugfs: cleanup gcc -Wall warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-07-13 16:00:12 -04:00
Theodore Ts'o 25f291c9b3 Eliminate unused parameter warnings from Android build
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-07-13 09:12:23 -04:00
Theodore Ts'o 99ceb8ec1a Move the check_plausibility() function from misc to lib/support
The check_plausibility() function is now used all over the place, so
we should move the plausible.c file to lib/support and remove the
special case handling for that file that had been in the build system.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-07-12 22:01:17 -04:00
Darrick J. Wong 2f8c0d028c debugfs: implement fallocate
Implement a fallocate function for debugfs, and add some tests to
demonstrate that it works (more or less).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-06-10 20:01:24 -04:00
Darrick J. Wong b085139224 misc: fix undo file setup
Fix Coverity bugs 1297094-1297101 by fixing all the mutations in the
*_setup_tdb() functions, fixing buffer overflows, and checking
return values.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-05-16 20:19:52 -04:00
Darrick J. Wong 491cc33ac6 debugfs: optionally create undo file
Provide the user with an option to create an undo file so that they
can roll back a failed debugfs expedition.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-05-05 10:42:04 -04: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 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
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
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 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 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
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
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
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 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 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 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 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 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 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
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 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