Commit Graph

32 Commits (master)

Author SHA1 Message Date
Theodore Ts'o ebb8b1aa04 debugfs: fix rdump so it can start from the root directory
Previously "rdump / /tmp/out" would fail with the error message:

rdump: File exists while making directory /tmp/out/

Also fix the fast symlink detection logic so that it works when a
symlink has one or more extended attributes.

Addresses-Debian-Bug: #766125

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-06-02 23:29:07 -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 2d3df8dc7f Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/newdir.c
2013-12-12 15:39:14 -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
Jan Kara 70f4632b62 libext2fs: provide functions to safely access name_len and file_type
Accessing name_len (and file_type) in ext4_dir_entry structure is
somewhat problematic because on big endian architecture we need to now
whether we are really dealing with ext4_dir_entry (which has u16
name_len which needs byte swapping) or ext4_dir_entry_2 (which has u8
name_len which must not be byte swapped).

Currently the code is somewhat surprising and name_len is always
treated as u16 and byte swapped (flag EXT2_DIRBLOCK_V2_STRUCT isn't
ever used) and then masking of name_len is used to access real
name_len or file_type. Doing things this way in applications using
libext2fs is unexpected to say the least (more natural is to type
struct ext4_dir_entry * to struct ext4_dir_entry_2 * but that gives
wrong results on big endian architectures. So provide helper functions
that give endian-safe access to these fields. Also convert users in
e2fsprogs to use these functions.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-08 17:03:05 -04:00
Zheng Liu d3b4de412c debugfs: fixup the hard-coded buffer length in dump_file
Allocate the block buffer in dump_file() instead of assuming that the
block size is no more than 8k.

CC: George Spelvin <linux@horizon.com>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-01 15:12:14 -05:00
Theodore Ts'o d1154eb460 Shorten compile commands run by the build system
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and
this was starting to cause some tools heartburn.  It also made "make
V=1" almost useless, since trying to following the individual commands
run by make was lost in the noise of all of the defines.

So fix this by putting the configure-generated defines in lib/config.h
and the directory pathnames to lib/dirpaths.h.

In addition, clean up some vestigal defines in configure.in and in the
Makefiles to further shorten the cc command lines.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-18 17:34:37 -04:00
Eric Sandeen 11ba79b3a6 e2fsprogs: Remove impossible name_len tests.
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-16 18:43:04 -04:00
Andreas Dilger cf5301d7f2 misc: clean up compiler warnings
Fix several types of compiler warnings (unused variables/labels),
uninitialized variables, etc that are hit with gcc -Wall.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 10:58:25 -04:00
Theodore Ts'o 5299580c1c Use format strings directly to prevent -Werror=format-security failures
Gcc is too stupid to realize that:

    const char *usage="String which has no percent signs";

    com_err(progname, 0, usage);

is OK.  I refuse to bow to stupidity with:

   com_err(progname, 0, "%s", usage);

but I will use the string directly for the sake of people who like to
build with -Werror=format-security.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:05:25 -05:00
Theodore Ts'o efc6f628e1 Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27 23:07:54 -04:00
Theodore Ts'o efac5a7f0d debugfs: support > 2GB files for the dump and rdump commands
Add _GNU_SOURCE define to make sure O_LARGEFILE is defined for
do_dump(), and use O_LARGEFILE when writing files using do_rdump().

Addresses Debian Bug: #412614

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-02 18:30:46 -04:00
Brian Behlendorf b772900b4b [COVERITY] Avoid static buffer overruns in debugfs
Add an extra byte to EXT2_NAME_LEN in the static allocation for the
required trailing null.  This allows filenames up to the maximum
length of EXT2_NAME_LEN withover an overrun.

Coverity ID: 11: Overrun Static
Coverity ID: 12: Overrun Static
Coverity ID: 13: Overrun Static

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-03-21 15:09:15 -04:00
Theodore Ts'o 544349270e Fix gcc -Wall nitpicks 2003-12-07 01:28:50 -05:00
Theodore Ts'o 88494bb6d4 util.c, ls.c, logdump.c, htree.c, dump.c, debugfs.h, debugfs.c, ChangeLog:
util.c (reset_getopt), debugfs.c (do_open_filesys,
  	do_show_super_stats), ls.c (do_list_dir), dump.c (do_dump),
  	htree.c (do_htree_dump, do_dx_hash), logdump.c (do_logdump):
  	Define and use a new function, reset_getopt(), which does whatever
  	is necessary to reset getopt() again.  This is different for
  	different implementations, so the portabilty issues are a bit of a
  	nightmare.  (Addresses Debian bug #192834)
2003-05-13 23:03:43 -04:00
Theodore Ts'o ed78c021c3 Fix up lots of portability problems that caused e2fsprogs not to build successfully
under Solaris.
2003-03-06 11:09:18 -05:00
Theodore Ts'o 819157db79 Remove 32-bit limitations for debugfs's dump command and to the
ext2fs library's ext2fs_file_read.
2003-01-22 18:25:39 -05:00
Theodore Ts'o 682720a41b Fix gcc -Wall nits. 2002-01-03 05:10:04 -05:00
Theodore Ts'o e1018eeaa3 Add new debugfs commands and arguments which make it easier to
recover deleted files.  The lsdel command now takes an optional
argument which allows the user to only see the most recently
deleted files.  Also added a new command, undel, which automates
undeleting a deleted inode and linking it back to a directory.
Also added an optional count argument to the testb, freeb, setb,
and find_free_block commands.  The ls command now takes a new
option, -d, which lists deleted directory entries.

Factored out out commonly used code into utility subroutines
for ease of maintenance and to make the executable size smaller.
2002-01-03 04:55:25 -05:00
Theodore Ts'o b044c2e02a Many files:
debugfs.c, debugfs.h, dump.c, icheck.c, ls.c, lsdel.c, ncheck.c,
  	setsuper.c, util.c: Change ino_t to ext2_ino_t.  Fix a few minor
  	gcc-wall complaints while we're at it.
2001-01-11 15:26:39 +00:00
Theodore Ts'o c5de1d4a0d ChangeLog, setsuper.c:
Remove hard-coded s_ from inode_size field.
ChangeLog, dump.c:
  dump.c (fix_perms): Fix bug for systems which don't have fchown; was
  	incorrectly using chmod instead of chown.
2000-12-31 01:39:54 +00:00
Theodore Ts'o 2e8d40d562 ChangeLog, debug_cmds.ct, debugfs.8.in, debugfs.c, dump.c, ls.c:
debugfs.8.in: Documented new behaviour.
  ls.c (ls_l_file): Fix Y2K bug -- was printing 22-May-100 for recent
  	files.  Switched to 4-digit years.
  dump.c, debug_cmds.ct (do_rdump): Add new debugfs command "rdump",
  	which recursively dumps a directory and its contents.
  	(fix_perms): New function.  Break permission-fixing code out of
  	dump_file() so it can be called by rdump code as well.
  	(dump_file): Call fix_perms().
  debugfs.c, debug_cmds.ct (do_lcd): Add new debugfs command "lcd",
  	which changes the cwd on the native filesystem.
  debugfs.c (open_filesystem): Extra args for superblock, blocksize, and
  	catastrophic mode.  Changed callers.
  	(do_open_filesys, main): Accept new -b, -s, -c options for
  	open_filesystem.
ChangeLog, mkdir.c:
  mkdir.c (ext2fs_mkdir): Read the parent directory's inode earlier, so
  	that if there's an error reading it, we can more cleanly back out of
  	the operation.
version.h:
  Update version file for WIP release.
2000-05-27 15:15:40 +00:00
Theodore Ts'o 4a31c48b82 ChangeLog, Makefile.in, bmap.c, bmove.c, ext2fs.h, jump.funcs:
ext2fs.h: If __STRICT_ANSI__ is defined and we're on a platform with
  	32 bit longs, then we need to manually define __s64 and __u64, since
  	the current kernel header files don't define these if __STRICT_ANSI__
  	is defined.  This is a problem if we are compiling with full GCC
  	warnings, since we do need 64 bit support.
  Makefile.in (OBJS): Remove bmove.o from files to be built, since we're
  	not using ext2fs_move_blocks() and there is some question as to its
  	usefulness in its current form.
  bmap.c (block_bmap): Remove unused function.
  bmove.c (process_block): Fix -Wall warning.
ChangeLog, debugfs.c, debugfs.h, dump.c:
  debugfs.h: Add declaration for do_dirty_filsys() to prevent -Wall
  	warnings.
  debugfs.c (copy_file):
  dump.c (dump_file): Fix -Wall warning caused by signed/unsigned mismatch.
1998-03-30 01:27:25 +00:00
Theodore Ts'o 5a51384ef2 ChangeLog, debugfs.c, dump.c:
debugfs.c (copy_file), dump.c (dump_file): Change to use the new
  	fileio primitives in libext2.
1997-10-25 22:41:14 +00:00
Theodore Ts'o f13048113f ChangeLog, debugfs.c, dump.c, ls.c:
debugfs.c (main, do_open_filesys):
  dump.c (do_dump): Make the variable which getopt returns into be
  	an int, so that it won't lose on platforms where char is
  	unsigned.
1997-10-25 03:51:53 +00:00
Theodore Ts'o fc6d9d519a Many files:
Checked in e2fsprogs 1.05
1997-04-29 14:51:31 +00:00
Theodore Ts'o 50e1e10fa0 Many files:
Checked in e2fsprogs 0.5c
1997-04-26 13:58:21 +00:00
Theodore Ts'o f3db3566b5 Many files:
Checkin of e2fsprogs 0.5b
1997-04-26 13:34:30 +00:00